Search in sources :

Example 1 with CD

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

the class Publisher method loadValueSets1.

private void loadValueSets1() throws Exception {
    page.log(" ...vocab #1", LogMessageType.Process);
    generateCodeSystemsPart1();
    generateValueSetsPart1();
    for (BindingSpecification cd : page.getDefinitions().getUnresolvedBindings()) {
        String ref = cd.getReference();
        if (ref.startsWith("http://hl7.org/fhir")) {
            // we expect to be able to resolve this
            ValueSet vs = page.getDefinitions().getValuesets().get(ref);
            if (vs == null)
                vs = page.getDefinitions().getExtraValuesets().get(ref);
            if (vs == null)
                vs = page.getWorkerContext().fetchResource(ValueSet.class, ref);
            if (vs == null) {
                if (page.getDefinitions().getBoundValueSets().containsKey(ref))
                    throw new Exception("Unable to resolve the value set reference " + ref + " but found it in load list");
                throw new Exception("Unable to resolve the value set reference " + ref);
            }
            cd.setValueSet(vs);
        } else {
            ValueSet vs = page.getWorkerContext().fetchResource(ValueSet.class, ref);
            if (vs != null)
                cd.setValueSet(vs);
            else if (!ref.startsWith("http://loinc.org/vs/LL"))
                System.out.println("Unresolved value set reference: " + ref);
        }
    }
    for (ImplementationGuideDefn ig : page.getDefinitions().getSortedIgs()) {
        for (BindingSpecification cd : ig.getUnresolvedBindings()) {
            String ref = cd.getReference();
            if (ref.contains("|"))
                ref = ref.substring(0, ref.indexOf("|"));
            ValueSet vs = page.getDefinitions().getValuesets().get(ref);
            if (vs == null)
                vs = ig.getValueSet(ref);
            if (vs == null)
                vs = page.getWorkerContext().fetchResource(ValueSet.class, ref);
            if (vs == null)
                throw new Exception("unable to resolve value set " + ref);
            cd.setValueSet(vs);
        }
    }
}
Also used : BindingSpecification(org.hl7.fhir.definitions.model.BindingSpecification) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) ValueSet(org.hl7.fhir.r5.model.ValueSet) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with CD

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

the class PageProcessor method findTranslations.

private void findTranslations(Set<String> res, List<ConceptDefinitionComponent> list) {
    for (ConceptDefinitionComponent cc : list) {
        for (ConceptDefinitionDesignationComponent cd : cc.getDesignation()) {
            if (cd.hasLanguage())
                res.add(cd.getLanguage());
        }
        Extension ex = cc.getExtensionByUrl(ToolingExtensions.EXT_CS_COMMENT);
        if (ex != null) {
            for (String l : ToolingExtensions.getLanguageTranslations(ex).keySet()) res.add(l);
        }
        findTranslations(res, cc.getConcept());
    }
}
Also used : Extension(org.hl7.fhir.r5.model.Extension) ConceptDefinitionComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent) ConceptDefinitionDesignationComponent(org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent)

Example 3 with CD

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

the class PageProcessor method genCodeSystemsTable.

private String genCodeSystemsTable() throws Exception {
    StringBuilder s = new StringBuilder();
    s.append("<table class=\"codes\">\r\n");
    List<String> names = new ArrayList<String>();
    names.addAll(definitions.getCodeSystems().keys());
    // for (String n : definitions.getBindings().keySet()) {
    // if ((definitions.getBindingByName(n).getBinding() == Binding.CodeList && !definitions.getBindingByName(n).getVSSources().contains("")) ||
    // (definitions.getBindingByName(n).getBinding() == Binding.Special))
    // names.add(definitions.getBindingByName(n).getReference().substring(1));
    // }
    // 
    // //  not this one      Logical Interactions (RESTful framework)  http://hl7.org/fhir/rest-operations 2.16.840.1.113883.6.308
    // s.append(" <tr><td><a href=\""+cd.getReference().substring(1)+".html\">http://hl7.org/fhir/"+cd.getReference().substring(1)+"</a></td><td>"+Utilities.escapeXml(cd.getDefinition())+"</td></tr>\r\n");
    // 
    Collections.sort(names);
    for (String n : names) {
        if (n.startsWith("http://hl7.org") && !n.startsWith("http://terminology.hl7.org/CodeSystem/v2") && !n.startsWith("http://terminology.hl7.org/CodeSystem/v3")) {
            // BindingSpecification cd = definitions.getBindingByReference("#"+n);
            CodeSystem ae = definitions.getCodeSystems().get(n);
            if (ae == null)
                s.append(" <tr><td><a href=\"" + "??" + ".html\">").append(n).append("</a></td><td>").append("??").append("</td></tr>\r\n");
            else {
                s.append(" <tr><td><a href=\"").append(ae.getUserData("path")).append("\">").append(n).append("</a></td><td>").append(ae.getDescription()).append("</td></tr>\r\n");
            }
        }
    }
    s.append("</table>\r\n");
    return s.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ArrayList(java.util.ArrayList) CodeSystem(org.hl7.fhir.r5.model.CodeSystem)

Example 4 with CD

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

the class CDAGenerator method addCDExtensions.

private void addCDExtensions(List<ElementDefinition> list, String n) {
    ElementDefinition ed = new ElementDefinition();
    ed.setPath(n + ".valueSet");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("1");
    ed.addType().setCode("string");
    ed.addRepresentation(PropertyRepresentation.XMLATTR);
    ed.setDefinition("The valueSet extension adds an attribute for elements with a CD dataType which indicates the particular value set constraining the coded concept");
    ed.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace").setValue(new UriType("urn:hl7-org:sdtc"));
    ed = new ElementDefinition();
    ed.setPath(n + ".valueSetVersion");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("1");
    ed.addType().setCode("string");
    ed.addRepresentation(PropertyRepresentation.XMLATTR);
    ed.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace").setValue(new UriType("urn:hl7-org:sdtc"));
    ed.setDefinition("The valueSetVersion extension adds an attribute for elements with a CD dataType which indicates the version of the particular value set constraining the coded concept.");
    list.add(ed);
}
Also used : ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) UriType(org.hl7.fhir.r5.model.UriType)

