Search in sources :

Example 6 with Observation

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

the class UnflattenerTest method testUnflattenEhrbaseMultiOccurrenceDeV1.

@Test
public void testUnflattenEhrbaseMultiOccurrenceDeV1() {
    Unflattener cut = new Unflattener(new TestDataTemplateProvider());
    EhrbaseMultiOccurrenceDeV1Composition dto = TestData.buildEhrbaseMultiOccurrenceDeV1();
    Composition rmObject = (Composition) cut.unflatten(dto);
    assertThat(rmObject).isNotNull();
    assertThat(rmObject.getArchetypeDetails().getTemplateId().getValue()).isEqualTo("ehrbase_multi_occurrence.de.v1");
    List<Object> observationList = rmObject.itemsAtPath("/content[openEHR-EHR-OBSERVATION.body_temperature.v2]");
    assertThat(observationList).size().isEqualTo(2);
    Observation observation1 = (Observation) observationList.get(0);
    List<Object> objects = observation1.itemsAtPath("/data[at0002]/events");
    assertThat(objects).extracting(o -> ((PointEvent) o)).extracting(p -> (DvQuantity) p.itemAtPath("/data[at0001]/items[at0004]/value")).extracting(DvQuantity::getMagnitude).containsExactlyInAnyOrder(11d, 22d);
    DvCodedText dvCodedText = (DvCodedText) observation1.itemAtPath("/protocol[at0020]/items[at0021]/value");
    assertThat(dvCodedText.getValue()).isEqualTo("Forehead");
    Observation observation2 = (Observation) observationList.get(1);
    DvText dvText = (DvText) observation2.itemAtPath("/protocol[at0020]/items[at0021]/value");
    assertFalse(dvText instanceof DvCodedText);
    assertThat(dvText.getValue()).isEqualTo("location");
}
Also used : EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) 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) DvCodedText(com.nedap.archie.rm.datavalues.DvCodedText) LaborergebnisObservation(org.ehrbase.client.classgenerator.examples.befundderblutgasanalysecomposition.definition.LaborergebnisObservation) GrosseLangeObservation(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.definition.GrosseLangeObservation) Observation(com.nedap.archie.rm.composition.Observation) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) DvText(com.nedap.archie.rm.datavalues.DvText) Test(org.junit.Test)

Example 7 with Observation

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

the class FlattenerTest method testFlattenSingleEventIntervallEvent.

@Test
public void testFlattenSingleEventIntervallEvent() {
    Unflattener unflattener = new Unflattener(new TestDataTemplateProvider());
    KorpergrosseComposition dto = new KorpergrosseComposition();
    dto.setGrosseLange(new GrosseLangeObservation());
    dto.getGrosseLange().setGrosseLangeMagnitude(22d);
    Composition rmObject = (Composition) unflattener.unflatten(dto);
    Observation observation = (Observation) rmObject.getContent().get(0);
    Event<ItemStructure> event = observation.getData().getEvents().get(0);
    observation.getData().getEvents().remove(event);
    IntervalEvent<ItemStructure> intervalEvent = new IntervalEvent<>();
    intervalEvent.setData(event.getData());
    intervalEvent.setArchetypeNodeId(event.getArchetypeNodeId());
    intervalEvent.setSampleCount(10L);
    observation.getData().getEvents().add(intervalEvent);
    assertThat(rmObject).isNotNull();
    Flattener cut = new Flattener(new TestDataTemplateProvider());
    KorpergrosseComposition actual = cut.flatten(rmObject, KorpergrosseComposition.class);
    assertThat(actual.getGrosseLange().getGrosseLangeMagnitude()).isEqualTo(22d);
}
Also used : KorpergrosseComposition(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.KorpergrosseComposition) GrosseLangeObservation(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.definition.GrosseLangeObservation) Composition(com.nedap.archie.rm.composition.Composition) TestData.buildEpisodeOfCareComposition(org.ehrbase.client.TestData.buildEpisodeOfCareComposition) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) CoronaAnamneseComposition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) EhrbaseMultiOccurrenceDeV1Composition(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition) TestData.buildAlternativeEventsComposition(org.ehrbase.client.TestData.buildAlternativeEventsComposition) KorpergrosseComposition(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.KorpergrosseComposition) AlternativeEventsComposition(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.AlternativeEventsComposition) Observation(com.nedap.archie.rm.composition.Observation) BodyTemperatureObservation(org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.definition.BodyTemperatureObservation) GrosseLangeObservation(org.ehrbase.client.classgenerator.examples.korpergrossecomposition.definition.GrosseLangeObservation) KorpergewichtAnyEventEnIntervalEvent(org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.definition.KorpergewichtAnyEventEnIntervalEvent) IntervalEvent(com.nedap.archie.rm.datastructures.IntervalEvent) ItemStructure(com.nedap.archie.rm.datastructures.ItemStructure) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) Test(org.junit.Test)

Example 8 with Observation

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

the class FlatJsonUnmarshallerTest method unmarshalUuid.

