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

The following examples show how to use org.hl7.fhir.r4.model.CodeSystem. 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: ICD11Generator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private CodeSystem makeMMSCodeSystem() {
  CodeSystem cs = new CodeSystem();
  cs.setId("icd11-mms");
  cs.setUrl("http://id.who.int/icd11/mms");
  cs.setName("ICD11MMS");
  cs.setTitle("ICD-11 MMS Linearization");
  cs.setStatus(PublicationStatus.ACTIVE);
  cs.setExperimental(false);
  cs.setDate(new Date());
  cs.setPublisher("WHO");
  cs.setCopyright("Consult WHO For terms of use");
  cs.setCaseSensitive(true);
  cs.setHierarchyMeaning(CodeSystemHierarchyMeaning.CLASSIFIEDWITH);
  cs.setCompositional(true);
  cs.setVersionNeeded(true);
  cs.setValueSet("http://id.who.int/icd11/ValueSet/all-MMS");
  cs.setContent(CodeSystemContentMode.COMPLETE);
  CodeSystemUtilities.defineCodeSystemProperty(cs, "kind", "The kind of artifact this concept represents", PropertyType.CODE).setUri("http://id.who.int/icd11/properties#kind");
  CodeSystemUtilities.defineCodeSystemProperty(cs, "terms", "Other keywords for searching", PropertyType.STRING).setUri("http://id.who.int/icd11/properties#terms");
  CodeSystemUtilities.defineCodeSystemProperty(cs, "codingNote", "Coding advice for this concept", PropertyType.STRING).setUri("http://id.who.int/icd11/properties#codingNote");
  CodeSystemUtilities.defineCodeSystemProperty(cs, "exclusion", "References to diseases that are excluded from this concept", PropertyType.CODING).setUri("http://id.who.int/icd11/properties#exclusion");
  CodeSystemUtilities.defineCodeSystemProperty(cs, "abstract", "If concept is abstract", PropertyType.BOOLEAN);
  CodeSystemUtilities.defineCodeSystemProperty(cs, "postcoordinationScale", "", PropertyType.CODE).setUri("http://id.who.int/icd11/properties#postcoordinationScale");
  return cs;
}
 
Example #2
Source File: CodeSystemUtilities.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public static boolean isDeprecated(CodeSystem cs, ConceptDefinitionComponent def)  {
  try {
    for (ConceptPropertyComponent p : def.getProperty()) {
      if (p.getCode().equals("status") && p.hasValue() && p.hasValueCodeType() && p.getValueCodeType().getCode().equals("deprecated"))
        return true;
      // this, though status should also be set
      if (p.getCode().equals("deprecationDate") && p.hasValue() && p.getValue() instanceof DateTimeType) 
        return ((DateTimeType) p.getValue()).before(new DateTimeType(Calendar.getInstance()));
      // legacy  
      if (p.getCode().equals("deprecated") && p.hasValue() && p.getValue() instanceof BooleanType) 
        return ((BooleanType) p.getValue()).getValue();
    }
    return false;
  } catch (FHIRException e) {
    return false;
  }
}
 
Example #3
Source File: CareConnectProfileDbValidationSupportR4.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
private CodeValidationResult testIfConceptIsInListInner(List<CodeSystem.ConceptDefinitionComponent> conceptList, boolean theCaseSensitive, String code) {
  logT("CareConnect testIfConceptIsInListInner: code=" + code);
  CodeValidationResult retVal = null;
  for (CodeSystem.ConceptDefinitionComponent next : conceptList) {
    // KGM
    logT("CareConnect testIfConceptIsInListInner NextCode = "+next.getCode());
    String nextCandidate = next.getCode();
    if (theCaseSensitive == false) {
      nextCandidate = nextCandidate.toUpperCase();
    }
    if (nextCandidate.equals(code)) {
      logD("Code "+code+" is in the list");
      retVal = new CodeValidationResult(next);
      break;
    }

    // recurse
    retVal = testIfConceptIsInList(code, next.getConcept(), theCaseSensitive);
    if (retVal != null) {
      break;
    }
  }

  return retVal;
}
 
