Search in sources :

Example 11 with CD

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

the class TerminologyNotesGenerator method scan.

private void scan(ElementDefn e, String path) throws Exception {
    if (e.hasBinding()) {
        BindingSpecification cd = e.getBinding();
        if (!txusages.containsKey(cd)) {
            txusages.put(cd, new ArrayList<CDUsage>());
            c++;
            txusages.get(cd).add(new CDUsage(String.valueOf(c), null));
        }
        txusages.get(cd).add(new CDUsage(path, e));
    }
    for (ElementDefn c : e.getElements()) {
        scan(c, path + "." + c.getName());
    }
}
Also used : BindingSpecification(org.hl7.fhir.definitions.model.BindingSpecification) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn)

Example 12 with CD

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

the class TerminologyNotesGenerator method gen.

private void gen(String prefix, Map<BindingSpecification, List<CDUsage>> txusages2) throws Exception {
    List<BindingSpecification> cds = new ArrayList<BindingSpecification>();
    cds.addAll(txusages.keySet());
    if (cds.size() == 0)
        return;
    Collections.sort(cds, new MyCompare());
    if (noHeader)
        write("<p>\r\n<b>Terminology Bindings</b>\r\n</p>\r\n");
    else
        write("<h3>\r\nTerminology Bindings\r\n</h3>\r\n");
    // 1. new form
    write("<table class=\"grid\">\r\n");
    write(" <tr><th>Path</th><th>Definition</th><th>Type</th><th>Reference</th></tr>\r\n");
    for (BindingSpecification cd : cds) {
        String path;
        List<CDUsage> list = txusages.get(cd);
        for (int i = 2; i < list.size(); i++) {
            if (!matchesTypes(list.get(i).element.typeCodeNoParams(), list.get(1).element.typeCodeNoParams()))
                throw new Exception("Mixed types on one concept domain in one type - not yet supported by the build process for binding " + cd.getName() + " (" + list.get(i).element.typeCode() + " vs " + list.get(1).element.typeCode() + ")");
        }
        String name = cd.getValueSet() != null ? cd.getValueSet().present() : cd.getName();
        write(" <tr><td valign=\"top\" title=\"" + name + "\">");
        boolean first = true;
        for (int i = 1; i < list.size(); i++) {
            if (!first)
                write("<br/>");
            first = false;
            write(list.get(i).path);
        }
        write(" </td>");
        write("<td valign=\"top\">" + Utilities.escapeXml(cd.getDefinition()) + "</td>");
        if (cd.getBinding() == BindingMethod.Unbound)
            write("<td>Unknown</td><td valign=\"top\">No details provided yet</td>");
        else {
            if (cd.hasMax()) {
                ValueSet vs = cd.getMaxValueSet();
                if (vs == null) {
                    write("<td><a href=\"" + prefix + "terminologies.html#" + cd.getStrength().toCode() + "\">" + cd.getStrength().getDisplay() + "</a>, but limited to <a href=\"" + cd.getMaxReference() + "\">" + cd.getMaxReference() + "</a></td>");
                } else {
                    String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
                    write("<td><a href=\"" + prefix + "terminologies.html#" + cd.getStrength().toCode() + "\">" + cd.getStrength().getDisplay() + "</a>, but limited to <a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + vs.getName() + "</a></td>");
                }
            } else
                write("<td><a href=\"" + prefix + "terminologies.html#" + cd.getStrength().toCode() + "\">" + cd.getStrength().getDisplay() + "</a></td>");
            write("<td valign=\"top\">");
            if (cd.getBinding() == BindingSpecification.BindingMethod.Special) {
                if (name.equals("MessageEvent"))
                    write("<a href=\"" + prefix + "valueset-message-events.html\">Message Events</a>");
                else if (name.equals("ResourceType"))
                    write("<a href=\"" + prefix + "valueset-resource-types.html\">Resource Types</a>");
                else if (name.equals("DataType"))
                    write("<a href=\"" + prefix + "valueset-data-types.html\">Data Types</a>");
                else if (name.equals("FHIRDefinedType"))
                    write("<a href=\"" + prefix + "valueset-defined-types.html\">Defined Types</a>");
                else if (name.equals("FHIRAllTypes"))
                    write("<a href=\"" + prefix + "valueset-all-types.html\">All Types</a>");
                else
                    throw new Exception("Unknown special type " + name);
            } else if (cd.getValueSet() != null) {
                ValueSet vs = cd.getValueSet();
                String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
                if (pp == null)
                    throw new Exception("unknown path on " + cd.getReference());
                write("<a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + vs.getName() + "</a><!-- b -->");
            } else if (cd.getBinding() == BindingSpecification.BindingMethod.ValueSet) {
                if (Utilities.noString(cd.getReference()))
                    write("??");
                else if (cd.getReference().startsWith("valueset-"))
                    write("<a href=\"" + prefix + cd.getReference() + ".html\">http://hl7.org/fhir/ValueSet/" + cd.getReference().substring(9) + "</a><!-- a -->");
                else if (cd.getReference().startsWith("http://hl7.org/fhir")) {
                    if (cd.getReference().startsWith("http://terminology.hl7.org/ValueSet/v3-")) {
                        ValueSet vs = page.getValueSets().get(cd.getReference());
                        String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
                        if (pp == null)
                            throw new Exception("unknown path on " + cd.getReference());
                        write("<a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + cd.getReference() + "</a><!-- b -->");
                    } else if (cd.getReference().startsWith("http://terminology.hl7.org/ValueSet/v2-")) {
                        ValueSet vs = page.getValueSets().get(cd.getReference());
                        String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
                        write("<a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + cd.getReference() + "</a><!-- c -->");
                    } else if (cd.getReference().startsWith("http://hl7.org/fhir/ValueSet/")) {
                        String ref = getBindingLink(cd);
                        write("<a href=\"" + prefix + ref + "\">" + cd.getReference() + "</a><!-- d -->");
                    // BindingSpecification bs1 = page.getDefinitions().getBindingByURL(cd.getReference());
                    // if (bs1 != null)
                    // write("<a href=\""+cd.getReference().substring(23)+".html\">"+cd.getReference()+"</a><!-- d -->");
                    // else
                    // write("<a href=\"valueset-"+cd.getReference().substring(23)+".html\">"+cd.getReference()+"</a><!-- d -->");
                    } else
                        throw new Exception("Internal reference " + cd.getReference() + " not handled yet");
                } else if (cd.getReference().startsWith("http:"))
                    write("<a href=\"" + cd.getReference() + "\">" + cd.getReference() + "</a><!-- e -->");
                else
                    write("<a href=\"" + prefix + "valueset-" + cd.getReference() + ".html\">http://hl7.org/fhir/" + cd.getReference() + "</a><!-- e -->");
            } else if (cd.getBinding() == BindingSpecification.BindingMethod.CodeList) {
                write("<a href=\"" + prefix + "valueset-" + cd.getReference().substring(1) + ".html\">http://hl7.org/fhir/" + cd.getReference().substring(1) + "</a><!-- f -->");
            }
            write("</td>");
        }
        write(" </tr>\r\n");
    }
    write("</table>\r\n<p> </p>\r\n");
}
Also used : BindingSpecification(org.hl7.fhir.definitions.model.BindingSpecification) ArrayList(java.util.ArrayList) ValueSet(org.hl7.fhir.r5.model.ValueSet) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 13 with CD

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

the class CodeListToValueSetParser method generateConceptMapV2.

private void generateConceptMapV2(String v2map, ValueSet vs, CodeSystem cs) throws Exception {
    ConceptMap cm = new ConceptMap();
    cm.setId("cm-" + vs.getId() + "-v2");
    cm.setVersion(version);
    cm.setUserData("path", cm.getId() + ".html");
    cm.setUserData("generate", true);
    cm.setUrl("http://hl7.org/fhir/ConceptMap/" + cm.getId());
    cm.setName("v2." + vs.getName());
    cm.setTitle("v2 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(v2map));
    if (cs != null)
        processV2ConceptDefs(cm, cs.getUrl(), cs.getConcept());
    for (ConceptSetComponent cc : vs.getCompose().getInclude()) for (ConceptReferenceComponent c : cc.getConcept()) {
        processV2Map(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)

Example 14 with CD

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

the class SchematronGenerator method genChildren.

private void genChildren(Section section, String path, String typeCode, ElementDefn ed, Definitions definitions, List<String> parents) throws Exception {
    if (!path.contains("//")) {
        ArrayList<String> l = new ArrayList<String>(parents);
        l.add(typeCode);
        for (ElementDefn cd : ed.getElements()) {
            if (!Utilities.noString(cd.typeCode()) && l.contains(cd.typeCode())) {
                // well, we've recursed. What's going to happen now is that we're going to write this as // because we're going to keep recursing.
                // the next call will write this rule, and then terminate
                generateInvariants(section, path + "/", cd, definitions, l, cd.getName());
            } else
                generateInvariants(section, path, cd, definitions, l, cd.getName());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn)

Example 15 with CD

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

the class IEEE11073Convertor method generateLoincMdcMap.

private static ConceptMap generateLoincMdcMap(CodeSystem mdc, String dst, String src) throws IOException, FHIRException {
    ConceptMap cm = new ConceptMap();
    cm.setId("loinc-mdc");
    cm.setUrl("http:/???/fhir/ConceptMap/loinc-mdc");
    cm.setVersion("[todo]");
    cm.setName("LoincMdcCrossMap");
    cm.setTitle("Cross Map between LOINC and MDC");
    cm.setStatus(PublicationStatus.DRAFT);
    cm.setExperimental(true);
    cm.setDateElement(new DateTimeType());
    cm.setPublisher("HL7, Inc");
    ContactDetail cd = cm.addContact();
    cd.setName("LOINC + IEEE");
    ContactPoint cp = cd.addTelecom();
    cp.setSystem(ContactPointSystem.URL);
    cp.setValue("http://loinc.org");
    cm.setDescription("A Cross Map between the LOINC and MDC Code systems");
    cm.setPurpose("To implementers map between medical device codes and LOINC codes");
    cm.setCopyright("This content LOINC \u00ae is copyright \u00a9 1995 Regenstrief Institute, Inc. and the LOINC Committee, and available at no cost under the license at http://loinc.org/terms-of-use");
    cm.setSource(new UriType("http://loinc.org/vs"));
    cm.setTarget(new UriType(MDC_ALL_VALUES));
    ConceptMapGroupComponent g = cm.addGroup();
    g.setSource("urn:iso:std:iso:11073:10101");
    g.setTarget("http://loinc.org");
    CSVReader csv = new CSVReader(new FileInputStream(src));
    csv.readHeaders();
    while (csv.line()) {
        SourceElementComponent e = g.addElement();
        e.setCode(csv.cell("IEEE_CF_CODE10"));
        e.setDisplay(csv.cell("IEEE_DESCRIPTION"));
        TargetElementComponent t = e.addTarget();
        t.setEquivalence(ConceptMapEquivalence.EQUIVALENT);
        t.setCode(csv.cell("LOINC_NUM"));
        t.setDisplay(csv.cell("LOINC_LONG_COMMON_NAME"));
    }
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "conceptmap-" + cm.getId() + ".xml")), cm);
    System.out.println("Done");
    return cm;
}
Also used : XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) CSVReader(org.hl7.fhir.utilities.CSVReader) FileOutputStream(java.io.FileOutputStream) TargetElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent) ConceptMapGroupComponent(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent) FileInputStream(java.io.FileInputStream) SourceElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent)

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