use of com.nedap.archie.rm.ehr.VersionedEhrStatus in project ehrbase by ehrbase.
the class OpenehrVersionedEhrStatusController method retrieveVersionedEhrStatusByEhr.
@GetMapping
@Override
public ResponseEntity<VersionedObjectResponseData<EhrStatus>> retrieveVersionedEhrStatusByEhr(@PathVariable(value = "ehr_id") String ehrIdString, @RequestHeader(value = HttpHeaders.ACCEPT, required = false) String accept) {
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");
}
VersionedEhrStatus versionedEhrStatus = ehrService.getVersionedEhrStatus(ehrId);
VersionedObjectResponseData<EhrStatus> response = new VersionedObjectResponseData<>(versionedEhrStatus);
HttpHeaders respHeaders = new HttpHeaders();
respHeaders.setContentType(resolveContentType(accept));
return ResponseEntity.ok().headers(respHeaders).body(response);
}
use of com.nedap.archie.rm.ehr.VersionedEhrStatus in project ehrbase by ehrbase.
the class EhrServiceImp method getVersionedEhrStatus.
@Override
public VersionedEhrStatus getVersionedEhrStatus(UUID ehrUid) {
// FIXME VERSIONED_OBJECT_POC: Pre_has_ehr: has_ehr (an_ehr_id)
// FIXME VERSIONED_OBJECT_POC: Pre_has_ehr_status_version: has_ehr_status_version (an_ehr_id, a_version_uid)
Optional<EhrStatus> ehrStatus = getEhrStatus(ehrUid);
VersionedEhrStatus versionedEhrStatus = new VersionedEhrStatus();
if (ehrStatus.isPresent()) {
versionedEhrStatus.setUid(new HierObjectId(ehrStatus.get().getUid().getRoot().getValue()));
versionedEhrStatus.setOwnerId(new ObjectRef<>(new HierObjectId(ehrUid.toString()), "local", "EHR"));
I_EhrAccess ehrAccess = I_EhrAccess.retrieveInstance(getDataAccess(), ehrUid);
versionedEhrStatus.setTimeCreated(new DvDateTime(OffsetDateTime.of(ehrAccess.getStatusAccess().getInitialTimeOfVersionedEhrStatus().toLocalDateTime(), OffsetDateTime.now().getOffset())));
}
return versionedEhrStatus;
}
Aggregations