use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project integration-adaptor-111 by nhsconnect.
the class CompositionMapper method getSectionText.
private SectionComponent getSectionText(POCDMT000002UK01Section sectionComponent5) {
SectionComponent sectionComponent = new SectionComponent();
if (sectionComponent5.isSetTitle()) {
sectionComponent.setTitle(nodeUtil.getAllText(sectionComponent5.getTitle().getDomNode()));
}
String content = extractSectionText(sectionComponent5);
if (StringUtils.isNotEmpty(content)) {
Narrative narrative = new Narrative();
narrative.setStatus(GENERATED);
XhtmlNode xhtmlNode = new XhtmlNode();
xhtmlNode.setNodeType(NodeType.Document);
xhtmlNode.addText(content);
narrative.setDiv(xhtmlNode);
sectionComponent.setText(narrative);
}
return sectionComponent;
}
use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project integration-adaptor-111 by nhsconnect.
the class ConsentMapper method extractTextBody.
private void extractTextBody(Consent consent, POCDMT000002UK01StructuredBody structuredBody) {
List<POCDMT000002UK01Section> sections = getSectionsOfType(structuredBody);
for (POCDMT000002UK01Section section : sections) {
Narrative narrative = new Narrative();
narrative.setStatus(GENERATED);
if (section.isSetText()) {
narrative.setDivAsString(Arrays.asList(DIV_START, section.getText().xmlText(), DIV_END).stream().collect(Collectors.joining()));
consent.setText(narrative);
}
}
}
use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project integration-adaptor-111 by nhsconnect.
the class EncounterMapper method addEncounterText.
private void addEncounterText(POCDMT000002UK01Encounter encounterITK, Encounter encounter) {
if (encounterITK.isSetText()) {
String divString = nodeUtil.getNodeValueString(encounterITK.getText());
Narrative narrative = new Narrative();
narrative.setStatus(GENERATED);
narrative.setDivAsString(Arrays.asList(DIV_START, divString, DIV_END).stream().collect(Collectors.joining()));
encounter.setText(narrative);
}
}
use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project org.hl7.fhir.core by hapifhir.
the class IEEE11073Convertor method generateMDC.
public static CodeSystem generateMDC(String src, String dst, UcumService ucum) throws IOException, FHIRException {
CSVReader csv = new CSVReader(new FileInputStream(src));
csv.readHeaders();
CodeSystem cs = new CodeSystem();
Map<String, String> ucumIssues = new HashMap<String, String>();
int errorCount = 0;
cs.setId("MDC");
cs.setUrl("urn:iso:std:iso:11073:10101");
cs.setVersion("[todo]");
cs.setName("11073:10101 codes for the FHIR community");
cs.setStatus(PublicationStatus.ACTIVE);
cs.setExperimental(false);
cs.setDateElement(new DateTimeType());
cs.setPublisher("HL7 (FHIR Project)");
ContactDetail cd = cs.addContact();
ContactPoint cp = cd.addTelecom();
cp.setSystem(ContactPointSystem.URL);
cp.setValue("http://ieee?");
cs.setDescription("1073 Codes for the FHIR community (generated from the Rosetta data");
Identifier i = new Identifier();
cs.setIdentifier(i);
i.setSystem("urn:ietf:rfc:3986");
i.setValue("urn:oid:2.16.840.1.113883.6.24");
cs.setCaseSensitive(false);
cs.setContent(CodeSystemContentMode.COMPLETE);
cs.addProperty().setCode("ucum").setDescription("UCUM units associated with Concept").setType(PropertyType.STRING);
cs.addProperty().setCode("unit").setDescription("MDC units associated with Concept").setType(PropertyType.STRING);
cs.addProperty().setCode("refid").setDescription("MDC Reference Id for Concept").setType(PropertyType.CODE);
Set<String> codes = new HashSet<String>();
while (csv.line()) {
if (csv.has("CF_CODE10")) {
String code = csv.cell("CF_CODE10");
if (codes.contains(code))
System.out.println("Duplicate Code " + code);
else {
codes.add(code);
ConceptDefinitionComponent c = cs.addConcept();
c.setCode(code);
c.setDisplay(csv.cell("Common Term"));
c.setDefinition(csv.cell("Term Description"));
String vd = csv.cell("Vendor_Description");
if (!c.hasDefinition())
c.setDefinition(vd);
if (!c.hasDisplay())
c.setDisplay(vd);
String refid = csv.cell("REFID");
c.addProperty().setCode("refid").setValue(new CodeType().setValue(refid));
if (csv.has("Synonym"))
c.addDesignation().setValue(csv.cell("Synonym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("synonym"));
if (csv.has("Acronym"))
c.addDesignation().setValue(csv.cell("Acronym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setDisplay("acronym"));
if (csv.has("Systematic Name")) {
String sysName = csv.cell("Systematic Name");
if (!c.hasDefinition())
c.setDefinition(sysName);
c.addDesignation().setValue(sysName).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("structured-name"));
}
if (csv.has("UOM_MDC"))
c.addProperty().setCode("unit").setValue(new StringType().setValue(csv.cell("UOM_MDC")));
if (csv.has("UOM_UCUM")) {
CommaSeparatedStringBuilder ul = new CommaSeparatedStringBuilder();
for (String u : csv.cell("UOM_UCUM").split(" ")) {
String msg = ucum.validate(u);
if (msg != null) {
errorCount++;
ucumIssues.put(u, msg);
} else
ul.append(u);
}
if (ul.length() > 0)
c.addProperty().setCode("ucum").setValue(new StringType().setValue(ul.toString()));
}
}
}
}
csv.close();
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "codesystem-" + cs.getId() + ".xml")), cs);
System.out.println(errorCount + "UCUM errors");
for (String u : sorted(ucumIssues.keySet())) System.out.println("Invalid UCUM code: " + u + " because " + ucumIssues.get(u));
return cs;
}
use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method renderLeaf.
private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, boolean title, boolean showCodeDetails, Map<String, String> displayHints) throws FHIRException, UnsupportedEncodingException, IOException {
if (ew == null)
return;
Base e = ew.getBase();
if (e instanceof StringType)
x.addText(((StringType) e).getValue());
else if (e instanceof CodeType)
x.addText(((CodeType) e).getValue());
else if (e instanceof IdType)
x.addText(((IdType) e).getValue());
else if (e instanceof Extension)
x.addText("Extensions: Todo");
else if (e instanceof InstantType)
x.addText(((InstantType) e).toHumanDisplay());
else if (e instanceof DateTimeType)
x.addText(((DateTimeType) e).toHumanDisplay());
else if (e instanceof Base64BinaryType)
x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
else if (e instanceof org.hl7.fhir.dstu2.model.DateType)
x.addText(((org.hl7.fhir.dstu2.model.DateType) e).toHumanDisplay());
else if (e instanceof Enumeration) {
Object ev = ((Enumeration<?>) e).getValue();
// todo: look up a display name if there is one
x.addText(ev == null ? "" : ev.toString());
} else if (e instanceof BooleanType)
x.addText(((BooleanType) e).getValue().toString());
else if (e instanceof CodeableConcept) {
renderCodeableConcept((CodeableConcept) e, x, showCodeDetails);
} else if (e instanceof Coding) {
renderCoding((Coding) e, x, showCodeDetails);
} else if (e instanceof Annotation) {
renderAnnotation((Annotation) e, x);
} else if (e instanceof Identifier) {
renderIdentifier((Identifier) e, x);
} else if (e instanceof org.hl7.fhir.dstu2.model.IntegerType) {
x.addText(Integer.toString(((org.hl7.fhir.dstu2.model.IntegerType) e).getValue()));
} else if (e instanceof org.hl7.fhir.dstu2.model.DecimalType) {
x.addText(((org.hl7.fhir.dstu2.model.DecimalType) e).getValue().toString());
} else if (e instanceof HumanName) {
renderHumanName((HumanName) e, x);
} else if (e instanceof SampledData) {
renderSampledData((SampledData) e, x);
} else if (e instanceof Address) {
renderAddress((Address) e, x);
} else if (e instanceof ContactPoint) {
renderContactPoint((ContactPoint) e, x);
} else if (e instanceof UriType) {
renderUri((UriType) e, x);
} else if (e instanceof Timing) {
renderTiming((Timing) e, x);
} else if (e instanceof Range) {
renderRange((Range) e, x);
} else if (e instanceof Quantity) {
renderQuantity((Quantity) e, x, showCodeDetails);
} else if (e instanceof Ratio) {
renderQuantity(((Ratio) e).getNumerator(), x, showCodeDetails);
x.addText("/");
renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails);
} else if (e instanceof Period) {
Period p = (Period) e;
x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
x.addText(" --> ");
x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
} else if (e instanceof Reference) {
Reference r = (Reference) e;
XhtmlNode c = x;
ResourceWithReference tr = null;
if (r.hasReferenceElement()) {
tr = resolveReference(res, r.getReference());
if (!r.getReference().startsWith("#")) {
if (tr != null && tr.getReference() != null)
c = x.addTag("a").attribute("href", tr.getReference());
else
c = x.addTag("a").attribute("href", r.getReference());
}
}
// what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
if (r.hasDisplayElement()) {
c.addText(r.getDisplay());
if (tr != null) {
c.addText(". Generated Summary: ");
generateResourceSummary(c, tr.getResource(), true, r.getReference().startsWith("#"));
}
} else if (tr != null) {
generateResourceSummary(c, tr.getResource(), r.getReference().startsWith("#"), r.getReference().startsWith("#"));
} else {
c.addText(r.getReference());
}
} else if (e instanceof Resource) {
return;
} else if (e instanceof ElementDefinition) {
x.addText("todo-bundle");
} else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta))
throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet");
}
Aggregations