use of org.hl7.fhir.r4.model.Narrative in project bunsen by cerner.
the class TestData method newCondition.
/**
* Returns a FHIR Condition for testing purposes.
*/
public static Condition newCondition() {
Condition condition = new Condition();
// Condition based on example from FHIR:
// https://www.hl7.org/fhir/condition-example.json.html
condition.setId("Condition/example");
condition.setLanguage("en_US");
// Narrative text
Narrative narrative = new Narrative();
narrative.setStatusAsString("generated");
narrative.setDivAsString("This data was generated for test purposes.");
XhtmlNode node = new XhtmlNode();
node.setNodeType(NodeType.Text);
node.setValue("Severe burn of left ear (Date: 24-May 2012)");
condition.setText(narrative);
condition.setSubject(new Reference("Patient/example").setDisplay("Here is a display for you."));
condition.setVerificationStatus(Condition.ConditionVerificationStatus.CONFIRMED);
// Condition code
CodeableConcept code = new CodeableConcept();
code.addCoding().setSystem("http://snomed.info/sct").setCode("39065001").setDisplay("Severe");
condition.setSeverity(code);
// Severity code
CodeableConcept severity = new CodeableConcept();
severity.addCoding().setSystem("http://snomed.info/sct").setCode("24484000").setDisplay("Burn of ear").setUserSelected(true);
condition.setSeverity(severity);
// Onset date time
DateTimeType onset = new DateTimeType();
onset.setValueAsString("2012-05-24");
condition.setOnset(onset);
return condition;
}
use of org.hl7.fhir.r4.model.Narrative in project kindling by HL7.
the class Publisher method addToResourceFeed.
private void addToResourceFeed(ValueSet vs, Bundle dest, String filename) throws Exception {
maybeFixResourceId(vs, filename);
if (vs.getId() == null)
throw new Exception("Resource has no id: " + vs.getName() + " (" + vs.getUrl() + ")");
if (ResourceUtilities.getById(dest, ResourceType.ValueSet, vs.getId()) != null)
throw new Exception("Attempt to add duplicate value set " + vs.getId() + " (" + vs.getName() + ")");
if (!vs.hasText() || !vs.getText().hasDiv()) {
RendererFactory.factory(vs, page.getRc().copy()).render(vs);
}
if (!vs.hasText() || vs.getText().getDiv() == null)
throw new Exception("Example Value Set " + vs.getId() + " does not have any narrative");
ResourceUtilities.meta(vs).setLastUpdated(page.getGenDate().getTime());
if (vs.getUrl().startsWith("http://hl7.org/fhir/") && !vs.getUrl().equals("http://hl7.org/fhir/" + vs.getResourceType().toString() + "/" + vs.getId()))
throw new Exception("URL mismatch on value set: " + vs.getUrl() + " vs " + "http://hl7.org/fhir/" + vs.getResourceType().toString() + "/" + vs.getId());
dest.getEntry().add(new BundleEntryComponent().setResource(vs).setFullUrl("http://hl7.org/fhir/" + vs.fhirType() + "/" + vs.getId()));
}
use of org.hl7.fhir.r4.model.Narrative in project kindling by HL7.
the class Publisher method genProfiledTypeProfile.
private void genProfiledTypeProfile(ProfiledType pt) throws Exception {
StructureDefinition profile = new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(pt, page.getValidationErrors());
if (page.getProfiles().has(profile.getUrl()))
throw new Exception("Duplicate Profile URL " + profile.getUrl());
page.getProfiles().see(profile, page.packageInfo());
pt.setProfile(profile);
// todo: what to do in the narrative?
}
use of org.hl7.fhir.r4.model.Narrative in project kindling by HL7.
the class Publisher method generateCodeSystemsPart1.
private void generateCodeSystemsPart1() throws Exception {
page.log(" ...code systems", LogMessageType.Process);
for (CodeSystem cs : page.getDefinitions().getCodeSystems().getList()) {
if (cs != null && !cs.hasUserData("external.url")) {
if (!cs.hasText()) {
cs.setText(new Narrative());
cs.getText().setStatus(NarrativeStatus.EMPTY);
}
if (!cs.getText().hasDiv()) {
cs.getText().setDiv(new XhtmlNode(NodeType.Element));
cs.getText().getDiv().setName("div");
}
// if (ToolingExtensions.getOID(cs) == null)
// throw new Exception("No OID on code system "+cs.getUrl());
}
}
}
use of org.hl7.fhir.r4.model.Narrative in project kindling by HL7.
the class Publisher method generateConceptMap.
private void generateConceptMap(ConceptMap cm) throws Exception {
String filename = cm.getUserString("path");
RenderingContext lrc = page.getRc().copy().setLocalPrefix("").setTooCostlyNoteEmpty(PageProcessor.TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(PageProcessor.TOO_MANY_CODES_TEXT_NOT_EMPTY);
RendererFactory.factory(cm, lrc).render(cm);
IParser json = new JsonParser().setOutputStyle(OutputStyle.PRETTY);
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".json"));
json.compose(s, cm);
s.close();
json = new JsonParser().setOutputStyle(OutputStyle.CANONICAL);
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".canonical.json"));
json.compose(s, cm);
s.close();
String n = Utilities.changeFileExt(filename, "");
jsonToXhtml(n, cm.getName(), resource2Json(cm), "conceptmap-instance", "Concept Map", null, wg("vocab"));
ttlToXhtml(n, cm.getName(), resource2Ttl(cm), "conceptmap-instance", "Concept Map", null, wg("vocab"));
IParser xml = new XmlParser().setOutputStyle(OutputStyle.PRETTY);
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".xml"));
xml.compose(s, cm);
s.close();
xml = new XmlParser().setOutputStyle(OutputStyle.CANONICAL);
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".canonical.xml"));
xml.compose(s, cm);
s.close();
cloneToXhtml(n, cm.getName(), false, "conceptmap-instance", "Concept Map", null, wg("vocab"));
// now, we create an html page from the narrative
String narrative = new XhtmlComposer(XhtmlComposer.HTML).compose(cm.getText().getDiv());
String html = TextFile.fileToString(page.getFolders().templateDir + "template-example.html").replace("<%example%>", narrative);
html = page.processPageIncludes(Utilities.changeFileExt(filename, ".html"), html, "conceptmap-instance", null, null, null, "Concept Map", null, null, wg("vocab"));
TextFile.stringToFile(html, page.getFolders().dstDir + Utilities.changeFileExt(filename, ".html"));
conceptMapsFeed.getEntry().add(new BundleEntryComponent().setResource(cm).setFullUrl("http://hl7.org/fhir/" + cm.fhirType() + "/" + cm.getId()));
page.getConceptMaps().see(cm, page.packageInfo());
page.getHTMLChecker().registerFile(n + ".html", cm.getName(), HTMLLinkChecker.XHTML_TYPE, false);
}
Aggregations