Search in sources :

Example 21 with DvDateTime

use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project openEHR_SDK by ehrbase.

the class CoronaTestIT method testNUMResearchCase_5.

/**
 * see https://wiki.vitagroup.ag/display/NUM/Research+Repository
 *
 * Containment test:
 *
 * contains COMPOSITION c[openEHR-EHR-COMPOSITION.event_summary.v0]
 * contains
 * (CLUSTER n[openEHR-EHR-CLUSTER.case_identification.v0]
 * and ADMIN_ENTRY u[openEHR-EHR-ADMIN_ENTRY.hospitalization.v0]
 * contains (CLUSTER a[openEHR-EHR-CLUSTER.location.v1]))
 */
@Test
public void testNUMResearchCase_5() {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildTestPatientenaufenthaltComposition());
    // build AQL
    PatientenaufenthaltCompositionContainment patientenaufenthaltCompositionContainment = PatientenaufenthaltCompositionContainment.getInstance();
    AbteilungsfallClusterContainment abteilungsfallClusterContainment = AbteilungsfallClusterContainment.getInstance();
    VersorgungsortAdminEntryContainment versorgungsortAdminEntryContainment = VersorgungsortAdminEntryContainment.getInstance();
    StandortClusterContainment standortClusterContainment = StandortClusterContainment.getInstance();
    ContainmentExpression containmentExpression = patientenaufenthaltCompositionContainment.contains(abteilungsfallClusterContainment.and(versorgungsortAdminEntryContainment.contains(standortClusterContainment)));
    // select set values from test data
    EntityQuery<Record3<TemporalAccessor, TemporalAccessor, String>> entityQuery = Query.buildEntityQuery(containmentExpression, versorgungsortAdminEntryContainment.BEGINN_VALUE, versorgungsortAdminEntryContainment.ENDE_VALUE, versorgungsortAdminEntryContainment.GRUND_DES_AUFENTHALTES_VALUE);
    Parameter<UUID> ehrIdParameter = entityQuery.buildParameter();
    entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter));
    List<Record3<TemporalAccessor, TemporalAccessor, String>> actual = openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr));
    assertThat(actual).extracting(Record3::value1, Record3::value2, Record3::value3).containsExactlyInAnyOrder(new Tuple(new DvDateTime("2020-01-01T10:00Z").getValue(), new DvDateTime("2020-01-01T12:00Z").getValue(), "test value"));
}
Also used : AbteilungsfallClusterContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.AbteilungsfallClusterContainment) StandortClusterContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.StandortClusterContainment) VersorgungsortAdminEntryContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.definition.VersorgungsortAdminEntryContainment) ContainmentExpression(org.ehrbase.client.aql.containment.ContainmentExpression) PatientenaufenthaltCompositionContainment(org.ehrbase.client.classgenerator.examples.patientenaufenthaltcomposition.PatientenaufenthaltCompositionContainment) UUID(java.util.UUID) Record3(org.ehrbase.client.aql.record.Record3) Tuple(org.assertj.core.groups.Tuple) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test)

Example 22 with DvDateTime

use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project openEHR_SDK by ehrbase.

the class CoronaTestIT method testNUMResearchCase_6.

/**
 * see https://wiki.vitagroup.ag/display/NUM/Research+Repository
 *
 * Containment test:
 *
 * contains COMPOSITION c[openEHR-EHR-COMPOSITION.fall.v0]
 * contains (
 * ADMIN_ENTRY p[openEHR-EHR-ADMIN_ENTRY.admission.v0] and
 * ADMIN_ENTRY b[openEHR-EHR-ADMIN_ENTRY.discharge_summary.v0])
 */
