Java Code Examples for org.hl7.fhir.r4.model.Extension#setValue()

The following examples show how to use org.hl7.fhir.r4.model.Extension#setValue() . 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: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void addMarkdownExtension(DomainResource dr, String url, String content) {
  if (!StringUtils.isBlank(content)) {
    Extension ex = getExtension(dr, url);
    if (ex != null)
      ex.setValue(new StringType(content));
    else
      dr.getExtension().add(Factory.newExtension(url, new MarkdownType(content), true));   
  }
}
 
Example 2
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void setExtension(Element focus, String url, Coding c) {
  for (Extension e : focus.getExtension()) 
    if (e.getUrl().equals(url)) {
      e.setValue(c);
      return;
    }
  focus.getExtension().add(new Extension().setUrl(url).setValue(c));    
}
 
Example 3
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void setAllowableUnits(ElementDefinition eld, CodeableConcept cc) {
  for (Extension e : eld.getExtension()) 
    if (e.getUrl().equals(EXT_ALLOWABLE_UNITS)) {
      e.setValue(cc);
      return;
    }
  eld.getExtension().add(new Extension().setUrl(EXT_ALLOWABLE_UNITS).setValue(cc));
}
 
Example 4
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void setIntegerExtension(DomainResource resource, String uri, int value) {
  Extension ext = getExtension(resource, uri);
  if (ext != null)
    ext.setValue(new IntegerType(value));
  else
    resource.getExtension().add(new Extension(new UriType(uri)).setValue(new IntegerType(value)));
}
 
Example 5
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void setCodeExtension(Element element, String uri, String value) {
  if (Utilities.noString(value))
    return;
  
  Extension ext = getExtension(element, uri);
  if (ext != null)
    ext.setValue(new CodeType(value));
  else
    element.getExtension().add(new Extension(new UriType(uri)).setValue(new CodeType(value)));
}
 
Example 6
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void setCodeExtension(DomainResource resource, String uri, String value) {
  if (Utilities.noString(value))
    return;
  
  Extension ext = getExtension(resource, uri);
  if (ext != null)
    ext.setValue(new CodeType(value));
  else
    resource.getExtension().add(new Extension(new UriType(uri)).setValue(new CodeType(value)));
}
 
Example 7
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void setStringExtension(Element resource, String uri, String value) {
  if (Utilities.noString(value))
    return;
      Extension ext = getExtension(resource, uri);
  if (ext != null)
    ext.setValue(new StringType(value));
  else
    resource.getExtension().add(new Extension(new UriType(uri)).setValue(new StringType(value)));
}
 
Example 8
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void setStringExtension(DomainResource resource, String uri, String value) {
  if (Utilities.noString(value))
    return;
      Extension ext = getExtension(resource, uri);
  if (ext != null)
    ext.setValue(new StringType(value));
  else
    resource.getExtension().add(new Extension(new UriType(uri)).setValue(new StringType(value)));
}
 
Example 9
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void addCodeExtension(DomainResource dr, String url, String value) {
  Extension ex = getExtension(dr, url);
  if (ex != null)
    ex.setValue(new CodeType(value));
  else
    dr.getExtension().add(Factory.newExtension(url, new CodeType(value), true));   
}
 
Example 10
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void addIntegerExtension(DomainResource dr, String url, int value) {
  Extension ex = getExtension(dr, url);
  if (ex != null)
    ex.setValue(new IntegerType(value));
  else
    dr.getExtension().add(Factory.newExtension(url, new IntegerType(value), true));   
}
 
Example 11
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void addBooleanExtension(DomainResource e, String url, boolean content) {
  Extension ex = getExtension(e, url);
  if (ex != null)
    ex.setValue(new BooleanType(content));
  else
    e.getExtension().add(Factory.newExtension(url, new BooleanType(content), true));   
}
 
Example 12
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void addBooleanExtension(Element e, String url, boolean content) {
  Extension ex = getExtension(e, url);
  if (ex != null)
    ex.setValue(new BooleanType(content));
  else
    e.getExtension().add(Factory.newExtension(url, new BooleanType(content), true));   
}
 
Example 13
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void addUriExtension(Element e, String url, String uri) {
  Extension ex = getExtension(e, url);
  if (ex != null)
    ex.setValue(new UriType(uri));
  else
    e.getExtension().add(Factory.newExtension(url, new UriType(uri), true));   
}
 
Example 14
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void addStringExtension(DomainResource e, String url, String content) {
  if (!StringUtils.isBlank(content)) {
    Extension ex = getExtension(e, url);
    if (ex != null)
      ex.setValue(new StringType(content));
    else
      e.getExtension().add(Factory.newExtension(url, new StringType(content), true));   
  }
}
 
Example 15
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void addCodeExtension(Element e, String url, String content) {
  if (!StringUtils.isBlank(content)) {
    Extension ex = getExtension(e, url);
    if (ex != null)
      ex.setValue(new CodeType(content));
    else
      e.getExtension().add(Factory.newExtension(url, new CodeType(content), true));   
  }
}
 
Example 16
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static void addStringExtension(Element e, String url, String content) {
  if (!StringUtils.isBlank(content)) {
    Extension ex = getExtension(e, url);
    if (ex != null)
      ex.setValue(new StringType(content));
    else
      e.getExtension().add(Factory.newExtension(url, new StringType(content), true));   
  }
}
 
