Search in sources :

Example 81 with ValueSetExpansionContainsComponent

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

the class ValueSetComparer method addExpansionRow.

private void addExpansionRow(HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<ValueSetExpansionContainsComponent> t, boolean hasSystem, boolean hasVersion, boolean hasAbstract, boolean hasInactive) {
    Row r = gen.new Row();
    rows.add(r);
    if (hasSystem) {
        r.getCells().add(gen.new Cell(null, null, t.either().getSystem(), null, null));
    }
    r.getCells().add(gen.new Cell(null, null, t.either().getCode(), null, null));
    if (t.hasLeft() && t.hasRight()) {
        if (t.getLeft().hasDisplay() && t.getRight().hasDisplay()) {
            if (t.getLeft().getDisplay().equals(t.getRight().getDisplay())) {
                r.getCells().add(gen.new Cell(null, null, t.getLeft().getDisplay(), null, null).span(2).center());
            } else {
                r.getCells().add(gen.new Cell(null, null, t.getLeft().getDisplay(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
                r.getCells().add(gen.new Cell(null, null, t.getRight().getDisplay(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
            }
        } else if (t.getLeft().hasDisplay()) {
            r.getCells().add(gen.new Cell(null, null, t.getLeft().getDisplay(), null, null));
            r.getCells().add(missingCell(gen, COLOR_NO_CELL_RIGHT));
        } else if (t.getRight().hasDisplay()) {
            r.getCells().add(missingCell(gen, COLOR_NO_CELL_LEFT));
            r.getCells().add(gen.new Cell(null, null, t.getRight().getDisplay(), null, null));
        } else {
            r.getCells().add(missingCell(gen).span(2).center());
        }
    } else if (t.hasLeft()) {
        r.setColor(COLOR_NO_ROW_RIGHT);
        r.getCells().add(gen.new Cell(null, null, t.either().getDisplay(), null, null));
        r.getCells().add(missingCell(gen));
    } else {
        r.setColor(COLOR_NO_ROW_LEFT);
        r.getCells().add(missingCell(gen));
        r.getCells().add(gen.new Cell(null, null, t.either().getDisplay(), null, null));
    }
    r.getCells().add(cellForMessages(gen, t.getMessages()));
    for (StructuralMatch<ValueSetExpansionContainsComponent> c : t.getChildren()) {
        addExpansionRow(gen, r.getSubRows(), c, hasSystem, hasVersion, hasAbstract, hasInactive);
    }
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) Row(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)

Example 82 with ValueSetExpansionContainsComponent

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

the class ValueSetComparer method renderExpansion.

public XhtmlNode renderExpansion(ValueSetComparison csc, String id, String prefix) throws IOException {
    if (csc.getExpansion() == null) {
        XhtmlNode p = new XhtmlNode(NodeType.Element, "p");
        p.tx("Unable to generate expansion - see errors");
        return p;
    }
    if (csc.getExpansion().getChildren().isEmpty()) {
        XhtmlNode p = new XhtmlNode(NodeType.Element, "p");
        p.tx("Expansion is empty");
        return p;
    }
    // columns: code(+system), version, display , abstract, inactive,
    boolean hasSystem = csc.getExpansion().getChildren().isEmpty() ? false : getSystemVaries(csc.getExpansion(), csc.getExpansion().getChildren().get(0).either().getSystem());
    boolean hasVersion = findVersion(csc.getExpansion());
    boolean hasAbstract = findAbstract(csc.getExpansion());
    boolean hasInactive = findInactive(csc.getExpansion());
    HierarchicalTableGenerator gen = new HierarchicalTableGenerator(Utilities.path("[tmp]", "comparison"), false);
    TableModel model = gen.new TableModel(id, true);
    model.setAlternating(true);
    if (hasSystem) {
        model.getTitles().add(gen.new Title(null, null, "System", "The code for the concept", null, 100));
    }
    model.getTitles().add(gen.new Title(null, null, "Code", "The system for the concept", null, 100));
    model.getTitles().add(gen.new Title(null, null, "Display", "The display for the concept", null, 200, 2));
    // if (hasVersion) {
    // model.getTitles().add(gen.new Title(null, null, "Version", "The version for the concept", null, 200, 2));
    // }
    // if (hasAbstract) {
    // model.getTitles().add(gen.new Title(null, null, "Abstract", "The abstract flag for the concept", null, 200, 2));
    // }
    // if (hasInactive) {
    // model.getTitles().add(gen.new Title(null, null, "Inactive", "The inactive flag for the concept", null, 200, 2));
    // }
    model.getTitles().add(gen.new Title(null, null, "Comments", "Additional information about the comparison", null, 200));
    for (StructuralMatch<ValueSetExpansionContainsComponent> t : csc.getExpansion().getChildren()) {
        addExpansionRow(gen, model.getRows(), t, hasSystem, hasVersion, hasAbstract, hasInactive);
    }
    return gen.generate(model, prefix, 0, null);
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) HierarchicalTableGenerator(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator) TableModel(org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 83 with ValueSetExpansionContainsComponent

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

the class ValueSetRenderer method addExpansionRowToTable.

private void addExpansionRowToTable(XhtmlNode t, ValueSetExpansionContainsComponent c, int i, boolean doLevel, boolean doSystem, boolean doDefinition, List<UsedConceptMap> maps, CodeSystem allCS, List<String> langs, boolean doLangs) {
    XhtmlNode tr = t.tr();
    XhtmlNode td = tr.td();
    String tgt = makeAnchor(c.getSystem(), c.getCode());
    td.an(tgt);
    if (doLevel) {
        td.addText(Integer.toString(i));
        td = tr.td();
    }
    String s = Utilities.padLeft("", '\u00A0', i * 2);
    td.attribute("style", "white-space:nowrap").addText(s);
    addCodeToTable(c.getAbstract(), c.getSystem(), c.getCode(), c.getDisplay(), td);
    if (doSystem) {
        td = tr.td();
        td.addText(c.getSystem());
    }
    td = tr.td();
    if (c.hasDisplayElement())
        td.addText(c.getDisplay());
    if (doDefinition) {
        CodeSystem cs = allCS;
        if (cs == null)
            cs = getContext().getWorker().fetchCodeSystem(c.getSystem());
        td = tr.td();
        if (cs != null)
            td.addText(CodeSystemUtilities.getCodeDefinition(cs, c.getCode()));
    }
    for (UsedConceptMap m : maps) {
        td = tr.td();
        List<TargetElementComponentWrapper> mappings = findMappingsForCode(c.getCode(), m.getMap());
        boolean first = true;
        for (TargetElementComponentWrapper mapping : mappings) {
            if (!first)
                td.br();
            first = false;
            XhtmlNode span = td.span(null, mapping.comp.getEquivalence().toString());
            span.addText(getCharForRelationship(mapping.comp));
            addRefToCode(td, mapping.group.getTarget(), m.getLink(), mapping.comp.getCode());
            if (!Utilities.noString(mapping.comp.getComment()))
                td.i().tx("(" + mapping.comp.getComment() + ")");
        }
    }
    if (doLangs) {
        addLangaugesToRow(c, langs, tr);
    }
    for (ValueSetExpansionContainsComponent cc : c.getContains()) {
        addExpansionRowToTable(t, cc, i + 1, doLevel, doSystem, doDefinition, maps, allCS, langs, doLangs);
    }
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) CodeSystem(org.hl7.fhir.r4b.model.CodeSystem) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 84 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>();
    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("Lvl");
    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 doLangs = false;
    for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
        scanForLangs(c, langs);
    }
    if (doDefinition) {
        tr.td().b().tx("Definition");
        doLangs = false;
    } else {
        // if we're not doing definitions and we don't have too many languages, we'll do them in line
        if (langs.size() < MAX_LANGS_IN_LINE) {
            doLangs = true;
            if (vs.hasLanguage()) {
                tdDisp.tx(" - " + describeLang(vs.getLanguage()));
            }
            for (String lang : langs) {
                tr.td().b().addText(describeLang(lang));
            }
        }
    }
    addMapHeaders(tr, maps);
    for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
        addExpansionRowToTable(t, c, 0, doLevel, doSystem, doDefinition, maps, allCS, langs, doLangs);
    }
    if (!doLangs && langs.size() > 0) {
        Collections.sort(langs);
        x.para().b().tx("Additional Language Displays");
        t = x.table("codes");
        tr = t.tr();
        tr.td().b().tx("Code");
        for (String lang : langs) {
            tr.td().b().addText(describeLang(lang));
        }
        for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
            addLanguageRow(c, t, langs);
        }
    }
    return hasExtensions;
}
Also used : Extension(org.hl7.fhir.r4b.model.Extension) ValueSetExpansionContainsComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionContainsComponent) ArrayList(java.util.ArrayList) BooleanType(org.hl7.fhir.r4b.model.BooleanType) CodeSystem(org.hl7.fhir.r4b.model.CodeSystem) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 85 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.r4b.model.Extension) ConceptReferenceDesignationComponent(org.hl7.fhir.r4b.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