use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class UnflattenerTest method testUnflattenBefundDerBlutgasanalyse.
@Test
public void testUnflattenBefundDerBlutgasanalyse() {
Unflattener cut = new Unflattener(new TestDataTemplateProvider());
BefundDerBlutgasanalyseComposition dto = new BefundDerBlutgasanalyseComposition();
LaborergebnisObservation laborergebnisObservation = new LaborergebnisObservation();
KohlendioxidpartialdruckCluster kohlendioxidpartialdruck = new KohlendioxidpartialdruckCluster();
kohlendioxidpartialdruck.setAnalytResultatMagnitude(22d);
laborergebnisObservation.setKohlendioxidpartialdruck(kohlendioxidpartialdruck);
dto.setLaborergebnis(laborergebnisObservation);
Composition rmObject = (Composition) cut.unflatten(dto);
assertThat(rmObject).isNotNull();
List<Object> clusters = rmObject.itemsAtPath("/content[openEHR-EHR-OBSERVATION.laboratory_test_result.v1]/data[at0001]/events[at0002]/data[at0003]/items[openEHR-EHR-CLUSTER.laboratory_test_analyte.v1]");
assertThat(clusters).size().isEqualTo(1);
}
use of com.nedap.archie.rm.composition.Composition 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.composition.Composition in project openEHR_SDK by ehrbase.
the class ParticipationTestIT method testParticipation.
@Test
@Ignore("see https://github.com/ehrbase/ehrbase/issues/710")
public void testParticipation() throws IOException {
ehr = openEhrClient.ehrEndpoint().createEhr();
Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.PARTICIPATION_NO_CONTENT.getStream(), StandardCharsets.UTF_8), Composition.class);
VersionUid versionUid = openEhrClient.compositionEndpoint(ehr).mergeRaw(composition);
Optional<Composition> postedComposition = openEhrClient.compositionEndpoint(ehr).findRaw(versionUid.getUuid());
assertThat(postedComposition.get()).isNotNull();
// check the actual participation IDs and Names
List<Participation> participations = postedComposition.get().getContext().getParticipations();
List<String> names = participations.stream().map(p -> p.getPerformer()).map(p -> ((PartyIdentified) p).getName()).collect(Collectors.toList());
assertThat(names).containsExactlyInAnyOrder("Dr. Marcus Johnson", "Zaza Markham");
List<String> ids = participations.stream().map(p -> p.getPerformer()).map(p -> p.getExternalRef().getId().getValue()).collect(Collectors.toList());
assertThat(ids).containsExactlyInAnyOrder("000", "123");
// use the sames IDs, but change one name. This raises an exception for conflicting identity!
((PartyIdentified) composition.getContext().getParticipations().get(0).getPerformer()).setName("Dummy");
try {
openEhrClient.compositionEndpoint(ehr).mergeRaw(composition);
fail("Didn't detect conflicting identity!");
} catch (WrongStatusCodeException e) {
// continue
}
// Now, keep the same names, but change an externalRef id
composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.PARTICIPATION_NO_CONTENT.getStream(), StandardCharsets.UTF_8), Composition.class);
composition.getContext().getParticipations().get(0).getPerformer().getExternalRef().setId(new GenericId("ABC", "HOSPITAL-NS"));
versionUid = openEhrClient.compositionEndpoint(ehr).mergeRaw(composition);
postedComposition = openEhrClient.compositionEndpoint(ehr).findRaw(versionUid.getUuid());
assertThat(postedComposition.get()).isNotNull();
// check the actual participation IDs and Names
participations = postedComposition.get().getContext().getParticipations();
names = participations.stream().map(p -> p.getPerformer()).map(p -> ((PartyIdentified) p).getName()).collect(Collectors.toList());
assertThat(names).containsExactlyInAnyOrder("Dr. Marcus Johnson", "Zaza Markham");
ids = participations.stream().map(p -> p.getPerformer()).map(p -> p.getExternalRef().getId().getValue()).collect(Collectors.toList());
assertThat(ids).containsExactlyInAnyOrder("ABC", "123");
// use the same name and id, but in another namespace
composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.PARTICIPATION_NO_CONTENT.getStream(), StandardCharsets.UTF_8), Composition.class);
composition.getContext().getParticipations().get(0).getPerformer().getExternalRef().setNamespace("ANOTHER_NAMESPACE");
versionUid = openEhrClient.compositionEndpoint(ehr).mergeRaw(composition);
postedComposition = openEhrClient.compositionEndpoint(ehr).findRaw(versionUid.getUuid());
assertThat(postedComposition.get()).isNotNull();
// check the actual participation IDs and Names
participations = postedComposition.get().getContext().getParticipations();
List<String> namespaces = participations.stream().map(p -> p.getPerformer()).map(p -> p.getExternalRef().getNamespace()).collect(Collectors.toList());
assertThat(namespaces).containsExactlyInAnyOrder("ANOTHER_NAMESPACE", "ANOTHER-HOSPITAL-NS");
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class ArbitraryQueryFeederAuditIT method setUp.
@Before
public void setUp() throws IOException {
ehrUUID = openEhrClient.ehrEndpoint().createEhr();
compositionEndpoint = openEhrClient.compositionEndpoint(ehrUUID);
aComposition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.FEEDER_AUDIT_DETAILS.getStream(), StandardCharsets.UTF_8), Composition.class);
Flattener flattener = new Flattener(new TestDataTemplateProvider());
TestAllTypesEnV1Composition testAllTypesEnV1Composition = flattener.flatten(aComposition, TestAllTypesEnV1Composition.class);
// create the composition
TestAllTypesEnV1Composition comp = compositionEndpoint.mergeCompositionEntity(testAllTypesEnV1Composition);
compositionUUID = comp.getVersionUid().getUuid();
arbitraryQuery = new ArbitraryQuery(ehrUUID, openEhrClient);
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class ArbitraryQueryOtherContextIT method setUp.
@Before
public void setUp() throws IOException {
// normal test run
ehrUUID = openEhrClient.ehrEndpoint().createEhr();
compositionEndpoint = openEhrClient.compositionEndpoint(ehrUUID);
aComposition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.VIROLOGY_FINDING_WITH_SPECIMEN_NO_UPDATE.getStream(), StandardCharsets.UTF_8), Composition.class);
Flattener flattener = new Flattener(new TestDataTemplateProvider());
VirologischerBefundComposition virologischerBefundComposition = flattener.flatten(aComposition, VirologischerBefundComposition.class);
// create the composition
VirologischerBefundComposition comp = compositionEndpoint.mergeCompositionEntity(virologischerBefundComposition);
compositionUUID = comp.getVersionUid().getUuid();
arbitraryQuery = new ArbitraryQuery(ehrUUID, openEhrClient);
simpleSelectQueryEngine = new SimpleSelectQuery(ehrUUID, compositionUUID, openEhrClient);
}
Aggregations