use of com.nedap.archie.rm.composition.AdminEntry in project openEHR_SDK by ehrbase.
the class UnflattenerTest method testUnflattenEpsiode.
@Test
public void testUnflattenEpsiode() {
EpisodeOfCareComposition episode = buildEpisodeOfCareComposition();
Unflattener cut = new Unflattener(new TestDataTemplateProvider());
Composition actual = (Composition) cut.unflatten(episode);
assertThat(actual).isNotNull();
assertThat(actual.getContent()).size().isEqualTo(1);
AdminEntry actualAdminEntry = (AdminEntry) actual.getContent().get(0);
List<Object> identifiers = actualAdminEntry.itemsAtPath("/data[at0001]/items[at0002]/value");
assertThat(identifiers).extracting(i -> ((DvIdentifier) i).getId()).containsExactlyInAnyOrder("123", "456");
List<Object> uris = actualAdminEntry.itemsAtPath("/data[at0001]/items[at0013]/value");
assertThat(uris).extracting(u -> ((DvURI) u).getValue()).containsExactlyInAnyOrder(URI.create("https://github.com/ehrbase"));
}
use of com.nedap.archie.rm.composition.AdminEntry in project openEHR_SDK by ehrbase.
the class DBEncodeTest method testDBDecodeDvIntervalCompositeClass.
@Test
public void testDBDecodeDvIntervalCompositeClass() throws Exception {
String db_encoded = IOUtils.resourceToString("/composition/canonical_json/composition_with_dvinterval_composite.json", UTF_8);
assertNotNull(db_encoded);
JsonElement converted = new LightRawJsonEncoder(db_encoded).encodeContentAsJson(null);
// see if this can be interpreted by Archie
Composition composition = new CanonicalJson().unmarshal(converted.toString(), Composition.class);
// hack the composition to figure out what is the format of DvInterval...
((DvInterval) ((Element) ((AdminEntry) composition.getContent().get(0)).getData().getItems().get(0)).getValue()).setLower(new DvDateTime("2019-11-22T00:00+01:00"));
((DvInterval) ((Element) ((AdminEntry) composition.getContent().get(0)).getData().getItems().get(0)).getValue()).setUpper(new DvDateTime("2019-12-22T00:00+01:00"));
assertNotNull(composition);
String toJson = new CanonicalJson().marshal(composition);
String interpreted = new CanonicalXML().marshal(composition);
assertNotNull(interpreted);
}
use of com.nedap.archie.rm.composition.AdminEntry in project ehrbase by ehrbase.
the class EntryAccess method setCompositionFields.
/**
* set the EntryRecord with fields from composition:<br>
* <ul>
* <li>category</li>
* <li>item type</li>
* <li>archetype node Id</li>
* <li>entry content (json)</li>
* </ul>
*
* @param record Target {@link EntryRecord}
* @param composition input data in {@link Composition} representation
*/
private void setCompositionFields(EntryRecord record, Composition composition) {
record.setCategory(record.getCategory());
if (composition.getContent() != null && !composition.getContent().isEmpty()) {
Object node = composition.getContent().get(0);
if (node instanceof Section) {
record.setItemType(EntryType.valueOf("section"));
} else if (node instanceof Evaluation || node instanceof Observation || node instanceof Instruction || node instanceof Action) {
record.setItemType(EntryType.valueOf("care_entry"));
} else if (node instanceof AdminEntry) {
record.setItemType(EntryType.valueOf("admin"));
}
} else {
record.setItemType(EntryType.valueOf("admin"));
}
record.setArchetypeId(composition.getArchetypeNodeId());
RawJson rawJson = new RawJson();
record.setEntry(JSONB.valueOf(rawJson.marshal(composition)));
}
Aggregations