Search in sources :

Example 1 with Record4

use of org.ehrbase.client.aql.record.Record4 in project openEHR_SDK by ehrbase.

the class CoronaTestIT method testCorona.

@Test
@Ignore("see https://github.com/ehrbase/project_management/issues/376")
public void testCorona() throws IOException {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.CORONA.getStream(), StandardCharsets.UTF_8), Composition.class);
    Flattener flattener = new Flattener(new TestDataTemplateProvider());
    CoronaAnamneseComposition coronaAnamneseComposition = flattener.flatten(composition, CoronaAnamneseComposition.class);
    openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(coronaAnamneseComposition);
    assertThat(openEhrClient.compositionEndpoint(ehr).find(coronaAnamneseComposition.getVersionUid().getUuid(), CoronaAnamneseComposition.class)).isNotNull();
    CoronaAnamneseCompositionContainment coronaAnamneseCompositionContainment = CoronaAnamneseCompositionContainment.getInstance();
    SymptomeSectionContainment symptomeSectionContainment = SymptomeSectionContainment.getInstance();
    HustenObservationContainment hustenObservationContainment = HustenObservationContainment.getInstance();
    FieberOderErhohteKorpertemperaturObservationContainment fieberOderErhohteKorpertemperaturObservationContainment = FieberOderErhohteKorpertemperaturObservationContainment.getInstance();
    HeiserkeitObservationContainment heiserkeitObservationContainment = HeiserkeitObservationContainment.getInstance();
    ContainmentExpression containmentExpression = coronaAnamneseCompositionContainment.contains(symptomeSectionContainment).contains(hustenObservationContainment.and(fieberOderErhohteKorpertemperaturObservationContainment).and(heiserkeitObservationContainment));
    EntityQuery<Record4<VorhandenDefiningCode, VorhandenDefiningCode, VorhandenDefiningCode, Language>> entityQuery = Query.buildEntityQuery(containmentExpression, hustenObservationContainment.VORHANDEN_DEFINING_CODE, fieberOderErhohteKorpertemperaturObservationContainment.VORHANDEN_DEFINING_CODE, heiserkeitObservationContainment.VORHANDEN_DEFINING_CODE, coronaAnamneseCompositionContainment.LANGUAGE);
    Parameter<UUID> ehrIdParameter = entityQuery.buildParameter();
    entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter));
    /*
        Select
              o0/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/defining_Code as F0,
              o1/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/defining_Code as F1,
              o2/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/defining_Code as F2,
              c3/language as F3
        from EHR e
              contains ( COMPOSITION c3[openEHR-EHR-COMPOSITION.report.v1] contains
               SECTION s4[openEHR-EHR-SECTION.adhoc.v1] contains
                (
                (OBSERVATION o0[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0]
                and
                OBSERVATION o1[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0])
                and
                OBSERVATION o2[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0])
                )
        where e/ehr_id/value = $parm0
         */
    List<Record4<VorhandenDefiningCode, VorhandenDefiningCode, VorhandenDefiningCode, Language>> actual = openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr));
    assertThat(actual).extracting(Record4::value1, Record4::value2, Record4::value3, Record4::value4).containsExactlyInAnyOrder(new Tuple(VorhandenDefiningCode.VORHANDEN, VorhandenDefiningCode.VORHANDEN, VorhandenDefiningCode.NICHT_VORHANDEN, Language.DE));
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CoronaAnamneseComposition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition) VirologischerBefundComposition(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) Flattener(org.ehrbase.client.flattener.Flattener) SymptomeSectionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.SymptomeSectionContainment) ContainmentExpression(org.ehrbase.client.aql.containment.ContainmentExpression) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider) CoronaAnamneseComposition(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition) HeiserkeitObservationContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.HeiserkeitObservationContainment) FieberOderErhohteKorpertemperaturObservationContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.FieberOderErhohteKorpertemperaturObservationContainment) CoronaAnamneseCompositionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment) Record4(org.ehrbase.client.aql.record.Record4) UUID(java.util.UUID) HustenObservationContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.HustenObservationContainment) Tuple(org.assertj.core.groups.Tuple) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Composition (com.nedap.archie.rm.composition.Composition)1 UUID (java.util.UUID)1 Tuple (org.assertj.core.groups.Tuple)1 ContainmentExpression (org.ehrbase.client.aql.containment.ContainmentExpression)1 Record4 (org.ehrbase.client.aql.record.Record4)1 CoronaAnamneseComposition (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition)1 CoronaAnamneseCompositionContainment (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment)1 FieberOderErhohteKorpertemperaturObservationContainment (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.FieberOderErhohteKorpertemperaturObservationContainment)1 HeiserkeitObservationContainment (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.HeiserkeitObservationContainment)1 HustenObservationContainment (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.HustenObservationContainment)1 SymptomeSectionContainment (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.SymptomeSectionContainment)1 VirologischerBefundComposition (org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition)1 Flattener (org.ehrbase.client.flattener.Flattener)1 TestDataTemplateProvider (org.ehrbase.client.templateprovider.TestDataTemplateProvider)1 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)1 CompositionTestDataCanonicalJson (org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1