Search in sources :

Example 1 with DataElement

use of org.hl7.fhir.dstu3.model.DataElement in project FAAAST-Service by FraunhoferIOSB.

the class AasServiceNodeManager method doRemoveFromMaps.

/**
 * Removes the given SubmodelElement from the maps.
 *
 * @param element The desired SubmodelElement
 * @param reference The reference to the desired SubmodelElement
 * @param referable The corresponding referable
 */
private void doRemoveFromMaps(AASSubmodelElementType element, Reference reference, Referable referable) {
    try {
        logger.debug("doRemoveFromMaps: remove SubmodelElement " + AasUtils.asString(reference));
        if (submodelElementOpcUAMap.containsKey(reference)) {
            submodelElementOpcUAMap.remove(reference);
            logger.debug("doRemoveFromMaps: remove SubmodelElement from submodelElementOpcUAMap: " + AasUtils.asString(reference));
        }
        if (element instanceof AASPropertyType) {
            AASPropertyType prop = (AASPropertyType) element;
            if (submodelElementAasMap.containsKey(prop.getValueNode().getNodeId())) {
                submodelElementAasMap.remove(prop.getValueNode().getNodeId());
                logger.debug("doRemoveFromMaps: remove Property NodeId " + prop.getValueNode().getNodeId());
            }
        } else if (element instanceof AASRangeType) {
            AASRangeType range = (AASRangeType) element;
            if (submodelElementAasMap.containsKey(range.getMinNode().getNodeId())) {
                submodelElementAasMap.remove(range.getMinNode().getNodeId());
                logger.debug("doRemoveFromMaps: remove Range Min NodeId " + range.getMinNode().getNodeId());
            }
            if (submodelElementAasMap.containsKey(range.getMaxNode().getNodeId())) {
                submodelElementAasMap.remove(range.getMaxNode().getNodeId());
                logger.debug("doRemoveFromMaps: remove Range Max NodeId " + range.getMaxNode().getNodeId());
            }
        } else if (element instanceof AASOperationType) {
            AASOperationType oper = (AASOperationType) element;
            if (submodelElementAasMap.containsKey(oper.getOperationNode().getNodeId())) {
                submodelElementAasMap.remove(oper.getOperationNode().getNodeId());
                logger.debug("doRemoveFromMaps: remove Operation NodeId " + oper.getOperationNode().getNodeId());
            }
        } else if (element instanceof AASBlobType) {
            AASBlobType blob = (AASBlobType) element;
            if (submodelElementAasMap.containsKey(blob.getValueNode().getNodeId())) {
                submodelElementAasMap.remove(blob.getValueNode().getNodeId());
                logger.debug("doRemoveFromMaps: remove Blob NodeId " + blob.getValueNode().getNodeId());
            }
        } else if (element instanceof AASMultiLanguagePropertyType) {
            AASMultiLanguagePropertyType mlp = (AASMultiLanguagePropertyType) element;
            if (submodelElementAasMap.containsKey(mlp.getValueNode().getNodeId())) {
                submodelElementAasMap.remove(mlp.getValueNode().getNodeId());
                logger.debug("doRemoveFromMaps: remove AASMultiLanguageProperty NodeId " + mlp.getValueNode().getNodeId());
            }
        } else if (element instanceof AASReferenceElementType) {
            AASReferenceElementType refElem = (AASReferenceElementType) element;
            NodeId nid = refElem.getValueNode().getKeysNode().getNodeId();
            if (submodelElementAasMap.containsKey(nid)) {
                submodelElementAasMap.remove(nid);
                logger.debug("doRemoveFromMaps: remove AASReferenceElement NodeId " + nid);
            }
        } else if (element instanceof AASRelationshipElementType) {
            AASRelationshipElementType relElem = (AASRelationshipElementType) element;
            NodeId nid = relElem.getFirstNode().getKeysNode().getNodeId();
            if (submodelElementAasMap.containsKey(nid)) {
                submodelElementAasMap.remove(nid);
                logger.debug("doRemoveFromMaps: remove AASRelationshipElement First NodeId " + nid);
            }
            nid = relElem.getSecondNode().getKeysNode().getNodeId();
            if (submodelElementAasMap.containsKey(nid)) {
                submodelElementAasMap.remove(nid);
                logger.debug("doRemoveFromMaps: remove AASRelationshipElement Second NodeId " + nid);
            }
            if (relElem instanceof AASAnnotatedRelationshipElementType) {
                if (referable instanceof AnnotatedRelationshipElement) {
                    AnnotatedRelationshipElement annRelElem = (AnnotatedRelationshipElement) referable;
                    for (DataElement de : annRelElem.getAnnotations()) {
                        doRemoveFromMaps(reference, de);
                    }
                }
            }
        } else if (element instanceof AASEntityType) {
            AASEntityType ent = (AASEntityType) element;
            if ((ent.getGlobalAssetIdNode() != null) && (ent.getGlobalAssetIdNode().getKeysNode() != null)) {
                NodeId nid = ent.getGlobalAssetIdNode().getKeysNode().getNodeId();
                if (submodelElementAasMap.containsKey(nid)) {
                    submodelElementAasMap.remove(nid);
                    logger.debug("doRemoveFromMaps: remove Entity GlobalAssetId NodeId " + nid);
                }
            }
            if (submodelElementAasMap.containsKey(ent.getEntityTypeNode().getNodeId())) {
                submodelElementAasMap.remove(ent.getEntityTypeNode().getNodeId());
                logger.debug("doRemoveFromMaps: remove Entity EntityType NodeId " + ent.getEntityTypeNode().getNodeId());
            }
        } else if (referable instanceof SubmodelElementCollection) {
            SubmodelElementCollection sec = (SubmodelElementCollection) referable;
            for (SubmodelElement se : sec.getValues()) {
                doRemoveFromMaps(reference, se);
            }
        }
    // Capability and File are currently not relevant here
    } catch (Throwable ex) {
        logger.error("doRemoveFromMaps Exception", ex);
        throw ex;
    }
}
Also used : AASEntityType(opc.i4aas.AASEntityType) AASRangeType(opc.i4aas.AASRangeType) AASBlobType(opc.i4aas.AASBlobType) AASPropertyType(opc.i4aas.AASPropertyType) SubmodelElementCollection(io.adminshell.aas.v3.model.SubmodelElementCollection) AASOperationType(opc.i4aas.AASOperationType) AnnotatedRelationshipElement(io.adminshell.aas.v3.model.AnnotatedRelationshipElement) AASRelationshipElementType(opc.i4aas.AASRelationshipElementType) DataElement(io.adminshell.aas.v3.model.DataElement) AASMultiLanguagePropertyType(opc.i4aas.AASMultiLanguagePropertyType) SubmodelElement(io.adminshell.aas.v3.model.SubmodelElement) AASAnnotatedRelationshipElementType(opc.i4aas.AASAnnotatedRelationshipElementType) NodeId(com.prosysopc.ua.stack.builtintypes.NodeId) AASReferenceElementType(opc.i4aas.AASReferenceElementType)

