Search in sources :

Example 6 with DvDuration

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

the class DvTemporalPostprocessor method process.

/**
 * {@inheritDoc}
 */
@Override
public void process(String term, DvTemporal rmObject, Map<FlatPathDto, String> values, Set<String> consumedPaths, Context<Map<FlatPathDto, String>> context) {
    Map<FlatPathDto, String> filter = FlatHelper.filter(values, term + "/_accuracy", false);
    if (!filter.isEmpty()) {
        rmObject.setAccuracy(new DvDuration());
        handleRmAttribute(term, rmObject.getAccuracy(), filter, consumedPaths, context, "accuracy");
    }
}
Also used : FlatPathDto(org.ehrbase.webtemplate.path.flat.FlatPathDto) DvDuration(com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration)

Example 7 with DvDuration

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

the class StatusesTestOverwrite method time.

@Override
@Test
public void time() 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/time", "13:20", "test_statuses/test_statuses:0/time|normal_status", "L", "test_statuses/test_statuses:0/time|magnitude_status", ">=", "test_statuses/test_statuses:0/time/_accuracy", "P1Y");
    RMDataFormat flatJson = getFlatJson(template, FlatFormat.SIM_SDT);
    Composition composition = flatJson.unmarshal(OBJECT_MAPPER.writeValueAsString(flatComposition));
    DvTime rmObject = (DvTime) composition.itemAtPath("/content[openEHR-EHR-OBSERVATION.test_statuses.v0]/data[at0001]/events[at0002]/data[at0003]/items[at0012]/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/time|normal_status", "L").containsEntry("test_statuses/test_statuses:0/time|magnitude_status", ">=").containsEntry("test_statuses/test_statuses:0/time/_accuracy", "P1Y");
}
Also used : Composition(com.nedap.archie.rm.composition.Composition) RMDataFormat(org.ehrbase.serialisation.RMDataFormat) DvDuration(com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration) DvTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvTime) Test(org.junit.Test) StatusesTest(care.better.platform.web.template.StatusesTest)

Example 8 with DvDuration

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

the class CanonicalJsonMarshallingTest method MarshalDuration.

@Test
public void MarshalDuration() {
    DvDuration duration = new DvDuration(Duration.ofDays(30L));
    CanonicalJson cut = new CanonicalJson();
    String actual = cut.marshal(duration);
    assertThat(actual).isEqualToIgnoringWhitespace("{" + "  \"_type\" : \"DV_DURATION\"," + "  \"value\" : \"PT720H\"" + "}");
}
Also used : DvDuration(com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration) Test(org.junit.Test)

Example 9 with DvDuration

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

the class DvDurationValidatorTest method testValidate_PeriodDuration.

@Test
void testValidate_PeriodDuration() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_duration_period_duration.json");
    var result = validator.validate(new DvDuration("P10Y5M2W3DT5H30M5S"), node);
    assertTrue(result.isEmpty());
    result = validator.validate(new DvDuration("P10Y5M3DT12H30M5S"), node);
    assertEquals(2, result.size());
}
Also used : DvDuration(com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration) Test(org.junit.jupiter.api.Test)

Example 10 with DvDuration

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

the class DvDurationValidatorTest method testValidate_Period.

@Test
void testValidate_Period() throws Exception {
    var node = parseNode("/webtemplate_nodes/dv_duration_period.json");
    var result = validator.validate(new DvDuration("P10Y5M3D"), node);
    assertTrue(result.isEmpty());
    result = validator.validate(new DvDuration("P5M3D"), node);
    assertFalse(result.isEmpty());
    result = validator.validate(new DvDuration("P1Y3D"), node);
    assertFalse(result.isEmpty());
}
Also used : DvDuration(com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration) Test(org.junit.jupiter.api.Test)

Aggregations

DvDuration (com.nedap.archie.rm.datavalues.quantity.datetime.DvDuration)10 Test (org.junit.Test)5 StatusesTest (care.better.platform.web.template.StatusesTest)4 Composition (com.nedap.archie.rm.composition.Composition)4 RMDataFormat (org.ehrbase.serialisation.RMDataFormat)4 Test (org.junit.jupiter.api.Test)3 DvDate (com.nedap.archie.rm.datavalues.quantity.datetime.DvDate)1 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)1 DvTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvTime)1 Duration (java.time.Duration)1 Period (java.time.Period)1 FlatPathDto (org.ehrbase.webtemplate.path.flat.FlatPathDto)1 PeriodDuration (org.threeten.extra.PeriodDuration)1