@Test
public void testNUMResearchCase_6() {
    ehr = openEhrClient.ehrEndpoint().createEhr();
    openEhrClient.compositionEndpoint(ehr).mergeCompositionEntity(TestData.buildTestStationarerVersorgungsfallComposition());
    // build AQL
    StationarerVersorgungsfallCompositionContainment stationarerVersorgungsfallCompositionContainment = StationarerVersorgungsfallCompositionContainment.getInstance();
    AufnahmedatenAdminEntryContainment aufnahmedatenAdminEntryContainment = AufnahmedatenAdminEntryContainment.getInstance();
    EntlassungsdatenAdminEntryContainment entlassungsdatenAdminEntryContainment = EntlassungsdatenAdminEntryContainment.getInstance();
    ContainmentExpression containmentExpression = stationarerVersorgungsfallCompositionContainment.contains(aufnahmedatenAdminEntryContainment.and(entlassungsdatenAdminEntryContainment));
    // select set values from test data
    EntityQuery<Record3<TemporalAccessor, TemporalAccessor, String>> entityQuery = Query.buildEntityQuery(containmentExpression, aufnahmedatenAdminEntryContainment.DATUM_UHRZEIT_DER_AUFNAHME_VALUE, entlassungsdatenAdminEntryContainment.DATUM_UHRZEIT_DER_ENTLASSUNG_VALUE, stationarerVersorgungsfallCompositionContainment.FALL_KENNUNG_VALUE);
    Parameter<UUID> ehrIdParameter = entityQuery.buildParameter();
    entityQuery.where(Condition.equal(EhrFields.EHR_ID(), ehrIdParameter));
    List<Record3<TemporalAccessor, TemporalAccessor, String>> actual = openEhrClient.aqlEndpoint().execute(entityQuery, ehrIdParameter.setValue(ehr));
    assertThat(actual).extracting(Record3::value1, Record3::value2, Record3::value3).containsExactlyInAnyOrder(new Tuple(new DvDateTime("2020-04-02T12:00:00Z").getValue(), new DvDateTime("2020-04-02T12:00:00Z").getValue(), "45657678"));
}
Also used : StationarerVersorgungsfallCompositionContainment(org.ehrbase.client.classgenerator.examples.stationarerversorgungsfallcomposition.StationarerVersorgungsfallCompositionContainment) EntlassungsdatenAdminEntryContainment(org.ehrbase.client.classgenerator.examples.stationarerversorgungsfallcomposition.definition.EntlassungsdatenAdminEntryContainment) ContainmentExpression(org.ehrbase.client.aql.containment.ContainmentExpression) AufnahmedatenAdminEntryContainment(org.ehrbase.client.classgenerator.examples.stationarerversorgungsfallcomposition.definition.AufnahmedatenAdminEntryContainment) UUID(java.util.UUID) Record3(org.ehrbase.client.aql.record.Record3) Tuple(org.assertj.core.groups.Tuple) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test)

Example 23 with DvDateTime

use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project openEHR_SDK by ehrbase.

the class CanonicalCompoAllTypeQueryIT method setUp.

public void setUp(CompositionTestDataCanonicalJson testComposition) throws IOException {
    // manual test use
    // ehrUUID = UUID.fromString("ecc0de4d-eb29-40c2-ad7a-e2ab8d66a9f8");
    // compositionUUID = UUID.fromString("a9c22c37-8002-4486-932a-f3e1729efe57");
    actualDvDateTime = new DvDateTime(OffsetDateTime.now());
    // normal test run
    ehrUUID = openEhrClient.ehrEndpoint().createEhr();
    compositionEndpoint = openEhrClient.compositionEndpoint(ehrUUID);
    if (testComposition != null) {
        aComposition = new CanonicalJson().unmarshal(IOUtils.toString(testComposition.getStream(), StandardCharsets.UTF_8), Composition.class);
        Flattener flattener = new Flattener(new TestDataTemplateProvider());
        TestAllTypesEnV1Composition testAllTypesEnV1Composition = flattener.flatten(aComposition, TestAllTypesEnV1Composition.class);
        // create the composition
        TestAllTypesEnV1Composition comp = compositionEndpoint.mergeCompositionEntity(testAllTypesEnV1Composition);
        compositionUUID = comp.getVersionUid().getUuid();
    }
}
Also used : CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) Composition(com.nedap.archie.rm.composition.Composition) TestAllTypesEnV1Composition(org.ehrbase.client.classgenerator.examples.testalltypesenv1composition.TestAllTypesEnV1Composition) Flattener(org.ehrbase.client.flattener.Flattener) TestAllTypesEnV1Composition(org.ehrbase.client.classgenerator.examples.testalltypesenv1composition.TestAllTypesEnV1Composition) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) TestDataTemplateProvider(org.ehrbase.client.templateprovider.TestDataTemplateProvider)

Example 24 with DvDateTime

use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project openEHR_SDK by ehrbase.

the class CompareCanonicalDvDateTimeTest method testComparatorDvDateTime.