Example #4
Source File: CareConnectProfileDbValidationSupportR4.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Override
public CodeValidationResult validateCode(FhirContext theContext, String theCodeSystem, String theCode, String theDisplay) {
  CodeSystem cs = fetchCodeSystem(theContext, theCodeSystem);
  logD("CareConnect validateCode system = "+ theCodeSystem);

  if (cs != null) {
    boolean caseSensitive = true;
    if (cs.hasCaseSensitive()) {
      caseSensitive = cs.getCaseSensitive();
    }

    CodeValidationResult retVal = testIfConceptIsInList(theCode, cs.getConcept(), caseSensitive);

    if (retVal != null) {
      return retVal;
    }
  }

  return new CodeValidationResult(IssueSeverity.WARNING, "CareConnect Unknown code: " + theCodeSystem + " / " + theCode);
}
 
Example #5
Source File: ValidationSupportR4.java    From synthea with Apache License 2.0 6 votes vote down vote up
@Override
public LookupCodeResult lookupCode(FhirContext theContext, String theSystem, String theCode) {
  if (isCodeSystemSupported(theContext, theSystem)) {
    LookupCodeResult result = new LookupCodeResult();
    result.setSearchedForSystem(theSystem);
    result.setSearchedForCode(theCode);
    result.setFound(false);

    CodeSystem cs = codeSystemMap.get(theSystem);
    for (ConceptDefinitionComponent def : cs.getConcept()) {
      if (def.getCode().equals(theCode)) {
        result.setCodeDisplay(def.getDisplay());
        result.setFound(true);
        return result;
      }
    }
  }
  return LookupCodeResult.notFound(theSystem, theCode);
}
 
Example #6
Source File: ValueSetExpanderSimple.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void includeCodes(ConceptSetComponent inc, List<ValueSetExpansionParameterComponent> params, Parameters expParams, boolean heirarchical) throws ETooCostly, FileNotFoundException, IOException, FHIRException {
  inc.checkNoModifiers("Compose.include", "expanding");
  List<ValueSet> imports = new ArrayList<ValueSet>();
  for (UriType imp : inc.getValueSet()) {
    imports.add(importValueSet(imp.getValue(), params, expParams));
  }

  if (!inc.hasSystem()) {
    if (imports.isEmpty()) // though this is not supposed to be the case
      return;
    ValueSet base = imports.get(0);
    imports.remove(0);
    base.checkNoModifiers("Imported ValueSet", "expanding");
    copyImportContains(base.getExpansion().getContains(), null, expParams, imports);
  } else {
    CodeSystem cs = context.fetchCodeSystem(inc.getSystem());
    if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE)) {
      doServerIncludeCodes(inc, heirarchical, params, imports, expParams);
    } else {
      doInternalIncludeCodes(inc, params, expParams, imports, cs);
    }
  }
}
 
Example #7
Source File: CodeSystem14_40.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public static org.hl7.fhir.r4.model.CodeSystem.CodeSystemFilterComponent convertCodeSystemFilterComponent(org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemFilterComponent src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.r4.model.CodeSystem.CodeSystemFilterComponent tgt = new org.hl7.fhir.r4.model.CodeSystem.CodeSystemFilterComponent();
    VersionConvertor_14_40.copyElement(src, tgt);
    if (src.hasCodeElement())
        tgt.setCodeElement(VersionConvertor_14_40.convertCode(src.getCodeElement()));
    if (src.hasDescription())
        tgt.setDescriptionElement(VersionConvertor_14_40.convertString(src.getDescriptionElement()));
    for (org.hl7.fhir.dstu2016may.model.CodeType t : src.getOperator()) try {
        tgt.addOperator(CodeSystem.FilterOperator.fromCode(t.getValue()));
    } catch (org.hl7.fhir.exceptions.FHIRException e) {
        throw new FHIRException(e);
    }
    if (src.hasValueElement())
        tgt.setValueElement(VersionConvertor_14_40.convertString(src.getValueElement()));
    return tgt;
}
 
