use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDate in project openEHR_SDK by ehrbase.
the class CompareCanonicalDvDate method isExpectedEqualToCanonicalUsing.
public Object isExpectedEqualToCanonicalUsing(DvDate referenceDate) {
// check each date/time part separately
Format formatter = DateTimeFormatter.ISO_LOCAL_DATE.toFormat();
DvDate actualDvDate = new DvDate(formatter.format(dvDate.getValue()));
DvDate expectedDvDate = new DvDate(formatter.format(referenceDate.getValue()));
// perform comparison of parts
DatePartComparator.compare(actualDvDate, expectedDvDate);
return null;
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDate in project openEHR_SDK by ehrbase.
the class CompareCanonicalDvDateTime method isExpectedEqualToCanonicalUsing.
public Object isExpectedEqualToCanonicalUsing(DvDateTime referenceDateTime) {
// check each date/time part separately
Format formatter = DateTimeFormatter.ISO_LOCAL_DATE.toFormat();
DvDate actualDvDate = new DvDate(formatter.format(dvDateTime.getValue()));
DvDate expectedDvDate = new DvDate(formatter.format(referenceDateTime.getValue()));
formatter = DateTimeFormatter.ISO_LOCAL_TIME.toFormat();
DvTime actualDvTime = new DvTime(formatter.format(dvDateTime.getValue()));
DvTime expectedDvTime = new DvTime(formatter.format(referenceDateTime.getValue()));
ZoneOffset actualZoneOffset = ZoneOffset.from(dvDateTime.getValue());
ZoneOffset expectedZoneOffset = ZoneOffset.from(referenceDateTime.getValue());
// perform comparison of parts
DatePartComparator.compare(actualDvDate, expectedDvDate);
if (!compareDateOnly)
TimePartComparator.compare(actualDvTime, expectedDvTime);
ZoneOffsetPartComparator.compare(actualZoneOffset, expectedZoneOffset);
return null;
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDate in project openEHR_SDK by ehrbase.
the class CompareCanonicalDvDateTimeTest method testComparatorDvDate.
@Test
public void testComparatorDvDate() {
DvDate dvDate = (DvDate) toRmObject(jsonDvDateRef, DvDate.class);
assertThat(new CompareCanonicalDvDate(dvDate).isExpectedEqualToCanonicalUsing(dvDate)).isNull();
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDate in project openEHR_SDK by ehrbase.
the class DvDateTimeAttributes method instanceFromValue.
public static DvDateTimeAttributes instanceFromValue(DvDateTime dvDateTime) {
TemporalAccessor localDate;
TemporalAccessor actual = dvDateTime.getValue();
if (actual.isSupported(ChronoField.YEAR) && actual.isSupported(ChronoField.MONTH_OF_YEAR) && actual.isSupported(ChronoField.DAY_OF_MONTH))
localDate = LocalDate.of(actual.get(ChronoField.YEAR), actual.get(ChronoField.MONTH_OF_YEAR), actual.get(ChronoField.DAY_OF_MONTH));
else if (actual.isSupported(ChronoField.YEAR) && actual.isSupported(ChronoField.MONTH_OF_YEAR))
localDate = YearMonth.of(actual.get(ChronoField.YEAR), actual.get(ChronoField.MONTH_OF_YEAR));
else if (actual.isSupported(ChronoField.YEAR))
localDate = Year.of(actual.get(ChronoField.YEAR));
else
throw new IllegalArgumentException("DvDateTime supplied is not valid:" + actual);
DvTimeAttributes dvTimeAttributes = DvTimeAttributes.instanceFromValue(dvDateTime.getValue());
DvDateAttributes dvDateAttributes = DvDateAttributes.instanceFromValue(new DvDate((Temporal) localDate));
if (dvTimeAttributes == null) {
dvDateTime = new DvDateTime(dvDateAttributes.getValueAsProvided());
}
return new DvDateTimeAttributes(dvDateTime, dvDateAttributes, dvTimeAttributes);
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDate in project openEHR_SDK by ehrbase.
the class DvDateValidatorTest method testValidate.
@Test
void testValidate() throws Exception {
var node = parseNode("/webtemplate_nodes/dv_date.json");
var result = validator.validate(new DvDate(LocalDate.now()), node);
assertTrue(result.isEmpty());
}
Aggregations