Search in sources :

Example 6 with DvDateTime

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

the class TemporalEncodingTest method testChronoFieldSupportDateTimeYYYYMMDDHHMMSSTZ.

public void testChronoFieldSupportDateTimeYYYYMMDDHHMMSSTZ() {
    DvDateTime dvDateTime = new DvDateTime("2020-12-12T10:10:10Z");
    DvDateTimeAttributes dateTimeAttributes = DvDateTimeAttributes.instanceFromValue(dvDateTime);
    assertTrue(dateTimeAttributes.isRmDvDateTime());
    assertTrue(dateTimeAttributes.isDateTimeYYYYMMDDHHMMSS());
    assertFalse(dateTimeAttributes.isDateTimeYYYYMM());
    assertEquals("2020-12-12T10:10:10Z", dateTimeAttributes.getValueAsProvided().toString());
    assertEquals("2020-12-12T10:10:10Z", dateTimeAttributes.getValueExtended().toString());
    // GMT: Saturday, December 12, 2020 10:10:10 AM == 1607767810 (https://www.epochconverter.com/)
    assertEquals(Long.valueOf(1607767810), dateTimeAttributes.getTimeStamp());
    assertEquals(Integer.valueOf(TemporalAttributes.DV_DATE_TIME | TemporalAttributes.YEAR | TemporalAttributes.MONTH_OF_YEAR | TemporalAttributes.DAY_OF_MONTH | TemporalAttributes.HOUR | TemporalAttributes.MINUTE_OF_HOUR | TemporalAttributes.SECOND_OF_MINUTE), dateTimeAttributes.getSupportedChronoFields());
}
Also used : DvDateTimeAttributes(org.ehrbase.serialisation.attributes.datavalues.datetime.datetime.DvDateTimeAttributes) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Example 7 with DvDateTime

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

the class DBEncodeTest method testDBEncodeDecodeInstruction.

@Test
public void testDBEncodeDecodeInstruction() throws IOException {
    Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.NESTED_EN_V1.getStream(), UTF_8), Composition.class);
    CompositionSerializer compositionSerializer = new CompositionSerializer();
    String encoded = compositionSerializer.dbEncode(composition);
    Assert.assertTrue(encoded.contains(CompositionSerializer.TAG_EXPIRY_TIME));
    String json = new LightRawJsonEncoder(encoded).encodeCompositionAsString();
    Composition result = new CanonicalJson().unmarshal(json, Composition.class);
    DvDateTime expiryTime = ((Instruction) ((Section) result.getContent().get(0)).getItems().get(0)).getExpiryTime();
    Assert.assertNotNull(expiryTime);
    Assert.assertEquals(OffsetDateTime.parse("2021-05-18T13:13:09.780+03:00"), expiryTime.getValue());
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) CanonicalJson(org.ehrbase.serialisation.jsonencoding.CanonicalJson) CompositionTestDataCanonicalJson(org.ehrbase.test_data.composition.CompositionTestDataCanonicalJson) LightRawJsonEncoder(org.ehrbase.serialisation.dbencoding.rawjson.LightRawJsonEncoder) Instruction(com.nedap.archie.rm.composition.Instruction) Section(com.nedap.archie.rm.composition.Section) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test)

Example 8 with DvDateTime

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

the class StatusesTestOverwrite method dateTime.

@Override
@Test
public void dateTime() throws Exception {
    String template = this.getFileContent("/res/test_statuses.opt");
    Map<String, Object> flatComposition = Map.of("ctx/language", "sl", "ctx/territory", "SI", "ctx/composer_name", "George Orwell", "test_statuses/test_statuses:0/datetime", "2017-10-01T13:20:00Z", "test_statuses/test_statuses:0/datetime|normal_status", "L", "test_statuses/test_statuses:0/datetime|magnitude_status", ">=", "test_statuses/test_statuses:0/datetime/_accuracy", "P1Y");
    RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
    Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
    DvDateTime rmObject = (DvDateTime) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0013]/value");
    assertThat(rmObject.getNormalStatus()).isNotNull();
    assertThat(rmObject.getNormalStatus().getTerminologyId().getValue()).isEqualTo("openehr_normal_statuses");
    assertThat(rmObject.getNormalStatus().getCodeString()).isEqualTo("L");
    assertThat(rmObject.getMagnitudeStatus()).isEqualTo(">=");
    assertThat(rmObject.getAccuracy()).isNotNull().extracting(DvDuration::getValue).extracting(Object::toString).isEqualTo("P1Y");
    Map<String, Object> value = OBJECT_MAPPER.readValue(flatJson.marshal(composition), Map.class);
    assertThat(value).containsEntry("test_statuses/test_statuses:0/datetime|normal_status", "L").containsEntry("test_statuses/test_statuses:0/datetime|magnitude_status", ">=").containsEntry("test_statuses/test_statuses:0/datetime/_accuracy", "P1Y");
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) DvDuration(com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test) StatusesTest(care.better.platform.web.template.StatusesTest)

Example 9 with DvDateTime

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

the class CanonicalJsonMarshallingTest method UnmarshalPartialDateTime.

@Test
public void UnmarshalPartialDateTime() throws IOException {
    String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/partialdvdatetime.json")));
    CanonicalJson cut = new CanonicalJson();
    DvDateTime dvDateTime = cut.unmarshal(value, DvDateTime.class);
    assertNotNull(dvDateTime);
    // NB. partial time (e.g. '10') is defaulted to '10:00' due to Java API handling of time values
    assertEquals("2020-08-01T10:00", dvDateTime.getValue().toString());
}
Also used : DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) Test(org.junit.Test)

Example 10 with DvDateTime

use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime 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;
}
Also used : BefundObservation(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.BefundObservation) PartyIdentified(com.nedap.archie.rm.generic.PartyIdentified) ProbeCluster(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProbeCluster) VirologischerBefundComposition(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.VirologischerBefundComposition) FallidentifikationCluster(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.FallidentifikationCluster) KulturCluster(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.KulturCluster) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime) ProVirusCluster(org.ehrbase.client.classgenerator.examples.virologischerbefundcomposition.definition.ProVirusCluster) DvIdentifier(com.nedap.archie.rm.datavalues.DvIdentifier) PartySelf(com.nedap.archie.rm.generic.PartySelf)

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