Search in sources :

Example 1 with Record3

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

the class DefaultRestAqlEndpointTestIT method testExecuteEntityQuery.

@Test
public void testExecuteEntityQuery() {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    EhrbaseBloodPressureSimpleDeV0Composition comp1 = openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0());
    EhrbaseBloodPressureSimpleDeV0Composition comp2 = openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0());
    EhrbaseBloodPressureSimpleDeV0CompositionContainment containmentComposition = EhrbaseBloodPressureSimpleDeV0CompositionContainment.getInstance();
    BloodPressureTrainingSampleObservationContainment containmentObservation = BloodPressureTrainingSampleObservationContainment.getInstance();
    containmentComposition.setContains(containmentObservation);
    EntityQuery<Record3<TemporalAccessor, BloodPressureTrainingSampleObservation, CuffSizeDefiningCode>> entityQuery = Query.buildEntityQuery(containmentComposition, containmentComposition.START_TIME_VALUE, containmentObservation.BLOOD_PRESSURE_TRAINING_SAMPLE_OBSERVATION, containmentObservation.CUFF_SIZE_DEFINING_CODE);
    Parameter<UUID> ehrIdParameter = entityQuery.buildParameter();
    entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter));
    List<Record3<TemporalAccessor, BloodPressureTrainingSampleObservation, CuffSizeDefiningCode>> actual = openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr));
    assertThat(actual).size().isEqualTo(2);
    Record3<TemporalAccessor, BloodPressureTrainingSampleObservation, CuffSizeDefiningCode> record1 = actual.get(0);
    assertThat(record1.value1()).isEqualTo(OffsetDateTime.of(2019, 04, 03, 22, 00, 00, 00, ZoneOffset.UTC));
    assertThat(record1.value2().getKorotkoffSoundsDefiningCode()).isEqualTo(KorotkoffSoundsDefiningCode.FIFTH_SOUND);
    assertThat(record1.value3()).isEqualTo(CuffSizeDefiningCode.ADULT);
}
Also used : BloodPressureTrainingSampleObservation(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.definition.BloodPressureTrainingSampleObservation) BloodPressureTrainingSampleObservationContainment(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.definition.BloodPressureTrainingSampleObservationContainment) TemporalAccessor(java.time.temporal.TemporalAccessor) EhrbaseBloodPressureSimpleDeV0Composition(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0Composition) UUID(java.util.UUID) CuffSizeDefiningCode(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.definition.CuffSizeDefiningCode) Record3(org.ehrbase.client.aql.record.Record3) EhrbaseBloodPressureSimpleDeV0CompositionContainment(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0CompositionContainment) Test(org.junit.Test)

Example 2 with Record3

use of org.ehrbase.client.aql.record.Record3 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 3 with Record3

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

the class CoronaTestIT method testNUMResearchCase_1_2.

/**
 * see https://wiki.vitagroup.ag/display/NUM/Research+Repository
 * containment test:
 *     contains COMPOSITION c[openEHR-EHR-COMPOSITION.event_summary.v0]
 *         contains ADMIN_ENTRY m[openEHR-EHR-ADMIN_ENTRY.hospitalization.v0]
 *              contains CLUSTER k[openEHR-EHR-CLUSTER.location.v1]
 */
