Search in sources :

Example 21 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class CanonicalSpreadsheetGenerator method renderCanonicalResource.

protected Sheet renderCanonicalResource(CanonicalResource cr) {
    Sheet sheet = makeSheet("Metadata");
    Row headerRow = sheet.createRow(0);
    addCell(headerRow, 0, "Property", styles.get("header"));
    addCell(headerRow, 1, "Value", styles.get("header"));
    addMetadataRow(sheet, "URL", cr.getUrl());
    for (Identifier id : cr.getIdentifier()) {
        addMetadataRow(sheet, "Identifier", dr.display(id));
    }
    addMetadataRow(sheet, "Version", cr.getVersion());
    addMetadataRow(sheet, "Name", cr.getName());
    addMetadataRow(sheet, "Title", cr.getTitle());
    addMetadataRow(sheet, "Status", cr.getStatusElement().asStringValue());
    addMetadataRow(sheet, "Experimental", cr.getExperimentalElement().asStringValue());
    addMetadataRow(sheet, "Date", cr.getDateElement().asStringValue());
    addMetadataRow(sheet, "Publisher", cr.getPublisher());
    for (ContactDetail c : cr.getContact()) {
        addMetadataRow(sheet, "Contact", dr.display(c));
    }
    for (CodeableConcept j : cr.getJurisdiction()) {
        addMetadataRow(sheet, "Jurisdiction", dr.display(j));
    }
    addMetadataRow(sheet, "Description", cr.getDescription());
    addMetadataRow(sheet, "Purpose", cr.getPurpose());
    addMetadataRow(sheet, "Copyright", cr.getCopyright());
    configureSheet(sheet);
    return sheet;
}
Also used : ContactDetail(org.hl7.fhir.r4b.model.ContactDetail) Identifier(org.hl7.fhir.r4b.model.Identifier) Row(org.apache.poi.ss.usermodel.Row) Sheet(org.apache.poi.ss.usermodel.Sheet) CodeableConcept(org.hl7.fhir.r4b.model.CodeableConcept)

Example 22 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class ConceptMapRenderer method render.

