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");
}
}
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");
}
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\"" + "}");
}
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());
}
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());
}
Aggregations