use of com.nedap.archie.rm.datavalues.quantity.DvQuantity in project openEHR_SDK by ehrbase.
the class UnflattenerTest method testUnflattenEhrbaseMultiOccurrenceDeV1.
@Test
public void testUnflattenEhrbaseMultiOccurrenceDeV1() {
Unflattener cut = new Unflattener(new TestDataTemplateProvider());
EhrbaseMultiOccurrenceDeV1Composition dto = TestData.buildEhrbaseMultiOccurrenceDeV1();
Composition rmObject = (Composition) cut.unflatten(dto);
assertThat(rmObject).isNotNull();
assertThat(rmObject.getArchetypeDetails().getTemplateId().getValue()).isEqualTo("ehrbase_multi_occurrence.de.v1");
List<Object> observationList = rmObject.itemsAtPath("/content[openEHR-EHR-OBSERVATION.body_temperature.v2]");
assertThat(observationList).size().isEqualTo(2);
Observation observation1 = (Observation) observationList.get(0);
List<Object> objects = observation1.itemsAtPath("/data[at0002]/events");
assertThat(objects).extracting(o -> ((PointEvent) o)).extracting(p -> (DvQuantity) p.itemAtPath("/data[at0001]/items[at0004]/value")).extracting(DvQuantity::getMagnitude).containsExactlyInAnyOrder(11d, 22d);
DvCodedText dvCodedText = (DvCodedText) observation1.itemAtPath("/protocol[at0020]/items[at0021]/value");
assertThat(dvCodedText.getValue()).isEqualTo("Forehead");
Observation observation2 = (Observation) observationList.get(1);
DvText dvText = (DvText) observation2.itemAtPath("/protocol[at0020]/items[at0021]/value");
assertFalse(dvText instanceof DvCodedText);
assertThat(dvText.getValue()).isEqualTo("location");
}
use of com.nedap.archie.rm.datavalues.quantity.DvQuantity in project openEHR_SDK by ehrbase.
the class UnflattenerTest method testUnflattenSingleEvent.
@Test
public void testUnflattenSingleEvent() {
Unflattener cut = new Unflattener(new TestDataTemplateProvider());
KorpergrosseComposition dto = new KorpergrosseComposition();
dto.setGrosseLange(new GrosseLangeObservation());
dto.getGrosseLange().setGrosseLangeMagnitude(22d);
Composition rmObject = (Composition) cut.unflatten(dto);
assertThat(rmObject).isNotNull();
Object event = rmObject.itemAtPath("/content[openEHR-EHR-OBSERVATION.height.v2]/data[at0001]/events[at0002]");
assertThat(event).isNotNull();
assertThat(event.getClass()).isEqualTo(PointEvent.class);
Object quantity = ((PointEvent) event).itemAtPath("/data[at0003]/items[at0004]/value");
assertThat(quantity).isNotNull();
assertThat(quantity.getClass()).isEqualTo(DvQuantity.class);
assertThat(((DvQuantity) quantity).getMagnitude()).isEqualTo(22d);
}
use of com.nedap.archie.rm.datavalues.quantity.DvQuantity in project openEHR_SDK by ehrbase.
the class NumericTestsIT method setUp.
@Before
public void setUp() throws IOException {
super.setUp(null);
// build a number of compositions with different DvQuantity values and different names
aComposition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.MINIMAL_EVAL.getStream(), StandardCharsets.UTF_8), Composition.class);
for (int i = 0; i < 10; i++) {
Element element = (Element) aComposition.itemsAtPath("/content[openEHR-EHR-EVALUATION.minimal.v1]/data[at0001]/items[at0002]").get(0);
element.setValue(new DvQuantity("kg", Double.valueOf("" + (i + 1)), 0L));
element.setName(new DvText("value-" + i + 1));
Flattener flattener = new Flattener(new TestDataTemplateProvider());
MinimalEvaluationEnV1Composition minimalEvaluationEnV1Composition = flattener.flatten(aComposition, MinimalEvaluationEnV1Composition.class);
// create the composition
MinimalEvaluationEnV1Composition comp = compositionEndpoint.mergeCompositionEntity(minimalEvaluationEnV1Composition);
}
numericQuery = new NumericQuery(ehrUUID, openEhrClient);
}
use of com.nedap.archie.rm.datavalues.quantity.DvQuantity in project openEHR_SDK by ehrbase.
the class DvQuantityValidatorTest method testValidate_List.
@Test
void testValidate_List() throws Exception {
var node = parseNode("/webtemplate_nodes/dv_quantity_list.json");
var result = validator.validate(new DvQuantity("kg", 100.0, 1L), node);
assertTrue(result.isEmpty());
result = validator.validate(new DvQuantity("g", 100.0, 1L), node);
assertEquals(1, result.size());
}
use of com.nedap.archie.rm.datavalues.quantity.DvQuantity in project openEHR_SDK by ehrbase.
the class DvQuantityValidatorTest method testValidate_ListValidation.
@Test
void testValidate_ListValidation() throws Exception {
var node = parseNode("/webtemplate_nodes/dv_quantity_list_validation.json");
var result = validator.validate(new DvQuantity("kg", 100.0, 1L), node);
assertTrue(result.isEmpty());
result = validator.validate(new DvQuantity("lb", 300.0, 1L), node);
assertTrue(result.isEmpty());
result = validator.validate(new DvQuantity("kg", 300.0, 1L), node);
assertEquals(1, result.size());
result = validator.validate(new DvQuantity("lb", 500.0, 1L), node);
assertEquals(1, result.size());
result = validator.validate(new DvQuantity("lb", 300.00, 2L), node);
assertEquals(1, result.size());
}
Aggregations