Search in sources :

Example 1 with AdminEntry

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"));
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LaborergebnisObservation(org.ehrbase.client.classgenerator.examples.befundderblutgasanalysecomposition.definition.LaborergebnisObservation) EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) GrosseLangeObservation(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.definition.GrosseLangeObservation) Element(com.nedap.archie.rm.datastructures.Element) Duration(java.time.Duration) Locatable(com.nedap.archie.rm.archetyped.Locatable) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) URI(java.net.URI) ZoneOffset(java.time.ZoneOffset) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) DvQuantity(com.nedap.archie.rm.datavalues.quantity.DvQuantity) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PartySelf(com.nedap.archie.rm.generic.PartySelf) Tuple(org.assertj.core.groups.Tuple) KorpergrosseComposition(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.KorpergrosseComposition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) DvText(com.nedap.archie.rm.datavalues.DvText) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) Test(org.junit.Test) IOException(java.io.IOException) PointEvent(com.nedap.archie.rm.datastructures.PointEvent) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) IOUtils(org.apache.commons.io.IOUtils) KohlendioxidpartialdruckCluster(org.ehrbase.client.classgenerator.examples.befundderblutgasanalysecomposition.definition.KohlendioxidpartialdruckCluster) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) Observation(com.nedap.archie.rm.composition.Observation) List(java.util.List) AlternativeEventsComposition(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.AlternativeEventsComposition) OffsetDateTime(java.time.OffsetDateTime) BefundDerBlutgasanalyseComposition(org.ehrbase.client.classgenerator.examples.befundderblutgasanalysecomposition.BefundDerBlutgasanalyseComposition) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) TestData(org.ehrbase.client.TestData) IntervalEvent(com.nedap.archie.rm.datastructures.IntervalEvent) TestAllTypesEnV1Composition(org.ehrbase.client.classgenerator.examples.testalltypesenv1composition.TestAllTypesEnV1Composition) AdminEntry(com.nedap.archie.rm.composition.AdminEntry) DvURI(com.nedap.archie.rm.datavalues.DvURI) TestAllTypesEvaluation(org.ehrbase.client.classgenerator.examples.testalltypesenv1composition.definition.TestAllTypesEvaluation) CoronaAnamneseComposition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition) Composition(com.nedap.archie.rm.composition.Composition) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) KorpergrosseComposition(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.KorpergrosseComposition) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) AlternativeEventsComposition(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.AlternativeEventsComposition) BefundDerBlutgasanalyseComposition(org.ehrbase.client.classgenerator.examples.befundderblutgasanalysecomposition.BefundDerBlutgasanalyseComposition) TestAllTypesEnV1Composition(org.ehrbase.client.classgenerator.examples.testalltypesenv1composition.TestAllTypesEnV1Composition) CoronaAnamneseComposition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition) AdminEntry(com.nedap.archie.rm.composition.AdminEntry) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) DvURI(com.nedap.archie.rm.datavalues.DvURI) Test(org.junit.Test)

Example 2 with AdminEntry

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);
}
Also used : DvInterval(com.nedap.archie.rm.datavalues.quantity.DvInterval) 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) AdminEntry(com.nedap.archie.rm.composition.AdminEntry) CanonicalXML(org.ehrbase.serialisation.xmlencoding.CanonicalXML) CompositionTestDataCanonicalXML(org.ehrbase.test_data.composition.CompositionTestDataCanonicalXML) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test)

Example 3 with AdminEntry

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)));
}
Also used : Evaluation(com.nedap.archie.rm.composition.Evaluation) Action(com.nedap.archie.rm.composition.Action) RawJson(org.ehrbase.serialisation.dbencoding.RawJson) AdminEntry(com.nedap.archie.rm.composition.AdminEntry) Observation(com.nedap.archie.rm.composition.Observation) Instruction(com.nedap.archie.rm.composition.Instruction) Section(com.nedap.archie.rm.composition.Section)

Aggregations

AdminEntry (com.nedap.archie.rm.composition.AdminEntry)3 Composition (com.nedap.archie.rm.composition.Composition)2 Observation (com.nedap.archie.rm.composition.Observation)2 JsonElement (com.google.gson.JsonElement)1 Locatable (com.nedap.archie.rm.archetyped.Locatable)1 Action (com.nedap.archie.rm.composition.Action)1 Evaluation (com.nedap.archie.rm.composition.Evaluation)1 Instruction (com.nedap.archie.rm.composition.Instruction)1 Section (com.nedap.archie.rm.composition.Section)1 Element (com.nedap.archie.rm.datastructures.Element)1 IntervalEvent (com.nedap.archie.rm.datastructures.IntervalEvent)1 PointEvent (com.nedap.archie.rm.datastructures.PointEvent)1 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)1 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)1 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)1 DvText (com.nedap.archie.rm.datavalues.DvText)1 DvURI (com.nedap.archie.rm.datavalues.DvURI)1 DvInterval (com.nedap.archie.rm.datavalues.quantity.DvInterval)1 DvQuantity (com.nedap.archie.rm.datavalues.quantity.DvQuantity)1 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)1