Search in sources :

Example 16 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetRenderer method scanForDesignations.

private void scanForDesignations(ValueSetExpansionContainsComponent c, List<String> langs, Map<String, String> designations) {
    for (Extension ext : c.getExtension()) {
        if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
            String lang = ToolingExtensions.readStringExtension(ext, "lang");
            if (!Utilities.noString(lang) && !langs.contains(lang)) {
                langs.add(lang);
            }
        }
    }
    for (ConceptReferenceDesignationComponent d : c.getDesignation()) {
        String lang = d.getLanguage();
        if (!Utilities.noString(lang) && !langs.contains(lang)) {
            langs.add(lang);
        } else {
            // can we present this as a designation that we know?
            String disp = getDisplayForDesignation(d);
            String url = getUrlForDesignation(d);
            if (disp == null) {
                disp = getDisplayForUrl(url);
            }
            if (disp != null && !designations.containsKey(url)) {
                designations.put(url, disp);
            }
        }
    }
    for (ValueSetExpansionContainsComponent cc : c.getContains()) {
        scanForDesignations(cc, langs, designations);
    }
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) ConceptReferenceDesignationComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent)

Example 17 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent in project snowstorm by IHTSDO.

the class HapiValueSetMapper method asDesignation.

private ConceptReferenceDesignationComponent asDesignation(Description d) {
    ConceptReferenceDesignationComponent designation = new ConceptReferenceDesignationComponent();
    designation.setLanguage(d.getLanguageCode());
    designation.setValue(d.getTerm());
    // Designation use context extension
    String descType = FHIRHelper.translateDescType(d.getTypeId());
    // For each acceptability of the acceptability map, add an extension instance
    // TODO: is there a smart way to control when the extension is intantiated?
    d.getAcceptabilityMap().forEach((langRefsetId, acceptability) -> {
        // Create designation use context Extension object using the URI
        // TODO: are there FHIR constants anywhere?
        Extension ducExt = new Extension("http://snomed.info/fhir/StructureDefinition/designation-use-context");
        // Add the context, i.e. the language reference set
        // TODO: is there a quick way to find a description for an id? Which description? Could be in any module/branch path.
        ducExt.addExtension("context", new Coding(SNOMED_URI, langRefsetId, null));
        // Add acceptability
        switch(acceptability) {
            case Concepts.ACCEPTABLE_CONSTANT:
                ducExt.addExtension("role", new Coding(SNOMED_URI, Concepts.ACCEPTABLE, Concepts.ACCEPTABLE_CONSTANT));
                break;
            case Concepts.PREFERRED_CONSTANT:
                ducExt.addExtension("role", new Coding(SNOMED_URI, Concepts.PREFERRED, Concepts.PREFERRED_CONSTANT));
        }
        ;
        // Add type, this is sometimes but not always redundant to designation.use!
        // TODO: currently it is truly redundant but as there are more alternatives for designation.use, e.g. "consumer", this is/will be needed here
        ducExt.addExtension("type", new Coding(SNOMED_URI, d.getTypeId(), descType));
        designation.addExtension(ducExt);
    });
    // End editing for designation use case extension
    Coding use = new Coding(SNOMED_URI, d.getTypeId(), descType);
    designation.setUse(use);
    return designation;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Coding(org.hl7.fhir.r4.model.Coding) ConceptReferenceDesignationComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent)

Example 18 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method convertDesignations.

private List<ConceptDefinitionDesignationComponent> convertDesignations(List<ConceptReferenceDesignationComponent> list) {
    List<ConceptDefinitionDesignationComponent> res = new ArrayList<CodeSystem.ConceptDefinitionDesignationComponent>();
    for (ConceptReferenceDesignationComponent t : list) {
        ConceptDefinitionDesignationComponent c = new ConceptDefinitionDesignationComponent();
        c.setLanguage(t.getLanguage());
        c.setUse(t.getUse());
        c.setValue(t.getValue());
    }
    return res;
}
Also used : ConceptDefinitionDesignationComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent) ArrayList(java.util.ArrayList) ConceptReferenceDesignationComponent(org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent) CodeSystem(org.hl7.fhir.r4.model.CodeSystem)

Example 19 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetCheckerSimple method validateCode.

