Java Code Examples for org.hl7.fhir.r4.model.ValueSet#setStatus()

The following examples show how to use org.hl7.fhir.r4.model.ValueSet#setStatus() . 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: ProfileComparer.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private ValueSet intersectByExpansion(ValueSet lvs, ValueSet rvs) {
  // this is pretty straight forward - we intersect the lists, and build a compose out of the intersection
  ValueSet vs = new ValueSet();
  vs.setStatus(PublicationStatus.DRAFT);
  
  Map<String, ValueSetExpansionContainsComponent> left = new HashMap<String, ValueSetExpansionContainsComponent>();
  scan(lvs.getExpansion().getContains(), left);
  Map<String, ValueSetExpansionContainsComponent> right = new HashMap<String, ValueSetExpansionContainsComponent>();
  scan(rvs.getExpansion().getContains(), right);
  Map<String, ConceptSetComponent> inc = new HashMap<String, ConceptSetComponent>();
  
  for (String s : left.keySet()) {
    if (right.containsKey(s)) {
      ValueSetExpansionContainsComponent cc = left.get(s);
      ConceptSetComponent c = inc.get(cc.getSystem());
      if (c == null) {
        c = vs.getCompose().addInclude().setSystem(cc.getSystem());
        inc.put(cc.getSystem(), c);
      }
      c.addConcept().setCode(cc.getCode()).setDisplay(cc.getDisplay());
    }
  }
  return vs;
}
 
Example 2
Source File: ICD11Generator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void makeFullVs(String dest, CodeSystem cs) throws FileNotFoundException, IOException {
  String url = "http://id.who.int/icd11/ValueSet/all-MMS";
  ValueSet vs = new ValueSet();
  vs.setId("all-MMS");
  vs.setUrl(url);
  vs.setName("ICDMMSAll");
  vs.setTitle("Value Set for all ICD MMS Codes");
  vs.setStatus(PublicationStatus.ACTIVE);
  vs.setExperimental(false);
  vs.setDate(cs.getDate());
  vs.setPublisher("WHO");
  vs.setCopyright("Consult WHO For terms of use");
  vs.setVersion(cs.getVersion());
  vs.setStatus(cs.getStatus());
  ConceptSetComponent inc = vs.getCompose().addInclude();
  inc.setSystem(cs.getUrl());
  new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "vs-all-MMS.xml")), vs);
}
 
Example 3
Source File: ICD11Generator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void makeFullVs2(String dest, CodeSystem cs) throws FileNotFoundException, IOException {
  String url = "http://id.who.int/icd11/ValueSet/all-foundation";
  ValueSet vs = new ValueSet();
  vs.setId("all-foundation");
  vs.setUrl(url);
  vs.setName("ICDFoundationAll");
  vs.setTitle("Value Set for all ICD Foundation Concepts");
  vs.setStatus(PublicationStatus.ACTIVE);
  vs.setExperimental(false);
  vs.setDate(cs.getDate());
  vs.setPublisher("WHO");
  vs.setCopyright("Consult WHO For terms of use");
  vs.setVersion(cs.getVersion());
  vs.setStatus(cs.getStatus());
  ConceptSetComponent inc = vs.getCompose().addInclude();
  inc.setSystem(cs.getUrl());
  new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "vs-all-foundation.xml")), vs);
}
 
Example 4
Source File: ICD11Generator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private String buildValueSet(CodeSystem cs, String code, String name, JsonObject o, String dest) throws FileNotFoundException, IOException {
  String id = code+"-"+name;
  String url = "http://id.who.int/icd11/ValueSet/"+id;
  ValueSet vs = new ValueSet();
  vs.setId(id);
  vs.setUrl(url);
  vs.setName("VS"+name+"4"+code);
  vs.setTitle("Value Set for "+name+" on "+code);
  vs.setStatus(PublicationStatus.ACTIVE);
  vs.setExperimental(false);
  vs.setDate(cs.getDate());
  vs.setPublisher("WHO");
  vs.setCopyright("Consult WHO For terms of use");
  vs.setVersion(cs.getVersion());
  vs.setStatus(cs.getStatus());
  ConceptSetComponent inc = vs.getCompose().addInclude();
  inc.setSystem(cs.getUrl());
  for (JsonElement e : o.getAsJsonArray("scaleEntity")) {
    inc.addFilter().setProperty("concept").setOp(FilterOperator.ISA).setValue(tail(e.getAsString()));
  }    
  new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "vs-"+id+".xml")), vs);
  return url;
}
 
Example 5
Source File: ImplicitValueSets.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private static ValueSet allUcumValueSet() {
  ValueSet vs = new ValueSet();
  vs.setUrl("http://unitsofmeasure.org/vs");
  vs.setStatus(PublicationStatus.ACTIVE);
  vs.setName("AllUcumCodes");
  vs.setTitle("All Ucum Codes");
  vs.getCompose().addInclude().setSystem("http://unitsofmeasure.org");
  return vs;
}
 
Example 6
Source File: ValueSetUtilities.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public static void markStatus(ValueSet vs, String wg, StandardsStatus status, String pckage, String fmm, IWorkerContext context, String normativeVersion) throws FHIRException {
  if (vs.hasUserData("external.url"))
    return;
  
  if (wg != null) {
    if (!ToolingExtensions.hasExtension(vs, ToolingExtensions.EXT_WORKGROUP) || 
        (!Utilities.existsInList(ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP), "fhir", "vocab") && Utilities.existsInList(wg, "fhir", "vocab"))) {
      ToolingExtensions.setCodeExtension(vs, ToolingExtensions.EXT_WORKGROUP, wg);
    }
  }
  if (status != null) {
    StandardsStatus ss = ToolingExtensions.getStandardsStatus(vs);
    if (ss == null || ss.isLowerThan(status)) 
      ToolingExtensions.setStandardsStatus(vs, status, normativeVersion);
    if (pckage != null) {
      if (!vs.hasUserData("ballot.package"))        
        vs.setUserData("ballot.package", pckage);
      else if (!pckage.equals(vs.getUserString("ballot.package")))
        if (!"infrastructure".equals(vs.getUserString("ballot.package")))
        System.out.println("Value Set "+vs.getUrl()+": ownership clash "+pckage+" vs "+vs.getUserString("ballot.package"));
    }
    if (status == StandardsStatus.NORMATIVE) {
      vs.setExperimental(false);
      vs.setStatus(PublicationStatus.ACTIVE);
    }
  }
  if (fmm != null) {
    String sfmm = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_FMM_LEVEL);
    if (Utilities.noString(sfmm) || Integer.parseInt(sfmm) < Integer.parseInt(fmm)) 
      ToolingExtensions.setIntegerExtension(vs, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(fmm));
  }
  if (vs.hasUserData("cs"))
    CodeSystemUtilities.markStatus((CodeSystem) vs.getUserData("cs"), wg, status, pckage, fmm, normativeVersion);
  else if (status == StandardsStatus.NORMATIVE && context != null) {
    for (ConceptSetComponent csc : vs.getCompose().getInclude()) {
      if (csc.hasSystem()) {
        CodeSystem cs = context.fetchCodeSystem(csc.getSystem());
        if (cs != null) {
          CodeSystemUtilities.markStatus(cs, wg, status, pckage, fmm, normativeVersion);
        }
      }
    }
  }
}