@Test
public void testComparatorDvDateTime() {
    DvDateTime dvDateTime = (DvDateTime) toRmObject(jsonDvDateTimeRef, DvDateTime.class);
    assertThat(new CompareCanonicalDvDateTime(dvDateTime).isExpectedEqualToCanonicalUsing(dvDateTime)).isNull();
    assertThat(new CompareCanonicalDvDateTime(dvDateTime).setCompareDateOnly(true).isExpectedEqualToCanonicalUsing(dvDateTime)).isNull();
    assertThat(new CompareCanonicalDvDateTime(dvDateTime).setCompareDateOnly(false).isExpectedEqualToCanonicalUsing(dvDateTime)).isNull();
}
Also used : DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test)

Example 25 with DvDateTime

use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime in project openEHR_SDK by ehrbase.

the class EventContextUnmarshalPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, EventContext rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    setValue(term + PATH_DIVIDER + "_location", null, values, rmObject::setLocation, String.class, consumedPaths);
    setValue(term + PATH_DIVIDER + "_end_time", null, values, s -> {
        if (s != null) {
            rmObject.setEndTime(new DvDateTime(s));
        }
    }, String.class, consumedPaths);
    Map<FlatPathDto, String> health_care_facilityValues = FlatHelper.filter(values, term + "/_health_care_facility", false);
    if (!health_care_facilityValues.isEmpty()) {
        rmObject.setHealthCareFacility(new PartyIdentified());
        handleRmAttribute(term, rmObject.getHealthCareFacility(), health_care_facilityValues, consumedPaths, context, "health_care_facility");
    }
    Map<Integer, Map<String, String>> other = extractMultiValued(term, "_participation", values);
    other.values().stream().map(Map::entrySet).map(s -> s.stream().collect(Collectors.toMap(e -> "ctx/" + DefaultValuePath.PARTICIPATION.getPath() + "_" + e.getKey().replace("identifiers_", "identifiers|"), e -> StringUtils.wrap(e.getValue(), '"'))).entrySet()).map(DefaultValues::buildParticipation).forEach(rmObject::addParticipation);
    consumeAllMatching(term + PATH_DIVIDER + "_participation", values, consumedPaths, false);
    // Strange Path with value true if setting = other care (238)
    consumedPaths.add(term + "/" + "setting|238");
    // Strange Path with value true if setting != other care (238)
    consumedPaths.add(term + "/" + "setting|");
    if (rmObject.getSetting() != null && (rmObject.getSetting().getDefiningCode().getTerminologyId() == null || rmObject.getSetting().getDefiningCode().getTerminologyId().getValue() == null)) {
        rmObject.getSetting().getDefiningCode().setTerminologyId(new TerminologyId("openehr"));
    }
}
Also used : Context(org.ehrbase.serialisation.walker.Context) FlatHelper(org.ehrbase.serialisation.walker.FlatHelper) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) DefaultValuePath(org.ehrbase.serialisation.walker.defaultvalues.DefaultValuePath) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) Set(java.util.Set) DefaultValues(org.ehrbase.serialisation.walker.defaultvalues.DefaultValues) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) EventContext(com.nedap.archie.rm.composition.EventContext) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) PATH_DIVIDER(org.ehrbase.webtemplate.parser.OPTParser.PATH_DIVIDER) FlatHelper.extractMultiValued(org.ehrbase.serialisation.walker.FlatHelper.extractMultiValued) Map(java.util.Map) FlatHelper.consumeAllMatching(org.ehrbase.serialisation.walker.FlatHelper.consumeAllMatching) TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) Map(java.util.Map) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Aggregations

DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)44 PartyIdentified (com.nedap.archie.rm.generic.PartyIdentified)11 Test (org.junit.Test)10 DvCodedText (com.nedap.archie.rm.datavalues.DvCodedText)8 PartyProxy (com.nedap.archie.rm.generic.PartyProxy)7 EventContext (com.nedap.archie.rm.composition.EventContext)6 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)5 TerminologyId (com.nedap.archie.rm.support.identification.TerminologyId)5 PersistedPartyProxy (org.ehrbase.dao.access.jooq.party.PersistedPartyProxy)5 Composition (com.nedap.archie.rm.composition.Composition)4 CodePhrase (com.nedap.archie.rm.datatypes.CodePhrase)4 Participation (com.nedap.archie.rm.generic.Participation)4 TemporalAccessor (java.time.temporal.TemporalAccessor)4 Objects (java.util.Objects)4 DvIdentifier (com.nedap.archie.rm.datavalues.DvIdentifier)3 DvText (com.nedap.archie.rm.datavalues.DvText)3 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)3 AuditDetails (com.nedap.archie.rm.generic.AuditDetails)3 UUID (java.util.UUID)3 Test (org.junit.jupiter.api.Test)3