Search in sources :

Example 1 with DvDate

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());
}
Also used : YearMonth(java.time.YearMonth) DvDate(com.nedap.archie.rm.datavalues.quantity.datetime.DvDate) DvDateAttributes(org.ehrbase.serialisation.attributes.datavalues.datetime.date.DvDateAttributes)

Example 2 with DvDate

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");
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) DvDate(com.nedap.archie.rm.datavalues.quantity.datetime.DvDate) DvDuration(com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration) Test(org.junit.Test) StatusesTest(care.better.platform.web.template.StatusesTest)

Example 3 with DvDate

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());
}
Also used : DvDate(com.nedap.archie.rm.datavalues.quantity.datetime.DvDate) Test(org.junit.Test)

Example 4 with DvDate

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());
}
Also used : DvDate(com.nedap.archie.rm.datavalues.quantity.datetime.DvDate) Test(org.junit.jupiter.api.Test)

Example 5 with DvDate

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());
}
Also used : DvDate(com.nedap.archie.rm.datavalues.quantity.datetime.DvDate) Test(org.junit.jupiter.api.Test)

Aggregations

DvDate (com.nedap.archie.rm.datavalues.quantity.datetime.DvDate)10 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)3 Format (java.text.Format)2 DvDateAttributes (org.ehrbase.serialisation.attributes.datavalues.datetime.date.DvDateAttributes)2 StatusesTest (care.better.platform.web.template.StatusesTest)1 Composition (com.nedap.archie.rm.composition.Composition)1 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)1 DvDuration (com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration)1 DvTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvTime)1 YearMonth (java.time.YearMonth)1 ZoneOffset (java.time.ZoneOffset)1 Temporal (java.time.temporal.Temporal)1 TemporalAccessor (java.time.temporal.TemporalAccessor)1 RMDataFormat (org.ehrbase.serialisation.RMDataFormat)1 DvTimeAttributes (org.ehrbase.serialisation.attributes.datavalues.datetime.time.DvTimeAttributes)1