Example 2 with DataElement

use of org.hl7.fhir.dstu3.model.DataElement in project org.hl7.fhir.core by hapifhir.

the class LoincToDEConvertor method processLoincCodes.

private void processLoincCodes() {
    Element row = XMLUtil.getFirstChild(xml.getDocumentElement());
    int i = 0;
    while (row != null) {
        i++;
        if (i % 1000 == 0)
            System.out.print(".");
        String code = col(row, "LOINC_NUM");
        String comp = col(row, "COMPONENT");
        DataElement de = new DataElement();
        de.setId("loinc-" + code);
        de.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));
        bundle.getEntry().add(new BundleEntryComponent().setResource(de));
        Identifier id = new Identifier();
        id.setSystem("http://hl7.org/fhir/commondataelement/loinc");
        id.setValue(code);
        de.addIdentifier(id);
        de.setPublisher("Regenstrief + FHIR Project Team");
        if (!col(row, "STATUS").equals("ACTIVE"))
            // till we get good at this
            de.setStatus(ConformanceResourceStatus.DRAFT);
        else
            de.setStatus(ConformanceResourceStatus.RETIRED);
        de.setDateElement(DateTimeType.now());
        de.setName(comp);
        ElementDefinition dee = de.addElement();
        // PROPERTY	ignore
        // TIME_ASPCT
        // SYSTEM
        // SCALE_TYP
        // METHOD_TYP
        // dee.getCategory().add(new CodeableConcept().setText(col(row, "CLASS")));
        // SOURCE
        // DATE_LAST_CHANGED - should be in ?
        // CHNG_TYPE
        dee.setComments(col(row, "COMMENTS"));
        if (hasCol(row, "CONSUMER_NAME"))
            dee.addAlias(col(row, "CONSUMER_NAME"));
        // SURVEY_QUEST_SRC
        if (hasCol(row, "RELATEDNAMES2")) {
            String n = col(row, "RELATEDNAMES2");
            for (String s : n.split("\\;")) {
                if (!Utilities.noString(s))
                    dee.addAlias(s);
            }
        }
        dee.addAlias(col(row, "SHORTNAME"));
        // ORDER_OBS
        // CDISC Code
        // HL7_FIELD_SUBFIELD_ID
        // ------------------ EXTERNAL_COPYRIGHT_NOTICE todo
        dee.setDefinition(col(row, "LONG_COMMON_NAME"));
        // HL7_V2_DATATYPE
        String cc = makeType(col(row, "HL7_V3_DATATYPE"), code);
        if (cc != null)
            dee.addType().setCode(cc);
        // todo... CURATED_RANGE_AND_UNITS
        // todo: DOCUMENT_SECTION
        // STATUS_REASON
        // STATUS_TEXT
        // CHANGE_REASON_PUBLIC
        // COMMON_TEST_RANK
        // COMMON_ORDER_RANK
        // COMMON_SI_TEST_RANK
        // HL7_ATTACHMENT_STRUCTURE
        // units:
        // UNITSREQUIRED
        // SUBMITTED_UNITS
        ToolingExtensions.setAllowableUnits(dee, makeUnits(col(row, "EXAMPLE_UNITS"), col(row, "EXAMPLE_UCUM_UNITS")));
        // EXAMPLE_SI_UCUM_UNITS
        row = XMLUtil.getNextSibling(row);
    }
    System.out.println("done");
}
Also used : DataElement(org.hl7.fhir.dstu2.model.DataElement) Meta(org.hl7.fhir.dstu2.model.Meta) BundleEntryComponent(org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.dstu2.model.Identifier) Element(org.w3c.dom.Element) DataElement(org.hl7.fhir.dstu2.model.DataElement) ElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition)