public boolean render(XhtmlNode x, ConceptMap cm) throws FHIRFormatError, DefinitionException, IOException {
    x.h2().addText(cm.getName() + " (" + cm.getUrl() + ")");
    XhtmlNode p = x.para();
    p.tx("Mapping from ");
    if (cm.hasSource())
        AddVsRef(cm.getSource().primitiveValue(), p);
    else
        p.tx("(not specified)");
    p.tx(" to ");
    if (cm.hasTarget())
        AddVsRef(cm.getTarget().primitiveValue(), p);
    else
        p.tx("(not specified)");
    p = x.para();
    if (cm.getExperimental())
        p.addText(Utilities.capitalize(cm.getStatus().toString()) + " (not intended for production usage). ");
    else
        p.addText(Utilities.capitalize(cm.getStatus().toString()) + ". ");
    p.tx("Published on " + (cm.hasDate() ? cm.getDateElement().toHumanDisplay() : "?ngen-10?") + " by " + cm.getPublisher());
    if (!cm.getContact().isEmpty()) {
        p.tx(" (");
        boolean firsti = true;
        for (ContactDetail ci : cm.getContact()) {
            if (firsti)
                firsti = false;
            else
                p.tx(", ");
            if (ci.hasName())
                p.addText(ci.getName() + ": ");
            boolean first = true;
            for (ContactPoint c : ci.getTelecom()) {
                if (first)
                    first = false;
                else
                    p.tx(", ");
                addTelecom(p, c);
            }
        }
        p.tx(")");
    }
    p.tx(". ");
    p.addText(cm.getCopyright());
    if (!Utilities.noString(cm.getDescription()))
        addMarkdown(x, cm.getDescription());
    x.br();
    CodeSystem cs = getContext().getWorker().fetchCodeSystem("http://hl7.org/fhir/concept-map-relationship");
    if (cs == null)
        cs = getContext().getWorker().fetchCodeSystem("http://hl7.org/fhir/concept-map-equivalence");
    String eqpath = cs == null ? null : cs.getUserString("path");
    for (ConceptMapGroupComponent grp : cm.getGroup()) {
        String src = grp.getSource();
        boolean comment = false;
        boolean ok = true;
        Map<String, HashSet<String>> sources = new HashMap<String, HashSet<String>>();
        Map<String, HashSet<String>> targets = new HashMap<String, HashSet<String>>();
        sources.put("code", new HashSet<String>());
        targets.put("code", new HashSet<String>());
        SourceElementComponent cc = grp.getElement().get(0);
        String dst = grp.getTarget();
        sources.get("code").add(grp.getSource());
        targets.get("code").add(grp.getTarget());
        for (SourceElementComponent ccl : grp.getElement()) {
            ok = ok && ccl.getTarget().size() == 1 && ccl.getTarget().get(0).getDependsOn().isEmpty() && ccl.getTarget().get(0).getProduct().isEmpty();
            for (TargetElementComponent ccm : ccl.getTarget()) {
                comment = comment || !Utilities.noString(ccm.getComment());
                for (OtherElementComponent d : ccm.getDependsOn()) {
                    if (!sources.containsKey(d.getProperty()))
                        sources.put(d.getProperty(), new HashSet<String>());
                    sources.get(d.getProperty()).add(d.getSystem());
                }
                for (OtherElementComponent d : ccm.getProduct()) {
                    if (!targets.containsKey(d.getProperty()))
                        targets.put(d.getProperty(), new HashSet<String>());
                    targets.get(d.getProperty()).add(d.getSystem());
                }
            }
        }
        String display;
        if (ok) {
            // simple
            XhtmlNode tbl = x.table("grid");
            XhtmlNode tr = tbl.tr();
            tr.td().b().tx("Source Code");
            tr.td().b().tx("Relationship");
            tr.td().b().tx("Destination Code");
            if (comment)
                tr.td().b().tx("Comment");
            for (SourceElementComponent ccl : grp.getElement()) {
                tr = tbl.tr();
                XhtmlNode td = tr.td();
                td.addText(ccl.getCode());
                display = getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()), ccl.getCode());
                if (display != null && !isSameCodeAndDisplay(ccl.getCode(), display))
                    td.tx(" (" + display + ")");
                TargetElementComponent ccm = ccl.getTarget().get(0);
                if (!ccm.hasEquivalence())
                    tr.td().tx(":" + "(" + ConceptMapEquivalence.NULL.toCode() + ")");
                else {
                    String code = ccm.getEquivalenceElement().primitiveValue();
                    tr.td().ah(eqpath + "#" + code).tx(presentEquivalenceCode(code));
                }
                td = tr.td();
                td.addText(ccm.getCode());
                display = getDisplayForConcept(systemFromCanonical(grp.getTarget()), versionFromCanonical(grp.getTarget()), ccm.getCode());
                if (display != null && !isSameCodeAndDisplay(ccm.getCode(), display))
                    td.tx(" (" + display + ")");
                if (comment)
                    tr.td().addText(ccm.getComment());
                addUnmapped(tbl, grp);
            }
        } else {
            boolean hasRelationships = false;
            for (int si = 0; si < grp.getElement().size(); si++) {
                SourceElementComponent ccl = grp.getElement().get(si);
                for (int ti = 0; ti < ccl.getTarget().size(); ti++) {
                    TargetElementComponent ccm = ccl.getTarget().get(ti);
                    if (ccm.hasEquivalence()) {
                        hasRelationships = true;
                    }
                }
            }
            XhtmlNode tbl = x.table("grid");
            XhtmlNode tr = tbl.tr();
            XhtmlNode td;
            tr.td().colspan(Integer.toString(1 + sources.size())).b().tx("Source Concept Details");
            if (hasRelationships) {
                tr.td().b().tx("Relationship");
            }
            tr.td().colspan(Integer.toString(1 + targets.size())).b().tx("Destination Concept Details");
            if (comment) {
                tr.td().b().tx("Comment");
            }
            tr = tbl.tr();
            if (sources.get("code").size() == 1) {
                String url = sources.get("code").iterator().next();
                renderCSDetailsLink(tr, url, true);
            } else
                tr.td().b().tx("Code");
            for (String s : sources.keySet()) {
                if (!s.equals("code")) {
                    if (sources.get(s).size() == 1) {
                        String url = sources.get(s).iterator().next();
                        renderCSDetailsLink(tr, url, false);
                    } else
                        tr.td().b().addText(getDescForConcept(s));
                }
            }
            if (hasRelationships) {
                tr.td();
            }
            if (targets.get("code").size() == 1) {
                String url = targets.get("code").iterator().next();
                renderCSDetailsLink(tr, url, true);
            } else
                tr.td().b().tx("Code");
            for (String s : targets.keySet()) {
                if (!s.equals("code")) {
                    if (targets.get(s).size() == 1) {
                        String url = targets.get(s).iterator().next();
                        renderCSDetailsLink(tr, url, false);
                    } else
                        tr.td().b().addText(getDescForConcept(s));
                }
            }
            if (comment)
                tr.td();
            for (int si = 0; si < grp.getElement().size(); si++) {
                SourceElementComponent ccl = grp.getElement().get(si);
                boolean slast = si == grp.getElement().size() - 1;
                boolean first = true;
                if (false) {
                    tr = tbl.tr();
                    td = tr.td().style("border-right-width: 0px");
                    if (!first)
                        td.style("border-top-style: none");
                    else
                        td.style("border-bottom-style: none");
                    if (sources.get("code").size() == 1)
                        td.addText(ccl.getCode());
                    else
                        td.addText(grp.getSource() + " / " + ccl.getCode());
                    display = getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()), ccl.getCode());
                    tr.td().style("border-left-width: 0px").tx(display == null ? "" : display);
                    tr.td().colspan("4").style("background-color: #efefef").tx("(not mapped)");
                } else {
                    for (int ti = 0; ti < ccl.getTarget().size(); ti++) {
                        TargetElementComponent ccm = ccl.getTarget().get(ti);
                        boolean last = ti == ccl.getTarget().size() - 1;
                        tr = tbl.tr();
                        td = tr.td().style("border-right-width: 0px");
                        if (!first && !last)
                            td.style("border-top-style: none; border-bottom-style: none");
                        else if (!first)
                            td.style("border-top-style: none");
                        else if (!last)
                            td.style("border-bottom-style: none");
                        if (first) {
                            if (sources.get("code").size() == 1)
                                td.addText(ccl.getCode());
                            else
                                td.addText(grp.getSource() + " / " + ccl.getCode());
                            display = ccl.hasDisplay() ? ccl.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()), ccl.getCode());
                            td = tr.td();
                            if (!last)
                                td.style("border-left-width: 0px; border-bottom-style: none");
                            else
                                td.style("border-left-width: 0px");
                            td.tx(display == null ? "" : display);
                        } else {
                            // for display
                            td = tr.td();
                            if (!last)
                                td.style("border-left-width: 0px; border-top-style: none; border-bottom-style: none");
                            else
                                td.style("border-top-style: none; border-left-width: 0px");
                        }
                        for (String s : sources.keySet()) {
                            if (!s.equals("code")) {
                                td = tr.td();
                                if (first) {
                                    td.addText(getValue(ccm.getDependsOn(), s, sources.get(s).size() != 1));
                                    display = getDisplay(ccm.getDependsOn(), s);
                                    if (display != null)
                                        td.tx(" (" + display + ")");
                                }
                            }
                        }
                        first = false;
                        if (hasRelationships) {
                            if (!ccm.hasEquivalence())
                                tr.td();
                            else {
                                String code = ccm.getEquivalenceElement().toString();
                                tr.td().ah(eqpath + "#" + code).tx(presentEquivalenceCode(code));
                            }
                        }
                        td = tr.td().style("border-right-width: 0px");
                        if (targets.get("code").size() == 1)
                            td.addText(ccm.getCode());
                        else
                            td.addText(grp.getTarget() + " / " + ccm.getCode());
                        display = ccm.hasDisplay() ? ccm.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getTarget()), versionFromCanonical(grp.getTarget()), ccm.getCode());
                        tr.td().style("border-left-width: 0px").tx(display == null ? "" : display);
                        for (String s : targets.keySet()) {
                            if (!s.equals("code")) {
                                td = tr.td();
                                td.addText(getValue(ccm.getProduct(), s, targets.get(s).size() != 1));
                                display = getDisplay(ccm.getProduct(), s);
                                if (display != null)
                                    td.tx(" (" + display + ")");
                            }
                        }
                        if (comment)
                            tr.td().addText(ccm.getComment());
                    }
                }
                addUnmapped(tbl, grp);
            }
        }
    }
    return true;
}
Also used : HashMap(java.util.HashMap) CodeSystem(org.hl7.fhir.r4b.model.CodeSystem) ContactPoint(org.hl7.fhir.r4b.model.ContactPoint) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) ContactDetail(org.hl7.fhir.r4b.model.ContactDetail) ContactPoint(org.hl7.fhir.r4b.model.ContactPoint) OtherElementComponent(org.hl7.fhir.r4b.model.ConceptMap.OtherElementComponent) TargetElementComponent(org.hl7.fhir.r4b.model.ConceptMap.TargetElementComponent) ConceptMapGroupComponent(org.hl7.fhir.r4b.model.ConceptMap.ConceptMapGroupComponent) SourceElementComponent(org.hl7.fhir.r4b.model.ConceptMap.SourceElementComponent) HashSet(java.util.HashSet)

