use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class FlattenerTest method testFlattenCorona.
@Test
public void testFlattenCorona() throws IOException {
Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.CORONA.getStream(), StandardCharsets.UTF_8), Composition.class);
Flattener cut = new Flattener(new TestDataTemplateProvider());
CoronaAnamneseComposition actual = cut.flatten(composition, CoronaAnamneseComposition.class);
assertThat(actual).isNotNull();
assertThat(actual.getSymptome()).isNotNull();
assertThat(actual.getSymptome().getHeiserkeit()).isNotNull();
assertThat(actual.getSymptome().getHeiserkeit().getVorhandenDefiningCode()).isEqualTo(VorhandenDefiningCode.NICHT_VORHANDEN);
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class FlattenerTest method testFlattenAltEvents.
@Test
public void testFlattenAltEvents() {
Composition composition = (Composition) new Unflattener(new TestDataTemplateProvider()).unflatten(buildAlternativeEventsComposition());
Flattener cut = new Flattener(new TestDataTemplateProvider());
AlternativeEventsComposition actual = cut.flatten(composition, AlternativeEventsComposition.class);
assertThat(actual).isNotNull();
assertThat(actual.getKorpergewicht()).size().isEqualTo(1);
KorpergewichtBirthEnPointEvent birthEn = actual.getKorpergewicht().get(0).getBirthEn();
assertThat(birthEn.getTimeValue()).isEqualTo(OffsetDateTime.of(1990, 11, 2, 12, 0, 0, 0, ZoneOffset.UTC));
assertThat(birthEn.getGewichtMagnitude()).isEqualTo(30d);
assertThat(birthEn.getGewichtUnits()).isEqualTo("kg");
List<KorpergewichtAnyEventEnPointEvent> eventEnPointEvents = actual.getKorpergewicht().get(0).getAnyEventEn().stream().filter(e -> KorpergewichtAnyEventEnPointEvent.class.isAssignableFrom(e.getClass())).map(e -> (KorpergewichtAnyEventEnPointEvent) e).collect(Collectors.toList());
assertThat(eventEnPointEvents).size().isEqualTo(1);
assertThat(eventEnPointEvents.get(0).getTimeValue()).isEqualTo(OffsetDateTime.of(2013, 11, 2, 12, 0, 0, 0, ZoneOffset.UTC));
assertThat(eventEnPointEvents.get(0).getGewichtMagnitude()).isEqualTo(55d);
assertThat(eventEnPointEvents.get(0).getGewichtUnits()).isEqualTo("kg");
List<KorpergewichtAnyEventEnIntervalEvent> anyEventEnIntervalEvents = actual.getKorpergewicht().get(0).getAnyEventEn().stream().filter(e -> KorpergewichtAnyEventEnIntervalEvent.class.isAssignableFrom(e.getClass())).map(e -> (KorpergewichtAnyEventEnIntervalEvent) e).collect(Collectors.toList());
assertThat(eventEnPointEvents).size().isEqualTo(1);
assertThat(anyEventEnIntervalEvents.get(0).getTimeValue()).isEqualTo(OffsetDateTime.of(2015, 11, 2, 12, 0, 0, 0, ZoneOffset.UTC));
assertThat(anyEventEnIntervalEvents.get(0).getGewichtMagnitude()).isEqualTo(60d);
assertThat(anyEventEnIntervalEvents.get(0).getGewichtUnits()).isEqualTo("kg");
assertThat(anyEventEnIntervalEvents.get(0).getMathFunctionDefiningCode()).isEqualTo(MathFunction.MEAN);
assertThat(anyEventEnIntervalEvents.get(0).getWidthValue()).isEqualTo(Duration.ofDays(30));
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class FlattenerTest method testFlattenSingleEventPointEvent.
@Test
public void testFlattenSingleEventPointEvent() {
Unflattener unflattener = new Unflattener(new TestDataTemplateProvider());
KorpergrosseComposition dto = new KorpergrosseComposition();
dto.setGrosseLange(new GrosseLangeObservation());
dto.getGrosseLange().setGrosseLangeMagnitude(22d);
Composition rmObject = (Composition) unflattener.unflatten(dto);
assertThat(rmObject).isNotNull();
Flattener cut = new Flattener(new TestDataTemplateProvider());
KorpergrosseComposition actual = cut.flatten(rmObject, KorpergrosseComposition.class);
assertThat(actual.getGrosseLange().getGrosseLangeMagnitude()).isEqualTo(22d);
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class AqlTestIT method testExecute13.
@Test
public void testExecute13() 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);
coronaAnamneseComposition.setVersionUid(null);
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(coronaAnamneseComposition);
Query query = Query.buildNativeQuery("Select DISTINCT " + " o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value as var1, o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value as var2 " + " from EHR e[ehr_id/value = $ehr_id] " + " contains COMPOSITION c3[openEHR-EHR-COMPOSITION.report.v1]" + " contains SECTION s4[openEHR-EHR-SECTION.adhoc.v1]" + " contains OBSERVATION o[openEHR-EHR-OBSERVATION.symptom_sign_screening.v0]" + " WHERE" + " o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0005]/value/value is not null " + " AND" + " o/data[at0001]/events[at0002]/data[at0003]/items[at0022]/items[at0004]/value/value is not null");
QueryResponseData result = openEhrClient.aqlEndpoint().executeRaw(query, new ParameterValue("ehr_id", ehr));
assertNotNull(result);
assertNotNull(result.getQuery());
assertNotNull(result.getRows());
assertNotNull(result.getColumns());
assertEquals(14, result.getRows().size());
assertEquals(2, result.getColumns().size());
List expectedResults = Arrays.asList(List.of("Nicht vorhanden", "Durchfall"), List.of("Nicht vorhanden", "Fieber oder erhöhte Körpertemperatur"), List.of("Nicht vorhanden", "gestörter Geruchssinn"), List.of("Nicht vorhanden", "gestörter Geschmackssinn"), List.of("Nicht vorhanden", "Heiserkeit"), List.of("Nicht vorhanden", "Husten"), List.of("Nicht vorhanden", "Schnupfen"), List.of("Vorhanden", "Durchfall"), List.of("Vorhanden", "Fieber oder erhöhte Körpertemperatur"), List.of("Vorhanden", "gestörter Geruchssinn"), List.of("Vorhanden", "gestörter Geschmackssinn"), List.of("Vorhanden", "Heiserkeit"), List.of("Vorhanden", "Husten"), List.of("Vorhanden", "Schnupfen"));
assertTrue(CollectionUtils.isEqualCollection(result.getRows(), expectedResults));
}
use of com.nedap.archie.rm.composition.Composition 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));
}
Aggregations