use of com.nedap.archie.rm.changecontrol.OriginalVersion in project openEHR_SDK by ehrbase.
the class DefaultRestVersionedCompositionEndpointIT method testFindVersionByIdWrongVersionedObjectUid.
@Test
public void testFindVersionByIdWrongVersionedObjectUid() {
ehrId = openEhrClient.ehrEndpoint().createEhr();
EpisodeOfCareComposition composition = TestData.buildEpisodeOfCareComposition();
openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition);
Optional<OriginalVersion<EpisodeOfCareComposition>> originalVersion = openEhrClient.versionedCompositionEndpoint(ehrId).findVersionById(UUID.randomUUID(), composition.getVersionUid(), EpisodeOfCareComposition.class);
Assert.assertTrue(originalVersion.isEmpty());
}
use of com.nedap.archie.rm.changecontrol.OriginalVersion in project openEHR_SDK by ehrbase.
the class DefaultRestVersionedCompositionEndpointIT method testFindVersionById.
@Test
public void testFindVersionById() {
ehrId = openEhrClient.ehrEndpoint().createEhr();
EpisodeOfCareComposition composition = TestData.buildEpisodeOfCareComposition();
openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition);
VersionUid v2 = openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition).getVersionUid();
openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition);
Optional<OriginalVersion<EpisodeOfCareComposition>> originalVersion = openEhrClient.versionedCompositionEndpoint(ehrId).findVersionById(v2.getUuid(), v2, EpisodeOfCareComposition.class);
Assert.assertTrue(originalVersion.isPresent());
Assert.assertEquals(v2.toString(), originalVersion.get().getUid().getValue());
Assert.assertEquals(composition.getLanguage(), originalVersion.get().getData().getLanguage());
}
use of com.nedap.archie.rm.changecontrol.OriginalVersion in project openEHR_SDK by ehrbase.
the class DefaultRestVersionedCompositionEndpointIT method testFindVersionAtTimeNull.
@Test
public void testFindVersionAtTimeNull() {
ehrId = openEhrClient.ehrEndpoint().createEhr();
EpisodeOfCareComposition composition = TestData.buildEpisodeOfCareComposition();
openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition);
openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition);
openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition);
Optional<OriginalVersion<EpisodeOfCareComposition>> originalVersion = openEhrClient.versionedCompositionEndpoint(ehrId).findVersionAtTime(composition.getVersionUid().getUuid(), null, EpisodeOfCareComposition.class);
Assert.assertTrue(originalVersion.isPresent());
Assert.assertEquals(composition.getVersionUid().toString(), originalVersion.get().getUid().getValue());
Assert.assertEquals(composition.getLanguage(), originalVersion.get().getData().getLanguage());
}
use of com.nedap.archie.rm.changecontrol.OriginalVersion in project openEHR_SDK by ehrbase.
the class DefaultRestVersionedCompositionEndpointIT method testFindVersionAtTimeInvalidIId.
@Test
public void testFindVersionAtTimeInvalidIId() {
LocalDateTime versionAtTime = LocalDateTime.now();
ehrId = openEhrClient.ehrEndpoint().createEhr();
EpisodeOfCareComposition composition = TestData.buildEpisodeOfCareComposition();
openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition);
UUID uuid = UUID.randomUUID();
Optional<OriginalVersion<EpisodeOfCareComposition>> result;
result = openEhrClient.versionedCompositionEndpoint(ehrId).findVersionAtTime(uuid, versionAtTime, EpisodeOfCareComposition.class);
Assert.assertTrue(result.isEmpty());
result = openEhrClient.versionedCompositionEndpoint(ehrId).findVersionAtTime(uuid, null, EpisodeOfCareComposition.class);
Assert.assertTrue(result.isEmpty());
}
use of com.nedap.archie.rm.changecontrol.OriginalVersion in project openEHR_SDK by ehrbase.
the class DefaultRestVersionedCompositionEndpoint method convert.
/**
* Converts an {@link OriginalVersionResponseData} into an {@link OriginalVersion}.
*
* @param originalVersion response data to convert
* @param clazz expected class
* @param <T> composition class
* @return converted object
*/
private <T> OriginalVersion<T> convert(OriginalVersionResponseData<Composition> originalVersion, Class<T> clazz) {
OriginalVersion<T> result = new OriginalVersion<>();
result.setUid(originalVersion.getVersionId());
result.setPrecedingVersionUid(originalVersion.getPrecedingVersionUid());
result.setLifecycleState(originalVersion.getLifecycleState());
result.setCommitAudit(originalVersion.getAuditDetails());
result.setSignature(originalVersion.getSignature());
result.setOtherInputVersionUids(originalVersion.getOtherInputVersionUids());
result.setAttestations(originalVersion.getAttestations());
T composition = new Flattener(defaultRestClient.getTemplateProvider()).flatten(originalVersion.getData(), clazz);
result.setData(composition);
return result;
}
Aggregations