Search in sources :

Example 21 with ConceptReferenceDesignationComponent

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

the class ValueSetRenderer 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.r4b.model.ValueSet.ConceptReferenceDesignationComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 22 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(ValueSetExpansionContainsComponent 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 23 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.r5.model.Extension) ConceptReferenceDesignationComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent)

Example 24 with ConceptReferenceDesignationComponent

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

the class DataRenderer method describeLang.

protected String describeLang(String lang) {
    // special cases:
    if ("fr-CA".equals(lang)) {
        // this one was omitted from the value set
        return "French (Canadian)";
    }
    ValueSet v = getContext().getWorker().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)) {
                    l = cc;
                    break;
                }
            }
            if (l == null) {
                for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) {
                    if (cc.getCode().startsWith(lang + "-")) {
                        l = cc;
                        break;
                    }
                }
            }
        }
        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 : ConceptReferenceDesignationComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent) ValueSet(org.hl7.fhir.r5.model.ValueSet) ConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent)

Example 25 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 : ConceptReferenceDesignationComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceDesignationComponent) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) ConceptReferenceComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent)

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