private ValidationResult validateCode(Coding code, CodeSystem cs) {
    ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code.getCode());
    if (cc == null)
        return new ValidationResult(IssueSeverity.ERROR, "Unknown Code " + gen(code) + " in " + cs.getUrl());
    if (code.getDisplay() == null)
        return new ValidationResult(cc);
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
    if (cc.hasDisplay()) {
        b.append(cc.getDisplay());
        if (code.getDisplay().equalsIgnoreCase(cc.getDisplay()))
            return new ValidationResult(cc);
    }
    for (ConceptDefinitionDesignationComponent ds : cc.getDesignation()) {
        b.append(ds.getValue());
        if (code.getDisplay().equalsIgnoreCase(ds.getValue()))
            return new ValidationResult(cc);
    }
    // also check to see if the value set has another display
    ConceptReferenceComponent vs = findValueSetRef(code.getSystem(), code.getCode());
    if (vs != null && (vs.hasDisplay() || vs.hasDesignation())) {
        if (vs.hasDisplay()) {
            b.append(vs.getDisplay());
            if (code.getDisplay().equalsIgnoreCase(vs.getDisplay()))
                return new ValidationResult(cc);
        }
        for (ConceptReferenceDesignationComponent ds : vs.getDesignation()) {
            b.append(ds.getValue());
            if (code.getDisplay().equalsIgnoreCase(ds.getValue()))
                return new ValidationResult(cc);
        }
    }
    return new ValidationResult(IssueSeverity.WARNING, "Display Name for " + code.getSystem() + "#" + code.getCode() + " should be one of '" + b.toString() + "' instead of " + code.getDisplay(), cc);
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ValidationResult(org.hl7.fhir.r4.context.IWorkerContext.ValidationResult)

Example 20 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method addCode.

private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List<ConceptDefinitionDesignationComponent> designations, Parameters expParams, boolean isAbstract, boolean inactive, List<ValueSet> filters, boolean noInactive) {
    if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code))
        return null;
    if (noInactive && inactive) {
        return null;
    }
    ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
    n.setSystem(system);
    n.setCode(code);
    if (isAbstract)
        n.setAbstract(true);
    if (inactive)
        n.setInactive(true);
    if (expParams.getParameterBool("includeDesignations") && designations != null) {
        for (ConceptDefinitionDesignationComponent t : designations) {
            if (t.getLanguage() != null || t.getValue() != null) {
                ConceptReferenceDesignationComponent d = n.addDesignation();
                if (t.getLanguage() != null) {
                    d.setLanguage(t.getLanguage().trim());
                }
                if (t.getValue() != null) {
                    d.setValue(t.getValue().trim());
                }
            }
        }
    }
    ConceptDefinitionDesignationComponent t = expParams.hasLanguage() ? getMatchingLang(designations, expParams.getLanguage()) : null;
    if (t == null)
        n.setDisplay(display);
    else
        n.setDisplay(t.getValue());
    String s = key(n);
    if (map.containsKey(s) || excludeKeys.contains(s)) {
        canBeHeirarchy = false;
    } else {
        codes.add(n);
        map.put(s, n);
        total++;
    }
    if (canBeHeirarchy && parent != null) {
        parent.getContains().add(n);
    } else {
        roots.add(n);
    }
    return n;
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent) ConceptReferenceDesignationComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent)

Aggregations

ConceptReferenceDesignationComponent (org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent)11 ConceptReferenceDesignationComponent (org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent)7 ArrayList (java.util.ArrayList)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)5 ConceptDefinitionDesignationComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent)4 Extension (org.hl7.fhir.r5.model.Extension)4 ConceptReferenceDesignationComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent)3 ConceptDefinitionDesignationComponent (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent)3 ConceptReferenceDesignationComponent (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceDesignationComponent)3 ConceptDefinitionDesignationComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionDesignationComponent)3 ConceptReferenceComponent (org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent)3 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)3 ConceptReferenceComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent)2 ValidationResult (org.hl7.fhir.r4.context.IWorkerContext.ValidationResult)2 CodeSystem (org.hl7.fhir.r4.model.CodeSystem)2 Extension (org.hl7.fhir.r4b.model.Extension)2 ConceptReferenceComponent (org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceComponent)2 ValueSetExpansionContainsComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent)2 ValidationResult (org.hl7.fhir.dstu3.context.IWorkerContext.ValidationResult)1 CodeSystem (org.hl7.fhir.dstu3.model.CodeSystem)1