org.hl7.fhir.dstu3.model.Narrative Java Examples
The following examples show how to use
org.hl7.fhir.dstu3.model.Narrative.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LibraryOperationsProvider.java From cqf-ruler with Apache License 2.0 | 8 votes |
@Operation(name = "$refresh-generated-content", type = Library.class) public MethodOutcome refreshGeneratedContent(HttpServletRequest theRequest, RequestDetails theRequestDetails, @IdParam IdType theId) { Library theResource = this.libraryResourceProvider.getDao().read(theId); //this.formatCql(theResource); ModelManager modelManager = this.getModelManager(); LibraryManager libraryManager = this.getLibraryManager(modelManager); CqlTranslator translator = this.dataRequirementsProvider.getTranslator(theResource, libraryManager, modelManager); if (translator.getErrors().size() > 0) { throw new RuntimeException("Errors during library compilation."); } this.dataRequirementsProvider.ensureElm(theResource, translator); this.dataRequirementsProvider.ensureRelatedArtifacts(theResource, translator, this); this.dataRequirementsProvider.ensureDataRequirements(theResource, translator); Narrative n = this.narrativeProvider.getNarrative(this.libraryResourceProvider.getContext(), theResource); theResource.setText(n); return this.libraryResourceProvider.update(theRequest, theResource, theId, theRequestDetails.getConditionalUrl(RestOperationTypeEnum.UPDATE), theRequestDetails); }
Example #2
Source File: ArgonautConverter.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void buildNarrative(DomainResource resource, Element child) { if (!Utilities.noString(child.getTextContent())) { XhtmlNode div = new XhtmlNode(NodeType.Element, "div"); String s = child.getTextContent().trim(); if (Utilities.noString(s)) div.addText("No Narrative provided in the source CDA document"); else div.addText(s); resource.setText(new Narrative().setStatus(NarrativeStatus.ADDITIONAL).setDiv(div)); } }
Example #3
Source File: CCDAConverter.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
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; }
Example #4
Source File: NarrativeGenerator.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private void inject(DomainResource r, XhtmlNode x, NarrativeStatus status) { if (!x.hasAttribute("xmlns")) x.setAttribute("xmlns", "http://www.w3.org/1999/xhtml"); if (!r.hasText() || !r.getText().hasDiv() || r.getText().getDiv().getChildNodes().isEmpty()) { r.setText(new Narrative()); r.getText().setDiv(x); r.getText().setStatus(status); } else { XhtmlNode n = r.getText().getDiv(); n.hr(); n.getChildNodes().addAll(x.getChildNodes()); } }
Example #5
Source File: LibraryOperationsProvider.java From cqf-ruler with Apache License 2.0 | 5 votes |
@Operation(name = "$get-narrative", idempotent = true, type = Library.class) public Parameters getNarrative(@IdParam IdType theId) { Library theResource = this.libraryResourceProvider.getDao().read(theId); Narrative n = this.narrativeProvider.getNarrative(this.libraryResourceProvider.getContext(), theResource); Parameters p = new Parameters(); p.addParameter().setValue(new StringType(n.getDivAsString())); return p; }
Example #6
Source File: MeasureOperationsProvider.java From cqf-ruler with Apache License 2.0 | 5 votes |
@Operation(name = "$get-narrative", idempotent = true, type = Measure.class) public Parameters getNarrative(@IdParam IdType theId) { Measure theResource = this.measureResourceProvider.getDao().read(theId); CqfMeasure cqfMeasure = this.dataRequirementsProvider.createCqfMeasure(theResource, this.libraryResolutionProvider); Narrative n = this.narrativeProvider.getNarrative(this.measureResourceProvider.getContext(), cqfMeasure); Parameters p = new Parameters(); p.addParameter().setValue(new StringType(n.getDivAsString())); return p; }
Example #7
Source File: AbstractFindingsAccessor.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public Optional<String> getText(DomainResource resource){ Narrative narrative = ((DomainResource) resource).getText(); if (narrative != null && narrative.getDivAsString() != null) { return ModelUtil.getNarrativeAsString(narrative); } return Optional.empty(); }
Example #8
Source File: AbstractHelper.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public Optional<String> getText(DomainResource domainResource){ Narrative narrative = domainResource.getText(); if (narrative != null && narrative.getDivAsString() != null) { return ModelUtil.getNarrativeAsString(narrative); } return Optional.empty(); }
Example #9
Source File: ModelUtil.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public static Optional<String> getNarrativeAsString(Narrative narrative) { String text = narrative.getDivAsString(); if (text != null) { String divDecodedText = text.replaceAll( "<div>|<div xmlns=\"http://www.w3.org/1999/xhtml\">|</div>|</ div>", ""); divDecodedText = divDecodedText.replaceAll("<br/>|<br />", "\n") .replaceAll("&", "&").replaceAll(">", ">").replaceAll("<", "<") .replaceAll("'§'", "§"); return Optional.of(divDecodedText); } return Optional.empty(); }
Example #10
Source File: ModelUtil.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public static void setNarrativeFromString(Narrative narrative, String text){ text = fixXhtmlContent(text); String divEncodedText = text.replaceAll("<", "<").replaceAll(">", ">").replaceAll("§", "'§'") .replaceAll("&", "&").replaceAll("(\r\n|\r|\n)", "<br />"); narrative.setDivAsString(divEncodedText); }
Example #11
Source File: AbstractFindingModelAdapter.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public Optional<String> getText(){ Optional<IBaseResource> resource = loadResource(); if (resource.isPresent() && resource.get() instanceof DomainResource) { Narrative narrative = ((DomainResource) resource.get()).getText(); if (narrative != null && narrative.getDivAsString() != null) { return ModelUtil.getNarrativeAsString(narrative); } } return Optional.empty(); }
Example #12
Source File: TestData.java From bunsen with Apache License 2.0 | 4 votes |
/** * Returns a FHIR Condition for testing purposes. * * @return a FHIR Condition for testing. */ 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/12345").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; }
Example #13
Source File: TestData.java From bunsen with Apache License 2.0 | 4 votes |
/** * 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; }
Example #14
Source File: CompositionSection.java From careconnect-reference-implementation with Apache License 2.0 | 4 votes |
public Narrative.NarrativeStatus getNarrativeStatus() { return narrativeStatus; }
Example #15
Source File: CompositionSection.java From careconnect-reference-implementation with Apache License 2.0 | 4 votes |
public void setNarrativeStatus(Narrative.NarrativeStatus narrativeStatus) { this.narrativeStatus = narrativeStatus; }