@Test
public void testNUMResearchCase_1_2() {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildTestPatientenaufenthaltComposition());
    // build AQL
    PatientenaufenthaltCompositionContainment patientenaufenthaltCompositionContainment = PatientenaufenthaltCompositionContainment.getInstance();
    VersorgungsortAdminEntryContainment versorgungsortAdminEntryContainment = VersorgungsortAdminEntryContainment.getInstance();
    StandortClusterContainment standortClusterContainment = StandortClusterContainment.getInstance();
    versorgungsortAdminEntryContainment.setContains(standortClusterContainment);
    patientenaufenthaltCompositionContainment.setContains(versorgungsortAdminEntryContainment);
    // select set values from test data
    EntityQuery<Record3<String, String, StandortschlusselDefiningCode>> entityQuery = Query.buildEntityQuery(patientenaufenthaltCompositionContainment, standortClusterContainment.STANDORTTYP_VALUE, standortClusterContainment.STANDORTBESCHREIBUNG_VALUE, standortClusterContainment.STANDORTSCHLUSSEL_DEFINING_CODE);
    Parameter<UUID> ehrIdParameter = entityQuery.buildParameter();
    entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter));
    List<Record3<String, String, StandortschlusselDefiningCode>> actual = openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr));
    assertThat(actual).extracting(Record3::value1, Record3::value2, Record3::value3).containsExactlyInAnyOrder(new Tuple("Test", "Beschreibung", StandortschlusselDefiningCode.ANGIOLOGIE));
}
Also used : StandortClusterContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.StandortClusterContainment) VersorgungsortAdminEntryContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.VersorgungsortAdminEntryContainment) PatientenaufenthaltCompositionContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.PatientenaufenthaltCompositionContainment) UUID(java.util.UUID) Record3(org.ehrbase.client.aql.record.Record3) Tuple(org.assertj.core.groups.Tuple) Test(org.junit.Test)

Example 4 with Record3

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

the class EntityQueryTest method buildAqlWithNativePath.

@Test
public void buildAqlWithNativePath() {
    BefundObservationContainment befundObservationContainment = BefundObservationContainment.getInstance();
    ProVirusClusterContainment proVirusClusterContainment = ProVirusClusterContainment.getInstance();
    ProbeClusterContainment probeClusterContainment = ProbeClusterContainment.getInstance();
    Containment compositionContainment = new Containment("COMPOSITION");
    ContainmentExpression containment = compositionContainment.contains(befundObservationContainment).contains(proVirusClusterContainment.and(probeClusterContainment));
    EntityQuery<Record3<String, TemporalAccessor, UUID>> entityQuery = Query.buildEntityQuery(containment, proVirusClusterContainment.VIRUS_VALUE, probeClusterContainment.ZEITPUNKT_DER_PROBENENTNAHME_VALUE, new NativeSelectAqlField<>(compositionContainment, "/uid/value", "uid", UUID.class));
    entityQuery.where(Condition.equal(new NativeSelectAqlField<>(compositionContainment, "/name/value", String.class), "Mikrobiologischer Befund"));
    assertThat(entityQuery.buildAql()).isEqualTo("Select c0/items[at0024]/value/value as virusValue, c1/items[at0015]/value/value as zeitpunktDerProbenentnahmeValue, c2/uid/value as uid " + "from EHR e " + "contains COMPOSITION c2 " + "contains OBSERVATION o3[openEHR-EHR-OBSERVATION.laboratory_test_result.v1] " + "contains (CLUSTER c0[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1] and CLUSTER c1[openEHR-EHR-CLUSTER.specimen.v1]) " + "where c2/name/value = 'Mikrobiologischer Befund'");
}
Also used : ProbeClusterContainment(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProbeClusterContainment) NativeSelectAqlField(org.ehrbase.client.aql.field.NativeSelectAqlField) ContainmentExpression(org.ehrbase.client.aql.containment.ContainmentExpression) UUID(java.util.UUID) Record3(org.ehrbase.client.aql.record.Record3) BefundObservationContainment(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.BefundObservationContainment) ProVirusClusterContainment(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProVirusClusterContainment) EhrbaseBloodPressureSimpleDeV0CompositionContainment(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0CompositionContainment) ProVirusClusterContainment(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProVirusClusterContainment) ProbeClusterContainment(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProbeClusterContainment) Containment(org.ehrbase.client.aql.containment.Containment) BefundObservationContainment(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.BefundObservationContainment) BloodPressureTrainingSampleObservationContainment(org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.definition.BloodPressureTrainingSampleObservationContainment) Test(org.junit.Test)

Example 5 with Record3

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

the class CoronaTestIT method testNUMResearchCase_5.

/**
 * see https://wiki.vitagroup.ag/display/NUM/Research+Repository
 *
 * Containment test:
 *
 * contains COMPOSITION c[openEHR-EHR-COMPOSITION.event_summary.v0]
 * contains
 * (CLUSTER n[openEHR-EHR-CLUSTER.case_identification.v0]
 * and ADMIN_ENTRY u[openEHR-EHR-ADMIN_ENTRY.hospitalization.v0]
 * contains (CLUSTER a[openEHR-EHR-CLUSTER.location.v1]))
 */
