Search in sources :

Example 51 with Composition

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);
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) LightRawJsonEncoder(org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder) CanonicalXML(org.ehrbase.serialisation.xmlencoding.CanonicalXML) CompositionTestDataCanonicalXML(org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML) Test(org.junit.Test)

Example 52 with Composition

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);
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) DvQuantity(com.nedap.archie.rm.datavalues.quantity.DvQuantity) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) Test(org.junit.Test) StatusesTest(care.better.platform.web.template.StatusesTest)

Example 53 with Composition

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");
}
Also used : DvOrdinal(com.nedap.archie.rm.datavalues.quantity.DvOrdinal) Composition(com.nedap.archie.rm.composition.Composition) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) Test(org.junit.Test) StatusesTest(care.better.platform.web.template.StatusesTest)

Example 54 with Composition

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");
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) DvDuration(com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test) StatusesTest(care.better.platform.web.template.StatusesTest)

Example 55 with Composition

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);
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) DvProportion(com.nedap.archie.rm.datavalues.quantity.DvProportion) Test(org.junit.Test) StatusesTest(care.better.platform.web.template.StatusesTest)

Aggregations

Composition (com.nedap.archie.rm.composition.Composition)138 Test (org.junit.Test)103 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)66 CompositionTestDataCanonicalJson (org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson)53 LightRawJsonEncoder (org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder)30 TestDataTemplateProvider (org.ehrbase.client.templateprovider.TestDataTemplateProvider)29 RMDataFormat (org.ehrbase.serialisation.RMDataFormat)28 IOException (java.io.IOException)21 List (java.util.List)21 CoronaAnamneseComposition (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition)20 Tuple (org.assertj.core.groups.Tuple)19 EhrbaseBloodPressureSimpleDeV0Composition (org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition)19 StandardCharsets (java.nio.charset.StandardCharsets)18 IOUtils (org.apache.commons.io.IOUtils)18 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)18 EhrbaseMultiOccurrenceDeV1Composition (org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition)18 OPERATIONALTEMPLATE (org.openehr.schemas.v1.OPERATIONALTEMPLATE)18 EpisodeOfCareComposition (org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition)17 CompositionTestDataCanonicalXML (org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML)17 WebTemplate (org.ehrbase.webtemplate.model.WebTemplate)16