Example 5 with CD

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

the class CDAGenerator method processDataType.

private void processDataType(Element dt, String n, String p) throws FileNotFoundException, IOException, FHIRFormatError, DefinitionException {
    if (!Utilities.existsInList(n, "TYPE", "BN", "BIN", "CO", "UID", "OID", "UUID", "RUID", "URL", "ADXP", "ENXP", "PN", "TN", "ON", "RTO", "CAL", "CLCY", "SET", "LIST", "GLIST", "SLIST", "BAG", "HXIT", "HIST", "UVP", "NPPD", "PPD")) {
        if (n.equals("GTS"))
            n = "SXCM_TS";
        System.out.print(" " + n);
        StructureDefinition sd = new StructureDefinition();
        sd.setId(fix(n));
        sd.setUrl("http://hl7.org/fhir/cda/StructureDefinition/" + fix(n));
        library.put(sd.getUrl(), sd);
        sd.setName("V3 Data type " + n + " (" + dt.getAttribute("title") + ")");
        sd.setTitle(sd.getName());
        sd.setStatus(PublicationStatus.ACTIVE);
        sd.setExperimental(false);
        sd.setPublisher("HL7");
        sd.setDescription(getDefinition(dt));
        sd.setType(sd.getUrl());
        sd.setKind(StructureDefinitionKind.LOGICAL);
        sd.setAbstract("true".equals(dt.getAttribute("isAbstract")));
        sd.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace").setValue(new UriType("urn:hl7-org:v3"));
        Element derived = XMLUtil.getNamedChild(dt, "mif:derivedFrom");
        if (Utilities.existsInList(n, "ST", "ED", "TEL", "AD", "EN", "IVL_PQ", "IVL_INT", "TS")) {
            sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/ANY");
        } else if (Utilities.existsInList(n, "SXCM_TS")) {
            sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/TS");
        } else if (n.equals("PIVL_TS") || n.equals("EIVL_TS") || n.equals("IVL_TS")) {
            sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/SXCM_TS");
        } else if (derived != null) {
            sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/" + XMLUtil.getNamedChildAttribute(derived, "mif:targetDatatype", "name"));
        } else
            sd.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Element");
        sd.setDerivation(TypeDerivationRule.SPECIALIZATION);
        ElementDefinition edb = new ElementDefinition();
        edb.setPath(sd.getId());
        seePath(edb);
        edb.setMin(1);
        edb.setMax("*");
        edb.addType().setCode("Element");
        sd.getDifferential().getElement().add(edb);
        if (n.equals("ED"))
            addEDElements(sd.getDifferential().getElement());
        if (n.equals("SC"))
            copyAttributes(sd, getDefinition("CV"), "code", "codeSystem", "codeSystemVersion", "displayName");
        if (primitiveTypes.containsKey(n))
            addValueAttribute(sd.getDifferential().getElement(), n, primitiveTypes.get(n));
        if (n.equals("TS"))
            edb.addExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-timeformat", new CodeType("YYYYMMDDHHMMSS.UUUU[+|-ZZzz]"));
        if (n.equals("TEL"))
            addValueAttribute(sd.getDifferential().getElement(), n, "uri");
        if (n.equals("SXCM_TS")) {
            addOperatorAttribute(sd.getDifferential().getElement(), "SXCM_TS");
            sd.setAbstract(true);
        }
        if (n.equals("AD")) {
            addParts(sd.getDifferential().getElement(), n, "delimiter", "country", "state", "county", "city", "postalCode", "streetAddressLine", "houseNumber", "houseNumberNumeric", "direction", "streetName", "streetNameBase", "streetNameType", "additionalLocator", "unitID", "unitType", "careOf", "censusTract", "deliveryAddressLine", "deliveryInstallationType", "deliveryInstallationArea", "deliveryInstallationQualifier", "deliveryMode", "deliveryModeIdentifier", "buildingNumberSuffix", "postBox", "precinct");
            addTextItem(sd.getDifferential().getElement(), n);
        }
        if (n.equals("EN")) {
            addParts(sd.getDifferential().getElement(), n, "delimiter", "family", "given", "prefix", "suffix");
            addTextItem(sd.getDifferential().getElement(), n);
        }
        List<Element> props = new ArrayList<Element>();
        XMLUtil.getNamedChildren(dt, "mif:property", props);
        for (Element prop : props) {
            processProperty(sd.getDifferential().getElement(), n, prop, p);
        }
        if (n.equals("TS") || n.equals("PQ"))
            addInclusiveAttribute(sd.getDifferential().getElement(), n);
        if (n.equals("CE") || n.equals("CV") || n.equals("CD"))
            addCDExtensions(sd.getDifferential().getElement(), n);
        new ProfileUtilities(null, null, null).setIds(sd, true);
        structures.add(sd);
    }
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) CodeType(org.hl7.fhir.r5.model.CodeType) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) UriType(org.hl7.fhir.r5.model.UriType)

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