Search in sources :

Example 61 with ConceptReferenceComponent

use of org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent 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 : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 62 with ConceptReferenceComponent

use of org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method generateComposition.

private boolean generateComposition(ResourceContext rcontext, XhtmlNode x, ValueSet vs, boolean header, List<UsedConceptMap> maps) throws FHIRException, IOException {
    boolean hasExtensions = false;
    List<String> langs = new ArrayList<String>();
    if (header) {
        XhtmlNode h = x.h2();
        h.addText(vs.present());
        addMarkdown(x, vs.getDescription());
        if (vs.hasCopyrightElement())
            generateCopyright(x, vs);
    }
    XhtmlNode p = x.para();
    p.tx("This value set includes codes from the following code systems:");
    XhtmlNode ul = x.ul();
    XhtmlNode li;
    for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
        hasExtensions = genInclude(rcontext, ul, inc, "Include", langs, maps) || hasExtensions;
    }
    for (ConceptSetComponent exc : vs.getCompose().getExclude()) {
        hasExtensions = genInclude(rcontext, ul, exc, "Exclude", langs, maps) || hasExtensions;
    }
    if (langs.size() > 0) {
        Collections.sort(langs);
        x.para().b().tx("Additional Language Displays");
        XhtmlNode t = x.table("codes");
        XhtmlNode tr = t.tr();
        tr.td().b().tx("Code");
        for (String lang : langs) tr.td().b().addText(describeLang(lang));
        for (ConceptSetComponent c : vs.getCompose().getInclude()) {
            for (ConceptReferenceComponent cc : c.getConcept()) {
                addLanguageRow(cc, t, langs);
            }
        }
    }
    return hasExtensions;
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 63 with ConceptReferenceComponent

use of org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent 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.r4b.model.ValueSet.ConceptReferenceDesignationComponent) ValueSet(org.hl7.fhir.r4b.model.ValueSet) ConceptReferenceComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceComponent)

Aggregations

ConceptReferenceComponent (org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent)17 ArrayList (java.util.ArrayList)14 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)14 ConceptReferenceComponent (org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceComponent)12 ConceptReferenceComponent (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent)10 HashMap (java.util.HashMap)7 ConceptReferenceComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent)7 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)7 ConceptSetComponent (org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent)7 ValueSet (org.hl7.fhir.r4.model.ValueSet)6 ConceptSetComponent (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent)6 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)6 NotImplementedException (org.apache.commons.lang3.NotImplementedException)5 NoTerminologyServiceException (org.hl7.fhir.exceptions.NoTerminologyServiceException)5 ConceptReferenceDesignationComponent (org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent)5 ConceptSetComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent)4 ConceptDefinitionComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)4 ConceptReferenceDesignationComponent (org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent)4 ValueSet (org.hl7.fhir.r5.model.ValueSet)4 ConceptSetFilterComponent (org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent)4