Example 23 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class LibraryRenderer method participantRow.

private void participantRow(XhtmlNode t, String label, ContactDetail cd, boolean email, boolean phone, boolean url) {
    XhtmlNode tr = t.tr();
    tr.td().tx(label);
    tr.td().tx(cd.getName());
    if (email) {
        renderContactPoint(tr.td(), cd.getEmail());
    }
    if (phone) {
        renderContactPoint(tr.td(), cd.getPhone());
    }
    if (url) {
        renderContactPoint(tr.td(), cd.getUrl());
    }
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 24 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class LibraryRenderer method render.

public boolean render(XhtmlNode x, Library lib) throws FHIRFormatError, DefinitionException, IOException {
    if (lib.hasAuthor() || lib.hasEditor() || lib.hasReviewer() || lib.hasEndorser()) {
        boolean email = hasCT(lib.getAuthor(), "email") || hasCT(lib.getEditor(), "email") || hasCT(lib.getReviewer(), "email") || hasCT(lib.getEndorser(), "email");
        boolean phone = hasCT(lib.getAuthor(), "phone") || hasCT(lib.getEditor(), "phone") || hasCT(lib.getReviewer(), "phone") || hasCT(lib.getEndorser(), "phone");
        boolean url = hasCT(lib.getAuthor(), "url") || hasCT(lib.getEditor(), "url") || hasCT(lib.getReviewer(), "url") || hasCT(lib.getEndorser(), "url");
        x.h2().tx("Participants");
        XhtmlNode t = x.table("grid");
        for (ContactDetail cd : lib.getAuthor()) {
            participantRow(t, "Author", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getEditor()) {
            participantRow(t, "Editor", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getReviewer()) {
            participantRow(t, "Reviewer", cd, email, phone, url);
        }
        for (ContactDetail cd : lib.getEndorser()) {
            participantRow(t, "Endorser", cd, email, phone, url);
        }
    }
    if (lib.hasRelatedArtifact()) {
        x.h2().tx("Related Artifacts");
        XhtmlNode t = x.table("grid");
        boolean label = false;
        boolean display = false;
        boolean citation = false;
        for (RelatedArtifact ra : lib.getRelatedArtifact()) {
            label = label || ra.hasLabel();
            display = display || ra.hasDisplay();
            citation = citation || ra.hasCitation();
        }
        for (RelatedArtifact ra : lib.getRelatedArtifact()) {
            renderArtifact(t, ra, lib, label, display, citation);
        }
    }
    if (lib.hasParameter()) {
        x.h2().tx("Parameters");
        XhtmlNode t = x.table("grid");
        boolean doco = false;
        for (ParameterDefinition p : lib.getParameter()) {
            doco = doco || p.hasDocumentation();
        }
        for (ParameterDefinition p : lib.getParameter()) {
            renderParameter(t, p, doco);
        }
    }
    if (lib.hasDataRequirement()) {
        x.h2().tx("Data Requirements");
        for (DataRequirement p : lib.getDataRequirement()) {
            renderDataRequirement(x, p);
        }
    }
    if (lib.hasContent()) {
        x.h2().tx("Contents");
        boolean isCql = false;
        int counter = 0;
        for (Attachment att : lib.getContent()) {
            renderAttachment(x, att, isCql, counter, lib.getId());
            isCql = isCql || (att.hasContentType() && att.getContentType().startsWith("text/cql"));
            counter++;
        }
    }
    return false;
}
Also used : ContactDetail(org.hl7.fhir.r4b.model.ContactDetail) Attachment(org.hl7.fhir.r4b.model.Attachment) DataRequirement(org.hl7.fhir.r4b.model.DataRequirement) RelatedArtifact(org.hl7.fhir.r4b.model.RelatedArtifact) ContactPoint(org.hl7.fhir.r4b.model.ContactPoint) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) ParameterDefinition(org.hl7.fhir.r4b.model.ParameterDefinition)

Example 25 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class ConceptMapRenderer method render.

public boolean render(XhtmlNode x, ConceptMap cm) throws FHIRFormatError, DefinitionException, IOException {
    x.h2().addText(cm.getName() + " (" + cm.getUrl() + ")");
    XhtmlNode p = x.para();
    p.tx("Mapping from ");
    if (cm.hasSource())
        AddVsRef(cm.getSource().primitiveValue(), p);
    else
        p.tx("(not specified)");
    p.tx(" to ");
    if (cm.hasTarget())
        AddVsRef(cm.getTarget().primitiveValue(), p);
    else
        p.tx("(not specified)");
    p = x.para();
    if (cm.getExperimental())
        p.addText(Utilities.capitalize(cm.getStatus().toString()) + " (not intended for production usage). ");
    else
        p.addText(Utilities.capitalize(cm.getStatus().toString()) + ". ");
    p.tx("Published on " + (cm.hasDate() ? display(cm.getDateElement()) : "?ngen-10?") + " by " + cm.getPublisher());
    if (!cm.getContact().isEmpty()) {
        p.tx(" (");
        boolean firsti = true;
        for (ContactDetail ci : cm.getContact()) {
            if (firsti)
                firsti = false;
            else
                p.tx(", ");
            if (ci.hasName())
                p.addText(ci.getName() + ": ");
            boolean first = true;
            for (ContactPoint c : ci.getTelecom()) {
                if (first)
                    first = false;
                else
                    p.tx(", ");
                addTelecom(p, c);
            }
        }
        p.tx(")");
    }
    p.tx(". ");
    p.addText(cm.getCopyright());
    if (!Utilities.noString(cm.getDescription()))
        addMarkdown(x, cm.getDescription());
    x.br();
    CodeSystem cs = getContext().getWorker().fetchCodeSystem("http://hl7.org/fhir/concept-map-relationship");
    if (cs == null)
        cs = getContext().getWorker().fetchCodeSystem("http://hl7.org/fhir/concept-map-equivalence");
    String eqpath = cs == null ? null : cs.getUserString("path");
    for (ConceptMapGroupComponent grp : cm.getGroup()) {
        String src = grp.getSource();
        boolean comment = false;
        boolean ok = true;
        Map<String, HashSet<String>> sources = new HashMap<String, HashSet<String>>();
        Map<String, HashSet<String>> targets = new HashMap<String, HashSet<String>>();
        sources.put("code", new HashSet<String>());
        targets.put("code", new HashSet<String>());
        SourceElementComponent cc = grp.getElement().get(0);
        String dst = grp.getTarget();
        sources.get("code").add(grp.getSource());
        targets.get("code").add(grp.getTarget());
        for (SourceElementComponent ccl : grp.getElement()) {
            ok = ok && ccl.getTarget().size() == 1 && ccl.getTarget().get(0).getDependsOn().isEmpty() && ccl.getTarget().get(0).getProduct().isEmpty();
            for (TargetElementComponent ccm : ccl.getTarget()) {
                comment = comment || !Utilities.noString(ccm.getComment());
                for (OtherElementComponent d : ccm.getDependsOn()) {
                    if (!sources.containsKey(d.getProperty()))
                        sources.put(d.getProperty(), new HashSet<String>());
                    sources.get(d.getProperty()).add(d.getSystem());
                }
                for (OtherElementComponent d : ccm.getProduct()) {
                    if (!targets.containsKey(d.getProperty()))
                        targets.put(d.getProperty(), new HashSet<String>());
                    targets.get(d.getProperty()).add(d.getSystem());
                }
            }
        }
        String display;
        if (ok) {
            // simple
            XhtmlNode tbl = x.table("grid");
            XhtmlNode tr = tbl.tr();
            tr.td().b().tx("Source Code");
            tr.td().b().tx("Relationship");
            tr.td().b().tx("Destination Code");
            if (comment)
                tr.td().b().tx("Comment");
            tr = tbl.tr();
            XhtmlNode td = tr.td().colspan(comment ? "4" : "3");
            td.tx("Mapping from ");
            if (grp.hasSource()) {
                renderCanonical(cm, td, grp.getSource());
            } else {
                td.code("unspecified code system");
            }
            td.tx(" to ");
            if (grp.hasTarget()) {
                renderCanonical(cm, td, grp.getTarget());
            } else {
                td.code("unspecified code system");
            }
            for (SourceElementComponent ccl : grp.getElement()) {
                tr = tbl.tr();
                td = tr.td();
                td.addText(ccl.getCode());
                display = ccl.hasDisplay() ? ccl.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()), ccl.getCode());
                if (display != null && !isSameCodeAndDisplay(ccl.getCode(), display))
                    td.tx(" (" + display + ")");
                TargetElementComponent ccm = ccl.getTarget().get(0);
                if (!ccm.hasRelationship())
                    tr.td().tx(":" + "(" + ConceptMapRelationship.EQUIVALENT.toCode() + ")");
                else {
                    if (ccm.getRelationshipElement().hasExtension(ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) {
                        String code = ToolingExtensions.readStringExtension(ccm.getRelationshipElement(), ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE);
                        tr.td().ah(eqpath + "#" + code).tx(presentEquivalenceCode(code));
                    } else {
                        tr.td().ah(eqpath + "#" + ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode()));
                    }
                }
                td = tr.td();
                td.addText(ccm.getCode());
                display = ccm.hasDisplay() ? ccm.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getTarget()), versionFromCanonical(grp.getTarget()), ccm.getCode());
                if (display != null && !isSameCodeAndDisplay(ccm.getCode(), display))
                    td.tx(" (" + display + ")");
                if (comment)
                    tr.td().addText(ccm.getComment());
                addUnmapped(tbl, grp);
            }
        } else {
            boolean hasRelationships = false;
            for (int si = 0; si < grp.getElement().size(); si++) {
                SourceElementComponent ccl = grp.getElement().get(si);
                for (int ti = 0; ti < ccl.getTarget().size(); ti++) {
                    TargetElementComponent ccm = ccl.getTarget().get(ti);
                    if (ccm.hasRelationship()) {
                        hasRelationships = true;
                    }
                }
            }
            XhtmlNode tbl = x.table("grid");
            XhtmlNode tr = tbl.tr();
            XhtmlNode td;
            tr.td().colspan(Integer.toString(1 + sources.size())).b().tx("Source Concept Details");
            if (hasRelationships) {
                tr.td().b().tx("Relationship");
            }
            tr.td().colspan(Integer.toString(1 + targets.size())).b().tx("Destination Concept Details");
            if (comment) {
                tr.td().b().tx("Comment");
            }
            tr = tbl.tr();
            if (sources.get("code").size() == 1) {
                String url = sources.get("code").iterator().next();
                renderCSDetailsLink(tr, url, true);
            } else
                tr.td().b().tx("Code");
            for (String s : sources.keySet()) {
                if (!s.equals("code")) {
                    if (sources.get(s).size() == 1) {
                        String url = sources.get(s).iterator().next();
                        renderCSDetailsLink(tr, url, false);
                    } else
                        tr.td().b().addText(getDescForConcept(s));
                }
            }
            if (hasRelationships) {
                tr.td();
            }
            if (targets.get("code").size() == 1) {
                String url = targets.get("code").iterator().next();
                renderCSDetailsLink(tr, url, true);
            } else
                tr.td().b().tx("Code");
            for (String s : targets.keySet()) {
                if (!s.equals("code")) {
                    if (targets.get(s).size() == 1) {
                        String url = targets.get(s).iterator().next();
                        renderCSDetailsLink(tr, url, false);
                    } else
                        tr.td().b().addText(getDescForConcept(s));
                }
            }
            if (comment)
                tr.td();
            for (int si = 0; si < grp.getElement().size(); si++) {
                SourceElementComponent ccl = grp.getElement().get(si);
                boolean slast = si == grp.getElement().size() - 1;
                boolean first = true;
                if (ccl.hasNoMap() && ccl.getNoMap()) {
                    tr = tbl.tr();
                    td = tr.td().style("border-right-width: 0px");
                    if (!first)
                        td.style("border-top-style: none");
                    else
                        td.style("border-bottom-style: none");
                    if (sources.get("code").size() == 1)
                        td.addText(ccl.getCode());
                    else
                        td.addText(grp.getSource() + " / " + ccl.getCode());
                    display = getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()), ccl.getCode());
                    tr.td().style("border-left-width: 0px").tx(display == null ? "" : display);
                    tr.td().colspan("4").style("background-color: #efefef").tx("(not mapped)");
                } else {
                    for (int ti = 0; ti < ccl.getTarget().size(); ti++) {
                        TargetElementComponent ccm = ccl.getTarget().get(ti);
                        boolean last = ti == ccl.getTarget().size() - 1;
                        tr = tbl.tr();
                        td = tr.td().style("border-right-width: 0px");
                        if (!first && !last)
                            td.style("border-top-style: none; border-bottom-style: none");
                        else if (!first)
                            td.style("border-top-style: none");
                        else if (!last)
                            td.style("border-bottom-style: none");
                        if (first) {
                            if (sources.get("code").size() == 1)
                                td.addText(ccl.getCode());
                            else
                                td.addText(grp.getSource() + " / " + ccl.getCode());
                            display = ccl.hasDisplay() ? ccl.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()), ccl.getCode());
                            td = tr.td();
                            if (!last)
                                td.style("border-left-width: 0px; border-bottom-style: none");
                            else
                                td.style("border-left-width: 0px");
                            td.tx(display == null ? "" : display);
                        } else {
                            // for display
                            td = tr.td();
                            if (!last)
                                td.style("border-left-width: 0px; border-top-style: none; border-bottom-style: none");
                            else
                                td.style("border-top-style: none; border-left-width: 0px");
                        }
                        for (String s : sources.keySet()) {
                            if (!s.equals("code")) {
                                td = tr.td();
                                if (first) {
                                    td.addText(getValue(ccm.getDependsOn(), s, sources.get(s).size() != 1));
                                    display = getDisplay(ccm.getDependsOn(), s);
                                    if (display != null)
                                        td.tx(" (" + display + ")");
                                }
                            }
                        }
                        first = false;
                        if (hasRelationships) {
                            if (!ccm.hasRelationship())
                                tr.td();
                            else {
                                if (ccm.getRelationshipElement().hasExtension(ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE)) {
                                    String code = ToolingExtensions.readStringExtension(ccm.getRelationshipElement(), ToolingExtensions.EXT_OLD_CONCEPTMAP_EQUIVALENCE);
                                    tr.td().ah(eqpath + "#" + code).tx(presentEquivalenceCode(code));
                                } else {
                                    tr.td().ah(eqpath + "#" + ccm.getRelationship().toCode()).tx(presentRelationshipCode(ccm.getRelationship().toCode()));
                                }
                            }
                        }
                        td = tr.td().style("border-right-width: 0px");
                        if (targets.get("code").size() == 1)
                            td.addText(ccm.getCode());
                        else
                            td.addText(grp.getTarget() + " / " + ccm.getCode());
                        display = ccm.hasDisplay() ? ccm.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getTarget()), versionFromCanonical(grp.getTarget()), ccm.getCode());
                        tr.td().style("border-left-width: 0px").tx(display == null ? "" : display);
                        for (String s : targets.keySet()) {
                            if (!s.equals("code")) {
                                td = tr.td();
                                td.addText(getValue(ccm.getProduct(), s, targets.get(s).size() != 1));
                                display = getDisplay(ccm.getProduct(), s);
                                if (display != null)
                                    td.tx(" (" + display + ")");
                            }
                        }
                        if (comment)
                            tr.td().addText(ccm.getComment());
                    }
                }
                addUnmapped(tbl, grp);
            }
        }
    }
    return true;
}
Also used : HashMap(java.util.HashMap) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) ContactDetail(org.hl7.fhir.r5.model.ContactDetail) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) OtherElementComponent(org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent) TargetElementComponent(org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent) ConceptMapGroupComponent(org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent) SourceElementComponent(org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent) HashSet(java.util.HashSet)

Aggregations

ContactDetail (org.hl7.fhir.dstu3.model.ContactDetail)15 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)15 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)9 ContactDetail (org.hl7.fhir.r4b.model.ContactDetail)7 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)7 CodeType (org.hl7.fhir.r5.model.CodeType)6 NotImplementedException (org.apache.commons.lang3.NotImplementedException)5 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)5 HashSet (java.util.HashSet)4 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)4 ContactPoint (org.hl7.fhir.r4b.model.ContactPoint)4 Gson (com.google.gson.Gson)3 GsonBuilder (com.google.gson.GsonBuilder)3 JsonArray (com.google.gson.JsonArray)3 JsonObject (com.google.gson.JsonObject)3 FileOutputStream (java.io.FileOutputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 HashMap (java.util.HashMap)3 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)3 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)3