Package org.ehrbase.api.service
Interface EhrService
public interface EhrService
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordWrapper forcreate(UUID, EhrStatusDto)response that contains theEHRid as well as theEhrStatusDtoand it'sObjectVersionId. -
Method Summary
Modifier and TypeMethodDescriptionvoidadminDeleteEhr(UUID ehrId) Admin method to delete an EHR from the DB.voidcheckEhrExists(UUID ehrId) Checks if an EHR with the given UUID exists.voidChecks if the EHR with the given UUID is modifiable.create(UUID ehrId, EhrStatusDto status) Creates new EHR instance, with default settings and values when no status or ID is supplied.findBySubject(String subjectId, String nameSpace) Search for an EHR_STATUS based on the given subject id and namespacecom.nedap.archie.rm.datavalues.quantity.datetime.DvDateTimegetCreationTime(UUID ehrId) Provides the creation time of the given EHR id.getEhrStatus(UUID ehrUuid) Gets latest EHR_STATUS of the given EHR.Optional<com.nedap.archie.rm.changecontrol.OriginalVersion<EhrStatusDto>> getEhrStatusAtVersion(UUID ehrUuid, UUID versionedObjectUid, int version) Gets particular EHR_STATUS matching the given version Uid.com.nedap.archie.rm.support.identification.ObjectVersionIdgetEhrStatusVersionByTimestamp(UUID ehrUid, OffsetDateTime timestamp) Get version number of EHR_STATUS associated with given EHR UID at given timestamp.com.nedap.archie.rm.support.identification.ObjectVersionIdgetLatestVersionUidOfStatus(UUID ehrId) Get latest version UID of an EHR_STATUS by given associated EHR UID.com.nedap.archie.rm.generic.RevisionHistoryGets revision history of EhrStatus associated with given EHR.getSubjectExtRef(String ehrId) Helper to directly get the external subject reference form the linked subject to given EHR.com.nedap.archie.rm.changecontrol.VersionedObject<EhrStatusDto> getVersionedEhrStatus(UUID ehrId) Gets version container EhrStatus associated with given EHR.booleanReturn True if a EHR with identifier ehrId exists.updateStatus(UUID ehrId, EhrStatusDto status, com.nedap.archie.rm.support.identification.ObjectVersionId targetObjId, UUID contribution, UUID audit) Update the EHR_STATUS linked to the given EHR
-
Method Details
-
create
Creates new EHR instance, with default settings and values when no status or ID is supplied.- Parameters:
ehrId- Optional, sets custom IDstatus- Optional, sets custom status- Returns:
EhrService.EhrResultof new EHR instance- Throws:
StateConflictException- when an EHR with the given id already existValidationException- when given status is invalid, e.g. not a valid openEHR RM object
-
updateStatus
EhrService.EhrResult updateStatus(UUID ehrId, EhrStatusDto status, com.nedap.archie.rm.support.identification.ObjectVersionId targetObjId, UUID contribution, UUID audit) Update the EHR_STATUS linked to the given EHR- Parameters:
ehrId- ID of linked EHRstatus- input EHR_STATUScontribution- Optional ID of custom contribution. Can be null.audit- Audit event id- Returns:
EhrService.EhrResultof the updated status- Throws:
ObjectNotFoundException- if no EHR is foundValidationException- when given status is invalid, e.g. not a valid openEHR RM object
-
getEhrStatus
Gets latest EHR_STATUS of the given EHR.- Parameters:
ehrUuid- EHR subject- Returns:
- Latest EHR_STATUS
- Throws:
ObjectNotFoundException- if no EHR is found
-
getEhrStatusAtVersion
Optional<com.nedap.archie.rm.changecontrol.OriginalVersion<EhrStatusDto>> getEhrStatusAtVersion(UUID ehrUuid, UUID versionedObjectUid, int version) Gets particular EHR_STATUS matching the given version Uid.- Parameters:
ehrUuid- Root EHRversionedObjectUid- Given Uid of EHR_STATUSversion- Given version of EHR_STATUS- Returns:
- Matching EHR_STATUS or empty
- Throws:
ObjectNotFoundException- if no EHR is found
-
findBySubject
Search for an EHR_STATUS based on the given subject id and namespace -
getLatestVersionUidOfStatus
Get latest version UID of an EHR_STATUS by given associated EHR UID.- Parameters:
ehrId- EHR ID- Returns:
- EHR_STATUS version UID
- Throws:
ObjectNotFoundException- if no EHR is found
-
getEhrStatusVersionByTimestamp
com.nedap.archie.rm.support.identification.ObjectVersionId getEhrStatusVersionByTimestamp(UUID ehrUid, OffsetDateTime timestamp) Get version number of EHR_STATUS associated with given EHR UID at given timestamp.- Parameters:
ehrUid- EHR UIDtimestamp- Timestamp of point in time- Returns:
- version number
- Throws:
ObjectNotFoundException- if no EHR is found
-
getCreationTime
Provides the creation time of the given EHR id.- Parameters:
ehrId- ID of the EHR- Returns:
DvDateTimeof the EHR creation
-
hasEhr
Return True if a EHR with identifier ehrId exists. Implements has_ehr from the openEHR Platform Abstract Service Model.- Parameters:
ehrId- identifier to test- Returns:
- True when existing, false if not
-
getVersionedEhrStatus
Gets version container EhrStatus associated with given EHR.- Parameters:
ehrId- Given EHR ID- Returns:
- Version container object
- Throws:
ObjectNotFoundException- if no EHR is found
-
getRevisionHistoryOfVersionedEhrStatus
Gets revision history of EhrStatus associated with given EHR.- Parameters:
ehrId- Given EHR ID- Returns:
- Revision history object
- Throws:
ObjectNotFoundException- if no EHR is found
-
adminDeleteEhr
Admin method to delete an EHR from the DB. See EHRbase Admin API specification for details.- Parameters:
ehrId- EHR to delete
-
getSubjectExtRef
Helper to directly get the external subject reference form the linked subject to given EHR.- Parameters:
ehrId- Given EHR ID- Returns:
- Linked external subject reference or null
- Throws:
ObjectNotFoundException- if no EHR is found
-
checkEhrExists
Checks if an EHR with the given UUID exists.- Parameters:
ehrId- EHR ID to check- Throws:
ObjectNotFoundException- if no EHR is found
-
checkEhrExistsAndIsModifiable
Checks if the EHR with the given UUID is modifiable.- Parameters:
ehrId- EHR ID to check- Throws:
ObjectNotFoundException- if no EHR is found.StateConflictException- if the EHR is not modifiable.
-