use of com.nedap.archie.rm.ehr.VersionedComposition in project openEHR_SDK by ehrbase.
the class DefaultRestVersionedCompositionEndpointIT method testFindValid.
@Test
public void testFindValid() {
ehrId = openEhrClient.ehrEndpoint().createEhr();
EhrbaseBloodPressureSimpleDeV0Composition composition = TestData.buildEhrbaseBloodPressureSimpleDeV0();
openEhrClient.compositionEndpoint(ehrId).mergeCompositionEntity(composition);
Optional<VersionedComposition> versionedComposition = openEhrClient.versionedCompositionEndpoint(ehrId).find(composition.getVersionUid().getUuid());
Assert.assertTrue(versionedComposition.isPresent());
Assert.assertEquals(composition.getVersionUid().getUuid().toString(), versionedComposition.get().getUid().getValue());
Assert.assertEquals(ehrId.toString(), versionedComposition.get().getOwnerId().getId().getValue());
}
use of com.nedap.archie.rm.ehr.VersionedComposition in project ehrbase by ehrbase.
the class OpenehrVersionedCompositionController method retrieveVersionedCompositionByVersionedObjectUid.
@GetMapping(path = "/{versioned_object_uid}")
@Override
public ResponseEntity<VersionedObjectResponseData<Composition>> retrieveVersionedCompositionByVersionedObjectUid(@RequestHeader(value = HttpHeaders.ACCEPT, required = false) String accept, @PathVariable(value = "ehr_id") String ehrIdString, @PathVariable(value = "versioned_object_uid") String versionedObjectUid) {
UUID ehrId = getEhrUuid(ehrIdString);
UUID versionedCompoUid = getCompositionVersionedObjectUidString(versionedObjectUid);
// check if parameters are valid
checkForValidEhrAndCompositionParameter(ehrId, versionedCompoUid);
VersionedComposition versionedComposition = compositionService.getVersionedComposition(ehrId, versionedCompoUid);
VersionedObjectResponseData<Composition> response = new VersionedObjectResponseData<>(versionedComposition);
HttpHeaders respHeaders = new HttpHeaders();
respHeaders.setContentType(resolveContentType(accept));
return ResponseEntity.ok().headers(respHeaders).body(response);
}
use of com.nedap.archie.rm.ehr.VersionedComposition in project ehrbase by ehrbase.
the class CompositionServiceImp method getVersionedComposition.
@Override
public VersionedComposition getVersionedComposition(UUID ehrId, UUID composition) {
Optional<CompositionDto> dto = retrieve(composition, 1);
VersionedComposition compo = new VersionedComposition();
if (dto.isPresent()) {
compo.setUid(new HierObjectId(dto.get().getUuid().toString()));
compo.setOwnerId(new ObjectRef<>(new HierObjectId(dto.get().getEhrId().toString()), "local", "ehr"));
Map<Integer, I_CompositionAccess> compos = I_CompositionAccess.getVersionMapOfComposition(getDataAccess(), composition);
if (compos.containsKey(1)) {
compo.setTimeCreated(new DvDateTime(OffsetDateTime.of(compos.get(1).getSysTransaction().toLocalDateTime(), OffsetDateTime.now().getOffset())));
} else {
throw new InternalServerException("Inconsistent composition data, no version 1 available");
}
}
return compo;
}
Aggregations