@Test
public void unmarshalUuid() throws IOException, XmlException {
    OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.CONFORMANCE.getStream()).getTemplate();
    WebTemplate webTemplate = new OPTParser(template).parse();
    FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller();
    String flat = IOUtils.toString(CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_OBSERVATION.getStream(), StandardCharsets.UTF_8);
    Composition actual = cut.unmarshal(flat, webTemplate);
    assertThat(actual).isNotNull();
    Observation observation = (Observation) actual.itemAtPath("/content[openEHR-EHR-SECTION.conformance_section.v0]/items[openEHR-EHR-OBSERVATION.conformance_observation.v0]");
    assertThat(observation.getUid().getValue()).hasToString("9fcc1c70-9349-444d-b9cb-8fa817697f5e");
    assertThat(observation.getData().getUid()).isNull();
}
Also used : OPERATIONALTEMPLATE(org.openehr.schemas.v1.OPERATIONALTEMPLATE) Composition(com.nedap.archie.rm.composition.Composition) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) OPTParser(org.ehrbase.webtemplate.parser.OPTParser) Observation(com.nedap.archie.rm.composition.Observation) Test(org.junit.Test)

Example 9 with Observation

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

the class ContainmentTest method testContainment.

@Test
public void testContainment() {
    List<TestCase> testCases = new ArrayList<>();
    testCases.add(new TestCase(1, "openEHR-EHR-COMPOSITION.sample_encounter.v1", Composition.class, "COMPOSITION v[openEHR-EHR-COMPOSITION.sample_encounter.v1]"));
    testCases.add(new TestCase(2, "openEHR-EHR-OBSERVATION.sample_blood_pressure.v1", Observation.class, "OBSERVATION v[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]"));
    testCases.add(new TestCase(3, "openEHR-EHR-ADMIN_ENTRY.discharge.v1", AdminEntry.class, "ADMIN_ENTRY v[openEHR-EHR-ADMIN_ENTRY.discharge.v1]"));
    EntityQuery query = mock(EntityQuery.class);
    when(query.buildVariabelName(any())).thenReturn("v");
    testCases.forEach(t -> {
        Containment cut = new Containment(t.archetype);
        cut.bindQuery(query);
        assertThat(cut.getType()).as(String.format("Test Case %d", t.id)).isEqualTo(t.type);
        assertThat(cut.buildAQL()).as(String.format("Test Case %d", t.id)).isEqualTo(t.aql);
    });
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) AdminEntry(com.nedap.archie.rm.composition.AdminEntry) ArrayList(java.util.ArrayList) Observation(com.nedap.archie.rm.composition.Observation) EntityQuery(org.ehrbase.client.aql.query.EntityQuery) Test(org.junit.Test)

Example 10 with Observation

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

the class WebTemplateSkeletonBuilderTest method build.

@Test
public void build() throws XmlException, IOException {
    org.openehr.schemas.v1.TemplateDocument document = org.openehr.schemas.v1.TemplateDocument.Factory.parse(OperationalTemplateTestData.BLOOD_PRESSURE_SIMPLE.getStream());
    OPERATIONALTEMPLATE operationaltemplate = document.getTemplate();
    WebTemplate webTemplate = new OPTParser(operationaltemplate).parse();
    Composition generate = WebTemplateSkeletonBuilder.build(webTemplate, true);
    assertThat(generate).isNotNull();
    assertThat(generate.getCategory().getDefiningCode()).extracting(CodePhrase::getCodeString, c -> c.getTerminologyId().getValue()).containsExactly("433", "openehr");
    assertThat(generate.itemAtPath("/composer")).isNotNull();
    assertThat(generate.itemAtPath("/context/end_time")).isNotNull();
    assertThat(generate.itemAtPath("/content[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]")).isNotNull();
    assertThat(((Observation) generate.itemAtPath("/content[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]")).getEncoding()).extracting(CodePhrase::getCodeString, c -> c.getTerminologyId().getValue()).containsExactly("UTF-8", "IANA_character-sets");
    assertThat(generate.itemAtPath("/content[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]/data[at0001]/events[at0002]/state[at0007]/items[at1005]/value")).isNotNull();
}
Also used : WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) OPERATIONALTEMPLATE(org.openehr.schemas.v1.OPERATIONALTEMPLATE) Observation(com.nedap.archie.rm.composition.Observation) Tuple(org.assertj.core.groups.Tuple) XmlException(org.apache.xmlbeans.XmlException) Composition(com.nedap.archie.rm.composition.Composition) OperationalTemplateTestData(org.ehrbase.test_data.operationaltemplate.OperationalTemplateTestData) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.junit.Test) IOException(java.io.IOException) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) OPTParser(org.ehrbase.webtemplate.parser.OPTParser) OPERATIONALTEMPLATE(org.openehr.schemas.v1.OPERATIONALTEMPLATE) Composition(com.nedap.archie.rm.composition.Composition) WebTemplate(org.ehrbase.webtemplate.model.WebTemplate) OPTParser(org.ehrbase.webtemplate.parser.OPTParser) Test(org.junit.Test)

Aggregations

Observation (com.nedap.archie.rm.composition.Observation)11 Composition (com.nedap.archie.rm.composition.Composition)10 Test (org.junit.Test)10 WebTemplate (org.ehrbase.webtemplate.model.WebTemplate)8 AdminEntry (com.nedap.archie.rm.composition.AdminEntry)6 IOException (java.io.IOException)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6 Tuple (org.assertj.core.groups.Tuple)6 IntervalEvent (com.nedap.archie.rm.datastructures.IntervalEvent)5 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)5 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)5 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)5 StandardCharsets (java.nio.charset.StandardCharsets)5 OffsetDateTime (java.time.OffsetDateTime)5 ZoneOffset (java.time.ZoneOffset)5 IOUtils (org.apache.commons.io.IOUtils)5 AlternativeEventsComposition (org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.AlternativeEventsComposition)5 CoronaAnamneseComposition (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition)5 EhrbaseBloodPressureSimpleDeV0Composition (org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition)5 EhrbaseMultiOccurrenceDeV1Composition (org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition)5