Search in sources :

Example 46 with ValueSetExpansionContainsComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetRenderer method addDesignationsToRow.

public void addDesignationsToRow(ValueSetExpansionContainsComponent c, Map<String, String> designations, XhtmlNode tr) {
    for (String url : designations.keySet()) {
        String d = null;
        if (d == null) {
            for (ConceptReferenceDesignationComponent dd : c.getDesignation()) {
                if (url.equals(getUrlForDesignation(dd))) {
                    d = dd.getValue();
                }
            }
        }
        tr.td().addText(d == null ? "" : d);
    }
}
Also used : ConceptReferenceDesignationComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent)

Example 47 with ValueSetExpansionContainsComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetRenderer method generateExpansion.

private boolean generateExpansion(XhtmlNode x, ValueSet vs, boolean header, List<UsedConceptMap> maps) throws FHIRFormatError, DefinitionException, IOException {
    boolean hasExtensions = false;
    List<String> langs = new ArrayList<String>();
    // map of url = description, where url is the designation code. Designations that are for languages won't make it into this list
    Map<String, String> designations = new HashMap<>();
    if (header) {
        XhtmlNode h = x.addTag(getHeader());
        h.tx("Value Set Contents");
        if (IsNotFixedExpansion(vs))
            addMarkdown(x, vs.getDescription());
        if (vs.hasCopyright())
            generateCopyright(x, vs);
    }
    if (ToolingExtensions.hasExtension(vs.getExpansion(), ToolingExtensions.EXT_EXP_TOOCOSTLY)) {
        List<Extension> exl = vs.getExpansion().getExtensionsByUrl(ToolingExtensions.EXT_EXP_TOOCOSTLY);
        boolean other = false;
        for (Extension ex : exl) {
            if (ex.getValue() instanceof BooleanType) {
                x.para().style("border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(vs.getExpansion().getContains().isEmpty() ? getContext().getTooCostlyNoteEmpty() : getContext().getTooCostlyNoteNotEmpty());
            } else if (!other) {
                x.para().style("border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(vs.getExpansion().getContains().isEmpty() ? getContext().getTooCostlyNoteEmptyDependent() : getContext().getTooCostlyNoteNotEmptyDependent());
                other = true;
            }
        }
    } else {
        Integer count = countMembership(vs);
        if (count == null)
            x.para().tx("This value set does not contain a fixed number of concepts");
        else
            x.para().tx("This value set contains " + count.toString() + " concepts");
    }
    generateContentModeNotices(x, vs.getExpansion());
    generateVersionNotice(x, vs.getExpansion());
    CodeSystem allCS = null;
    boolean doLevel = false;
    for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) {
        if (cc.hasContains()) {
            doLevel = true;
            break;
        }
    }
    // checkDoSystem(vs, src);
    boolean doSystem = true;
    boolean doDefinition = checkDoDefinition(vs.getExpansion().getContains());
    if (doSystem && allFromOneSystem(vs)) {
        doSystem = false;
        XhtmlNode p = x.para();
        p.tx("All codes in this table are from the system ");
        allCS = getContext().getWorker().fetchCodeSystem(vs.getExpansion().getContains().get(0).getSystem());
        String ref = null;
        if (allCS != null)
            ref = getCsRef(allCS);
        if (ref == null)
            p.code(vs.getExpansion().getContains().get(0).getSystem());
        else
            p.ah(context.fixReference(ref)).code(vs.getExpansion().getContains().get(0).getSystem());
    }
    XhtmlNode t = x.table("codes");
    XhtmlNode tr = t.tr();
    if (doLevel)
        tr.td().b().tx("Level");
    tr.td().attribute("style", "white-space:nowrap").b().tx("Code");
    if (doSystem)
        tr.td().b().tx("System");
    XhtmlNode tdDisp = tr.td();
    tdDisp.b().tx("Display");
    boolean doDesignations = false;
    for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
        scanForDesignations(c, langs, designations);
    }
    if (doDefinition) {
        tr.td().b().tx("Definition");
        doDesignations = false;
    } else {
        // if we're not doing definitions and we don't have too many languages, we'll do them in line
        doDesignations = langs.size() + designations.size() < MAX_DESIGNATIONS_IN_LINE;
        if (doDesignations) {
            if (vs.hasLanguage()) {
                tdDisp.tx(" - " + describeLang(vs.getLanguage()));
            }
            for (String url : designations.keySet()) {
                tr.td().b().addText(designations.get(url));
            }
            for (String lang : langs) {
                tr.td().b().addText(describeLang(lang));
            }
        }
    }
    addMapHeaders(tr, maps);
    for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
        addExpansionRowToTable(t, c, 1, doLevel, doSystem, doDefinition, maps, allCS, langs, designations, doDesignations);
    }
    if (!doDesignations && langs.size() + designations.size() > 0) {
        Collections.sort(langs);
        if (designations.size() == 0) {
            x.para().b().tx("Additional Language Displays");
        } else if (langs.size() == 0) {
            x.para().b().tx("Additional Designations");
        } else {
            x.para().b().tx("Additional Designations and Language Displays");
        }
        t = x.table("codes");
        tr = t.tr();
        tr.td().b().tx("Code");
        for (String url : designations.keySet()) {
            tr.td().b().addText(designations.get(url));
        }
        for (String lang : langs) {
            tr.td().b().addText(describeLang(lang));
        }
        for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
            addDesignationRow(c, t, langs, designations);
        }
    }
    return hasExtensions;
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BooleanType(org.hl7.fhir.r5.model.BooleanType) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) Extension(org.hl7.fhir.r5.model.Extension)

Example 48 with ValueSetExpansionContainsComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSetRenderer method getConceptForCodeFromExpansion.

private ConceptDefinitionComponent getConceptForCodeFromExpansion(List<ValueSetExpansionContainsComponent> list, String code) {
    for (ValueSetExpansionContainsComponent c : list) {
        if (code.equals(c.getCode())) {
            ConceptDefinitionComponent res = new ConceptDefinitionComponent();
            res.setCode(c.getCode());
            res.setDisplay(c.getDisplay());
            return res;
        }
        ConceptDefinitionComponent v = getConceptForCodeFromExpansion(c.getContains(), code);
        if (v != null)
            return v;
    }
    return null;
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)

Example 49 with ValueSetExpansionContainsComponent

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

Example 50 with ValueSetExpansionContainsComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent 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)

Aggregations

ValueSetExpansionContainsComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent)32 ValueSetExpansionContainsComponent (org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent)22 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)20 ValueSetExpansionContainsComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent)17 ValueSet (org.hl7.fhir.r4.model.ValueSet)9 HashMap (java.util.HashMap)8 ValueSet (org.hl7.fhir.r5.model.ValueSet)8 ArrayList (java.util.ArrayList)7 ValueSetExpansionContainsComponent (org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent)7 ValueSetExpansionContainsComponent (org.hl7.fhir.dstu2016may.model.ValueSet.ValueSetExpansionContainsComponent)7 IOException (java.io.IOException)6 ValueSetExpansionContainsComponent (org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent)6 ValueSetExpansionComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent)6 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)6 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)5 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)5 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)5 ValueSet (org.hl7.fhir.dstu2016may.model.ValueSet)4 ValueSet (org.hl7.fhir.r4b.model.ValueSet)4 FHIRException (org.hl7.fhir.exceptions.FHIRException)3