use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class OldDtoModelTest method checkTestCase.
public void checkTestCase(TestCase testCase, SoftAssertions softly) throws IOException {
String value = IOUtils.toString(testCase.simSDTJson.getStream(), UTF_8);
RMDataFormat flatJson = new FlatJasonProvider(new TestDataTemplateProvider()).buildFlatJson(FlatFormat.SIM_SDT, testCase.templateId);
Composition composition = flatJson.unmarshal(value);
Flattener flattener = new Flattener(new TestDataTemplateProvider());
Object flatten = flattener.flatten(composition, testCase.dtoClass);
Unflattener unflattener = new Unflattener(new TestDataTemplateProvider());
RMObject actual = unflattener.unflatten(flatten);
String actualFlat = flatJson.marshal(actual);
List<String> errors = compere(actualFlat, value);
softly.assertThat(errors).filteredOn(s -> s.startsWith("Missing")).as("Test Case %s", testCase.id).containsExactlyInAnyOrder(testCase.missing);
softly.assertThat(errors).filteredOn(s -> s.startsWith("Extra")).as("Test Case %s", testCase.id).containsExactlyInAnyOrder(testCase.extra);
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class StatusesTestOverwrite method count.
@Override
@Test
public void count() throws Exception {
String template = this.getFileContent("/res/test_statuses.opt");
Map<String, Object> flatComposition = Map.of("ctx/language", "sl", "ctx/territory", "SI", "ctx/composer_name", "George Orwell", "test_statuses/test_statuses:0/count", 1, "test_statuses/test_statuses:0/count|normal_status", "L", "test_statuses/test_statuses:0/count|magnitude_status", ">=", "test_statuses/test_statuses:0/count|accuracy", 10.0, "test_statuses/test_statuses:0/count|accuracy_is_percent", true);
RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
DvCount rmObject = (DvCount) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0014]/value");
assertThat(rmObject.getNormalStatus()).isNotNull();
assertThat(rmObject.getNormalStatus().getTerminologyId().getValue()).isEqualTo("openehr_normal_statuses");
assertThat(rmObject.getNormalStatus().getCodeString()).isEqualTo("L");
assertThat(rmObject.getMagnitudeStatus()).isEqualTo(">=");
assertThat(rmObject.getAccuracy()).isEqualTo(10);
assertThat(rmObject.getAccuracyIsPercent()).isTrue();
Map<String, Object> value = OBJECT_MAPPER.readValue(flatJson.marshal(composition), Map.class);
assertThat(value).containsEntry("test_statuses/test_statuses:0/count|normal_status", "L").containsEntry("test_statuses/test_statuses:0/count|magnitude_status", ">=").containsEntry("test_statuses/test_statuses:0/count|accuracy", 10.0).containsEntry("test_statuses/test_statuses:0/count|accuracy_is_percent", true);
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class StatusesTestOverwrite method time.
@Override
@Test
public void time() throws Exception {
String template = this.getFileContent("/res/test_statuses.opt");
Map<String, Object> flatComposition = Map.of("ctx/language", "sl", "ctx/territory", "SI", "ctx/composer_name", "George Orwell", "test_statuses/test_statuses:0/time", "13:20", "test_statuses/test_statuses:0/time|normal_status", "L", "test_statuses/test_statuses:0/time|magnitude_status", ">=", "test_statuses/test_statuses:0/time/_accuracy", "P1Y");
RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
DvTime rmObject = (DvTime) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0012]/value");
assertThat(rmObject.getNormalStatus()).isNotNull();
assertThat(rmObject.getNormalStatus().getTerminologyId().getValue()).isEqualTo("openehr_normal_statuses");
assertThat(rmObject.getNormalStatus().getCodeString()).isEqualTo("L");
assertThat(rmObject.getMagnitudeStatus()).isEqualTo(">=");
assertThat(rmObject.getAccuracy()).isNotNull().extracting(DvDuration::getValue).extracting(Object::toString).isEqualTo("P1Y");
Map<String, Object> value = OBJECT_MAPPER.readValue(flatJson.marshal(composition), Map.class);
assertThat(value).containsEntry("test_statuses/test_statuses:0/time|normal_status", "L").containsEntry("test_statuses/test_statuses:0/time|magnitude_status", ">=").containsEntry("test_statuses/test_statuses:0/time/_accuracy", "P1Y");
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class StatusesTestOverwrite method ordinal.
@Override
@Test
public void ordinal() throws Exception {
String template = this.getFileContent("/res/test_statuses.opt");
Map<String, Object> flatComposition = Map.of("ctx/language", "sl", "ctx/territory", "SI", "ctx/id_scheme", "ispek", "ctx/id_namespace", "ispek", "ctx/composer_name", "George Orwell", "test_statuses/test_statuses:0/ordinal", "at0006", "test_statuses/test_statuses:0/ordinal|normal_status", "L");
RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
DvOrdinal ordinal = (DvOrdinal) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0005]/value");
assertThat(ordinal.getNormalStatus()).isNotNull();
assertThat(ordinal.getNormalStatus().getTerminologyId().getValue()).isEqualTo("openehr_normal_statuses");
assertThat(ordinal.getNormalStatus().getCodeString()).isEqualTo("L");
Map<String, Object> value = OBJECT_MAPPER.readValue(flatJson.marshal(composition), Map.class);
assertThat(value).containsEntry("test_statuses/test_statuses:0/ordinal|normal_status", "L");
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class TermMappingTestOverwritten method testTermMappingFromMap.
@Override
@Test
public void testTermMappingFromMap() throws Exception {
String template = this.getFileContent("/res/Demo Vitals.xml");
String rawJson = this.getFileContent("/res/TmComposition.json");
Composition unmarshal = new CanonicalJson().unmarshal(rawJson.replace("\"@class\"", "\"_type\""), Composition.class);
String flatJson = getFlatJson(template, FlatFormat.SIM_SDT).marshal(unmarshal);
Composition actualComposition = getFlatJson(template, FlatFormat.SIM_SDT).unmarshal(flatJson);
List<TermMapping> termMappings = ((DvText) actualComposition.itemsAtPath("/content[openEHR-EHR-SECTION.ispek_dialog.v1]/items[openEHR-EHR-OBSERVATION.body_temperature-zn.v1]/data[at0002]/events/data/items[at0.63]/value").get(0)).getMappings();
assertThat(termMappings).extracting(TermMapping::getMatch, t -> t.getTarget().getCodeString(), t -> t.getTarget().getTerminologyId().getValue(), TermMapping::getPurpose).containsExactlyInAnyOrder(new Tuple('=', "21794005", "SNOMED-CT", null), new Tuple('=', "W.11.7", "RTX", null));
List<TermMapping> termMappings2 = ((DvText) actualComposition.itemsAtPath("/content[openEHR-EHR-SECTION.ispek_dialog.v1]/items[openEHR-EHR-OBSERVATION.body_temperature-zn.v1]/data[at0002]/events/state/items[at0041]/value").get(0)).getMappings();
assertThat(termMappings2).extracting(TermMapping::getMatch, t -> t.getTarget().getCodeString(), t -> t.getTarget().getTerminologyId().getValue(), TermMapping::getPurpose).containsExactlyInAnyOrder(new Tuple('=', "99.1", "IAXA", new DvCodedText("Purpose 1", new CodePhrase(new TerminologyId("Purposes"), "p.0.63.1"))));
}
Aggregations