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));
}
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]");
}
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])");
}
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));
}
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])");
}
Aggregations