Search in sources :

Example 1 with TS

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

the class CDAGenerator method addValueAttribute.

private void addValueAttribute(List<ElementDefinition> list, String dtn, String t) {
    ElementDefinition ed = new ElementDefinition();
    ed.setPath(dtn + ".value");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("1");
    ed.addType().setCode(t);
    if (dtn.equals("ST"))
        ed.addRepresentation(PropertyRepresentation.XMLTEXT);
    else
        ed.addRepresentation(PropertyRepresentation.XMLATTR);
    if (dtn.equals("TS"))
        ed.addExtension().setUrl("http://www.healthintersections.com.au/fhir/StructureDefinition/elementdefinition-dateformat").setValue(new StringType("v3"));
    list.add(ed);
}
Also used : StringType(org.hl7.fhir.r5.model.StringType) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition)

Example 2 with TS

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

Example 3 with TS

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

the class CDAGenerator method processDataTypes.

private void processDataTypes(String filename) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException, FHIRFormatError, DefinitionException {
    System.out.println("Process Data Types");
    Document dtMif = XMLUtil.parseFileToDom(filename);
    List<Element> dts = new ArrayList<Element>();
    XMLUtil.getNamedChildren(dtMif.getDocumentElement(), "mif:datatype", dts);
    for (Element dt : dts) {
        String n = dt.getAttribute("name");
        types.put(n, dt);
        if (n.equals("IVL")) {
            processDataType(dt, n + "_TS", "TS");
            processDataType(dt, n + "_PQ", "PQ");
            processDataType(dt, n + "_INT", "INT");
        } else if (n.equals("PIVL")) {
            processDataType(dt, n + "_TS", null);
        } else if (n.equals("EIVL")) {
            processDataType(dt, n + "_TS", null);
        } else if (n.equals("RTO")) {
            processDataType(dt, n + "_PQ_PQ", "PQ");
        } else if (!"Binding".equals(dt.getAttribute("datatypeKind")))
            processDataType(dt, n, null);
    }
    buildSXPR();
    buildInfrastructureRoot();
    for (StructureDefinition sd : structures) {
        // if (!sd.getAbstract())
        generateSnapShot(sd);
    }
    System.out.println(" ... done");
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document)

Example 4 with TS

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

the class SourceParser method loadCompositeType.

