Search in sources :

Example 51 with RMObject

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

the class SelectRMIT method testCompositionAttributeQuery.

@Test
public void testCompositionAttributeQuery() throws IOException {
    String rootPath = "c";
    RMObject referenceNode = aComposition;
    // reads in the test set
    BufferedReader inputCSVSetReader = new BufferedReader(new FileReader("src/test/resources/testsets/testCompositionAttributeQuery.csv"));
    String csvParams;
    CsvParser csvParser = new CsvParser(new CsvParserSettings());
    while ((csvParams = inputCSVSetReader.readLine()) != null) {
        String[] params = csvParser.parseLine(csvParams);
        String attributePath = params[0];
        if (params.length == 1) {
            // conventionally, if params[1] exists, this means skip the test
            QueryResponseData result = simpleSelectQueryEngine.performQuery(rootPath, attributePath, "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]");
            List<Object> objectList = result.getRows().get(0);
            // null value
            if (attributePath.contains("uid")) {
                assertThat(objectList.get(0)).isNotNull();
            } else
                assertThat(valueObject(objectList.get(0))).as(rootPath + "/" + attributePath).isEqualTo(attributeValueAt(referenceNode, attributePath));
        }
    }
}
Also used : CsvParserSettings(org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParserSettings) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) CsvParser(org.junit.jupiter.params.shadow.com.univocity.parsers.csv.CsvParser) QueryResponseData(org.ehrbase.response.openehr.QueryResponseData) RMObject(com.nedap.archie.rm.RMObject) RMObject(com.nedap.archie.rm.RMObject) Test(org.junit.Test)

Example 52 with RMObject

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

the class SelectRMIT method testSectionDrillDown.

@Test
public void testSectionDrillDown() throws IOException {
    String rootPath = "s";
    RMObject referenceNode = (RMObject) aComposition.itemsAtPath("/content[openEHR-EHR-SECTION.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]";
    String csvTestSet = dirPath + "/testSectionDrillDown.csv";
    assertThat(simpleSelectQueryEngine.testItemPaths(csvTestSet, rootPath, contains, referenceNode)).isTrue();
}
Also used : RMObject(com.nedap.archie.rm.RMObject) Test(org.junit.Test)

Example 53 with RMObject

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

the class SelectRMIT method testInstructionDrillDown.

@Test
public void testInstructionDrillDown() 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 + "/testInstructionDrillDown.csv";
    assertThat(simpleSelectQueryEngine.testItemPaths(csvTestSet, rootPath, contains, referenceNode)).isTrue();
}
Also used : RMObject(com.nedap.archie.rm.RMObject) Test(org.junit.Test)

Example 54 with RMObject

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

the class CanonicalEhrQuery2IT method testEhrAttributesDrillDown.

@Test
public void testEhrAttributesDrillDown() {
    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", "subject", "subject/external_ref", "subject/external_ref/id", "subject/external_ref/id/value", "subject/external_ref/id/scheme", "subject/external_ref/namespace", "subject/external_ref/type", "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 55 with RMObject

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

the class CanonicalEhrQuery3IT method testEhrAutoWhere.

@Test
public void testEhrAutoWhere() throws IOException {
    EhrStatus referenceEhrStatus = new CanonicalJson().unmarshal(IOUtils.toString(EhrTestDataCanonicalJson.EHR_STATUS_SUBJECT_EXTERNAL_REF_OTHER_DETAILS.getStream(), StandardCharsets.UTF_8), EhrStatus.class);
    String rootPath = "e/ehr_status";
    RMObject referenceNode = referenceEhrStatus;
    String csvTestSet = dirPath + "/testEhrStatusWhere.csv";
    assertThat(new AutoEhrStatusWhereQuery(ehrUUID, openEhrClient).testItemPaths(csvTestSet, rootPath, referenceNode)).isTrue();
}
Also used : CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) EhrTestDataCanonicalJson(org.ehrbase.test_data.ehr.EhrTestDataCanonicalJson) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) AutoEhrStatusWhereQuery(org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.auto.AutoEhrStatusWhereQuery) RMObject(com.nedap.archie.rm.RMObject)

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