use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class StatusesTestOverwrite method date.
@Override
@Test
public void date() 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/date", "2017-10-01", "test_statuses/test_statuses:0/date|normal_status", "L", "test_statuses/test_statuses:0/date|magnitude_status", ">=", "test_statuses/test_statuses:0/date/_accuracy", "P1Y");
RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
DvDate rmObject = (DvDate) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0011]/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/date|normal_status", "L").containsEntry("test_statuses/test_statuses:0/date|magnitude_status", ">=").containsEntry("test_statuses/test_statuses:0/date/_accuracy", "P1Y");
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class StatusesTestOverwrite method duration.
@Override
@Test
public void duration() 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/duration", "P1Y", "test_statuses/test_statuses:0/duration|normal_status", "L", "test_statuses/test_statuses:0/duration|magnitude_status", ">=", "test_statuses/test_statuses:0/duration|accuracy", 10.0, "test_statuses/test_statuses:0/duration|accuracy_is_percent", true);
RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
DvDuration rmObject = (DvDuration) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0009]/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/duration|normal_status", "L").containsEntry("test_statuses/test_statuses:0/duration|magnitude_status", ">=").containsEntry("test_statuses/test_statuses:0/duration|accuracy", 10.0).containsEntry("test_statuses/test_statuses:0/duration|accuracy_is_percent", true);
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class TermMappingTestOverwritten method testTermMappingFromJson.
@Override
@Test
public void testTermMappingFromJson() 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 structuredJson = getFlatJson(template, FlatFormat.STRUCTURED).marshal(unmarshal);
Composition actualComposition = getFlatJson(template, FlatFormat.STRUCTURED).unmarshal(structuredJson);
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"))));
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class FlatJsonUnmarshallerTest method unmarshalAlt.
@Test
public void unmarshalAlt() throws IOException, XmlException {
OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.ALT_EVENTS.getStream()).getTemplate();
WebTemplate webTemplate = new OPTParser(template).parse();
FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller();
String flat = IOUtils.toString(CompositionTestDataSimSDTJson.ALTERNATIVE_EVENTS.getStream(), StandardCharsets.UTF_8);
Composition actual = cut.unmarshal(flat, webTemplate);
assertThat(actual).isNotNull();
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class FlatJsonUnmarshallerTest method unmarshalDeterioriationAssessment.
@Test
public void unmarshalDeterioriationAssessment() throws IOException, XmlException {
OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.DETERIORIATION_ASSESSMENT.getStream()).getTemplate();
WebTemplate webTemplate = new OPTParser(template).parse();
FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller();
String flat = IOUtils.toString(CompositionTestDataSimSDTJson.DETERIORIATION_ASSESSMENT.getStream(), StandardCharsets.UTF_8);
Composition actual = cut.unmarshal(flat, webTemplate);
assertThat(actual).isNotNull();
}
Aggregations