Search in sources :

Example 61 with CD

use of org.hl7.v3.CD in project kindling by HL7.

the class TerminologyNotesGenerator method describeBinding.

public static String describeBinding(String prefix, BindingSpecification cd, PageProcessor page) throws Exception {
    if (cd.getBinding() == BindingSpecification.BindingMethod.Unbound)
        return cd.getDefinition();
    if (cd.getBinding() == BindingSpecification.BindingMethod.Special) {
        if (cd.getValueSet().getName().equals("MessageEvent"))
            return "the <a href=\"" + prefix + "valueset-message-events.html\">Event List in the messaging framework</a>";
        else if (cd.getValueSet().getName().equals("ResourceType"))
            return "<a href=\"" + prefix + "valueset-resource-types.html\">Any defined Resource Type name</a>";
        else if (cd.getValueSet().getName().equals("DataType"))
            return "<a href=\"" + prefix + "valueset-data-types.html\">Any defined Data Type name</a>";
        else if (cd.getValueSet().getName().equals("FHIRDefinedType"))
            return "<a href=\"" + prefix + "valueset-defined-types.html\">Any defined Resource or Data Type name</a>";
        else if (cd.getValueSet().getName().equals("FHIRAllTypes"))
            return "<a href=\"" + prefix + "valueset-all-types.html\">Any defined Resource or Data Type name (including \"Any\" and \"Type\")</a>";
        else
            throw new Exception("Unknown special type " + cd.getValueSet().getName());
    }
    String mx = "";
    if (cd.hasMax()) {
        if (cd.getMaxValueSet() == null)
            mx = " but limited to ??";
        else {
            String pp = cd.getMaxValueSet().hasUserData("external.url") ? cd.getMaxValueSet().getUserString("external.url") : cd.getMaxValueSet().getUserString("path");
            mx = " but limited to <a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + cd.getMaxValueSet().present() + "</a>";
        }
    }
    String bs = "<a href=\"" + prefix + "terminologies.html#" + cd.getStrength().toCode() + "\">" + cd.getStrength().getDisplay() + "</a>";
    if (cd.getValueSet() != null) {
        ValueSet vs = cd.getValueSet();
        String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
        return "<a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + cd.getValueSet().present() + "</a> (" + bs + mx + ")";
    } else if (cd.getBinding() == BindingSpecification.BindingMethod.ValueSet) {
        if (Utilities.noString(cd.getReference()))
            return cd.getDescription();
        else if (cd.getValueSet() == null)
            return bs + ": <a href=\"" + (cd.getReference().startsWith("http") ? cd.getReference() : prefix + cd.getReference() + ".html") + "\">See " + cd.getDescription() + "</a> (" + cd.getDefinition() + mx + ")";
        else
            return bs + ": <a href=\"" + prefix + cd.getReference() + ".html\">See " + cd.getValueSet().getUrl() + "</a> (" + cd.getDefinition() + mx + ")";
    } else if (cd.getBinding() == BindingSpecification.BindingMethod.CodeList) {
        if (Utilities.noString(cd.getReference()))
            return bs + ": " + cd.getDescription() + " (" + cd.getDefinition() + mx + ")";
        else
            return bs + ": <a href=\"" + prefix + "valueset-" + cd.getReference().substring(1) + ".html\">http://hl7.org/fhir/" + cd.getReference().substring(1) + "</a> (" + cd.getDefinition() + mx + ")";
    }
    return "??";
}
Also used : ValueSet(org.hl7.fhir.r5.model.ValueSet) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 62 with CD

use of org.hl7.v3.CD in project kindling by HL7.

the class DictHTMLGenerator method describeBinding.

