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));
}
}
}
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();
}
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();
}
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));
}
}
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();
}
Aggregations