Search in sources :

Example 6 with OriginalVersion

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());
}
Also used : OriginalVersion(com.nedap.archie.rm.changecontrol.OriginalVersion) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) Test(org.junit.Test)

Example 7 with OriginalVersion

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());
}
Also used : OriginalVersion(com.nedap.archie.rm.changecontrol.OriginalVersion) VersionUid(org.ehrbase.client.openehrclient.VersionUid) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) Test(org.junit.Test)

Example 8 with OriginalVersion

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());
}
Also used : OriginalVersion(com.nedap.archie.rm.changecontrol.OriginalVersion) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) Test(org.junit.Test)

Example 9 with OriginalVersion

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());
}
Also used : LocalDateTime(java.time.LocalDateTime) OriginalVersion(com.nedap.archie.rm.changecontrol.OriginalVersion) EpisodeOfCareComposition(org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition) UUID(java.util.UUID) Test(org.junit.Test)

Example 10 with OriginalVersion

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;
}
Also used : OriginalVersion(com.nedap.archie.rm.changecontrol.OriginalVersion) Flattener(org.ehrbase.client.flattener.Flattener)

Aggregations

OriginalVersion (com.nedap.archie.rm.changecontrol.OriginalVersion)16 UUID (java.util.UUID)8 ObjectNotFoundException (org.ehrbase.api.exception.ObjectNotFoundException)6 Test (org.junit.Test)6 LocalDateTime (java.time.LocalDateTime)5 InternalServerException (org.ehrbase.api.exception.InternalServerException)5 EpisodeOfCareComposition (org.ehrbase.client.classgenerator.examples.episodeofcarecomposition.EpisodeOfCareComposition)5 RevisionHistory (com.nedap.archie.rm.generic.RevisionHistory)4 InvalidApiParameterException (org.ehrbase.api.exception.InvalidApiParameterException)4 HttpHeaders (org.springframework.http.HttpHeaders)4 MediaType (org.springframework.http.MediaType)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)3 VersionedEhrStatus (com.nedap.archie.rm.ehr.VersionedEhrStatus)3 ObjectVersionId (com.nedap.archie.rm.support.identification.ObjectVersionId)3 Objects (java.util.Objects)3 Optional (java.util.Optional)3 ContributionService (org.ehrbase.api.service.ContributionService)3 EhrService (org.ehrbase.api.service.EhrService)3 ContributionDto (org.ehrbase.response.ehrscape.ContributionDto)3