Search in sources :

Example 36 with CD

use of org.hl7.v3.CD in project org.hl7.fhir.core by hapifhir.

the class CodeSystemComparer method merge.

private ConceptDefinitionComponent merge(ConceptDefinitionComponent l, ConceptDefinitionComponent r, List<PropertyComponent> destProps, CodeSystemComparison res) {
    ConceptDefinitionComponent cd = l.copy();
    if (!l.hasDisplay() && r.hasDisplay()) {
        cd.setDisplay(r.getDisplay());
    }
    if (!l.hasDefinition() && r.hasDefinition()) {
        cd.setDefinition(r.getDefinition());
    }
    mergeProps(cd, l, r, destProps, res);
    mergeDesignations(cd, l, r);
    return cd;
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)

Example 37 with CD

use of org.hl7.v3.CD in project org.hl7.fhir.core by hapifhir.

the class CodeSystemRenderer method addDefineRowToTable.

private boolean addDefineRowToTable(XhtmlNode t, ConceptDefinitionComponent c, int level, boolean hasHierarchy, boolean hasDisplay, boolean hasDefinitions, boolean comment, boolean version, boolean deprecated, List<UsedConceptMap> maps, String system, CodeSystem cs, List<PropertyComponent> properties, CodeSystemNavigator csNav, List<String> langs, boolean isSupplement) throws FHIRFormatError, DefinitionException, IOException {
    boolean hasExtensions = false;
    XhtmlNode tr = t.tr();
    XhtmlNode td = tr.td();
    if (hasHierarchy) {
        td.addText(Integer.toString(level + 1));
        td = tr.td();
        String s = Utilities.padLeft("", '\u00A0', level * 2);
        td.addText(s);
    }
    String link = isSupplement ? getLinkForCode(cs.getSupplements(), null, c.getCode()) : null;
    if (link != null) {
        td.ah(link).attribute("style", "white-space:nowrap").addText(c.getCode());
    } else {
        td.attribute("style", "white-space:nowrap").addText(c.getCode());
    }
    XhtmlNode a;
    if (c.hasCodeElement()) {
        td.an(cs.getId() + "-" + Utilities.nmtokenize(c.getCode()));
    }
    for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
        if (cd.hasLanguage() && !langs.contains(cd.getLanguage()) && (!cs.hasLanguage() || !cs.getLanguage().equals(cd.getLanguage()))) {
            langs.add(cd.getLanguage());
        }
    }
    if (hasDisplay) {
        td = tr.td();
        renderDisplayName(c, cs, td);
    }
    if (hasDefinitions) {
        td = tr.td();
        if (c != null && c.hasDefinitionElement()) {
            if (getContext().getLang() == null) {
                if (hasMarkdownInDefinitions(cs))
                    addMarkdown(td, c.getDefinition());
                else
                    td.addText(c.getDefinition());
            } else if (getContext().getLang().equals("*")) {
                boolean sl = false;
                for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue()))
                    sl = true;
                td.addText((sl ? cs.getLanguage("en") + ": " : "") + c.getDefinition());
                for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
                    if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue())) {
                        td.br();
                        td.addText(cd.getLanguage() + ": " + cd.getValue());
                    }
                }
            } else if (getContext().getLang().equals(cs.getLanguage()) || (getContext().getLang().equals("en") && !cs.hasLanguage())) {
                td.addText(c.getDefinition());
            } else {
                for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
                    if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && cd.getLanguage().equals(getContext().getLang())) {
                        td.addText(cd.getValue());
                    }
                }
            }
        }
    }
    if (deprecated) {
        td = tr.td();
        Boolean b = CodeSystemUtilities.isDeprecated(cs, c, false);
        if (b != null && b) {
            smartAddText(td, getContext().getWorker().translator().translate("xhtml-gen-cs", "Deprecated", getContext().getLang()));
            hasExtensions = true;
            if (ToolingExtensions.hasExtension(c, ToolingExtensions.EXT_REPLACED_BY)) {
                Coding cc = (Coding) ToolingExtensions.getExtension(c, ToolingExtensions.EXT_REPLACED_BY).getValue();
                td.tx(" (replaced by ");
                String url = getCodingReference(cc, system);
                if (url != null) {
                    td.ah(url).addText(cc.getCode());
                    td.tx(": " + cc.getDisplay() + ")");
                } else
                    td.addText(cc.getCode() + " '" + cc.getDisplay() + "' in " + cc.getSystem() + ")");
            }
        }
    }
    if (comment) {
        td = tr.td();
        Extension ext = c.getExtensionByUrl(ToolingExtensions.EXT_CS_COMMENT);
        if (ext != null) {
            hasExtensions = true;
            String bc = ext.hasValue() ? ext.getValue().primitiveValue() : null;
            Map<String, String> translations = ToolingExtensions.getLanguageTranslations(ext.getValue());
            if (getContext().getLang() == null) {
                if (bc != null)
                    td.addText(bc);
            } else if (getContext().getLang().equals("*")) {
                boolean sl = false;
                for (String l : translations.keySet()) if (bc == null || !bc.equalsIgnoreCase(translations.get(l)))
                    sl = true;
                if (bc != null) {
                    td.addText((sl ? cs.getLanguage("en") + ": " : "") + bc);
                }
                for (String l : translations.keySet()) {
                    if (bc == null || !bc.equalsIgnoreCase(translations.get(l))) {
                        if (!td.getChildNodes().isEmpty())
                            td.br();
                        td.addText(l + ": " + translations.get(l));
                    }
                }
            } else if (getContext().getLang().equals(cs.getLanguage()) || (getContext().getLang().equals("en") && !cs.hasLanguage())) {
                if (bc != null)
                    td.addText(bc);
            } else {
                if (bc != null)
                    translations.put(cs.getLanguage("en"), bc);
                for (String l : translations.keySet()) {
                    if (l.equals(getContext().getLang())) {
                        td.addText(translations.get(l));
                    }
                }
            }
        }
    }
    if (version) {
        td = tr.td();
        if (c.hasUserData("cs.version.notes"))
            td.addText(c.getUserString("cs.version.notes"));
    }
    if (properties != null) {
        for (PropertyComponent pc : properties) {
            td = tr.td();
            boolean first = true;
            List<ConceptPropertyComponent> pcvl = CodeSystemUtilities.getPropertyValues(c, pc.getCode());
            for (ConceptPropertyComponent pcv : pcvl) {
                if (pcv.hasValue()) {
                    if (first)
                        first = false;
                    else
                        td.addText(", ");
                    if (pcv.hasValueCoding()) {
                        td.addText(pcv.getValueCoding().getCode());
                    } else if (pcv.hasValueStringType() && Utilities.isAbsoluteUrlLinkable(pcv.getValue().primitiveValue())) {
                        td.ah(pcv.getValue().primitiveValue()).tx(pcv.getValue().primitiveValue());
                    } else {
                        td.addText(pcv.getValue().primitiveValue());
                    }
                }
            }
        }
    }
    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.hasRelationship() ? mapping.comp.getRelationship().toCode() : "");
            span.addText(getCharForRelationship(mapping.comp));
            a = td.ah(getContext().getSpecificationLink() + m.getLink() + "#" + makeAnchor(mapping.group.getTarget(), mapping.comp.getCode()));
            a.addText(mapping.comp.getCode());
            if (!Utilities.noString(mapping.comp.getComment()))
                td.i().tx("(" + mapping.comp.getComment() + ")");
        }
    }
    List<ConceptDefinitionComponent> ocl = csNav.getOtherChildren(c);
    for (ConceptDefinitionComponent cc : csNav.getConcepts(c)) {
        hasExtensions = addDefineRowToTable(t, cc, level + 1, hasHierarchy, hasDisplay, hasDefinitions, comment, version, deprecated, maps, system, cs, properties, csNav, langs, isSupplement) || hasExtensions;
    }
    for (ConceptDefinitionComponent cc : ocl) {
        tr = t.tr();
        td = tr.td();
        td.addText(Integer.toString(level + 2));
        td = tr.td();
        String s = Utilities.padLeft("", '\u00A0', (level + 1) * 2);
        td.addText(s);
        td.attribute("style", "white-space:nowrap");
        a = td.ah("#" + cs.getId() + "-" + Utilities.nmtokenize(cc.getCode()));
        a.addText(cc.getCode());
        if (hasDisplay) {
            td = tr.td();
            renderDisplayName(cc, cs, td);
        }
        int w = 1 + (deprecated ? 1 : 0) + (comment ? 1 : 0) + (version ? 1 : 0) + maps.size();
        if (properties != null) {
            w = w + properties.size();
        }
        td = tr.td().colspan(Integer.toString(w));
    }
    return hasExtensions;
}
Also used : ConceptPropertyComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) Extension(org.hl7.fhir.r5.model.Extension) PropertyComponent(org.hl7.fhir.r5.model.CodeSystem.PropertyComponent) ConceptPropertyComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent) Coding(org.hl7.fhir.r5.model.Coding)

