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