private String describeBinding(String path, ElementDefn e) throws Exception {
    if (!e.hasBinding())
        return null;
    // name (description): [[ValueSet]], Strength = [[]]
    StringBuilder b = new StringBuilder();
    BindingSpecification cd = e.getBinding();
    if (cd.getValueSet() == null) {
        if (!Utilities.noString(cd.getReference()))
            b.append("<a href=\"" + prefix + cd.getReference() + "\">" + e.getBinding().getName() + "</a>: ");
        else
            b.append("<a href=\"" + prefix + "terminologies.html#unbound\">" + e.getBinding().getName() + "</a>: ");
    } else
        b.append(TerminologyNotesGenerator.describeBinding(prefix, cd, page));
    // "<a href=\"terminologies.html#conformance\">"+(cd.getBindingStrength() == null ? "--" : cd.getBindingStrength().toString().toLowerCase())+"</a>)");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) BindingSpecification(org.hl7.fhir.definitions.model.BindingSpecification)

Example 63 with CD

use of org.hl7.v3.CD in project kindling by HL7.

the class PageProcessor method generateCode.

private void generateCode(BindingSpecification cd, StringBuilder s, boolean hasSource, boolean hasId, boolean hasComment, boolean hasDefinition, boolean hasParent, int level, DefinedCode c) {
    String id = hasId ? "<td>" + fixNull(c.getId()) + "</td>" : "";
    String src = "";
    if (hasSource) {
        if (Utilities.noString(c.getSystem())) {
            src = "<td></td>";
        } else {
            String url = c.getSystem();
            url = fixUrlReference(url);
            src = "<td><a href=\"" + url + "\">" + codeSystemDescription(c.getSystem()) + "</a></td>";
        }
    }
    String lvl = hasParent ? "<td>" + Integer.toString(level) + "</td>" : "";
    String indent = "";
    for (int i = 1; i < level; i++) indent = indent + "&nbsp;&nbsp;";
    if (hasComment)
        s.append("    <tr>" + id + src + lvl + "<td>" + indent + Utilities.escapeXml(c.getCode()) + "</td><td>" + Utilities.escapeXml(c.getDefinition()) + "</td><td>" + Utilities.escapeXml(c.getComment()) + "</td></tr>\r\n");
    else if (hasDefinition)
        s.append("    <tr>" + id + src + lvl + "<td>" + indent + Utilities.escapeXml(c.getCode()) + "</td><td colspan=\"2\">" + Utilities.escapeXml(c.getDefinition()) + "</td></tr>\r\n");
    else
        s.append("    <tr>" + id + src + lvl + "<td colspan=\"3\">" + indent + Utilities.escapeXml(c.getCode()) + "</td></tr>\r\n");
    for (DefinedCode ch : c.getChildCodes()) {
        generateCode(cd, s, hasSource, hasId, hasComment, hasDefinition, hasParent, level + 1, ch);
    }
}
Also used : DefinedCode(org.hl7.fhir.definitions.model.DefinedCode) ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

Example 64 with CD

use of org.hl7.v3.CD in project kindling by HL7.

the class CodeListToValueSetParser method processV3Map.

private void processV3Map(ConceptMap cm, String url, String code, String v3map) throws Exception {
    if (Utilities.noString(v3map))
        return;
    for (String m : v3map.split(",")) {
        // analyse m
        String[] n = m.split("\\(");
        String comm = (n.length > 1) ? n[1].substring(0, n[1].length() - 1) : null;
        n = n[0].split("\\.");
        if (n.length != 2)
            throw new Exception("Error processing v3 map value for " + cm.getName() + "." + code + " '" + m + "' - format should be CodeSystem.code (comment) - the comment bit is optional");
        String rel = null;
        String tbl = n[0];
        if (Utilities.existsInList(n[0].substring(0, 1), "=", "~", ">", "<")) {
            rel = n[0].substring(0, 1);
            tbl = n[0].substring(1);
        }
        String cd = n[1];
        ConceptMapGroupComponent grp = getGroup(cm, url, "http://terminology.hl7.org/CodeSystem/v3-" + tbl);
        SourceElementComponent src = getSource(grp, code);
        TargetElementComponent tgt = src.addTarget();
        tgt.setCode(cd.trim());
        tgt.setComment(comm);
        if (rel == null || rel.equals("="))
            tgt.setRelationship(ConceptMapRelationship.EQUIVALENT);
        else if (rel.equals("~"))
            tgt.setRelationship(ConceptMapRelationship.EQUIVALENT);
        else if (rel.equals("<"))
            tgt.setRelationship(ConceptMapRelationship.SOURCEISNARROWERTHANTARGET);
        else if (rel.equals(">")) {
            tgt.setRelationship(ConceptMapRelationship.SOURCEISBROADERTHANTARGET);
            if (!tgt.hasComment())
                throw new Exception("Missing comment for narrower match on " + cm.getName() + "/" + code);
        } else
            throw new Exception("Unable to understand relationship character " + rel);
    }
}
Also used : TargetElementComponent(org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent) ConceptMapGroupComponent(org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent) SourceElementComponent(org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent)

Example 65 with CD

use of org.hl7.v3.CD in project kindling by HL7.

the class CodeListToValueSetParser method generateConceptMapV3.

private void generateConceptMapV3(String v3map, ValueSet vs, CodeSystem cs) throws Exception {
    if (!v3map.startsWith("http://terminology.hl7.org/ValueSet/v3-"))
        v3map = "http://terminology.hl7.org/ValueSet/v3-" + v3map;
    ConceptMap cm = new ConceptMap();
    cm.setVersion(version);
    cm.setId("cm-" + vs.getId() + "-v3");
    cm.setUserData("path", cm.getId() + ".html");
    cm.setUserData("generate", true);
    cm.setUrl("http://hl7.org/fhir/ConceptMap/" + cm.getId());
    cm.setName("v3." + vs.getName());
    cm.setTitle("v3 map for " + vs.present());
    cm.setPublisher("HL7 (FHIR Project)");
    for (ContactDetail cc : vs.getContact()) {
        ContactDetail cd = cm.addContact();
        cd.setName(cc.getName());
        for (ContactPoint ccs : cc.getTelecom()) cd.addTelecom(ccs.copy());
    }
    cm.setCopyright(vs.getCopyright());
    // until we publish DSTU, then .review
    cm.setStatus(vs.getStatus());
    cm.setDate(vs.getDate());
    cm.setSource(Factory.newCanonical(vs.getUrl()));
    cm.setTarget(Factory.newCanonical(v3map));
    if (cs != null)
        processV3ConceptDefs(cm, cs.getUrl(), cs.getConcept());
    for (ConceptSetComponent cc : vs.getCompose().getInclude()) for (ConceptReferenceComponent c : cc.getConcept()) {
        processV3Map(cm, cc.getSystem(), c.getCode(), c.getUserString("v2"));
    }
    maps.see(cm, packageInfo);
}
Also used : ContactDetail(org.hl7.fhir.r5.model.ContactDetail) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) ConceptSetComponent(org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) ConceptReferenceComponent(org.hl7.fhir.r5.model.ValueSet.ConceptReferenceComponent)

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