Search in sources :

Example 1 with VersionedEhrStatus

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);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) VersionedEhrStatus(com.nedap.archie.rm.ehr.VersionedEhrStatus) VersionedEhrStatus(com.nedap.archie.rm.ehr.VersionedEhrStatus) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) VersionedObjectResponseData(org.ehrbase.response.openehr.VersionedObjectResponseData) ObjectNotFoundException(org.ehrbase.api.exception.ObjectNotFoundException) UUID(java.util.UUID) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with VersionedEhrStatus

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;
}
Also used : VersionedEhrStatus(com.nedap.archie.rm.ehr.VersionedEhrStatus) VersionedEhrStatus(com.nedap.archie.rm.ehr.VersionedEhrStatus) EhrStatus(com.nedap.archie.rm.ehr.EhrStatus) HierObjectId(com.nedap.archie.rm.support.identification.HierObjectId) DvDateTime(com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)

Aggregations

EhrStatus (com.nedap.archie.rm.ehr.EhrStatus)2 VersionedEhrStatus (com.nedap.archie.rm.ehr.VersionedEhrStatus)2 DvDateTime (com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime)1 HierObjectId (com.nedap.archie.rm.support.identification.HierObjectId)1 UUID (java.util.UUID)1 ObjectNotFoundException (org.ehrbase.api.exception.ObjectNotFoundException)1 VersionedObjectResponseData (org.ehrbase.response.openehr.VersionedObjectResponseData)1 HttpHeaders (org.springframework.http.HttpHeaders)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1