Search in sources :

Example 1 with RevisionHistoryResponseData

use of org.ehrbase.response.openehr.RevisionHistoryResponseData 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 2 with RevisionHistoryResponseData

use of org.ehrbase.response.openehr.RevisionHistoryResponseData in project openEHR_SDK by ehrbase.

the class DefaultRestVersionedCompositionEndpoint method findRevisionHistory.

@Override
public List<RevisionHistoryItem> findRevisionHistory(UUID versionedObjectUid) {
    URI uri = defaultRestClient.getConfig().getBaseUri().resolve(EHR_PATH + ehrId + VERSIONED_COMPOSITION_PATH + versionedObjectUid + REVISION_HISTORY_PATH);
    Optional<RevisionHistoryResponseData> result = defaultRestClient.httpGet(uri, RevisionHistoryResponseData.class);
    if (result.isEmpty()) {
        return new ArrayList<>();
    } else {
        return result.get().getRevisionHistoryItems();
    }
}
Also used : RevisionHistoryResponseData(org.ehrbase.response.openehr.RevisionHistoryResponseData) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 3 with RevisionHistoryResponseData

use of org.ehrbase.response.openehr.RevisionHistoryResponseData 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

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