org.hl7.fhir.r4.model.Narrative Java Examples

The following examples show how to use org.hl7.fhir.r4.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 5 votes vote down vote up
@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);

try {
	Narrative n = this.narrativeProvider.getNarrative(this.libraryResourceProvider.getContext(), theResource);
	theResource.setText(n);
} catch (Exception e) {
	//Ignore the exception so the resource still gets updated
}

      return this.libraryResourceProvider.update(theRequest, theResource, theId,
              theRequestDetails.getConditionalUrl(RestOperationTypeEnum.UPDATE), theRequestDetails);
  }
 
Example #2
Source File: LibraryOperationsProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
@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 #3
Source File: MeasureOperationsProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
@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 #4
Source File: TestData.java    From bunsen with Apache License 2.0 4 votes vote down vote up
/**
 * 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 #5
Source File: IdentifiableDomainResourceAttributeMapper.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
default void mapNarrative(Identifiable source, DomainResource target) {
	Narrative narrative = new Narrative();
	narrative.setStatus(NarrativeStatus.GENERATED);
	narrative.setDivAsString(source.getLabel());
	target.setText(narrative);
}