use of com.nedap.archie.rm.generic.RevisionHistory in project ehrbase by ehrbase.
the class CompositionServiceImp method getRevisionHistoryOfVersionedComposition.
@Override
public RevisionHistory getRevisionHistoryOfVersionedComposition(UUID composition) {
// get number of versions
int versions = getLastVersionNumber(composition);
// fetch each version and add to revision history
RevisionHistory revisionHistory = new RevisionHistory();
for (int i = 1; i <= versions; i++) {
Optional<OriginalVersion<Composition>> compoVersion = getOriginalVersionComposition(composition, i);
compoVersion.ifPresent(compositionOriginalVersion -> revisionHistory.addItem(revisionHistoryItemFromComposition(compositionOriginalVersion)));
}
if (revisionHistory.getItems().isEmpty()) {
throw new InternalServerException(// never should be empty; not valid
"Problem creating RevisionHistory");
}
return revisionHistory;
}
use of com.nedap.archie.rm.generic.RevisionHistory in project ehrbase by ehrbase.
the class OpenehrVersionedEhrStatusController method retrieveVersionedEhrStatusRevisionHistoryByEhr.
@GetMapping(path = "/revision_history")
@Override
public ResponseEntity<RevisionHistoryResponseData> retrieveVersionedEhrStatusRevisionHistoryByEhr(@RequestHeader(value = HttpHeaders.ACCEPT, required = false) String accept, @PathVariable(value = "ehr_id") String ehrIdString) {
UUID ehrId = getEhrUuid(ehrIdString);
// check if EHR is valid
if (!ehrService.hasEhr(ehrId)) {
throw new ObjectNotFoundException("ehr", "No EHR with this ID can be found");
}
RevisionHistory revisionHistory = ehrService.getRevisionHistoryOfVersionedEhrStatus(ehrId);
RevisionHistoryResponseData response = new RevisionHistoryResponseData(revisionHistory);
HttpHeaders respHeaders = new HttpHeaders();
respHeaders.setContentType(resolveContentType(accept));
return ResponseEntity.ok().headers(respHeaders).body(response);
}
use of com.nedap.archie.rm.generic.RevisionHistory in project ehrbase by ehrbase.
the class OpenehrVersionedCompositionController method retrieveVersionedCompositionRevisionHistoryByEhr.
@GetMapping(path = "/{versioned_object_uid}/revision_history")
@Override
public ResponseEntity<RevisionHistoryResponseData> retrieveVersionedCompositionRevisionHistoryByEhr(@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);
RevisionHistory revisionHistory = compositionService.getRevisionHistoryOfVersionedComposition(versionedCompoUid);
RevisionHistoryResponseData response = new RevisionHistoryResponseData(revisionHistory);
HttpHeaders respHeaders = new HttpHeaders();
respHeaders.setContentType(resolveContentType(accept));
return ResponseEntity.ok().headers(respHeaders).body(response);
}
Aggregations