Search in sources :

Example 11 with ElementDefinition

use of org.hl7.fhir.r4b.model.ElementDefinition 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 12 with ElementDefinition

use of org.hl7.fhir.r4b.model.ElementDefinition in project kindling by HL7.

the class CDAGenerator method generateSnapShot.

private void generateSnapShot(StructureDefinition dst, StructureDefinition src, String typeName) {
    if (dst.hasSnapshot() && dst.getSnapshot().getElement().size() > 1)
        return;
    if (src.hasBaseDefinition()) {
        StructureDefinition dt = getDataType(src.getBaseDefinition());
        if (dt != null)
            generateSnapShot(dst, dt, typeName);
    }
    for (ElementDefinition ed : src.getDifferential().getElement()) {
        String path = ed.getPath();
        if (path.contains(".")) {
            path = typeName + path.substring(path.indexOf("."));
            seePath(path);
            boolean found = false;
            for (ElementDefinition de : dst.getSnapshot().getElement()) {
                if (de.getPath().equals(path))
                    found = true;
            }
            if (!found) {
                ElementDefinition ned = ed.copy();
                ned.setPath(path);
                ned.getBase().setPath(ed.getPath()).setMin(ned.getMin()).setMax(ned.getMax());
                dst.getSnapshot().getElement().add(ned);
            }
        }
    }
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition)

Example 13 with ElementDefinition

use of org.hl7.fhir.r4b.model.ElementDefinition 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 14 with ElementDefinition

use of org.hl7.fhir.r4b.model.ElementDefinition 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 15 with ElementDefinition

use of org.hl7.fhir.r4b.model.ElementDefinition in project kindling by HL7.

the class CDAGenerator method addInfrastructureRootAttributes.

private void addInfrastructureRootAttributes(List<ElementDefinition> list, String path) {
    StructureDefinition any = getDataType("http://hl7.org/fhir/cda/StructureDefinition/ANY");
    addAbstractClassAttributes(list, path, any);
    StructureDefinition ir = getDataType("http://hl7.org/fhir/cda/StructureDefinition/InfrastructureRoot");
    addAbstractClassAttributes(list, path, ir);
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition)

Aggregations

ArrayList (java.util.ArrayList)226 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)199 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)120 FHIRException (org.hl7.fhir.exceptions.FHIRException)116 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)92 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)91 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)85 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)82 ElementDefinition (org.hl7.fhir.r4.model.ElementDefinition)68 TypeRefComponent (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent)60 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)57 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)51 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)50 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)46 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)44 ElementDefinition (org.hl7.fhir.dstu2016may.model.ElementDefinition)42 ElementDefinition (org.hl7.fhir.dstu2.model.ElementDefinition)41 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)41 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)38 List (java.util.List)37