use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class AutoWhereIT method testEvaluationAutoWhere.
@Test
public void testEvaluationAutoWhere() throws IOException {
String rootPath = "eval";
RMObject referenceNode = (RMObject) aComposition.itemsAtPath("/content[openEHR-EHR-EVALUATION.test_all_types.v1]").get(0);
String contains = "composition c[openEHR-EHR-COMPOSITION.test_all_types.v1]" + " contains evaluation eval[openEHR-EHR-EVALUATION.test_all_types.v1]";
String csvTestSet = dirPath + "/testEvaluationWhere.csv";
assertThat(autoWhereQuery.testItemPaths(csvTestSet, rootPath, contains, referenceNode)).isTrue();
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class FlattenerTest method testFlatten.
@Test
public void testFlatten() {
Flattener cut = new Flattener(new TestDataTemplateProvider());
BloodpressureListDe bloodpressureListDe = TestData.buildExampleBloodpressureListDe();
RMObject rmObject = new Unflattener(new TestDataTemplateProvider()).unflatten(bloodpressureListDe);
BloodpressureListDe expected = cut.flatten(rmObject, BloodpressureListDe.class);
assertThat(expected).isNotNull();
assertThat(expected.getStartTime()).isEqualTo(bloodpressureListDe.getStartTime());
assertThat(expected.getBloodpressures()).extracting(BloodpressureListDe.Bloodpressure::getSystolischValue).containsExactlyInAnyOrder(12d, 22d);
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class FlattenerTest method testFlattenEhrbaseBloodPressureSimpleDeV0.
@Test
public void testFlattenEhrbaseBloodPressureSimpleDeV0() {
Flattener cut = new Flattener(new TestDataTemplateProvider());
EhrbaseBloodPressureSimpleDeV0Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseBloodPressureSimpleDeV0();
RMObject rmObject = new Unflattener(new TestDataTemplateProvider()).unflatten(bloodPressureSimpleDeV0);
EhrbaseBloodPressureSimpleDeV0Composition actual = cut.flatten((Locatable) rmObject, EhrbaseBloodPressureSimpleDeV0Composition.class);
assertThat(actual).isNotNull();
assertThat(actual.getComposer()).isNotNull().extracting(Object::getClass).isEqualTo(PartyIdentified.class);
PartyIdentified composer = (PartyIdentified) actual.getComposer();
assertThat(composer.getName()).isEqualTo("Test");
assertThat(actual.getParticipations()).extracting(p -> ((PartyIdentified) p.getPerformer()).getName(), p -> p.getFunction().getValue()).containsExactlyInAnyOrder(new Tuple("Test", "Pos1"), new Tuple("Test2", "Pos2"));
assertThat(actual.getBloodPressureTrainingSample()).size().isEqualTo(1);
assertThat(actual.getBloodPressureTrainingSample().get(0).getSubject()).isNotNull().extracting(Object::getClass).isEqualTo(PartySelf.class);
assertThat(actual.getBloodPressureTrainingSample().get(0).getSystolicMagnitude()).isEqualTo(22d);
assertThat(actual.getBloodPressureTrainingSample().get(0).getSystolicUnits()).isEqualTo("mm[Hg]");
assertThat(actual.getBloodPressureTrainingSample().get(0).getKorotkoffSoundsDefiningCode()).isEqualTo(KorotkoffSoundsDefiningCode.FIFTH_SOUND);
assertThat(actual.getBloodPressureTrainingSample().get(0).getMeanArterialPressureNullFlavourDefiningCode()).isNull();
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class FlattenerTest method testFlattenEhrbaseMultiOccurrenceDeV1.
@Test
public void testFlattenEhrbaseMultiOccurrenceDeV1() {
Flattener cut = new Flattener(new TestDataTemplateProvider());
EhrbaseMultiOccurrenceDeV1Composition bloodPressureSimpleDeV0 = TestData.buildEhrbaseMultiOccurrenceDeV1();
RMObject rmObject = new Unflattener(new TestDataTemplateProvider()).unflatten(bloodPressureSimpleDeV0);
EhrbaseMultiOccurrenceDeV1Composition actual = cut.flatten((Locatable) rmObject, EhrbaseMultiOccurrenceDeV1Composition.class);
assertThat(actual).isNotNull();
assertThat(actual.getBodyTemperature()).size().isEqualTo(2);
BodyTemperatureObservation bodyTemperature1 = actual.getBodyTemperature().get(0);
assertThat(bodyTemperature1.getAnyEvent()).extracting(e -> ((BodyTemperatureAnyEventPointEvent) e).getTemperatureMagnitude()).containsExactlyInAnyOrder(11d, 22d);
BodyTemperatureLocationOfMeasurementChoice locationOfMeasurement1 = bodyTemperature1.getLocationOfMeasurement();
assertThat(locationOfMeasurement1.getClass()).isEqualTo(BodyTemperatureLocationOfMeasurementDvCodedText.class);
assertThat(((BodyTemperatureLocationOfMeasurementDvCodedText) locationOfMeasurement1).getLocationOfMeasurementDefiningCode()).isEqualTo(LocationOfMeasurementDefiningCode.FOREHEAD);
BodyTemperatureObservation bodyTemperature2 = actual.getBodyTemperature().get(1);
BodyTemperatureLocationOfMeasurementChoice locationOfMeasurement2 = bodyTemperature2.getLocationOfMeasurement();
assertThat(locationOfMeasurement2.getClass()).isEqualTo(BodyTemperatureLocationOfMeasurementDvText.class);
assertThat(((BodyTemperatureLocationOfMeasurementDvText) locationOfMeasurement2).getLocationOfMeasurementValue()).isEqualTo("location");
}
use of com.nedap.archie.rm.RMObject in project openEHR_SDK by ehrbase.
the class OldDtoModelTest method checkTestCase.
public void checkTestCase(TestCase testCase, SoftAssertions softly) throws IOException {
String value = IOUtils.toString(testCase.simSDTJson.getStream(), UTF_8);
RMDataFormat flatJson = new FlatJasonProvider(new TestDataTemplateProvider()).buildFlatJson(FlatFormat.SIM_SDT, testCase.templateId);
Composition composition = flatJson.unmarshal(value);
Flattener flattener = new Flattener(new TestDataTemplateProvider());
Object flatten = flattener.flatten(composition, testCase.dtoClass);
Unflattener unflattener = new Unflattener(new TestDataTemplateProvider());
RMObject actual = unflattener.unflatten(flatten);
String actualFlat = flatJson.marshal(actual);
List<String> errors = compere(actualFlat, value);
softly.assertThat(errors).filteredOn(s -> s.startsWith("Missing")).as("Test Case %s", testCase.id).containsExactlyInAnyOrder(testCase.missing);
softly.assertThat(errors).filteredOn(s -> s.startsWith("Extra")).as("Test Case %s", testCase.id).containsExactlyInAnyOrder(testCase.extra);
}
Aggregations