Search in sources :

Example 46 with Composition

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

the class RawJsonTest method marshal.

@Test
public void marshal() 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);
    assertThat(marshal).isNotEmpty();
}
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)

Example 47 with Composition

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

the class RawJsonTest method unmarshal2.

@Test
public void unmarshal2() throws IOException {
    String value = IOUtils.toString(CompositionTestDataCanonicalXML.ALL_TYPES_FIXED.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("Test all types");
}
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)

Example 48 with Composition

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

the class DBEncodeRoundTripTest method testAlternativeEventsRoundTrip.

@Test
@Ignore
public void testAlternativeEventsRoundTrip() throws IOException {
    String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/alternative_events_reduced_flat.json")));
    RMDataFormat flatJson = new FlatJasonProvider(new TestDataTemplateProvider()).buildFlatJson(FlatFormat.SIM_SDT, "AlternativeEvents");
    Composition composition = flatJson.unmarshal(value);
    assertThat(composition).isNotNull();
    CompositionSerializer compositionSerializerRawJson = new CompositionSerializer();
    String db_encoded = compositionSerializerRawJson.dbEncode(composition);
    assertNotNull(db_encoded);
    String converted = new LightRawJsonEncoder(db_encoded).encodeCompositionAsString();
    assertNotNull(converted);
    Composition actual = new CanonicalJson().unmarshal(converted, Composition.class);
    String actualFlat = flatJson.marshal(actual);
    assertNotNull(actualFlat);
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) LightRawJsonEncoder(org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) FlatJasonProvider(org.ehrbase.serialisation.flatencoding.FlatJasonProvider) TestDataTemplateProvider(org.ehrbase.serialisation.templateprovider.TestDataTemplateProvider) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 49 with Composition

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

the class DBEncodeTest method testDBDecodeIssue350.

@Test
public void testDBDecodeIssue350() throws Exception {
    String db_encoded = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/bug350_missing_data.json")));
    assertNotNull(db_encoded);
    // see if this can be interpreted by Archie
    Composition object = new RawJson().unmarshal(db_encoded, Composition.class);
    assertEquals(8, ((Section) object.itemsAtPath("/content[openEHR-EHR-SECTION.respect_headings.v0]").get(0)).getItems().size());
    String interpreted = new CanonicalXML().marshal(object);
    assertNotNull(interpreted);
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalXML(org.ehrbase.serialisation.xmlencoding.CanonicalXML) CompositionTestDataCanonicalXML(org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML) Section(com.nedap.archie.rm.composition.Section) Test(org.junit.Test)

Example 50 with Composition

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

the class DBEncodeTest method compositionEncodingEmptyProtocol.

@Test
public void compositionEncodingEmptyProtocol() throws Exception {
    String value = IOUtils.toString(CompositionTestDataCanonicalJson.GECCO_PERSONENDATEN.getStream(), UTF_8);
    CanonicalJson cut = new CanonicalJson();
    Composition composition = cut.unmarshal(value, 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 : 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) 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