private String loadCompositeType(String n, Map<String, org.hl7.fhir.definitions.model.TypeDefn> map, String fmm, boolean isAbstract) throws Exception {
    TypeParser tp = new TypeParser(version.toString());
    List<TypeRef> ts = tp.parse(n, false, null, context, true);
    definitions.getKnownTypes().addAll(ts);
    StandardsStatus status = loadStatus(n);
    String nv = loadNormativeVersion(n);
    try {
        TypeRef t = ts.get(0);
        File csv = new CSFile(dtDir + t.getName().toLowerCase() + ".xml");
        if (csv.exists()) {
            OldSpreadsheetParser p = new OldSpreadsheetParser("core", new CSFileInputStream(csv), csv.getName(), csv.getAbsolutePath(), definitions, srcDir, logger, registry, version, context, genDate, isAbstract, page, true, ini, wg("fhir"), definitions.getProfileIds(), fpUsages, page.getConceptMaps(), exceptionIfExcelNotNormalised, page.packageInfo(), page.getRc());
            org.hl7.fhir.definitions.model.TypeDefn el = p.parseCompositeType();
            el.setFmmLevel(fmm);
            el.setStandardsStatus(status);
            el.setNormativeVersion(nv);
            map.put(t.getName(), el);
            genTypeProfile(el);
            errors.addAll(p.getErrors());
            return el.getName();
        } else {
            String p = ini.getStringProperty("types", n);
            csv = new CSFile(dtDir + p.toLowerCase() + ".xml");
            if (!csv.exists())
                throw new Exception("unable to find a definition for " + n + " in " + p);
            XLSXmlParser xls = new XLSXmlParser(new CSFileInputStream(csv), csv.getAbsolutePath());
            new XLSXmlNormaliser(csv.getAbsolutePath(), exceptionIfExcelNotNormalised).go();
            Sheet sheet = xls.getSheets().get("Restrictions");
            boolean found = false;
            for (int i = 0; i < sheet.rows.size(); i++) {
                if (sheet.getColumn(i, "Name").equals(n)) {
                    found = true;
                    Invariant inv = new Invariant();
                    inv.setId(n);
                    inv.setEnglish(sheet.getColumn(i, "Rules"));
                    inv.setOcl(sheet.getColumn(i, "OCL"));
                    inv.setXpath(sheet.getColumn(i, "XPath"));
                    inv.setExpression(sheet.getColumn(i, "Expression"));
                    inv.setExplanation(sheet.getColumn(i, "Explanation"));
                    inv.setTurtle(sheet.getColumn(i, "RDF"));
                    ProfiledType pt = new ProfiledType();
                    pt.setDefinition(sheet.getColumn(i, "Definition"));
                    pt.setDescription(sheet.getColumn(i, "Rules"));
                    String structure = sheet.getColumn(i, "Structure");
                    if (!Utilities.noString(structure)) {
                        String[] parts = structure.split("\\;");
                        for (String pp : parts) {
                            String[] words = pp.split("\\=");
                            pt.getRules().put(words[0], words[1]);
                        }
                    }
                    pt.setName(n);
                    pt.setBaseType(p);
                    pt.setInvariant(inv);
                    definitions.getConstraints().put(n, pt);
                }
            }
            if (!found)
                throw new Exception("Unable to find definition for " + n);
            return n;
        }
    } catch (Exception e) {
        throw new Exception("Unable to load " + n + ": " + e.getMessage(), e);
    }
}
Also used : Invariant(org.hl7.fhir.definitions.model.Invariant) ProfiledType(org.hl7.fhir.definitions.model.ProfiledType) TypeRef(org.hl7.fhir.definitions.model.TypeRef) XLSXmlParser(org.hl7.fhir.utilities.xls.XLSXmlParser) XLSXmlNormaliser(org.hl7.fhir.utilities.xls.XLSXmlNormaliser) CSFile(org.hl7.fhir.utilities.CSFile) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) OldSpreadsheetParser(org.hl7.fhir.definitions.parsers.spreadsheets.OldSpreadsheetParser) TypeDefn(org.hl7.fhir.definitions.model.TypeDefn) StandardsStatus(org.hl7.fhir.utilities.StandardsStatus) IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile) Sheet(org.hl7.fhir.utilities.xls.XLSXmlParser.Sheet) CSFileInputStream(org.hl7.fhir.utilities.CSFileInputStream)

Example 5 with TS

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

the class ElementDefn method typeCodeBase.

public String typeCodeBase() {
    List<String> ts = new ArrayList<>();
    for (TypeRef t : types) {
        ts.add(t.getName());
    }
    Collections.sort(ts);
    CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
    for (String t : ts) b.append(t);
    return b.toString();
}
Also used : TypeRef(org.hl7.fhir.definitions.model.TypeRef) ArrayList(java.util.ArrayList) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Aggregations

ArrayList (java.util.ArrayList)15 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)9 CS (net.ihe.gazelle.hl7v3.datatypes.CS)8 II (net.ihe.gazelle.hl7v3.datatypes.II)8 TS (net.ihe.gazelle.hl7v3.datatypes.TS)8 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)8 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 BL (net.ihe.gazelle.hl7v3.datatypes.BL)7 CD (net.ihe.gazelle.hl7v3.datatypes.CD)7 CE (net.ihe.gazelle.hl7v3.datatypes.CE)7 INT (net.ihe.gazelle.hl7v3.datatypes.INT)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 FHIRException (org.hl7.fhir.exceptions.FHIRException)7 Identifier (org.hl7.fhir.r4.model.Identifier)7 Test (org.junit.jupiter.api.Test)7 COCTMT090003UV01AssignedEntity (net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01AssignedEntity)6 COCTMT090003UV01Organization (net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01Organization)6