use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class CanonicalCompoAllTypeQueryIT method setUp.
public void setUp(CompositionTestDataCanonicalJson testComposition) throws IOException {
// manual test use
// ehrUUID = UUID.fromString("ecc0de4d-eb29-40c2-ad7a-e2ab8d66a9f8");
// compositionUUID = UUID.fromString("a9c22c37-8002-4486-932a-f3e1729efe57");
actualDvDateTime = new DvDateTime(OffsetDateTime.now());
// normal test run
ehrUUID = openEhrClient.ehrEndpoint().createEhr();
compositionEndpoint = openEhrClient.compositionEndpoint(ehrUUID);
if (testComposition != null) {
aComposition = new CanonicalJson().unmarshal(IOUtils.toString(testComposition.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();
}
}
use of com.nedap.archie.rm.composition.Composition 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.Composition in project openEHR_SDK by ehrbase.
the class FlattenerTest method testFlattenEpisodeOfCare.
@Test
public void testFlattenEpisodeOfCare() {
Composition composition = (Composition) new Unflattener(new TestDataTemplateProvider()).unflatten(buildEpisodeOfCareComposition());
Flattener cut = new Flattener(new TestDataTemplateProvider());
EpisodeOfCareComposition actual = cut.flatten(composition, EpisodeOfCareComposition.class);
assertThat(actual).isNotNull();
assertThat(actual.getEpisodeofcare()).size().isEqualTo(1);
EpisodeofcareAdminEntry episodeofcareAdminEntry = actual.getEpisodeofcare().get(0);
assertThat(episodeofcareAdminEntry.getIdentifier()).extracting(e -> e.getValue().getId()).containsExactlyInAnyOrder("123", "456");
assertThat(episodeofcareAdminEntry.getTeam()).extracting(EpisodeofcareTeamElement::getValue).containsExactlyInAnyOrder(URI.create("https://github.com/ehrbase"));
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class OldDtoModelTest method testFlattenCorona.
@Test
public void testFlattenCorona() throws IOException {
Composition composition = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.CORONA.getStream(), StandardCharsets.UTF_8), Composition.class);
Flattener cut = new Flattener(new TestDataTemplateProvider());
CoronaAnamneseComposition actual = cut.flatten(composition, CoronaAnamneseComposition.class);
assertThat(actual).isNotNull();
assertThat(actual.getSymptome()).isNotNull();
assertThat(actual.getSymptome().getHeiserkeit()).isNotNull();
assertThat(actual.getSymptome().getHeiserkeit().getVorhandenDefiningcode()).isEqualTo(VorhandenDefiningcode.NICHT_VORHANDEN);
}
use of com.nedap.archie.rm.composition.Composition in project openEHR_SDK by ehrbase.
the class OldDtoModelTest method testUnflattenCorona.
@Test
public void testUnflattenCorona() throws IOException {
Composition expected = new CanonicalJson().unmarshal(IOUtils.toString(CompositionTestDataCanonicalJson.CORONA.getStream(), StandardCharsets.UTF_8), Composition.class);
Flattener flattener = new Flattener(new TestDataTemplateProvider());
CoronaAnamneseComposition coronaAnamneseComposition = flattener.flatten(expected, CoronaAnamneseComposition.class);
Unflattener cut = new Unflattener(new TestDataTemplateProvider());
Composition actual = (Composition) cut.unflatten(coronaAnamneseComposition);
assertThat(actual).isNotNull();
assertThat(actual.getContent()).extracting(Locatable::getNameAsString, Locatable::getArchetypeNodeId).containsExactlyInAnyOrder(actual.getContent().stream().map(c -> new Tuple(c.getNameAsString(), c.getArchetypeNodeId())).toArray(Tuple[]::new));
}
Aggregations