Example 17
Source File: ToolingExtensions.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static Extension makeIssueSource(Source source) {
  Extension ex = new Extension();
  // todo: write this up and get it published with the pack (and handle the redirect?)
  ex.setUrl(ToolingExtensions.EXT_ISSUE_SOURCE);
  CodeType c = new CodeType();
  c.setValue(source.toString());
  ex.setValue(c);
  return ex;
}
 
Example 18
Source File: HospitalExporterR4.java    From synthea with Apache License 2.0 4 votes vote down vote up
/**
 * Add FHIR extensions to capture additional information.
 */
public static void addHospitalExtensions(Provider h, Organization organizationResource) {
  Table<Integer, String, AtomicInteger> utilization = h.getUtilization();
  // calculate totals for utilization
  int totalEncounters = utilization.column(Provider.ENCOUNTERS).values().stream()
      .mapToInt(ai -> ai.get()).sum();
  Extension encountersExtension = new Extension(SYNTHEA_URI + "utilization-encounters-extension");
  IntegerType encountersValue = new IntegerType(totalEncounters);
  encountersExtension.setValue(encountersValue);
  organizationResource.addExtension(encountersExtension);

  int totalProcedures = utilization.column(Provider.PROCEDURES).values().stream()
      .mapToInt(ai -> ai.get()).sum();
  Extension proceduresExtension = new Extension(SYNTHEA_URI + "utilization-procedures-extension");
  IntegerType proceduresValue = new IntegerType(totalProcedures);
  proceduresExtension.setValue(proceduresValue);
  organizationResource.addExtension(proceduresExtension);

  int totalLabs = utilization.column(Provider.LABS).values().stream().mapToInt(ai -> ai.get())
      .sum();
  Extension labsExtension = new Extension(SYNTHEA_URI + "utilization-labs-extension");
  IntegerType labsValue = new IntegerType(totalLabs);
  labsExtension.setValue(labsValue);
  organizationResource.addExtension(labsExtension);

  int totalPrescriptions = utilization.column(Provider.PRESCRIPTIONS).values().stream()
      .mapToInt(ai -> ai.get()).sum();
  Extension prescriptionsExtension = new Extension(
      SYNTHEA_URI + "utilization-prescriptions-extension");
  IntegerType prescriptionsValue = new IntegerType(totalPrescriptions);
  prescriptionsExtension.setValue(prescriptionsValue);
  organizationResource.addExtension(prescriptionsExtension);

  Integer bedCount = h.getBedCount();
  if (bedCount != null) {
    Extension bedCountExtension = new Extension(SYNTHEA_URI + "bed-count-extension");
    IntegerType bedCountValue = new IntegerType(bedCount);
    bedCountExtension.setValue(bedCountValue);
    organizationResource.addExtension(bedCountExtension);
  }
}
 
Example 19
Source File: MeasureOperationsProvider.java    From cqf-ruler with Apache License 2.0 4 votes vote down vote up
@Operation(name = "$evaluate-measure", idempotent = true, type = Measure.class)
public MeasureReport evaluateMeasure(@IdParam IdType theId, @RequiredParam(name = "periodStart") String periodStart,
        @RequiredParam(name = "periodEnd") String periodEnd, @OptionalParam(name = "measure") String measureRef,
        @OptionalParam(name = "reportType") String reportType, @OptionalParam(name = "patient") String patientRef,
        @OptionalParam(name = "productLine") String productLine,
        @OptionalParam(name = "practitioner") String practitionerRef,
        @OptionalParam(name = "lastReceivedOn") String lastReceivedOn,
        @OptionalParam(name = "source") String source, @OptionalParam(name = "user") String user,
        @OptionalParam(name = "pass") String pass) throws InternalErrorException, FHIRException {
    LibraryLoader libraryLoader = LibraryHelper.createLibraryLoader(this.libraryResolutionProvider);
    MeasureEvaluationSeed seed = new MeasureEvaluationSeed(this.factory, libraryLoader, this.libraryResolutionProvider);
    Measure measure = this.measureResourceProvider.getDao().read(theId);

    if (measure == null) {
        throw new RuntimeException("Could not find Measure/" + theId.getIdPart());
    }

    seed.setup(measure, periodStart, periodEnd, productLine, source, user, pass);

    // resolve report type
    MeasureEvaluation evaluator = new MeasureEvaluation(seed.getDataProvider(), this.registry, seed.getMeasurementPeriod());
    if (reportType != null) {
        switch (reportType) {
        case "patient":
            return evaluator.evaluatePatientMeasure(seed.getMeasure(), seed.getContext(), patientRef);
        case "patient-list":
            return evaluator.evaluateSubjectListMeasure(seed.getMeasure(), seed.getContext(), practitionerRef);
        case "population":
            return  evaluator.evaluatePopulationMeasure(seed.getMeasure(), seed.getContext());
        default:
            throw new IllegalArgumentException("Invalid report type: " + reportType);
        }
    }

    // default report type is patient
    MeasureReport report = evaluator.evaluatePatientMeasure(seed.getMeasure(), seed.getContext(), patientRef);
    if (productLine != null)
    {
        Extension ext = new Extension();
        ext.setUrl("http://hl7.org/fhir/us/cqframework/cqfmeasures/StructureDefinition/cqfm-productLine");
        ext.setValue(new StringType(productLine));
        report.addExtension(ext);
    }

    return report;
}
 
Example 20
Source File: IPatientPatientAttributeMapper.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
private void mapComments(IPatient source, Patient target) {
	Extension elexisPatientNote = new Extension();
	elexisPatientNote.setUrl("www.elexis.info/extensions/patient/notes");
	elexisPatientNote.setValue(new StringType(source.getComment()));
	target.addExtension(elexisPatientNote);
}