Example #8
Source File: CodeSystem14_40.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode> convertCodeSystemContentMode(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemContentMode> src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentModeEnumFactory());
    VersionConvertor_14_40.copyElement(src, tgt);
    switch(src.getValue()) {
        case NOTPRESENT:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode.NOTPRESENT);
            break;
        case EXAMPLAR:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode.EXAMPLE);
            break;
        case FRAGMENT:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode.FRAGMENT);
            break;
        case COMPLETE:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode.COMPLETE);
            break;
        default:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode.NULL);
            break;
    }
    return tgt;
}
 
Example #9
Source File: ValueSet10_40.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
static public void processConcept(List<ValueSet.ConceptDefinitionComponent> concepts, ConceptDefinitionComponent cs, CodeSystem srcCS) throws FHIRException {
    org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent ct = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent();
    concepts.add(ct);
    ct.setCode(cs.getCode());
    ct.setDisplay(cs.getDisplay());
    ct.setDefinition(cs.getDefinition());
    if (CodeSystemUtilities.isNotSelectable(srcCS, cs))
        ct.setAbstract(true);
    for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) {
        org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent();
        cst.setLanguage(csd.getLanguage());
        cst.setUse(VersionConvertor_10_40.convertCoding(csd.getUse()));
        cst.setValue(csd.getValue());
    }
    for (ConceptDefinitionComponent csc : cs.getConcept()) processConcept(ct.getConcept(), csc, srcCS);
}
 
Example #10
Source File: ICD11Generator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private CodeSystem makeEntityCodeSystem() {
    CodeSystem cs = new CodeSystem();
    cs.setId("icd11-foundation");
    cs.setUrl("http://id.who.int/icd11/foundation");
    cs.setName("ICD11Entity");
    cs.setTitle("ICD-11 Entities (Foundation)");
    cs.setStatus(PublicationStatus.ACTIVE);
    cs.setExperimental(false);
    cs.setDate(new Date());
    cs.setPublisher("WHO");
    cs.setCopyright("Consult WHO For terms of use");
    cs.setCaseSensitive(true);
    cs.setHierarchyMeaning(CodeSystemHierarchyMeaning.ISA); // though we aren't going to have a heirarchy
//    cs.setCompositional(true);
//    cs.setVersionNeeded(true);
    cs.setValueSet("http://id.who.int/icd11/ValueSet/all-foundation");
    cs.setContent(CodeSystemContentMode.COMPLETE);
    CodeSystemUtilities.defineCodeSystemProperty(cs, "exclusion", "References to diseases that are excluded from this concept", PropertyType.CODING).setUri("http://id.who.int/icd11/properties#exclusion");
    CodeSystemUtilities.defineCodeSystemProperty(cs, "inclusion", "References to diseases that are included from this concept", PropertyType.CODING).setUri("http://id.who.int/icd11/properties#inclusion");
    CodeSystemUtilities.defineCodeSystemProperty(cs, "narrowerTerm", "Narrower terms for this entity", PropertyType.CODE).setUri("http://id.who.int/icd11/properties#narrowerTerm");
    CodeSystemUtilities.defineCodeSystemProperty(cs, "parent", "Parent for this concept", PropertyType.CODE);
    CodeSystemUtilities.defineCodeSystemProperty(cs, "child", "Child for this concept", PropertyType.CODE);
    return cs;
  }
 
Example #11
Source File: ValueSet10_40.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
static public void processConcept(List<ConceptDefinitionComponent> concepts, org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent cs, CodeSystem tgtcs) throws FHIRException {
    org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent ct = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent();
    concepts.add(ct);
    ct.setCode(cs.getCode());
    ct.setDisplay(cs.getDisplay());
    ct.setDefinition(cs.getDefinition());
    if (cs.getAbstract())
        CodeSystemUtilities.setNotSelectable(tgtcs, ct);
    for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) {
        org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent();
        cst.setLanguage(csd.getLanguage());
        cst.setUse(VersionConvertor_10_40.convertCoding(csd.getUse()));
        cst.setValue(csd.getValue());
    }
    for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent csc : cs.getConcept()) processConcept(ct.getConcept(), csc, tgtcs);
}
 
