Search in sources :

Example 41 with Composition

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

the class DBEncodeTest method testNestedLanguageSubjectPartySelf.

@Test
public void testNestedLanguageSubjectPartySelf() 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("PartySelf", composition2.itemsAtPath("/content[openEHR-EHR-SECTION.allgemeine_angaben.v1]/items[openEHR-EHR-EVALUATION.problem_diagnosis_covid.v1]/subject").get(0).getClass().getSimpleName());
}
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 42 with Composition

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

the class DBEncodeTest method compositionEncodingNoContentXML.

@Test
public void compositionEncodingNoContentXML() throws Exception {
    Composition composition = new CanonicalXML().unmarshal(IOUtils.toString(CompositionTestDataCanonicalXML.ALL_TYPES_NO_CONTENT.getStream(), UTF_8), Composition.class);
    assertNotNull(composition);
    CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
    String db_encoded = compositionSerializerRawJson.dbEncode(composition);
    assertNotNull(db_encoded);
    String converted = new LightRawJsonEncoder(db_encoded).encodeCompositionAsString();
    assertNotNull(converted);
    // see if this can be interpreted by Archie
    Composition object = new CanonicalJson().unmarshal(converted, Composition.class);
    assertNotNull(object);
    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 43 with Composition

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

the class DBEncodeTest method testDvIntervalRoundTrip.

@Test
public void testDvIntervalRoundTrip() throws IOException {
    Composition composition = new CanonicalJson().unmarshal(IOUtils.resourceToString("/composition/canonical_json/simple_composition_dvinterval.json", 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);
}
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 44 with Composition

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

the class DBEncodeTest method compositionEncodingFeederAuditDetails.

@Test
public void compositionEncodingFeederAuditDetails() throws Exception {
    String value = IOUtils.toString(CompositionTestDataCanonicalJson.FEEDER_AUDIT_DETAILS.getStream(), UTF_8);
    CanonicalJson cut = new CanonicalJson();
    Composition composition = cut.unmarshal(value, Composition.class);
    // check compo
    assertNotNull(composition);
    assertNotNull(composition.getFeederAudit().getFeederSystemAudit());
    // other details
    assertNotNull(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails());
    assertEquals("family group", composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getName().getValue());
    assertTrue(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails() instanceof ItemTree);
    assertEquals(1, composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getItems().size());
    assertTrue(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getItems().get(0) instanceof Element);
    assertTrue(((Element) composition.getFeederAudit().getFeederSystemAudit().getOtherDetails().getItems().get(0)).getValue() instanceof DvIdentifier);
    // version id
    assertNotNull(composition.getFeederAudit().getFeederSystemAudit().getVersionId());
    assertEquals("final", composition.getFeederAudit().getFeederSystemAudit().getVersionId());
    // DB encode other details
    CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
    String dbEncoded = compositionSerializerRawJson.dbEncode(composition.getFeederAudit().getFeederSystemAudit().getOtherDetails());
    assertNotNull(dbEncoded);
    // Convert encoded string into map to write to DB
    Map<String, Object> asMap = new LightRawJsonEncoder(dbEncoded).encodeOtherDetailsAsMap();
    assertNotNull(asMap);
    assertEquals(4, asMap.size());
    assertNotNull(asMap.get("/items[at0001]"));
    // Attribute mapping and correct archetype node id path in naming
    Map<String, Object> map = new FeederAuditAttributes(composition.getFeederAudit()).toMap();
    assertNotNull(map);
    assertNotNull(map.get("feeder_system_audit"));
    Map<String, Object> feederMap = (Map) map.get("feeder_system_audit");
    assertNotNull(feederMap);
    assertNotNull(feederMap.get("other_details[openEHR-EHR-ITEM_TREE.generic.v1]"));
    assertEquals(4, ((Map<String, Object>) feederMap.get("other_details[openEHR-EHR-ITEM_TREE.generic.v1]")).size());
}
Also used : CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) Composition(com.nedap.archie.rm.composition.Composition) LightRawJsonEncoder(org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder) Element(com.nedap.archie.rm.datastructures.Element) JsonElement(com.google.gson.JsonElement) ItemTree(com.nedap.archie.rm.datastructures.ItemTree) FeederAuditAttributes(org.ehrbase.serialisation.attributes.FeederAuditAttributes) Map(java.util.Map) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) Test(org.junit.Test)

Example 45 with Composition

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

the class RawJsonTest method unmarshal.

@Test
public void unmarshal() throws IOException {
    String value = IOUtils.toString(CompositionTestDataCanonicalXML.DIADEM.getStream(), UTF_8);
    CanonicalXML canonicalXML = new CanonicalXML();
    Composition composition = canonicalXML.unmarshal(value, Composition.class);
    RawJson cut = new RawJson();
    String marshal = cut.marshal(composition);
    Composition actual = cut.unmarshal(marshal, Composition.class);
    assertThat(actual).isNotNull();
    assertThat(composition.getName().getValue()).isEqualTo("DiADeM Assessment");
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalXML(org.ehrbase.serialisation.xmlencoding.CanonicalXML) CompositionTestDataCanonicalXML(org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML) 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