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());
}
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);
}
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);
}
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());
}
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");
}
Aggregations