Example #12
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 #13
Source File: CodeSystemUpdateProvider.java    From cqf-ruler with Apache License 2.0 6 votes vote down vote up
/***
 * Perform union of codes within a ValueSet and CodeSystem
 *
 * @param valueSetCodes The codes contained within a ValueSet
 * @param codeSystem A CodeSystem resource
 * @return List of distinct codes strings
 */
private List<String> getUnionDistinctCodes(ValueSet.ConceptSetComponent valueSetCodes, CodeSystem codeSystem)
{
    if (!codeSystem.hasConcept())
    {
        return valueSetCodes.getConcept().stream().map(ValueSet.ConceptReferenceComponent::getCode).collect(Collectors.toList());
    }
    return Stream.concat(
            valueSetCodes.getConcept().stream().map(
                    ValueSet.ConceptReferenceComponent::getCode).collect(Collectors.toList()
            ).stream(),
            codeSystem.getConcept().stream().map(
                    CodeSystem.ConceptDefinitionComponent::getCode).collect(Collectors.toList()
            ).stream()
    )
            .distinct()
            .collect(Collectors.toList());
}
 
Example #14
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 #15
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 #16
Source File: CodeSystem14_40.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemPropertyComponent convertPropertyComponent(org.hl7.fhir.r4.model.CodeSystem.PropertyComponent src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemPropertyComponent tgt = new org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemPropertyComponent();
    VersionConvertor_14_40.copyElement(src, tgt);
    if (src.hasCodeElement())
        tgt.setCodeElement(VersionConvertor_14_40.convertCode(src.getCodeElement()));
    if (src.hasDescription())
        tgt.setDescriptionElement(VersionConvertor_14_40.convertString(src.getDescriptionElement()));
    if (src.hasType())
        tgt.setTypeElement(convertPropertyType(src.getTypeElement()));
    return tgt;
}
 
Example #17
Source File: CodeSystemUpdateProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
/***
 * Overwrite the given CodeSystem codes with the given codes
 *
 * @param codeSystem A CodeSystem resource
 * @param codes List of (unique) code strings
 */
private void updateCodeSystem(CodeSystem codeSystem, List<String> codes)
{
    codeSystem.setConcept(
            codes.stream().map(
                    x -> new CodeSystem.ConceptDefinitionComponent().setCode(x)
            )
            .collect(Collectors.toList())
    ).setContent(CodeSystem.CodeSystemContentMode.COMPLETE).setStatus(Enumerations.PublicationStatus.ACTIVE);

    this.codeSystemDao.update(codeSystem);
}
 
Example #18
Source File: CodeSystem14_40.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CodeSystem.PropertyType> convertPropertyType(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.CodeSystem.PropertyType> src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CodeSystem.PropertyType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CodeSystem.PropertyTypeEnumFactory());
    VersionConvertor_14_40.copyElement(src, tgt);
    switch(src.getValue()) {
        case CODE:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.PropertyType.CODE);
            break;
        case CODING:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.PropertyType.CODING);
            break;
        case STRING:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.PropertyType.STRING);
            break;
        case INTEGER:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.PropertyType.INTEGER);
            break;
        case BOOLEAN:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.PropertyType.BOOLEAN);
            break;
        case DATETIME:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.PropertyType.DATETIME);
            break;
        default:
            tgt.setValue(org.hl7.fhir.r4.model.CodeSystem.PropertyType.NULL);
            break;
    }
    return tgt;
}
 
Example #19
Source File: CodeSystem14_40.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static org.hl7.fhir.r4.model.CodeSystem.PropertyComponent convertPropertyComponent(org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemPropertyComponent src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.r4.model.CodeSystem.PropertyComponent tgt = new org.hl7.fhir.r4.model.CodeSystem.PropertyComponent();
    VersionConvertor_14_40.copyElement(src, tgt);
    if (src.hasCodeElement())
        tgt.setCodeElement(VersionConvertor_14_40.convertCode(src.getCodeElement()));
    if (src.hasDescription())
        tgt.setDescriptionElement(VersionConvertor_14_40.convertString(src.getDescriptionElement()));
    if (src.hasType())
        tgt.setTypeElement(convertPropertyType(src.getTypeElement()));
    return tgt;
}
 
