Search in sources :

Example 1 with DvTime

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

the class TemporalEncodingTest method testChronoFieldSupportTime.

public void testChronoFieldSupportTime() {
    DvTime dvTime = new DvTime("10:10:10Z");
    DvTimeAttributes timeAttributes = DvTimeAttributes.instanceFromValue(dvTime);
    assertTrue(timeAttributes.isRmDvTime());
    assertEquals(Long.valueOf(36610), timeAttributes.getTimeStamp());
    assertFalse(timeAttributes.isTimeHH());
    assertFalse(timeAttributes.isTimeHHMM());
    assertTrue(timeAttributes.isTimeHHMMSS());
    assertFalse(timeAttributes.isTimeHHMMSSmmm());
    // String encoded = new TemporalEncoding().toDB(dvDate);
    assertEquals("10:10:10Z", timeAttributes.getValueAsProvided().toString());
    assertEquals(Integer.valueOf(TemporalAttributes.DV_TIME | TemporalAttributes.HOUR | TemporalAttributes.MINUTE_OF_HOUR | TemporalAttributes.SECOND_OF_MINUTE), timeAttributes.getSupportedChronoFields());
}
Also used : DvTimeAttributes(org.ehrbase.serialisation.attributes.datavalues.datetime.time.DvTimeAttributes) DvTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvTime)

Example 2 with DvTime

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

the class TemporalEncodingTest method testChronoFieldSupportTimeHH.

public void testChronoFieldSupportTimeHH() {
    DvTime dvTime = new DvTime("10");
    DvTimeAttributes timeAttributes = DvTimeAttributes.instanceFromValue(dvTime);
    // Archie encode this time as 10:00, should we enforce this minimalist encoding?
    assertFalse(timeAttributes.isTimeHH());
    assertTrue(timeAttributes.isTimeHHMM());
    assertFalse(timeAttributes.isTimeHHMMSS());
    assertFalse(timeAttributes.isTimeHHMMSSmmm());
    assertEquals("10:00", timeAttributes.getValueAsProvided().toString());
    assertEquals(Integer.valueOf(TemporalAttributes.DV_TIME | TemporalAttributes.HOUR | TemporalAttributes.MINUTE_OF_HOUR), timeAttributes.getSupportedChronoFields());
    assertEquals("YYYY-MM-DD\"T\"HH24:MI", timeAttributes.getISOdateTimeSQLFormatter(timeAttributes.getSupportedChronoFields()));
}
Also used : DvTimeAttributes(org.ehrbase.serialisation.attributes.datavalues.datetime.time.DvTimeAttributes) DvTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvTime)

Example 3 with DvTime

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

the class CompareCanonicalDvDateTimeTest method testComparatorDvTime.

@Test
public void testComparatorDvTime() {
    DvTime dvTime = (DvTime) toRmObject(jsonDvTimeRef, DvTime.class);
    assertThat(new CompareCanonicalDvTime(dvTime).isExpectedEqualToCanonicalUsing(dvTime)).isNull();
}
Also used : DvTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvTime) Test(org.junit.Test)

Example 4 with DvTime

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

the class CompareCanonicalDvTime method isExpectedEqualToCanonicalUsing.

public Object isExpectedEqualToCanonicalUsing(DvTime referenceTime) {
    // check each date/time part separately
    Format formatter = DateTimeFormatter.ISO_LOCAL_TIME.toFormat();
    DvTime actualDvTime = new DvTime(formatter.format(dvTime.getValue()));
    DvTime expectedDvTime = new DvTime(formatter.format(referenceTime.getValue()));
    ZoneOffset actualZoneOffset = ZoneOffset.from(dvTime.getValue());
    ZoneOffset expectedZoneOffset = ZoneOffset.from(referenceTime.getValue());
    // perform comparison of parts
    TimePartComparator.compare(actualDvTime, expectedDvTime);
    ZoneOffsetPartComparator.compare(actualZoneOffset, expectedZoneOffset);
    return null;
}
Also used : Format(java.text.Format) DvTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvTime) ZoneOffset(java.time.ZoneOffset)

Example 5 with DvTime

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

the class DvTimeValidatorTest method testValidate.

@Test
void testValidate() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_time.json");
    var result = validator.validate(new DvTime(LocalTime.now()), node);
    assertTrue(result.isEmpty());
}
Also used : DvTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvTime) Test(org.junit.jupiter.api.Test)

Aggregations

DvTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvTime)11 DvTimeAttributes (org.ehrbase.serialisation.attributes.datavalues.datetime.time.DvTimeAttributes)3 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)3 Format (java.text.Format)2 ZoneOffset (java.time.ZoneOffset)2 StatusesTest (care.better.platform.web.template.StatusesTest)1 Composition (com.nedap.archie.rm.composition.Composition)1 DvDate (com.nedap.archie.rm.datavalues.quantity.datetime.DvDate)1 DvDuration (com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration)1 OffsetDateTime (java.time.OffsetDateTime)1 RMDataFormat (org.ehrbase.serialisation.RMDataFormat)1