use of org.ehrbase.client.aql.field.NativeSelectAqlField in project openEHR_SDK by ehrbase.
the class DefaultRestFolderDAO method find.
@Override
public <T> List<T> find(Class<T> clazz) {
Containment compositionContainment = new Containment("COMPOSITION");
EntityQuery<Record1<T>> query = Query.buildEntityQuery(compositionContainment, new NativeSelectAqlField<>(compositionContainment, "", clazz));
query.where(Condition.equal(EhrFields.EHR_ID(), directoryEndpoint.getEhrId()).and(Condition.equal(new NativeSelectAqlField<>(compositionContainment, "/template_id", String.class), extractTemplateId(clazz))).and(Condition.matches(new NativeSelectAqlField<>(compositionContainment, "/uid/value", String.class), getFolder().getItems().stream().map(ObjectRef::getId).map(Object::toString).toArray(String[]::new))));
List<Record1<T>> execute = directoryEndpoint.getDefaultRestClient().aqlEndpoint().execute(query);
return execute.stream().map(Record1::value1).collect(Collectors.toList());
}
use of org.ehrbase.client.aql.field.NativeSelectAqlField 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.aql.field.NativeSelectAqlField in project openEHR_SDK by ehrbase.
the class AqlTestIT method testExecute12.
@Test
public void testExecute12() {
ehr = openEhrClient.ehrEndpoint().createEhr();
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildEhrbaseBloodPressureSimpleDeV0());
EhrbaseBloodPressureSimpleDeV0Composition pressureSimple1 = TestData.buildEhrbaseBloodPressureSimpleDeV0();
pressureSimple1.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1);
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple1);
EhrbaseBloodPressureSimpleDeV0Composition pressureSimple2 = TestData.buildEhrbaseBloodPressureSimpleDeV0();
pressureSimple2.getBloodPressureTrainingSample().get(0).setSystolicMagnitude(1.1);
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(pressureSimple2);
Containment observationContainment = new Containment("OBSERVATION");
NativeSelectAqlField<Double> magnitudeField = new NativeSelectAqlField<>(observationContainment, "/data[at0001]/events[at0002]/data[at0003]/items[at0004]/value/magnitude", Double.class);
EntityQuery<Record2<UUID, Double>> entityQuery = Query.buildEntityQuery(observationContainment, EhrFields.EHR_ID(), magnitudeField);
Parameter<UUID> ehrIdParameter = entityQuery.buildParameter();
entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter).and(Condition.equal(magnitudeField, 1.1d)));
List<Record2<UUID, Double>> result = openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr));
assertThat(result).isNotNull().size().isEqualTo(1);
}
Aggregations