use of com.nedap.archie.rm.composition.Observation 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.composition.Observation in project openEHR_SDK by ehrbase.
the class FlattenerTest method testFlattenSingleEventIntervallEvent.
@Test
public void testFlattenSingleEventIntervallEvent() {
Unflattener unflattener = new Unflattener(new TestDataTemplateProvider());
KorpergrosseComposition dto = new KorpergrosseComposition();
dto.setGrosseLange(new GrosseLangeObservation());
dto.getGrosseLange().setGrosseLangeMagnitude(22d);
Composition rmObject = (Composition) unflattener.unflatten(dto);
Observation observation = (Observation) rmObject.getContent().get(0);
Event<ItemStructure> event = observation.getData().getEvents().get(0);
observation.getData().getEvents().remove(event);
IntervalEvent<ItemStructure> intervalEvent = new IntervalEvent<>();
intervalEvent.setData(event.getData());
intervalEvent.setArchetypeNodeId(event.getArchetypeNodeId());
intervalEvent.setSampleCount(10L);
observation.getData().getEvents().add(intervalEvent);
assertThat(rmObject).isNotNull();
Flattener cut = new Flattener(new TestDataTemplateProvider());
KorpergrosseComposition actual = cut.flatten(rmObject, KorpergrosseComposition.class);
assertThat(actual.getGrosseLange().getGrosseLangeMagnitude()).isEqualTo(22d);
}
use of com.nedap.archie.rm.composition.Observation in project openEHR_SDK by ehrbase.
the class FlatJsonUnmarshallerTest method unmarshalUuid.
@Test
public void unmarshalUuid() throws IOException, XmlException {
OPERATIONALTEMPLATE template = TemplateDocument.Factory.parse(OperationalTemplateTestData.CONFORMANCE.getStream()).getTemplate();
WebTemplate webTemplate = new OPTParser(template).parse();
FlatJsonUnmarshaller cut = new FlatJsonUnmarshaller();
String flat = IOUtils.toString(CompositionTestDataConformanceSDTJson.EHRBASE_CONFORMANCE_OBSERVATION.getStream(), StandardCharsets.UTF_8);
Composition actual = cut.unmarshal(flat, webTemplate);
assertThat(actual).isNotNull();
Observation observation = (Observation) actual.itemAtPath("/content[openEHR-EHR-SECTION.conformance_section.v0]/items[openEHR-EHR-OBSERVATION.conformance_observation.v0]");
assertThat(observation.getUid().getValue()).hasToString("9fcc1c70-9349-444d-b9cb-8fa817697f5e");
assertThat(observation.getData().getUid()).isNull();
}
use of com.nedap.archie.rm.composition.Observation in project openEHR_SDK by ehrbase.
the class ContainmentTest method testContainment.
@Test
public void testContainment() {
List<TestCase> testCases = new ArrayList<>();
testCases.add(new TestCase(1, "openEHR-EHR-COMPOSITION.sample_encounter.v1", Composition.class, "COMPOSITION v[openEHR-EHR-COMPOSITION.sample_encounter.v1]"));
testCases.add(new TestCase(2, "openEHR-EHR-OBSERVATION.sample_blood_pressure.v1", Observation.class, "OBSERVATION v[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]"));
testCases.add(new TestCase(3, "openEHR-EHR-ADMIN_ENTRY.discharge.v1", AdminEntry.class, "ADMIN_ENTRY v[openEHR-EHR-ADMIN_ENTRY.discharge.v1]"));
EntityQuery query = mock(EntityQuery.class);
when(query.buildVariabelName(any())).thenReturn("v");
testCases.forEach(t -> {
Containment cut = new Containment(t.archetype);
cut.bindQuery(query);
assertThat(cut.getType()).as(String.format("Test Case %d", t.id)).isEqualTo(t.type);
assertThat(cut.buildAQL()).as(String.format("Test Case %d", t.id)).isEqualTo(t.aql);
});
}
use of com.nedap.archie.rm.composition.Observation in project openEHR_SDK by ehrbase.
the class WebTemplateSkeletonBuilderTest method build.
@Test
public void build() throws XmlException, IOException {
org.openehr.schemas.v1.TemplateDocument document = org.openehr.schemas.v1.TemplateDocument.Factory.parse(OperationalTemplateTestData.BLOOD_PRESSURE_SIMPLE.getStream());
OPERATIONALTEMPLATE operationaltemplate = document.getTemplate();
WebTemplate webTemplate = new OPTParser(operationaltemplate).parse();
Composition generate = WebTemplateSkeletonBuilder.build(webTemplate, true);
assertThat(generate).isNotNull();
assertThat(generate.getCategory().getDefiningCode()).extracting(CodePhrase::getCodeString, c -> c.getTerminologyId().getValue()).containsExactly("433", "openehr");
assertThat(generate.itemAtPath("/composer")).isNotNull();
assertThat(generate.itemAtPath("/context/end_time")).isNotNull();
assertThat(generate.itemAtPath("/content[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]")).isNotNull();
assertThat(((Observation) generate.itemAtPath("/content[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]")).getEncoding()).extracting(CodePhrase::getCodeString, c -> c.getTerminologyId().getValue()).containsExactly("UTF-8", "IANA_character-sets");
assertThat(generate.itemAtPath("/content[openEHR-EHR-OBSERVATION.sample_blood_pressure.v1]/data[at0001]/events[at0002]/state[at0007]/items[at1005]/value")).isNotNull();
}
Aggregations