use of org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.BefundObservationContainment 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'");
}
use of org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.BefundObservationContainment in project openEHR_SDK by ehrbase.
the class CoronaTestIT method testNUMResearchCase_8.
/**
* see https://wiki.vitagroup.ag/display/NUM/Research+Repository
*
* Containment test UC 8:
*
* contains COMPOSITION c
* contains OBSERVATION v[openEHR-EHR-OBSERVATION.laboratory_test_result.v1]
* contains (
* CLUSTER h[openEHR-EHR-CLUSTER.laboratory_test_panel.v0] and
* CLUSTER x[openEHR-EHR-CLUSTER.specimen.v1] and
* CLUSTER q[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1])
*/
@Test
public void testNUMResearchCase_8() {
VirologischerBefundComposition virologischerBefundComposition = TestData.buildTestVirologischerBefundComposition();
assertThat(virologischerBefundComposition.getBefund()).isNotNull();
ehr = openEhrClient.ehrEndpoint().createEhr();
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(virologischerBefundComposition);
// build AQL expression
Containment compositionContainment = new Containment("COMPOSITION");
BefundObservationContainment befundObservationContainment = BefundObservationContainment.getInstance();
ProbeClusterContainment probeClusterContainment = ProbeClusterContainment.getInstance();
KulturClusterContainment kulturClusterContainment = KulturClusterContainment.getInstance();
ProVirusClusterContainment proVirusClusterContainment = ProVirusClusterContainment.getInstance();
ContainmentExpression containmentExpression = compositionContainment.contains(befundObservationContainment.contains(kulturClusterContainment.and(probeClusterContainment.and(proVirusClusterContainment))));
EntityQuery<Record2<String, Long>> entityQuery = Query.buildEntityQuery(containmentExpression, proVirusClusterContainment.VIRUS_VALUE, proVirusClusterContainment.ANALYSEERGEBNIS_REIHENFOLGE_MAGNITUDE);
Parameter<UUID> ehrIdParameter = entityQuery.buildParameter();
entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter).and(Condition.equal(new NativeSelectAqlField<>(compositionContainment, "/name/value", String.class), "Virologischer Befund")));
List<Record2<String, Long>> actual = openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr));
// NB. At the moment, we cannot specify DISTINCT with SDK
assertThat(actual).extracting(Record2::value1, Record2::value2).containsExactlyInAnyOrder(new Tuple("SARS-Cov-2", 32L), new Tuple("SARS-Cov-2", 34L), new Tuple("SARS-Cov-2", 32L), new Tuple("SARS-Cov-2", 34L));
}
Aggregations