Search in sources :

Example 16 with RMObject

use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.

the class AutoWhereIT method testContextAutoWhere.

@Test
public void testContextAutoWhere() throws IOException {
    String rootPath = "c/context";
    RMObject referenceNode = aComposition.getContext();
    String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]";
    String csvTestSet = dirPath + "/testContextAttributesWhere.csv";
    assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)).isTrue();
}
Also used : RMObject(com.nedap.archie.rm.RMObject) Test(org.junit.Test)

Example 17 with RMObject

use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.

the class AutoWhereIT method testInstructionAutoWhere.

@Test
public void testInstructionAutoWhere() throws IOException {
    String rootPath = "i";
    RMObject referenceNode = (RMObject) aComposition.itemsAtPath("/content[openEHR-EHR-SECTION.test_all_types.v1]/items[at0001]/items[at0002]/items[openEHR-EHR-INSTRUCTION.test_all_types.v1]").get(0);
    String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" + " contains section s[openEHR-EHR-SECTION.test_all_types.v1]" + " contains instruction i[openEHR-EHR-INSTRUCTION.test_all_types.v1]";
    String csvTestSet = dirPath + "/testInstructionWhere.csv";
    assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)).isTrue();
}
Also used : RMObject(com.nedap.archie.rm.RMObject) Test(org.junit.Test)

Example 18 with RMObject

use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.

the class CanonicalEhrQuery1IT method testEhrAttributesDrillDown3.

@Test
public void testEhrAttributesDrillDown3() {
    String rootPath = "e/ehr_status";
    RMObject referenceNode = referenceEhrStatus;
    String[] attributePaths = { "archetype_node_id", "archetype_details", "archetype_details/archetype_id", "archetype_details/archetype_id/value", "archetype_details/template_id", "archetype_details/template_id/value", "archetype_details/rm_version", "subject", "is_queryable", "is_modifiable" };
    for (String attributePath : attributePaths) {
        String aqlSelect = rootPath + "/" + attributePath;
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("select ");
        stringBuilder.append(aqlSelect);
        stringBuilder.append(" from EHR e[ehr_id/value = $ehr_id]");
        Query<Record1<Map>> query = Query.buildNativeQuery(stringBuilder.toString(), Map.class);
        QueryResponseData result = openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehrUUID));
        List<Object> objectList = result.getRows().get(0);
        assertThat(valueObject(objectList.get(0))).as(aqlSelect).isEqualTo(attributeValueAt(referenceNode, attributePath));
    }
}
Also used : ParameterValue(org.ehrbase.client.aql.parameter.ParameterValue) QueryResponseData(org.ehrbase.response.openehr.QueryResponseData) RMObject(com.nedap.archie.rm.RMObject) RMObject(com.nedap.archie.rm.RMObject) Record1(org.ehrbase.client.aql.record.Record1)

Example 19 with RMObject

use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.

the class CanonicalXML method marshal.

public String marshal(RMObject rmObject, Boolean withHeader) {
    StringWriter stringWriter = new StringWriter();
    try {
        Marshaller marshaller = JAXBUtil.getArchieJAXBContext().createMarshaller();
        marshaller.setProperty("jaxb.fragment", !withHeader);
        if (rmObject.getClass().getAnnotation(XmlRootElement.class) == null) {
            QName qName = new QName(null, new SnakeCase(rmObject.getClass().getSimpleName()).camelToSnake());
            JAXBElement<RMObject> root = new JAXBElement<>(qName, RMObject.class, rmObject);
            marshaller.marshal(root, stringWriter);
        } else {
            marshaller.marshal(rmObject, stringWriter);
        }
    } catch (JAXBException e) {
        throw new org.ehrbase.serialisation.exception.MarshalException(e.getMessage(), e);
    }
    return stringWriter.toString();
}
Also used : XmlRootElement(javax.xml.bind.annotation.XmlRootElement) SnakeCase(org.ehrbase.serialisation.util.SnakeCase) StringWriter(java.io.StringWriter) QName(javax.xml.namespace.QName) RMObject(com.nedap.archie.rm.RMObject)

Example 20 with RMObject

use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.

the class ToCompositionWalker method postHandle.

@Override
protected void postHandle(Context<T> context) {
    RMObject currentRM = context.getRmObjectDeque().peek();
    WebTemplateNode currentNode = context.getNodeDeque().peek();
    if (currentRM instanceof Locatable) {
        org.ehrbase.webtemplate.parser.NodeId nodeId = new NodeId(currentNode.getNodeId());
        if (nodeId.isArchetypeId()) {
            Archetyped archetyped = new Archetyped();
            archetyped.setArchetypeId(new ArchetypeID(nodeId.getNodeId()));
            archetyped.setRmVersion(RM_VERSION_1_4_0);
            TemplateId templateId = new TemplateId();
            templateId.setValue(context.getTemplateId());
            archetyped.setTemplateId(templateId);
            ((Locatable) currentRM).setArchetypeDetails(archetyped);
            ((Locatable) currentRM).setArchetypeNodeId(nodeId.getNodeId());
        }
    }
    normalise(currentRM);
}
Also used : NodeId(org.ehrbase.webtemplate.parser.NodeId) WebTemplateNode(org.ehrbase.webtemplate.model.WebTemplateNode) NodeId(org.ehrbase.webtemplate.parser.NodeId) Archetyped(com.nedap.archie.rm.archetyped.Archetyped) TemplateId(com.nedap.archie.rm.archetyped.TemplateId) RMObject(com.nedap.archie.rm.RMObject) Locatable(com.nedap.archie.rm.archetyped.Locatable) ArchetypeID(com.nedap.archie.rm.support.identification.ArchetypeID)

Aggregations

RMObject (com.nedap.archie.rm.RMObject)57 Test (org.junit.Test)19 Composition (com.nedap.archie.rm.composition.Composition)10 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)9 QueryResponseData (org.ehrbase.response.openehr.QueryResponseData)8 Locatable (com.nedap.archie.rm.archetyped.Locatable)7 List (java.util.List)7 WebTemplateNode (org.ehrbase.webtemplate.model.WebTemplateNode)6 Collectors (java.util.stream.Collectors)5 TemplateId (com.nedap.archie.rm.archetyped.TemplateId)4 IOException (java.io.IOException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Map (java.util.Map)4 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)4 TestDataTemplateProvider (org.ehrbase.client.templateprovider.TestDataTemplateProvider)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Archetyped (com.nedap.archie.rm.archetyped.Archetyped)3 Version (com.nedap.archie.rm.changecontrol.Version)3 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)3