Example #20
Source File: R2016MayToR4Loader.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Override
public void handleCodeSystem(CodeSystem cs, ValueSet vs) {
  cs.setId(vs.getId());
  cs.setValueSet(vs.getUrl());
  cslist.add(cs);
  
}
 
Example #21
Source File: JpaTerminologyProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized Code lookup(Code code, CodeSystemInfo codeSystem) throws ResourceNotFoundException {
    CodeSystem cs = terminologySvcR4.fetchCodeSystem(context, codeSystem.getId());
    for (CodeSystem.ConceptDefinitionComponent concept : cs.getConcept()) {
        if (concept.getCode().equals(code.getCode()))
            return code.withSystem(codeSystem.getId()).withDisplay(concept.getDisplay());
    }
    return code;
}
 
Example #22
Source File: ValidationSupportR4.java    From synthea with Apache License 2.0 5 votes vote down vote up
/**
 * Defines the custom validation support for various implementation guides.
 */
public ValidationSupportR4() {
  resources = new ArrayList<IBaseResource>();
  resourcesMap = new HashMap<String, IBaseResource>();
  definitions = new ArrayList<StructureDefinition>();
  definitionsMap = new HashMap<String, StructureDefinition>();
  codeSystemMap = new HashMap<String, CodeSystem>();

  try {
    loadFromDirectory(profileDir);
  } catch (Throwable t) {
    throw new RuntimeException(t);
  }
}
 
Example #23
Source File: CodeSystem14_40.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemContactComponent convertCodeSystemContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemContactComponent tgt = new org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemContactComponent();
    VersionConvertor_14_40.copyElement(src, tgt);
    if (src.hasName())
        tgt.setNameElement(VersionConvertor_14_40.convertString(src.getNameElement()));
    for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(VersionConvertor_14_40.convertContactPoint(t));
    return tgt;
}
 
Example #24
Source File: CodeSystem14_40.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static org.hl7.fhir.r4.model.ContactDetail convertCodeSystemContactComponent(org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemContactComponent src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail();
    VersionConvertor_14_40.copyElement(src, tgt);
    if (src.hasName())
        tgt.setNameElement(VersionConvertor_14_40.convertString(src.getNameElement()));
    for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(VersionConvertor_14_40.convertContactPoint(t));
    return tgt;
}
 
Example #25
Source File: CountryCodesConverter.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public void setMetadata(Document src, CodeSystem cs, String id, String url, String partName, String partTitle) {
  cs.setId(id);
  cs.setUrl(url);
  cs.setName("ISOCountryCodes"+partName);
  cs.setTitle("ISO Country Codes (ISO-3166)"+partTitle);
  cs.setVersion(XMLUtil.getFirstChild(src.getDocumentElement()).getAttribute("version"));
  cs.setStatus(PublicationStatus.ACTIVE);
  cs.setExperimental(false);
  cs.addContact().setName("FHIR Project Team").addTelecom().setSystem(ContactPointSystem.URL).setValue("http://hl7.org/fhir");
  cs.setDateElement(new DateTimeType(src.getDocumentElement().getAttribute("generated")));
  cs.setCopyright("Copyright ISO. See https://www.iso.org/obp/ui/#search/code/");
  cs.setCaseSensitive(true);
  cs.setContent(CodeSystemContentMode.COMPLETE);
  cs.setLanguage("en");
}
 
