public org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.instance.model.Narrative src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative(); copyElement(src, tgt); tgt.setStatus(convertNarrativeStatus(src.getStatus())); tgt.setDiv(src.getDiv()); return tgt; }
protected String addReference(DomainResource r, String title, String id) throws Exception { if (r.getText() == null) r.setText(new Narrative()); if (r.getText().getDiv() == null) { r.getText().setStatus(NarrativeStatus.GENERATED); new NarrativeGenerator("", "", context).generate(r); } r.setMeta(new Meta().setLastUpdatedElement(InstantType.now())); r.setId(id); feed.getEntry().add(new BundleEntryComponent().setResource(r)); return id; }
public org.hl7.fhir.instance.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.Narrative tgt = new org.hl7.fhir.instance.model.Narrative(); copyElement(src, tgt); tgt.setStatus(convertNarrativeStatus(src.getStatus())); tgt.setDiv(src.getDiv()); return tgt; }
public StructureMap generateMapFromMappings(StructureDefinition sd) throws IOException, FHIRException { String id = getLogicalMappingId(sd); if (id == null) return null; String prefix = ToolingExtensions.readStringExtension(sd, ToolingExtensions.EXT_MAPPING_PREFIX); String suffix = ToolingExtensions.readStringExtension(sd, ToolingExtensions.EXT_MAPPING_SUFFIX); if (prefix == null || suffix == null) return null; // we build this by text. Any element that has a mapping, we put it's mappings inside it.... StringBuilder b = new StringBuilder(); b.append(prefix); ElementDefinition root = sd.getSnapshot().getElementFirstRep(); String m = getMapping(root, id); if (m != null) b.append(m+"\r\n"); addChildMappings(b, id, "", sd, root, false); b.append("\r\n"); b.append(suffix); b.append("\r\n"); StructureMap map = parse(b.toString()); map.setId(tail(map.getUrl())); if (!map.hasStatus()) map.setStatus(PublicationStatus.DRAFT); map.getText().setStatus(NarrativeStatus.GENERATED); map.getText().setDiv(new XhtmlNode(NodeType.Element, "div")); map.getText().getDiv().addTag("pre").addText(render(map)); return map; }
/** * @return {@link #text} (A human-readable narrative that contains the attested content of the section, used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it "clinically safe" for a human to just read the narrative.) */ public Narrative getText() { if (this.text == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create SectionComponent.text"); else if (Configuration.doAutoCreate()) this.text = new Narrative(); // cc return this.text; }
private void loadCache() throws FHIRFormatError, IOException { File[] files = new File(cacheFolder).listFiles(); for (File f : files) { if (f.getName().endsWith(".xml")) { final FileInputStream is = new FileInputStream(f); try { Resource r = context.newXmlParser().setOutputStyle(OutputStyle.PRETTY).parse(is); if (r instanceof OperationOutcome) { OperationOutcome oo = (OperationOutcome) r; expansions.put(ToolingExtensions.getExtension(oo,VS_ID_EXT).getValue().toString(), new ValueSetExpansionOutcome(new XhtmlComposer(XhtmlComposer.XML).composePlainText(oo.getText().getDiv()), TerminologyServiceErrorClass.UNKNOWN)); } else { ValueSet vs = (ValueSet) r; expansions.put(vs.getUrl(), new ValueSetExpansionOutcome(vs)); } } finally { IOUtils.closeQuietly(is); } } } }
public Narrative copy() { Narrative dst = new Narrative(); copyValues(dst); dst.status = status == null ? null : status.copy(); dst.div = div == null ? null : div.copy(); return dst; }
private void loadStructureDefinitions(FhirContext theContext, Map<String, StructureDefinition> theCodeSystems, String theClasspath) { ourLog.info("Loading structure definitions from classpath: {}", theClasspath); InputStream valuesetText = DefaultProfileValidationSupport.class.getResourceAsStream(theClasspath); if (valuesetText != null) { InputStreamReader reader = new InputStreamReader(valuesetText, Charsets.UTF_8); Bundle bundle = theContext.newXmlParser().parseResource(Bundle.class, reader); for (BundleEntryComponent next : bundle.getEntry()) { if (next.getResource() instanceof StructureDefinition) { StructureDefinition nextSd = (StructureDefinition) next.getResource(); nextSd.getText().setDivAsString(""); String system = nextSd.getUrl(); if (isNotBlank(system)) { theCodeSystems.put(system, nextSd); } } } } else { ourLog.warn("Unable to load resource: {}", theClasspath); } }
@Override public Base setProperty(String name, Base value) throws FHIRException { if (name.equals("status")) { value = new NarrativeStatusEnumFactory().fromType(castToCode(value)); this.status = (Enumeration) value; // Enumeration<NarrativeStatus> } else if (name.equals("div")) { this.div = castToXhtml(value); // XhtmlNode } else return super.setProperty(name, value); return value; }
public boolean hasText() { return this.text != null && !this.text.isEmpty(); }
@Override public boolean equalsDeep(Base other_) { if (!super.equalsDeep(other_)) return false; if (!(other_ instanceof Narrative)) return false; Narrative o = (Narrative) other_; return compareDeep(status, o.status, true) && compareDeep(div, o.div, true); }
/** * @return {@link #text} (A human-readable narrative that contains a summary of the resource, and may be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it "clinically safe" for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety.) */ public Narrative getText() { if (this.text == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create DomainResource.text"); else if (Configuration.doAutoCreate()) this.text = new Narrative(); // cc return this.text; }
public void parseResource( final JCas jCas, final Basic resource ) { // composition.addAuthor( practitioner.getPractitionerReference() ); // composition.setId( FhirElementFactory.createId( jCas, ID_NAME_COMPOSITION, noteSpecs.getNoteTime() ) ); // composition.setStatus( Composition.CompositionStatus.FINAL ); // composition.setType( getCompositionType() ); // composition.setLanguage( "English" ); // composition.setSubject( noteSpecs.getSubjectReference( FhirNoteSpecs.SUBJECT_PATIENT ) ); // The following claim to have a 0 .. 1 cardinality, but the doc also states that they SHALL be listed. // composition.setEncounter( noteSpecs.getEncounterReference() ); // composition.setCustodian( practitioner.getOrganizationReference() ); // composition.addEvent( noteSpecs.getEvent() ); // composition.addAttester( practitioner.createAttester( noteSpecs ) ); // composition.setText( FhirElementFactory.createNarrative( jCas.getDocumentText() ) ); final Narrative narrative = resource.getText(); final XhtmlNode htmlNode = narrative.getDiv(); final String docText = htmlNode.allText(); jCas.setDocumentText( docText ); }
if (next.getResource() instanceof CodeSystem) { CodeSystem nextValueSet = (CodeSystem) next.getResource(); nextValueSet.getText().setDivAsString(""); String system = nextValueSet.getUrl(); if (isNotBlank(system)) { nextValueSet.getText().setDivAsString(""); String system = nextValueSet.getUrl(); if (isNotBlank(system)) {
@Override public Base setProperty(int hash, String name, Base value) throws FHIRException { switch (hash) { case -892481550: // status value = new NarrativeStatusEnumFactory().fromType(castToCode(value)); this.status = (Enumeration) value; // Enumeration<NarrativeStatus> return value; case 99473: // div this.div = castToXhtml(value); // XhtmlNode return value; default: return super.setProperty(hash, name, value); } }
public boolean hasText() { return this.text != null && !this.text.isEmpty(); }
public static org.hl7.fhir.dstu3.model.Narrative convertNarrative(org.hl7.fhir.dstu2016may.model.Narrative src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Narrative tgt = new org.hl7.fhir.dstu3.model.Narrative(); copyElement(src, tgt); tgt.setStatus(convertNarrativeStatus(src.getStatus())); tgt.setDiv(src.getDiv()); return tgt; }
protected String addReference(DomainResource r, String title, String id) throws Exception { if (r.getText() == null) r.setText(new Narrative()); if (r.getText().getDiv() == null) { r.getText().setStatus(NarrativeStatus.GENERATED); new NarrativeGenerator("", "", context).generate(r); } r.setMeta(new Meta().setLastUpdatedElement(InstantType.now())); r.setId(id); feed.getEntry().add(new BundleEntryComponent().setResource(r)); return id; }
public static org.hl7.fhir.dstu2016may.model.Narrative convertNarrative(org.hl7.fhir.dstu3.model.Narrative src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.Narrative tgt = new org.hl7.fhir.dstu2016may.model.Narrative(); copyElement(src, tgt); tgt.setStatus(convertNarrativeStatus(src.getStatus())); tgt.setDiv(src.getDiv()); return tgt; }
@Override public Base addChild(String name) throws FHIRException { if (name.equals("text")) { this.text = new Narrative(); return this.text; } else if (name.equals("contained")) { throw new FHIRException("Cannot call addChild on an abstract type DomainResource.contained"); } else if (name.equals("extension")) { return addExtension(); } else if (name.equals("modifierExtension")) { return addModifierExtension(); } else return super.addChild(name); }