Example 3 with DataElement

use of org.hl7.fhir.dstu3.model.DataElement in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeDataElement.

protected void composeDataElement(Complex parent, String parentType, String name, DataElement element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "DataElement", name, element, index);
    if (element.hasUrlElement())
        composeUri(t, "DataElement", "url", element.getUrlElement(), -1);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "DataElement", "identifier", element.getIdentifier().get(i), i);
    if (element.hasVersionElement())
        composeString(t, "DataElement", "version", element.getVersionElement(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "DataElement", "status", element.getStatusElement(), -1);
    if (element.hasExperimentalElement())
        composeBoolean(t, "DataElement", "experimental", element.getExperimentalElement(), -1);
    if (element.hasDateElement())
        composeDateTime(t, "DataElement", "date", element.getDateElement(), -1);
    if (element.hasPublisherElement())
        composeString(t, "DataElement", "publisher", element.getPublisherElement(), -1);
    if (element.hasNameElement())
        composeString(t, "DataElement", "name", element.getNameElement(), -1);
    if (element.hasTitleElement())
        composeString(t, "DataElement", "title", element.getTitleElement(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeContactDetail(t, "DataElement", "contact", element.getContact().get(i), i);
    for (int i = 0; i < element.getUseContext().size(); i++) composeUsageContext(t, "DataElement", "useContext", element.getUseContext().get(i), i);
    for (int i = 0; i < element.getJurisdiction().size(); i++) composeCodeableConcept(t, "DataElement", "jurisdiction", element.getJurisdiction().get(i), i);
    if (element.hasCopyrightElement())
        composeMarkdown(t, "DataElement", "copyright", element.getCopyrightElement(), -1);
    if (element.hasStringencyElement())
        composeEnum(t, "DataElement", "stringency", element.getStringencyElement(), -1);
    for (int i = 0; i < element.getMapping().size(); i++) composeDataElementDataElementMappingComponent(t, "DataElement", "mapping", element.getMapping().get(i), i);
    for (int i = 0; i < element.getElement().size(); i++) composeElementDefinition(t, "DataElement", "element", element.getElement().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 4 with DataElement

use of org.hl7.fhir.dstu3.model.DataElement in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeDataElementDataElementMappingComponent.

protected void composeDataElementDataElementMappingComponent(Complex parent, String parentType, String name, DataElement.DataElementMappingComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "mapping", name, element, index);
    if (element.hasIdentityElement())
        composeId(t, "DataElement", "identity", element.getIdentityElement(), -1);
    if (element.hasUriElement())
        composeUri(t, "DataElement", "uri", element.getUriElement(), -1);
    if (element.hasNameElement())
        composeString(t, "DataElement", "name", element.getNameElement(), -1);
    if (element.hasCommentElement())
        composeString(t, "DataElement", "comment", element.getCommentElement(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 5 with DataElement

use of org.hl7.fhir.dstu3.model.DataElement in project org.hl7.fhir.core by hapifhir.

the class ResourceUtilities method representDataElementCollection.

public static String representDataElementCollection(IWorkerContext context, Bundle bundle, boolean profileLink, String linkBase) {
    StringBuilder b = new StringBuilder();
    DataElement common = showDECHeader(b, bundle);
    b.append("<table class=\"grid\">\r\n");
    List<String> cols = chooseColumns(bundle, common, b, profileLink);
    for (BundleEntryComponent e : bundle.getEntry()) {
        DataElement de = (DataElement) e.getResource();
        renderDE(de, cols, b, profileLink, linkBase);
    }
    b.append("</table>\r\n");
    return b.toString();
}
Also used : DataElement(org.hl7.fhir.dstu2.model.DataElement) BundleEntryComponent(org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Aggregations

BundleEntryComponent (org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent)3 DataElement (org.hl7.fhir.dstu2.model.DataElement)3 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)3 BundleEntryComponent (org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent)3 DataElement (org.hl7.fhir.dstu2016may.model.DataElement)3 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)3 DataElement (org.hl7.fhir.dstu3.model.DataElement)3 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)3 Element (org.w3c.dom.Element)3 DataElement (io.adminshell.aas.v3.model.DataElement)2 FileOutputStream (java.io.FileOutputStream)2 AASAnnotatedRelationshipElementType (opc.i4aas.AASAnnotatedRelationshipElementType)2 AASRelationshipElementType (opc.i4aas.AASRelationshipElementType)2 ElementDefinition (org.hl7.fhir.dstu2.model.ElementDefinition)2 ElementDefinition (org.hl7.fhir.dstu2016may.model.ElementDefinition)2 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)2 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)2 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)2 Test (org.junit.jupiter.api.Test)2 NodeId (com.prosysopc.ua.stack.builtintypes.NodeId)1