use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDate in project openEHR_SDK by ehrbase.
the class TemporalEncodingTest method testChronoFieldSupport2.
public void testChronoFieldSupport2() {
YearMonth yearMonth = YearMonth.parse("2020-08");
DvDate dvDate = new DvDate(yearMonth);
// check supported ChronoField
assertTrue(dvDate.getValue().isSupported(ChronoField.YEAR));
assertTrue(dvDate.getValue().isSupported(ChronoField.MONTH_OF_YEAR));
assertFalse(dvDate.getValue().isSupported(ChronoField.DAY_OF_MONTH));
DvDateAttributes dvDateAttributes = DvDateAttributes.instanceFromValue(dvDate);
assertTrue(dvDateAttributes.isRmDvDate());
assertTrue(dvDateAttributes.isDateYYYYMM());
assertFalse(dvDateAttributes.isDateYYYY());
assertFalse(dvDateAttributes.isDateYYYYMMDD());
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDate in project openEHR_SDK by ehrbase.
the class StatusesTestOverwrite method date.
@Override
@Test
public void date() 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/date", "2017-10-01", "test_statuses/test_statuses:0/date|normal_status", "L", "test_statuses/test_statuses:0/date|magnitude_status", ">=", "test_statuses/test_statuses:0/date/_accuracy", "P1Y");
RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
DvDate rmObject = (DvDate) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0011]/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/date|normal_status", "L").containsEntry("test_statuses/test_statuses:0/date|magnitude_status", ">=").containsEntry("test_statuses/test_statuses:0/date/_accuracy", "P1Y");
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDate in project openEHR_SDK by ehrbase.
the class CanonicalJsonMarshallingTest method UnmarshalPartialDate.
@Test
public void UnmarshalPartialDate() throws IOException {
String value = new String(Files.readAllBytes(Paths.get("src/test/resources/sample_data/partialdvdate.json")));
CanonicalJson cut = new CanonicalJson();
DvDate dvDate = cut.unmarshal(value, DvDate.class);
assertNotNull(dvDate);
assertEquals("2020-08", dvDate.getValue().toString());
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDate in project openEHR_SDK by ehrbase.
the class DvDateValidatorTest method testValidate_Range.
@Test
void testValidate_Range() throws Exception {
var node = parseNode("/webtemplate_nodes/dv_date_range.json");
var result = validator.validate(new DvDate(LocalDate.of(2022, 1, 10)), node);
assertTrue(result.isEmpty());
result = validator.validate(new DvDate(LocalDate.of(2021, 1, 22)), node);
assertEquals(1, result.size());
result = validator.validate(new DvDate(LocalDate.of(2022, 2, 1)), node);
assertEquals(1, result.size());
}
use of com.nedap.archie.rm.datavalues.quantity.datetime.DvDate in project openEHR_SDK by ehrbase.
the class DvDateValidatorTest method testValidate_Pattern.
@Test
void testValidate_Pattern() throws Exception {
var node = parseNode("/webtemplate_nodes/dv_date_pattern.json");
var result = validator.validate(new DvDate(LocalDate.of(2022, 1, 10)), node);
assertTrue(result.isEmpty());
}
Aggregations