Example 38 with CD

use of org.hl7.v3.CD 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 39 with CD

use of org.hl7.v3.CD 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.r5.model.ContactDetail) Attachment(org.hl7.fhir.r5.model.Attachment) DataRequirement(org.hl7.fhir.r5.model.DataRequirement) RelatedArtifact(org.hl7.fhir.r5.model.RelatedArtifact) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) ParameterDefinition(org.hl7.fhir.r5.model.ParameterDefinition)

Example 40 with CD

use of org.hl7.v3.CD in project org.hl7.fhir.core by hapifhir.

the class LibraryRenderer method render.

public boolean render(XhtmlNode x, ResourceWrapper lib) throws FHIRFormatError, DefinitionException, IOException {
    PropertyWrapper authors = lib.getChildByName("author");
    PropertyWrapper editors = lib.getChildByName("editor");
    PropertyWrapper reviewers = lib.getChildByName("reviewer");
    PropertyWrapper endorsers = lib.getChildByName("endorser");
    if ((authors != null && authors.hasValues()) || (editors != null && editors.hasValues()) || (reviewers != null && reviewers.hasValues()) || (endorsers != null && endorsers.hasValues())) {
        boolean email = hasCT(authors, "email") || hasCT(editors, "email") || hasCT(reviewers, "email") || hasCT(endorsers, "email");
        boolean phone = hasCT(authors, "phone") || hasCT(editors, "phone") || hasCT(reviewers, "phone") || hasCT(endorsers, "phone");
        boolean url = hasCT(authors, "url") || hasCT(editors, "url") || hasCT(reviewers, "url") || hasCT(endorsers, "url");
        x.h2().tx("Participants");
        XhtmlNode t = x.table("grid");
        if (authors != null) {
            for (BaseWrapper cd : authors.getValues()) {
                participantRow(t, "Author", cd, email, phone, url);
            }
        }
        if (authors != null) {
            for (BaseWrapper cd : editors.getValues()) {
                participantRow(t, "Editor", cd, email, phone, url);
            }
        }
        if (authors != null) {
            for (BaseWrapper cd : reviewers.getValues()) {
                participantRow(t, "Reviewer", cd, email, phone, url);
            }
        }
        if (authors != null) {
            for (BaseWrapper cd : endorsers.getValues()) {
                participantRow(t, "Endorser", cd, email, phone, url);
            }
        }
    }
    PropertyWrapper artifacts = lib.getChildByName("relatedArtifact");
    if (artifacts != null && artifacts.hasValues()) {
        x.h2().tx("Related Artifacts");
        XhtmlNode t = x.table("grid");
        boolean label = false;
        boolean display = false;
        boolean citation = false;
        for (BaseWrapper ra : artifacts.getValues()) {
            label = label || ra.has("label");
            display = display || ra.has("display");
            citation = citation || ra.has("citation");
        }
        for (BaseWrapper ra : artifacts.getValues()) {
            renderArtifact(t, ra, lib, label, display, citation);
        }
    }
    PropertyWrapper parameters = lib.getChildByName("parameter");
    if (parameters != null && parameters.hasValues()) {
        x.h2().tx("Parameters");
        XhtmlNode t = x.table("grid");
        boolean doco = false;
        for (BaseWrapper p : parameters.getValues()) {
            doco = doco || p.has("documentation");
        }
        for (BaseWrapper p : parameters.getValues()) {
            renderParameter(t, p, doco);
        }
    }
    PropertyWrapper dataRequirements = lib.getChildByName("dataRequirement");
    if (dataRequirements != null && dataRequirements.hasValues()) {
        x.h2().tx("Data Requirements");
        for (BaseWrapper p : dataRequirements.getValues()) {
            renderDataRequirement(x, (DataRequirement) p.getBase());
        }
    }
    PropertyWrapper contents = lib.getChildByName("content");
    if (contents != null) {
        x.h2().tx("Contents");
        boolean isCql = false;
        int counter = 0;
        for (BaseWrapper p : contents.getValues()) {
            Attachment att = (Attachment) p.getBase();
            renderAttachment(x, att, isCql, counter, lib.getId());
            isCql = isCql || (att.hasContentType() && att.getContentType().startsWith("text/cql"));
            counter++;
        }
    }
    return false;
}
Also used : PropertyWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper) BaseWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper) Attachment(org.hl7.fhir.r5.model.Attachment) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

ArrayList (java.util.ArrayList)24 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)16 Coding (org.hl7.fhir.r4.model.Coding)10 ValueSet (org.hl7.fhir.r5.model.ValueSet)10 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)9 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)8 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 CD (net.ihe.gazelle.hl7v3.datatypes.CD)7 CS (net.ihe.gazelle.hl7v3.datatypes.CS)7 II (net.ihe.gazelle.hl7v3.datatypes.II)7 TS (net.ihe.gazelle.hl7v3.datatypes.TS)7 MCCIMT000100UV01Device (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Device)7 MCCIMT000100UV01Receiver (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Receiver)7 MCCIMT000100UV01Sender (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Sender)7 Identifier (org.hl7.fhir.r4.model.Identifier)7 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)7 IOException (java.io.IOException)6 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)6 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)5