use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class DBEncodeTest method compositionEncodingCycleWithDuplicateSections.
@Test
public void compositionEncodingCycleWithDuplicateSections() throws Exception {
Composition composition = new CanonicalXML().unmarshal(IOUtils.toString(CompositionTestDataCanonicalXML.REGISTRO_DE_ATENDIMENTO.getStream(), UTF_8), Composition.class);
assertNotNull(composition);
int sectionOccurrences = composition.getContent().size();
CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
String db_encoded = compositionSerializerRawJson.dbEncode(composition);
assertNotNull(db_encoded);
String converted = new LightRawJsonEncoder(db_encoded).encodeCompositionAsString();
// see if this can be interpreted by Archie
Composition object = new CanonicalJson().unmarshal(converted, Composition.class);
assertNotNull(object);
// check if encoded/decode carry the same name
assertEquals(sectionOccurrences, object.getContent().size());
String interpreted = new CanonicalXML().marshal(object);
assertNotNull(interpreted);
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class StatusesTestOverwrite method quantity.
@Override
@Test
public void quantity() 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/quantity|unit", "m", "test_statuses/test_statuses:0/quantity|magnitude", 1, "test_statuses/test_statuses:0/quantity|normal_status", "L", "test_statuses/test_statuses:0/quantity|magnitude_status", ">=", "test_statuses/test_statuses:0/quantity|accuracy", 10.0, "test_statuses/test_statuses:0/quantity|accuracy_is_percent", true);
RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
DvQuantity rmObject = (DvQuantity) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0010]/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/quantity|normal_status", "L").containsEntry("test_statuses/test_statuses:0/quantity|magnitude_status", ">=").containsEntry("test_statuses/test_statuses:0/quantity|accuracy", 10.0).containsEntry("test_statuses/test_statuses:0/quantity|accuracy_is_percent", true);
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class StatusesTestOverwrite method ordinalN.
@Override
@Test
public void ordinalN() 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", "N");
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("N");
Map<String, Object> value = OBJECT_MAPPER.readValue(flatJson.marshal(composition), Map.class);
assertThat(value).containsEntry("test_statuses/test_statuses:0/ordinal|normal_status", "N");
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class StatusesTestOverwrite method dateTime.
@Override
@Test
public void dateTime() 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/datetime", "2017-10-01T13:20:00Z", "test_statuses/test_statuses:0/datetime|normal_status", "L", "test_statuses/test_statuses:0/datetime|magnitude_status", ">=", "test_statuses/test_statuses:0/datetime/_accuracy", "P1Y");
RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
DvDateTime rmObject = (DvDateTime) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0013]/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/datetime|normal_status", "L").containsEntry("test_statuses/test_statuses:0/datetime|magnitude_status", ">=").containsEntry("test_statuses/test_statuses:0/datetime/_accuracy", "P1Y");
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class StatusesTestOverwrite method proportion.
@Override
@Test
public void proportion() 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/proportion|numerator", 17, "test_statuses/test_statuses:0/proportion|denominator", 33, "test_statuses/test_statuses:0/proportion|normal_status", "L", "test_statuses/test_statuses:0/proportion|magnitude_status", ">=", "test_statuses/test_statuses:0/proportion|accuracy", 10.0, "test_statuses/test_statuses:0/proportion|accuracy_is_percent", true);
RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
DvProportion rmObject = (DvProportion) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0015]/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/proportion|normal_status", "L").containsEntry("test_statuses/test_statuses:0/proportion|magnitude_status", ">=").containsEntry("test_statuses/test_statuses:0/proportion|accuracy", 10.0).containsEntry("test_statuses/test_statuses:0/proportion|accuracy_is_percent", true);
}
Aggregations