Search in sources :

Example 76 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.

the class BuildWorkerContext method verifyCode.

private ValidationResult verifyCode(CodeSystem cs, String code, String display) throws Exception {
    ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code);
    if (cc == null)
        return new ValidationResult(IssueSeverity.ERROR, "Unknown Code " + code + " in " + cs.getUrl());
    if (display == null)
        return new ValidationResult(cc);
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
    if (cc.hasDisplay()) {
        b.append(cc.getDisplay());
        if (display.equalsIgnoreCase(cc.getDisplay()))
            return new ValidationResult(cc);
    }
    for (ConceptDefinitionDesignationComponent ds : cc.getDesignation()) {
        b.append(ds.getValue());
        if (display.equalsIgnoreCase(ds.getValue()))
            return new ValidationResult(cc);
    }
    return new ValidationResult(IssueSeverity.ERROR, "Display Name for " + code + " must be one of '" + b.toString() + "'");
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 77 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.

the class BuildWorkerContext method verifyUcum.

private ValidationResult verifyUcum(String code, String display) {
    String s = ucum.validate(code);
    if (s != null) {
        System.out.println("UCUM eror: " + s);
        return new ValidationResult(IssueSeverity.ERROR, s);
    } else {
        ConceptDefinitionComponent def = new ConceptDefinitionComponent();
        def.setCode(code);
        def.setDisplay(ucum.getCommonDisplay(code));
        return new ValidationResult(def);
    }
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)

Example 78 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.

the class BuildWorkerContext method locateLoinc.

private ConceptDefinitionComponent locateLoinc(String code) throws Exception {
    if (!loincCodes.containsKey(code))
        return null;
    ConceptDefinitionComponent cc = new ConceptDefinitionComponent();
    cc.setCode(code);
    String s = loincCodes.get(code).display;
    cc.setDisplay(s);
    return cc;
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)

Example 79 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.

the class BuildWorkerContext method locateSnomed.

private ConceptDefinitionComponent locateSnomed(String code) throws Exception {
    if (!snomedCodes.containsKey(code))
        queryForTerm(code);
    if (!snomedCodes.containsKey(code))
        return null;
    ConceptDefinitionComponent cc = new ConceptDefinitionComponent();
    cc.setCode(code);
    cc.setDisplay(snomedCodes.get(code).display);
    return cc;
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)

Example 80 with ConceptDefinitionComponent

use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.

the class ValueSetValidator method checkCodeCaseDuplicates.

private void checkCodeCaseDuplicates(List<ValidationMessage> errors, String nameForErrors, CodeSystem cs, Set<String> codes, List<ConceptDefinitionComponent> concepts) {
    for (ConceptDefinitionComponent c : concepts) {
        if (c.hasCode()) {
            String cc = c.getCode().toLowerCase();
            rule(errors, IssueType.BUSINESSRULE, getWg(cs) + ":CodeSystem[" + cs.getId() + "].define", !codes.contains(cc), "Value set " + nameForErrors + " (" + cs.getName() + "): Code '" + cc + "' is defined twice, different by case - this is not allowed in a FHIR definition");
            if (c.hasConcept())
                checkCodeCaseDuplicates(errors, nameForErrors, cs, codes, c.getConcept());
        }
    }
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)

Aggregations

ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)54 ArrayList (java.util.ArrayList)26 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)26 ConceptDefinitionComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)22 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)21 ConceptDefinitionComponent (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent)17 ConceptDefinitionComponent (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent)16 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)15 FHIRException (org.hl7.fhir.exceptions.FHIRException)14 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)12 ConceptPropertyComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent)10 ConceptPropertyComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent)10 IOException (java.io.IOException)9 HashMap (java.util.HashMap)9 NotImplementedException (org.apache.commons.lang3.NotImplementedException)9 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)9 FileNotFoundException (java.io.FileNotFoundException)8 ConceptDefinitionComponent (org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent)8 ValidationResult (org.hl7.fhir.r5.context.IWorkerContext.ValidationResult)8 ConceptDefinitionDesignationComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent)8