Search in sources :

Example 76 with CD

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

the class ResourceRenderer method renderCommitteeLink.

protected void renderCommitteeLink(XhtmlNode x, CanonicalResource cr) {
    String code = ToolingExtensions.readStringExtension(cr, ToolingExtensions.EXT_WORKGROUP);
    CodeSystem cs = context.getWorker().fetchCodeSystem("http://terminology.hl7.org/CodeSystem/hl7-work-group");
    if (cs == null || !cs.hasUserData("path"))
        x.tx(code);
    else {
        ConceptDefinitionComponent cd = CodeSystemUtilities.findCode(cs.getConcept(), code);
        if (cd == null) {
            x.tx(code);
        } else {
            x.ah(cs.getUserString("path") + "#" + cs.getId() + "-" + cd.getCode()).tx(cd.getDisplay());
        }
    }
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) CodeSystem(org.hl7.fhir.r5.model.CodeSystem)

Example 77 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, BaseWrapper cd, boolean email, boolean phone, boolean url) throws UnsupportedEncodingException, FHIRException, IOException {
    XhtmlNode tr = t.tr();
    tr.td().tx(label);
    tr.td().tx(cd.get("name") != null ? cd.get("name").primitiveValue() : null);
    PropertyWrapper telecoms = cd.getChildByName("telecom");
    if (email) {
        renderContactPoint(tr.td(), getContactPoint(telecoms, "email"));
    }
    if (phone) {
        renderContactPoint(tr.td(), getContactPoint(telecoms, "phone"));
    }
    if (url) {
        renderContactPoint(tr.td(), getContactPoint(telecoms, "url"));
    }
}
Also used : PropertyWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 78 with CD

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

the class NarrativeGenerator method describeLang.

private String describeLang(String lang) {
    ValueSet v = context.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) || cc.getCode().startsWith(lang + "-"))
                    l = cc;
            }
        }
        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.dstu3.model.ValueSet.ConceptReferenceDesignationComponent) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) ConceptReferenceComponent(org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent)

Example 79 with CD

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

the class NarrativeGenerator method genInclude.

private boolean genInclude(ResourceContext rcontext, XhtmlNode ul, ConceptSetComponent inc, String type, List<String> langs, List<UsedConceptMap> maps) throws FHIRException, IOException {
    boolean hasExtensions = false;
    XhtmlNode li;
    li = ul.li();
    CodeSystem e = context.fetchCodeSystem(inc.getSystem());
    if (inc.hasSystem()) {
        if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) {
            li.addText(type + " all codes defined in ");
            addCsRef(inc, li, e);
        } else {
            if (inc.getConcept().size() > 0) {
                li.addText(type + " these codes as defined in ");
                addCsRef(inc, li, e);
                XhtmlNode t = li.table("none");
                boolean hasComments = false;
                boolean hasDefinition = false;
                for (ConceptReferenceComponent c : inc.getConcept()) {
                    hasComments = hasComments || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT);
                    hasDefinition = hasDefinition || ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION);
                }
                if (hasComments || hasDefinition)
                    hasExtensions = true;
                addMapHeaders(addTableHeaderRowStandard(t, false, true, hasDefinition, hasComments, false, false, null), maps);
                for (ConceptReferenceComponent c : inc.getConcept()) {
                    XhtmlNode tr = t.tr();
                    XhtmlNode td = tr.td();
                    ConceptDefinitionComponent cc = getConceptForCode(e, c.getCode(), inc);
                    addCodeToTable(false, inc.getSystem(), c.getCode(), c.hasDisplay() ? c.getDisplay() : cc != null ? cc.getDisplay() : "", td);
                    td = tr.td();
                    if (!Utilities.noString(c.getDisplay()))
                        td.addText(c.getDisplay());
                    else if (cc != null && !Utilities.noString(cc.getDisplay()))
                        td.addText(cc.getDisplay());
                    td = tr.td();
                    if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_DEFINITION))
                        smartAddText(td, ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_DEFINITION));
                    else if (cc != null && !Utilities.noString(cc.getDefinition()))
                        smartAddText(td, cc.getDefinition());
                    if (ExtensionHelper.hasExtension(c, ToolingExtensions.EXT_VS_COMMENT)) {
                        smartAddText(tr.td(), "Note: " + ToolingExtensions.readStringExtension(c, ToolingExtensions.EXT_VS_COMMENT));
                    }
                    for (ConceptReferenceDesignationComponent cd : c.getDesignation()) {
                        if (cd.hasLanguage() && !langs.contains(cd.getLanguage()))
                            langs.add(cd.getLanguage());
                    }
                }
            }
            boolean first = true;
            for (ConceptSetFilterComponent f : inc.getFilter()) {
                if (first) {
                    li.addText(type + " codes from ");
                    first = false;
                } else
                    li.tx(" and ");
                addCsRef(inc, li, e);
                li.tx(" where " + f.getProperty() + " " + describe(f.getOp()) + " ");
                if (e != null && codeExistsInValueSet(e, f.getValue())) {
                    String href = prefix + getCsRef(e);
                    if (href.contains("#"))
                        href = href + "-" + Utilities.nmtokenize(f.getValue());
                    else
                        href = href + "#" + e.getId() + "-" + Utilities.nmtokenize(f.getValue());
                    li.ah(href).addText(f.getValue());
                } else if ("concept".equals(f.getProperty()) && inc.hasSystem()) {
                    li.addText(f.getValue());
                    ValidationResult vr = context.validateCode(terminologyServiceOptions, inc.getSystem(), f.getValue(), null);
                    if (vr.isOk()) {
                        li.tx(" (" + vr.getDisplay() + ")");
                    }
                } else
                    li.addText(f.getValue());
                String disp = ToolingExtensions.getDisplayHint(f);
                if (disp != null)
                    li.tx(" (" + disp + ")");
            }
        }
        if (inc.hasValueSet()) {
            li.tx(", where the codes are contained in ");
            boolean first = true;
            for (UriType vs : inc.getValueSet()) {
                if (first)
                    first = false;
                else
                    li.tx(", ");
                AddVsRef(rcontext, vs.asStringValue(), li);
            }
        }
    } else {
        li.tx("Import all the codes that are contained in ");
        boolean first = true;
        for (UriType vs : inc.getValueSet()) {
            if (first)
                first = false;
            else
                li.tx(", ");
            AddVsRef(rcontext, vs.asStringValue(), li);
        }
    }
    return hasExtensions;
}
Also used : ValidationResult(org.hl7.fhir.r4.context.IWorkerContext.ValidationResult) CodeSystem(org.hl7.fhir.r4.model.CodeSystem) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 80 with CD

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

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