Example #26
Source File: ValidationSupportR4.java    From synthea with Apache License 2.0 5 votes vote down vote up
private void handleResource(IBaseResource resource) {
  if (resource instanceof Bundle) {
    Bundle bundle = (Bundle) resource;
    for (BundleEntryComponent entry : bundle.getEntry()) {
      if (entry.hasResource()) {
        handleResource(entry.getResource());
      }
    }
  } else {
    resources.add(resource);
    if (resource instanceof CodeSystem) {
      CodeSystem cs = (CodeSystem) resource;
      resourcesMap.put(cs.getUrl(), cs);
      codeSystemMap.put(cs.getUrl(), cs);
    } else if (resource instanceof ValueSet) {
      ValueSet vs = (ValueSet) resource;
      resourcesMap.put(vs.getUrl(), vs);

      if (vs.hasExpansion() && vs.getExpansion().hasContains()) {
        processExpansion(vs.getExpansion().getContains());
      }
    } else if (resource instanceof StructureDefinition) {
      StructureDefinition sd = (StructureDefinition) resource;
      resourcesMap.put(sd.getUrl(), sd);
      definitions.add(sd);
      definitionsMap.put(sd.getUrl(), sd);
    }
  }
}
 
Example #27
Source File: CodeSystemUpdateProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
public OperationOutcome performCodeSystemUpdate(ValueSet vs)
{
    OperationOutcomeBuilder responseBuilder = new OperationOutcomeBuilder();

    List<String> codeSystems = new ArrayList<>();
    if (vs.hasCompose() && vs.getCompose().hasInclude())
    {
        CodeSystem codeSystem;
        for (ValueSet.ConceptSetComponent csc : vs.getCompose().getInclude())
        {
            if (!csc.hasSystem()) continue;

            codeSystem = getCodeSystemByUrl(csc.getSystem());

            if (!csc.hasConcept()) continue;

            updateCodeSystem(
                    codeSystem.setUrl(csc.getSystem()),
                    getUnionDistinctCodes(csc, codeSystem)
            );

            codeSystems.add(codeSystem.getUrl());
        }
    }

    return responseBuilder.buildIssue(
            "information",
            "informational",
            "Successfully updated the following CodeSystems: " + String.join(", ", codeSystems)
    ).build();
}
 
Example #28
Source File: CodeSystemUpdateProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
/***
 * Fetch CodeSystem matching the given url search parameter
 *
 * @param url The url of the CodeSystem to fetch
 * @return The CodeSystem that matches the url parameter or a new CodeSystem with the url and id populated
 */
private CodeSystem getCodeSystemByUrl(String url)
{
    IBundleProvider bundleProvider =
            this.codeSystemDao.search(
                            new SearchParameterMap().add(CodeSystem.SP_URL, new UriParam(url))
            );

    if (bundleProvider.size() >= 1)
    {
        return (CodeSystem) bundleProvider.getResources(0, 1).get(0);
    }

    return (CodeSystem) new CodeSystem().setUrl(url).setId(RandomIdBuilder.build(null));
}
 
Example #29
Source File: CodeSystemUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static boolean isNotSelectable(CodeSystem cs, ConceptDefinitionComponent def) {
  for (ConceptPropertyComponent p : def.getProperty()) {
    if (p.getCode().equals("notSelectable") && p.hasValue() && p.getValue() instanceof BooleanType) 
      return ((BooleanType) p.getValue()).getValue();
  }
  return false;
}
 
Example #30
Source File: CodeSystem14_40.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public static org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemFilterComponent convertCodeSystemFilterComponent(org.hl7.fhir.r4.model.CodeSystem.CodeSystemFilterComponent src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemFilterComponent tgt = new org.hl7.fhir.dstu2016may.model.CodeSystem.CodeSystemFilterComponent();
    VersionConvertor_14_40.copyElement(src, tgt);
    if (src.hasCodeElement())
        tgt.setCodeElement(VersionConvertor_14_40.convertCode(src.getCodeElement()));
    if (src.hasDescription())
        tgt.setDescriptionElement(VersionConvertor_14_40.convertString(src.getDescriptionElement()));
    for (Enumeration<FilterOperator> t : src.getOperator()) tgt.addOperator(t.getValue().toCode());
    if (src.hasValueElement())
        tgt.setValueElement(VersionConvertor_14_40.convertString(src.getValueElement()));
    return tgt;
}