Search in sources :

Example 1 with RevisionHistory

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;
}
Also used : OriginalVersion(com.nedap.archie.rm.changecontrol.OriginalVersion) RevisionHistory(com.nedap.archie.rm.generic.RevisionHistory) InternalServerException(org.ehrbase.api.exception.InternalServerException)

Example 2 with 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);
}
Also used : RevisionHistoryResponseData(org.ehrbase.response.openehr.RevisionHistoryResponseData) HttpHeaders(org.springframework.http.HttpHeaders) RevisionHistory(com.nedap.archie.rm.generic.RevisionHistory) ObjectNotFoundException(org.ehrbase.api.exception.ObjectNotFoundException) UUID(java.util.UUID) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with RevisionHistory

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);
}
Also used : RevisionHistoryResponseData(org.ehrbase.response.openehr.RevisionHistoryResponseData) HttpHeaders(org.springframework.http.HttpHeaders) RevisionHistory(com.nedap.archie.rm.generic.RevisionHistory) UUID(java.util.UUID) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

RevisionHistory (com.nedap.archie.rm.generic.RevisionHistory)3 UUID (java.util.UUID)2 RevisionHistoryResponseData (org.ehrbase.response.openehr.RevisionHistoryResponseData)2 HttpHeaders (org.springframework.http.HttpHeaders)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 OriginalVersion (com.nedap.archie.rm.changecontrol.OriginalVersion)1 InternalServerException (org.ehrbase.api.exception.InternalServerException)1 ObjectNotFoundException (org.ehrbase.api.exception.ObjectNotFoundException)1