Search in sources :

Example 1 with CoronaAnamneseCompositionContainment

use of org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment in project openEHR_SDK by ehrbase.

the class CoronaTestIT method testCoronaWithJoin.

@Test
@Ignore
public void testCoronaWithJoin() 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);
    openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0());
    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();
    RisikogebietSectionContainment risikogebietSectionContainment = RisikogebietSectionContainment.getInstance();
    ReisefallObservationContainment reisefallObservationContainment = ReisefallObservationContainment.getInstance();
    // @formatter:off
    ContainmentExpression containmentExpression = coronaAnamneseCompositionContainment.contains(symptomeSectionContainment.contains(hustenObservationContainment).and(risikogebietSectionContainment.contains(reisefallObservationContainment)));
    // @formatter:on
    EntityQuery<Record3<VorhandenDefiningCode, Language, Language>> entityQuery = Query.buildEntityQuery(containmentExpression, hustenObservationContainment.VORHANDEN_DEFINING_CODE, coronaAnamneseCompositionContainment.LANGUAGE, reisefallObservationContainment.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,
              c1/language as F1,
              o2/language as F2
              from EHR e
              contains COMPOSITION c1[openEHR-EHR-COMPOSITION.report.v1] contains (
                                                                                    (SECTION s3[openEHR-EHR-SECTION.adhoc.v1] contains
                                                                                                                                    OBSERVATION o0[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0] )
                                                                                    and
                                                                                    ( SECTION s4[openEHR-EHR-SECTION.adhoc.v1] contains
                                                                                                                                    OBSERVATION o2[openEHR-EHR-OBSERVATION.travel_event.v0] )
                                                                                   )
             where e/ehr_id/value = $parm0
         */
    List<Record3<VorhandenDefiningCode, Language, Language>> actual = openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr));
    assertThat(actual).extracting(Record3::value1, Record3::value2, Record3::value3).containsExactlyInAnyOrder(new Tuple(VorhandenDefiningCode.VORHANDEN, Language.DE, 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) ReisefallObservationContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.ReisefallObservationContainment) Flattener(org.ehrbase.client.flattener.Flattener) SymptomeSectionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.SymptomeSectionContainment) ContainmentExpression(org.ehrbase.client.aql.containment.ContainmentExpression) RisikogebietSectionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.RisikogebietSectionContainment) 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) UUID(java.util.UUID) Record3(org.ehrbase.client.aql.record.Record3) HustenObservationContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.HustenObservationContainment) Tuple(org.assertj.core.groups.Tuple) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with CoronaAnamneseCompositionContainment

use of org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment in project openEHR_SDK by ehrbase.

the class ContainmentExpressionTest method buildAQLContains.

@Test
public void buildAQLContains() {
    CoronaAnamneseCompositionContainment coronaAnamneseCompositionContainment = CoronaAnamneseCompositionContainment.getInstance();
    SymptomeSectionContainment symptomeSectionContainment = SymptomeSectionContainment.getInstance();
    coronaAnamneseCompositionContainment.setContains(symptomeSectionContainment);
    Query.buildEntityQuery(coronaAnamneseCompositionContainment);
    assertThat(coronaAnamneseCompositionContainment.buildAQL()).isEqualTo("COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1] contains SECTION s1[openEHR-EHR-SECTION.adhoc.v1]");
}
Also used : CoronaAnamneseCompositionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment) SymptomeSectionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.SymptomeSectionContainment) Test(org.junit.Test)

Example 3 with CoronaAnamneseCompositionContainment

use of org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment in project openEHR_SDK by ehrbase.

the class ContainmentExpressionTest method buildAQLOr.

@Test
public void buildAQLOr() {
    CoronaAnamneseCompositionContainment coronaAnamneseCompositionContainment = CoronaAnamneseCompositionContainment.getInstance();
    SymptomeSectionContainment symptomeSectionContainment = SymptomeSectionContainment.getInstance();
    AllgemeineAngabenSectionContainment allgemeineAngabenSectionContainment = AllgemeineAngabenSectionContainment.getInstance();
    coronaAnamneseCompositionContainment.setContains(ContainmentExpression.or(allgemeineAngabenSectionContainment, symptomeSectionContainment));
    Query.buildEntityQuery(coronaAnamneseCompositionContainment);
    assertThat(coronaAnamneseCompositionContainment.buildAQL()).isEqualTo("COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1] contains (SECTION s1[openEHR-EHR-SECTION.adhoc.v1] or SECTION s2[openEHR-EHR-SECTION.adhoc.v1])");
}
Also used : AllgemeineAngabenSectionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.AllgemeineAngabenSectionContainment) CoronaAnamneseCompositionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment) SymptomeSectionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.SymptomeSectionContainment) Test(org.junit.Test)

Example 4 with CoronaAnamneseCompositionContainment

use of org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment 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)

Example 5 with CoronaAnamneseCompositionContainment

use of org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment in project openEHR_SDK by ehrbase.

the class ContainmentExpressionTest method buildAQLAnd.

@Test
public void buildAQLAnd() {
    CoronaAnamneseCompositionContainment coronaAnamneseCompositionContainment = CoronaAnamneseCompositionContainment.getInstance();
    SymptomeSectionContainment symptomeSectionContainment = SymptomeSectionContainment.getInstance();
    AllgemeineAngabenSectionContainment allgemeineAngabenSectionContainment = AllgemeineAngabenSectionContainment.getInstance();
    coronaAnamneseCompositionContainment.setContains(ContainmentExpression.and(allgemeineAngabenSectionContainment, symptomeSectionContainment));
    Query.buildEntityQuery(coronaAnamneseCompositionContainment);
    assertThat(coronaAnamneseCompositionContainment.buildAQL()).isEqualTo("COMPOSITION c0[openEHR-EHR-COMPOSITION.report.v1] contains (SECTION s1[openEHR-EHR-SECTION.adhoc.v1] and SECTION s2[openEHR-EHR-SECTION.adhoc.v1])");
}
Also used : AllgemeineAngabenSectionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.AllgemeineAngabenSectionContainment) CoronaAnamneseCompositionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment) SymptomeSectionContainment(org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.definition.SymptomeSectionContainment) Test(org.junit.Test)

Aggregations

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