use of org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition in project openEHR_SDK by ehrbase.
the class TestData method buildTestVirologischerBefundComposition.
public static VirologischerBefundComposition buildTestVirologischerBefundComposition() {
// openEHR-EHR-COMPOSITION.report-result.v1
VirologischerBefundComposition virologischerBefundComposition = new VirologischerBefundComposition();
virologischerBefundComposition.setComposer(new PartyIdentified(null, "Test", null));
virologischerBefundComposition.setCategoryDefiningCode(Category.EVENT);
virologischerBefundComposition.setLanguage(Language.DE);
virologischerBefundComposition.setTerritory(Territory.DE);
virologischerBefundComposition.setStartTimeValue(OffsetDateTime.now());
virologischerBefundComposition.setSettingDefiningCode(Setting.SECONDARY_MEDICAL_CARE);
// context, other_context
FallidentifikationCluster fallidentifikationCluster = new FallidentifikationCluster();
fallidentifikationCluster.setFallKennungValue("9251377");
virologischerBefundComposition.setFallidentifikation(fallidentifikationCluster);
virologischerBefundComposition.setBerichtIdValue("15a69a62-1ea7-4111-98a5-28aeae854bcd");
virologischerBefundComposition.setStatusValue("Endbefund");
// openEHR-EHR-CLUSTER.specimen.v1
ProbeCluster probeCluster = new ProbeCluster();
probeCluster.setZeitpunktDerProbenentnahmeValue(new DvDateTime("2020-04-01T12:00:00Z").getValue());
probeCluster.setProbenartValue("Blut");
probeCluster.setZeitpunktDesProbeneingangsValue(new DvDateTime("2020-04-02T09:00:00Z").getValue());
probeCluster.setKommentarDesProbennehmersValue("Kommentar zur Probe");
probeCluster.setKommentarValue("Kommentar");
// openEHR-EHR-CLUSTER.laboratory_test_analyte.v1
ProVirusCluster proVirusCluster1 = new ProVirusCluster();
proVirusCluster1.setVirusValue("SARS-Cov-2");
proVirusCluster1.setAnalyseergebnisReihenfolgeMagnitude(Long.valueOf(32));
DvIdentifier identifier = new DvIdentifier();
identifier.setIssuer("Issuer");
identifier.setAssigner("Assigner");
identifier.setId("9a0e5173-07c8-443d-b414-24432b9d95ca");
identifier.setType("Prescription");
proVirusCluster1.setZugehorigeLaborprobe(identifier);
ProVirusCluster proVirusCluster2 = new ProVirusCluster();
proVirusCluster2.setVirusValue("SARS-Cov-2");
proVirusCluster2.setAnalyseergebnisReihenfolgeMagnitude(Long.valueOf(34));
proVirusCluster2.setZugehorigeLaborprobe(identifier);
// openEHR-EHR-CLUSTER.laboratory_test_panel.v0
KulturCluster kulturCluster = new KulturCluster();
kulturCluster.setProVirus(new ArrayList<>());
kulturCluster.getProVirus().add(proVirusCluster1);
kulturCluster.getProVirus().add(proVirusCluster2);
// openEHR-EHR-OBSERVATION.laboratory_test_result.v1
BefundObservation befundObservation = new BefundObservation();
// set clusters in observation
befundObservation.setKultur(new ArrayList<>());
befundObservation.getKultur().add(kulturCluster);
befundObservation.setProbe(new ArrayList<>());
befundObservation.getProbe().add(probeCluster);
befundObservation.setOriginValue(new DvDateTime("2020-04-02T12:00:00Z").getValue());
befundObservation.setTimeValue(new DvDateTime("2020-04-02T14:00:00Z").getValue());
befundObservation.setLabortestBezeichnungValue("Virologische Untersuchung");
befundObservation.setSubject(new PartySelf());
befundObservation.setLanguage(Language.DE);
virologischerBefundComposition.setBefund(befundObservation);
return virologischerBefundComposition;
}
use of org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition 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));
}
use of org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition in project openEHR_SDK by ehrbase.
the class CoronaTestIT method testNUMResearchCase_3.
/**
* see https://wiki.vitagroup.ag/display/NUM/Research+Repository
*
* Containment test:
*
* contains COMPOSITION c[openEHR-EHR-COMPOSITION.report-result.v1]
* contains (
* CLUSTER f[openEHR-EHR-CLUSTER.case_identification.v0] and
* CLUSTER z[openEHR-EHR-CLUSTER.specimen.v1] and
* CLUSTER j[openEHR-EHR-CLUSTER.laboratory_test_panel.v0]
* contains CLUSTER g[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1])
*/
@Test
public void testNUMResearchCase_3() throws IOException {
// Should use: TestData.buildTestVirologischerBefundComposition();
// with the test data
VirologischerBefundComposition virologischerBefundComposition = TestData.buildTestVirologischerBefundComposition();
assertThat(virologischerBefundComposition.getBefund()).isNotNull();
ehr = openEhrClient.ehrEndpoint().createEhr();
openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(virologischerBefundComposition);
// build AQL expression
VirologischerBefundCompositionContainment virologischerBefundCompositionContainment = VirologischerBefundCompositionContainment.getInstance();
ProbeClusterContainment probeClusterContainment = ProbeClusterContainment.getInstance();
KulturClusterContainment kulturClusterContainment = KulturClusterContainment.getInstance();
ProVirusClusterContainment proVirusClusterContainment = ProVirusClusterContainment.getInstance();
// contains COMPOSITION c[openEHR-EHR-COMPOSITION.report-result.v1]
// contains (
// CLUSTER z[openEHR-EHR-CLUSTER.specimen.v1] and
// CLUSTER j[openEHR-EHR-CLUSTER.laboratory_test_panel.v0]
// contains CLUSTER g[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1])
ContainmentExpression containmentExpression = virologischerBefundCompositionContainment.contains(probeClusterContainment.and(kulturClusterContainment.contains(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));
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));
}
use of org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition in project openEHR_SDK by ehrbase.
the class DefaultRestCompositionEndpointIT method testVirologischerBefund.
@Test
public void testVirologischerBefund() throws IOException {
Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.VIROLOGY_FINDING_WITH_SPECIMEN.getStream(), StandardCharsets.UTF_8), Composition.class);
assertThat(composition.itemsAtPath("/content[openEHR-EHR-OBSERVATION.laboratory_test_result.v1]/data[at0001]/events[at0002]/data[at0003]")).isNotNull();
Flattener flattener = new Flattener(new TestDataTemplateProvider());
VirologischerBefundComposition virologischerBefundComposition = flattener.flatten(composition, VirologischerBefundComposition.class);
assertThat(virologischerBefundComposition.getBefund()).isNotNull();
// with the test data
virologischerBefundComposition = TestData.buildTestVirologischerBefundComposition();
assertThat(virologischerBefundComposition.getBefund()).isNotNull();
ehr = openEhrClient.ehrEndpoint().createEhr();
VirologischerBefundComposition version1 = openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(virologischerBefundComposition);
Optional<VirologischerBefundComposition> actual = openEhrClient.compositionEndpoint(ehr).find(version1.getVersionUid().getUuid(), VirologischerBefundComposition.class);
assertThat(actual).isPresent();
assertThat(actual.get().getBefund()).isNotNull();
assertThat(actual.get().getBefund().getKultur().get(0).getProVirus()).extracting(ProVirusCluster::getVirusValue, ProVirusCluster::getAnalyseergebnisReihenfolgeMagnitude).containsExactlyInAnyOrder(new Tuple("SARS-Cov-2", 32L), new Tuple("SARS-Cov-2", 34L));
}
use of org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition in project openEHR_SDK by ehrbase.
the class ArbitraryQueryOtherContextIT method setUp.
@Before
public void setUp() throws IOException {
// normal test run
ehrUUID = openEhrClient.ehrEndpoint().createEhr();
compositionEndpoint = openEhrClient.compositionEndpoint(ehrUUID);
aComposition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.VIROLOGY_FINDING_WITH_SPECIMEN_NO_UPDATE.getStream(), StandardCharsets.UTF_8), Composition.class);
Flattener flattener = new Flattener(new TestDataTemplateProvider());
VirologischerBefundComposition virologischerBefundComposition = flattener.flatten(aComposition, VirologischerBefundComposition.class);
// create the composition
VirologischerBefundComposition comp = compositionEndpoint.mergeCompositionEntity(virologischerBefundComposition);
compositionUUID = comp.getVersionUid().getUuid();
arbitraryQuery = new ArbitraryQuery(ehrUUID, openEhrClient);
simpleSelectQueryEngine = new SimpleSelectQuery(ehrUUID, compositionUUID, openEhrClient);
}
Aggregations