Search in sources :

Example 6 with ConceptReferenceDesignationComponent

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

the class NarrativeGenerator method addLanguageRow.

private void addLanguageRow(ConceptReferenceComponent c, XhtmlNode t, List<String> langs) {
    XhtmlNode tr = t.tr();
    tr.td().addText(c.getCode());
    for (String lang : langs) {
        String d = null;
        for (ConceptReferenceDesignationComponent cd : c.getDesignation()) {
            String l = cd.getLanguage();
            if (lang.equals(l))
                d = cd.getValue();
        }
        tr.td().addText(d == null ? "" : d);
    }
}
Also used : ConceptReferenceDesignationComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 7 with ConceptReferenceDesignationComponent

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

the class ValueSetRenderer method addLangaugesToRow.

public void addLangaugesToRow(ConceptReferenceComponent c, List<String> langs, XhtmlNode tr) {
    for (String lang : langs) {
        String d = null;
        for (Extension ext : c.getExtension()) {
            if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
                String l = ToolingExtensions.readStringExtension(ext, "lang");
                if (lang.equals(l)) {
                    d = ToolingExtensions.readStringExtension(ext, "content");
                }
            }
        }
        if (d == null) {
            for (ConceptReferenceDesignationComponent dd : c.getDesignation()) {
                String l = dd.getLanguage();
                if (lang.equals(l)) {
                    d = dd.getValue();
                }
            }
        }
        tr.td().addText(d == null ? "" : d);
    }
}
Also used : Extension(org.hl7.fhir.r4b.model.Extension) ConceptReferenceDesignationComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent)

Example 8 with ConceptReferenceDesignationComponent

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

the class NarrativeGenerator method describeLang.

private String describeLang(String lang) {
    ValueSet v = context.fetchResource(ValueSet.class, "http://hl7.org/fhir/ValueSet/languages");
    if (v != null) {
        ConceptReferenceComponent l = null;
        for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) {
            if (cc.getCode().equals(lang))
                l = cc;
        }
        if (l == null) {
            if (lang.contains("-"))
                lang = lang.substring(0, lang.indexOf("-"));
            for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) {
                if (cc.getCode().equals(lang) || cc.getCode().startsWith(lang + "-"))
                    l = cc;
            }
        }
        if (l != null) {
            if (lang.contains("-"))
                lang = lang.substring(0, lang.indexOf("-"));
            String en = l.getDisplay();
            String nativelang = null;
            for (ConceptReferenceDesignationComponent cd : l.getDesignation()) {
                if (cd.getLanguage().equals(lang))
                    nativelang = cd.getValue();
            }
            if (nativelang == null)
                return en + " (" + lang + ")";
            else
                return nativelang + " (" + en + ", " + lang + ")";
        }
    }
    return lang;
}
Also used : ValueSet(org.hl7.fhir.r4.model.ValueSet)

Example 9 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.r4.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 = cs.hasUserData("tx.cs.special") ? ((SpecialCodeSystem) cs.getUserData("tx.cs.special")).findConcept(code) : findCodeInConcept(cs.getConcept(), code.getCode());
    if (cc == null) {
        if (cs.getContent() == CodeSystemContentMode.FRAGMENT) {
            return new ValidationResult(IssueSeverity.WARNING, context.formatMessage(I18nConstants.UNKNOWN_CODE__IN_FRAGMENT, gen(code), cs.getUrl()));
        } else {
            return new ValidationResult(IssueSeverity.ERROR, context.formatMessage(I18nConstants.UNKNOWN_CODE__IN_, gen(code), cs.getUrl()));
        }
    }
    if (code.getDisplay() == null) {
        return new ValidationResult(code.getSystem(), cc);
    }
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
    if (cc.hasDisplay()) {
        b.append(cc.getDisplay());
        if (code.getDisplay().equalsIgnoreCase(cc.getDisplay())) {
            return new ValidationResult(code.getSystem(), cc);
        }
    }
    for (ConceptDefinitionDesignationComponent ds : cc.getDesignation()) {
        b.append(ds.getValue());
        if (code.getDisplay().equalsIgnoreCase(ds.getValue())) {
            return new ValidationResult(code.getSystem(), 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(code.getSystem(), cc);
            }
        }
        for (ConceptReferenceDesignationComponent ds : vs.getDesignation()) {
            b.append(ds.getValue());
            if (code.getDisplay().equalsIgnoreCase(ds.getValue())) {
                return new ValidationResult(code.getSystem(), cc);
            }
        }
    }
    return new ValidationResult(IssueSeverity.WARNING, context.formatMessage(I18nConstants.DISPLAY_NAME_FOR__SHOULD_BE_ONE_OF__INSTEAD_OF_, code.getSystem(), code.getCode(), b.toString(), code.getDisplay()), code.getSystem(), cc);
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionDesignationComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ConceptReferenceDesignationComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent) ValidationResult(org.hl7.fhir.r4b.context.IWorkerContext.ValidationResult) ConceptReferenceComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceComponent)

Example 10 with ConceptReferenceDesignationComponent

use of org.hl7.fhir.r4.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.r4b.model.CodeSystem.ConceptDefinitionDesignationComponent) ArrayList(java.util.ArrayList) ConceptReferenceDesignationComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent) CodeSystem(org.hl7.fhir.r4b.model.CodeSystem)

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