Search in sources :

Example 36 with Composition

use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.

the class DBEncodeTest method testOtherParticipationsPartyRef.

@Test
public void testOtherParticipationsPartyRef() throws IOException {
    Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.OTHER_PARTICIPATIONS.getStream(), UTF_8), Composition.class);
    assertNotNull(composition);
    CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
    String db_encoded = compositionSerializerRawJson.dbEncode(composition);
    assertNotNull(db_encoded);
    JsonElement converted = new LightRawJsonEncoder(db_encoded).encodeContentAsJson("composition");
    // see if this can be interpreted by Archie
    Composition composition2 = new CanonicalJson().unmarshal(converted.toString(), Composition.class);
    assertNotNull(composition2);
    assertEquals("PERSON", composition2.itemsAtPath("/content[openEHR-EHR-ACTION.minimal.v1]/other_participations/performer/external_ref/type").get(0));
}
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) JsonElement(com.google.gson.JsonElement) Test(org.junit.Test)

Example 37 with Composition

use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.

the class DBEncodeTest method testDBEncodeDecodeInstruction.

@Test
public void testDBEncodeDecodeInstruction() throws IOException {
    Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.NESTED_EN_V1.getStream(), UTF_8), Composition.class);
    CompositionSerializer compositionSerializer = new CompositionSerializer();
    String encoded = compositionSerializer.dbEncode(composition);
    Assert.assertTrue(encoded.contains(CompositionSerializer.TAG_EXPIRY_TIME));
    String json = new LightRawJsonEncoder(encoded).encodeCompositionAsString();
    Composition result = new CanonicalJson().unmarshal(json, Composition.class);
    DvDateTime expiryTime = ((Instruction) ((Section) result.getContent().get(0)).getItems().get(0)).getExpiryTime();
    Assert.assertNotNull(expiryTime);
    Assert.assertEquals(OffsetDateTime.parse("2021-05-18T13:13:09.780+03:00"), expiryTime.getValue());
}
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) Instruction(com.nedap.archie.rm.composition.Instruction) Section(com.nedap.archie.rm.composition.Section) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test)

Example 38 with Composition

use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.

the class DBEncodeTest method testDateTimeEncodeDecode.

@Test
public void testDateTimeEncodeDecode() throws IOException {
    Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.DATE_TIME_TESTS.getStream(), UTF_8), Composition.class);
    assertNotNull(composition);
    CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
    String db_encoded = compositionSerializerRawJson.dbEncode(composition);
    assertNotNull(db_encoded);
    JsonElement converted = new LightRawJsonEncoder(db_encoded).encodeContentAsJson("composition");
    // see if this can be interpreted by Archie
    Composition composition2 = new CanonicalJson().unmarshal(converted.toString(), Composition.class);
    assertNotNull(composition2);
    String dvtestPrefix = "/content[openEHR-EHR-OBSERVATION.test_all_types.v1]/data[at0001]/events[at0002]/data[at0003]";
    assertEquals("2019-01-28", composition2.itemsAtPath(dvtestPrefix + "/items[at0010.1]/value/value").get(0).toString());
    assertEquals("2019-01-28T10:00", composition2.itemsAtPath(dvtestPrefix + "/items[at0010.2]/value/value").get(0).toString());
    assertEquals("2019-01-28T10:00+07:00", composition2.itemsAtPath(dvtestPrefix + "/items[at0010.21]/value/value").get(0).toString());
    assertEquals("2019-01", composition2.itemsAtPath(dvtestPrefix + "/items[at0010.3]/value/value").get(0).toString());
    assertEquals("2019", composition2.itemsAtPath(dvtestPrefix + "/items[at0010.4]/value/value").get(0).toString());
    assertEquals("2019-01-28T21:22:49.427+07:00", composition2.itemsAtPath(dvtestPrefix + "/items[at0011]/value/value").get(0).toString());
    assertEquals("18:36:49", composition2.itemsAtPath(dvtestPrefix + "/items[at0012.1]/value/value").get(0).toString());
    assertEquals("18:36", composition2.itemsAtPath(dvtestPrefix + "/items[at0012.2]/value/value").get(0).toString());
    assertEquals("18:00", composition2.itemsAtPath(dvtestPrefix + "/items[at0012.3]/value/value").get(0).toString());
    assertEquals("18:36+07:00", composition2.itemsAtPath(dvtestPrefix + "/items[at0012.4]/value/value").get(0).toString());
}
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) JsonElement(com.google.gson.JsonElement) Test(org.junit.Test)

Example 39 with Composition

use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.

the class DBEncodeTest method testNestedLanguage.

@Test
public void testNestedLanguage() throws IOException {
    Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.SUBJECT_PARTY_SELF.getStream(), UTF_8), Composition.class);
    assertNotNull(composition);
    CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
    String db_encoded = compositionSerializerRawJson.dbEncode(composition);
    assertNotNull(db_encoded);
    JsonElement converted = new LightRawJsonEncoder(db_encoded).encodeContentAsJson("composition");
    // see if this can be interpreted by Archie
    Composition composition2 = new CanonicalJson().unmarshal(converted.toString(), Composition.class);
    assertNotNull(composition2);
    assertEquals("de", composition2.itemsAtPath("/content[openEHR-EHR-SECTION.allgemeine_angaben.v1]/items[openEHR-EHR-EVALUATION.problem_diagnosis_covid.v1]/language/code_string").get(0).toString());
}
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) JsonElement(com.google.gson.JsonElement) Test(org.junit.Test)

Example 40 with Composition

use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.

the class DBEncodeTest method testNestedLanguageSubjectPartyIdentified.

@Test
public void testNestedLanguageSubjectPartyIdentified() throws IOException {
    Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.SUBJECT_PARTY_IDENTIFIED.getStream(), UTF_8), Composition.class);
    assertNotNull(composition);
    CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
    String db_encoded = compositionSerializerRawJson.dbEncode(composition);
    assertNotNull(db_encoded);
    JsonElement converted = new LightRawJsonEncoder(db_encoded).encodeContentAsJson("composition");
    // see if this can be interpreted by Archie
    Composition composition2 = new CanonicalJson().unmarshal(converted.toString(), Composition.class);
    assertNotNull(composition2);
    assertEquals("1", composition2.itemsAtPath("/content[openEHR-EHR-SECTION.allgemeine_angaben.v1]/items[openEHR-EHR-EVALUATION.problem_diagnosis_covid.v1]/subject/external_ref/id/value").get(0).toString());
}
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) JsonElement(com.google.gson.JsonElement) Test(org.junit.Test)

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