Search in sources :

Example 6 with DvQuantity

use of com.nedap.archie.rm.datavalues.quantity.DvQuantity 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 DvQuantity

use of com.nedap.archie.rm.datavalues.quantity.DvQuantity in project openEHR_SDK by ehrbase.

the class UnflattenerTest method testUnflattenSingleEvent.

@Test
public void testUnflattenSingleEvent() {
    Unflattener cut = new Unflattener(new TestDataTemplateProvider());
    KorpergrosseComposition dto = new KorpergrosseComposition();
    dto.setGrosseLange(new GrosseLangeObservation());
    dto.getGrosseLange().setGrosseLangeMagnitude(22d);
    Composition rmObject = (Composition) cut.unflatten(dto);
    assertThat(rmObject).isNotNull();
    Object event = rmObject.itemAtPath("/content[openEHR-EHR-OBSERVATION.height.v2]/data[at0001]/events[at0002]");
    assertThat(event).isNotNull();
    assertThat(event.getClass()).isEqualTo(PointEvent.class);
    Object quantity = ((PointEvent) event).itemAtPath("/data[at0003]/items[at0004]/value");
    assertThat(quantity).isNotNull();
    assertThat(quantity.getClass()).isEqualTo(DvQuantity.class);
    assertThat(((DvQuantity) quantity).getMagnitude()).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) 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) DvQuantity(com.nedap.archie.rm.datavalues.quantity.DvQuantity) PointEvent(com.nedap.archie.rm.datastructures.PointEvent) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) Test(org.junit.Test)

Example 8 with DvQuantity

use of com.nedap.archie.rm.datavalues.quantity.DvQuantity in project openEHR_SDK by ehrbase.

the class NumericTestsIT method setUp.

@Before
public void setUp() throws IOException {
    super.setUp(null);
    // build a number of compositions with different DvQuantity values and different names
    aComposition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.MINIMAL_EVAL.getStream(), StandardCharsets.UTF_8), Composition.class);
    for (int i = 0; i < 10; i++) {
        Element element = (Element) aComposition.itemsAtPath("/content[openEHR-EHR-EVALUATION.minimal.v1]/data[at0001]/items[at0002]").get(0);
        element.setValue(new DvQuantity("kg", Double.valueOf("" + (i + 1)), 0L));
        element.setName(new DvText("value-" + i + 1));
        Flattener flattener = new Flattener(new TestDataTemplateProvider());
        MinimalEvaluationEnV1Composition minimalEvaluationEnV1Composition = flattener.flatten(aComposition, MinimalEvaluationEnV1Composition.class);
        // create the composition
        MinimalEvaluationEnV1Composition comp = compositionEndpoint.mergeCompositionEntity(minimalEvaluationEnV1Composition);
    }
    numericQuery = new NumericQuery(ehrUUID, openEhrClient);
}
Also used : NumericQuery(org.ehrbase.client.openehrclient.defaultrestclient.systematic.compositionquery.queries.arbitrary.NumericQuery) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) Composition(com.nedap.archie.rm.composition.Composition) MinimalEvaluationEnV1Composition(org.ehrbase.client.classgenerator.examples.minimalevaluationenv1composition.MinimalEvaluationEnV1Composition) DvQuantity(com.nedap.archie.rm.datavalues.quantity.DvQuantity) Element(com.nedap.archie.rm.datastructures.Element) Flattener(org.ehrbase.client.flattener.Flattener) MinimalEvaluationEnV1Composition(org.ehrbase.client.classgenerator.examples.minimalevaluationenv1composition.MinimalEvaluationEnV1Composition) DvText(com.nedap.archie.rm.datavalues.DvText) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) Before(org.junit.Before)

Example 9 with DvQuantity

use of com.nedap.archie.rm.datavalues.quantity.DvQuantity in project openEHR_SDK by ehrbase.

the class DvQuantityValidatorTest method testValidate_List.

@Test
void testValidate_List() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_quantity_list.json");
    var result = validator.validate(new DvQuantity("kg", 100.0, 1L), node);
    assertTrue(result.isEmpty());
    result = validator.validate(new DvQuantity("g", 100.0, 1L), node);
    assertEquals(1, result.size());
}
Also used : DvQuantity(com.nedap.archie.rm.datavalues.quantity.DvQuantity) Test(org.junit.jupiter.api.Test)

Example 10 with DvQuantity

use of com.nedap.archie.rm.datavalues.quantity.DvQuantity in project openEHR_SDK by ehrbase.

the class DvQuantityValidatorTest method testValidate_ListValidation.

@Test
void testValidate_ListValidation() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_quantity_list_validation.json");
    var result = validator.validate(new DvQuantity("kg", 100.0, 1L), node);
    assertTrue(result.isEmpty());
    result = validator.validate(new DvQuantity("lb", 300.0, 1L), node);
    assertTrue(result.isEmpty());
    result = validator.validate(new DvQuantity("kg", 300.0, 1L), node);
    assertEquals(1, result.size());
    result = validator.validate(new DvQuantity("lb", 500.0, 1L), node);
    assertEquals(1, result.size());
    result = validator.validate(new DvQuantity("lb", 300.00, 2L), node);
    assertEquals(1, result.size());
}
Also used : DvQuantity(com.nedap.archie.rm.datavalues.quantity.DvQuantity) Test(org.junit.jupiter.api.Test)

Aggregations

DvQuantity (com.nedap.archie.rm.datavalues.quantity.DvQuantity)10 Composition (com.nedap.archie.rm.composition.Composition)7 Test (org.junit.Test)6 Element (com.nedap.archie.rm.datastructures.Element)4 PointEvent (com.nedap.archie.rm.datastructures.PointEvent)4 DvText (com.nedap.archie.rm.datavalues.DvText)4 AlternativeEventsComposition (org.ehrbase.client.classgenerator.examples.alternativeeventscomposition.AlternativeEventsComposition)4 BefundDerBlutgasanalyseComposition (org.ehrbase.client.classgenerator.examples.befundderblutgasanalysecomposition.BefundDerBlutgasanalyseComposition)4 CoronaAnamneseComposition (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition)4 EhrbaseBloodPressureSimpleDeV0Composition (org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition)4 EhrbaseMultiOccurrenceDeV1Composition (org.ehrbase.client.classgenerator.examples.ehrbasemultioccurrencedev1composition.EhrbaseMultiOccurrenceDeV1Composition)4 EpisodeOfCareComposition (org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition)4 TestDataTemplateProvider (org.ehrbase.client.templateprovider.TestDataTemplateProvider)4 Locatable (com.nedap.archie.rm.archetyped.Locatable)3 AdminEntry (com.nedap.archie.rm.composition.AdminEntry)3 Observation (com.nedap.archie.rm.composition.Observation)3 IntervalEvent (com.nedap.archie.rm.datastructures.IntervalEvent)3 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)3 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)3 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)3