@Test
public void testNUMResearchCase_5() {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildTestPatientenaufenthaltComposition());
    // build AQL
    PatientenaufenthaltCompositionContainment patientenaufenthaltCompositionContainment = PatientenaufenthaltCompositionContainment.getInstance();
    AbteilungsfallClusterContainment abteilungsfallClusterContainment = AbteilungsfallClusterContainment.getInstance();
    VersorgungsortAdminEntryContainment versorgungsortAdminEntryContainment = VersorgungsortAdminEntryContainment.getInstance();
    StandortClusterContainment standortClusterContainment = StandortClusterContainment.getInstance();
    ContainmentExpression containmentExpression = patientenaufenthaltCompositionContainment.contains(abteilungsfallClusterContainment.and(versorgungsortAdminEntryContainment.contains(standortClusterContainment)));
    // select set values from test data
    EntityQuery<Record3<TemporalAccessor, TemporalAccessor, String>> entityQuery = Query.buildEntityQuery(containmentExpression, versorgungsortAdminEntryContainment.BEGINN_VALUE, versorgungsortAdminEntryContainment.ENDE_VALUE, versorgungsortAdminEntryContainment.GRUND_DES_AUFENTHALTES_VALUE);
    Parameter<UUID> ehrIdParameter = entityQuery.buildParameter();
    entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter));
    List<Record3<TemporalAccessor, TemporalAccessor, String>> actual = openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr));
    assertThat(actual).extracting(Record3::value1, Record3::value2, Record3::value3).containsExactlyInAnyOrder(new Tuple(new DvDateTime("2020-01-01T10:00Z").getValue(), new DvDateTime("2020-01-01T12:00Z").getValue(), "test value"));
}
Also used : AbteilungsfallClusterContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.AbteilungsfallClusterContainment) StandortClusterContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.StandortClusterContainment) VersorgungsortAdminEntryContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.VersorgungsortAdminEntryContainment) ContainmentExpression(org.ehrbase.client.aql.containment.ContainmentExpression) PatientenaufenthaltCompositionContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.PatientenaufenthaltCompositionContainment) UUID(java.util.UUID) Record3(org.ehrbase.client.aql.record.Record3) Tuple(org.assertj.core.groups.Tuple) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test)

Aggregations

Record3 (org.ehrbase.client.aql.record.Record3)8 Test (org.junit.Test)8 UUID (java.util.UUID)7 Tuple (org.assertj.core.groups.Tuple)4 ContainmentExpression (org.ehrbase.client.aql.containment.ContainmentExpression)4 EhrbaseBloodPressureSimpleDeV0CompositionContainment (org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.EhrbaseBloodPressureSimpleDeV0CompositionContainment)3 BloodPressureTrainingSampleObservationContainment (org.ehrbase.client.classgenerator.examples.ehrbasebloodpressuresimpledev0composition.definition.BloodPressureTrainingSampleObservationContainment)3 Composition (com.nedap.archie.rm.composition.Composition)2 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)2 PatientenaufenthaltCompositionContainment (org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.PatientenaufenthaltCompositionContainment)2 StandortClusterContainment (org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.StandortClusterContainment)2 VersorgungsortAdminEntryContainment (org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.VersorgungsortAdminEntryContainment)2 CanonicalJson (org.ehrbase.serialisation.jsonencoding.CanonicalJson)2 CompositionTestDataCanonicalJson (org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson)2 TemporalAccessor (java.time.temporal.TemporalAccessor)1 Containment (org.ehrbase.client.aql.containment.Containment)1 ContainmentPath (org.ehrbase.client.aql.containment.ContainmentPath)1 NativeSelectAqlField (org.ehrbase.client.aql.field.NativeSelectAqlField)1 CoronaAnamneseComposition (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseComposition)1 CoronaAnamneseCompositionContainment (org.ehrbase.client.classgenerator.examples.coronaanamnesecomposition.CoronaAnamneseCompositionContainment)1