Package com.ibm.fhir.persistence
Interface FHIRPersistence
-
- All Known Implementing Classes:
FHIRPersistenceJDBCImpl
public interface FHIRPersistence
This interface defines the contract between the FHIR Server's REST API layer and the underlying persistence layer that is responsible for interacting with a particular datastore to manage instances of FHIR Resources.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T extends Resource>
SingleResourceResult<T>create(FHIRPersistenceContext context, T resource)
Stores a new FHIR Resource in the datastore.default <T extends Resource>
SingleResourceResult<T>delete(FHIRPersistenceContext context, Class<T> resourceType, String logicalId)
Deletes the specified FHIR Resource from the datastore.ResourcePayload
fetchResourcePayloads(Class<? extends Resource> resourceType, Instant fromLastModified, Instant toLastModified, Function<ResourcePayload,Boolean> process)
Special function for high speed export of resource payloads.String
generateResourceId()
Generates a resource ID.OperationOutcome
getHealth()
Returns an OperationOutcome indicating the current status of the persistence store / backendFHIRPersistenceTransaction
getTransaction()
Returns a FHIRPersistenceTransaction object associated with the persistence layer implementation in use.<T extends Resource>
MultiResourceResult<T>history(FHIRPersistenceContext context, Class<T> resourceType, String logicalId)
Retrieves all of the versions of the specified FHIR Resource.default boolean
isDeleteSupported()
Returns true iff the persistence layer implementation supports the "delete" operation.default boolean
isReindexSupported()
Returns true iff the persistence layer implementation supports the "reindex" special operationboolean
isTransactional()
Returns true iff the persistence layer implementation supports transactions.<T extends Resource>
SingleResourceResult<T>read(FHIRPersistenceContext context, Class<T> resourceType, String logicalId)
Retrieves the most recent version of a FHIR Resource from the datastore.int
reindex(FHIRPersistenceContext context, OperationOutcome.Builder operationOutcomeResult, Instant tstamp, String resourceLogicalId)
Initiates reindexing for resources not yet processed.MultiResourceResult<Resource>
search(FHIRPersistenceContext context, Class<? extends Resource> resourceType)
Performs a search on the specified target resource type using the specified search parameters.<T extends Resource>
SingleResourceResult<T>update(FHIRPersistenceContext context, String logicalId, T resource)
Updates an existing FHIR Resource by storing a new version in the datastore.<T extends Resource>
SingleResourceResult<T>vread(FHIRPersistenceContext context, Class<T> resourceType, String logicalId, String versionId)
Retrieves a specific version of a FHIR Resource from the datastore.
-
-
-
Method Detail
-
create
<T extends Resource> SingleResourceResult<T> create(FHIRPersistenceContext context, T resource) throws FHIRPersistenceException
Stores a new FHIR Resource in the datastore.- Parameters:
context
- the FHIRPersistenceContext instance associated with the current requestresource
- the FHIR Resource instance to be created in the datastore- Returns:
- a SingleResourceResult with a copy of resource with Meta fields updated by the persistence layer and/or an OperationOutcome with hints, warnings, or errors related to the interaction
- Throws:
FHIRPersistenceException
-
read
<T extends Resource> SingleResourceResult<T> read(FHIRPersistenceContext context, Class<T> resourceType, String logicalId) throws FHIRPersistenceException
Retrieves the most recent version of a FHIR Resource from the datastore.- Parameters:
context
- the FHIRPersistenceContext instance associated with the current requestresourceType
- the resource type of the Resource instance to be retrievedlogicalId
- the logical id of the Resource instance to be retrieved- Returns:
- a SingleResourceResult with the FHIR Resource that was retrieved from the datastore and/or an OperationOutcome with hints, warnings, or errors related to the interaction
- Throws:
FHIRPersistenceException
-
vread
<T extends Resource> SingleResourceResult<T> vread(FHIRPersistenceContext context, Class<T> resourceType, String logicalId, String versionId) throws FHIRPersistenceException
Retrieves a specific version of a FHIR Resource from the datastore.- Parameters:
context
- the FHIRPersistenceContext instance associated with the current requestresourceType
- the resource type of the Resource instance to be retrievedlogicalId
- the logical id of the Resource instance to be retrievedversionId
- the version of the Resource instance to be retrieved- Returns:
- a SingleResourceResult with the FHIR Resource that was retrieved from the datastore and/or an OperationOutcome with hints, warnings, or errors related to the interaction
- Throws:
FHIRPersistenceException
-
update
<T extends Resource> SingleResourceResult<T> update(FHIRPersistenceContext context, String logicalId, T resource) throws FHIRPersistenceException
Updates an existing FHIR Resource by storing a new version in the datastore.- Parameters:
context
- the FHIRPersistenceContext instance associated with the current requestlogicalId
- the logical id of the FHIR Resource to be updatedresource
- the new contents of the FHIR Resource to be stored- Returns:
- a SingleResourceResult with a copy of resource with fields updated by the persistence layer and/or an OperationOutcome with hints, warnings, or errors related to the interaction
- Throws:
FHIRPersistenceException
-
delete
default <T extends Resource> SingleResourceResult<T> delete(FHIRPersistenceContext context, Class<T> resourceType, String logicalId) throws FHIRPersistenceException
Deletes the specified FHIR Resource from the datastore.- Parameters:
context
- the FHIRPersistenceContext instance associated with the current requestresourceType
- The type of FHIR Resource to be deleted.logicalId
- the logical id of the FHIR Resource to be deleted- Returns:
- a SingleResourceResult with the FHIR Resource that was deleted or null if the specified resource doesn't exist and/or an OperationOutcome with hints, warnings, or errors related to the interaction
- Throws:
FHIRPersistenceException
-
history
<T extends Resource> MultiResourceResult<T> history(FHIRPersistenceContext context, Class<T> resourceType, String logicalId) throws FHIRPersistenceException
Retrieves all of the versions of the specified FHIR Resource.- Parameters:
context
- the FHIRPersistenceContext instance associated with the current requestresourceType
- the resource type of the Resource instances to be retrievedlogicalId
- the logical id of the Resource instances to be retrieved- Returns:
- a MultiResourceResult with a list containing the available versions of the specified FHIR Resource and/or an OperationOutcome with hints, warnings, or errors related to the interaction
- Throws:
FHIRPersistenceException
-
search
MultiResourceResult<Resource> search(FHIRPersistenceContext context, Class<? extends Resource> resourceType) throws FHIRPersistenceException
Performs a search on the specified target resource type using the specified search parameters.- Parameters:
context
- the FHIRPersistenceContext instance associated with the current requestresourceType
- the resource type which is the target of the search- Returns:
- a MultiResourceResult with the list of FHIR Resources in the search result set and/or an OperationOutcome with hints, warnings, or errors related to the interaction
- Throws:
FHIRPersistenceException
-
isTransactional
boolean isTransactional()
Returns true iff the persistence layer implementation supports transactions.
-
getHealth
OperationOutcome getHealth() throws FHIRPersistenceException
Returns an OperationOutcome indicating the current status of the persistence store / backend- Returns:
- An OperationOutcome with a list of 0 or more OperationalOutcomeIssue indicating the status of the underlying datastore
- Throws:
FHIRPersistenceException
-
getTransaction
FHIRPersistenceTransaction getTransaction()
Returns a FHIRPersistenceTransaction object associated with the persistence layer implementation in use. This can then be used to control transactional boundaries.
-
isDeleteSupported
default boolean isDeleteSupported()
Returns true iff the persistence layer implementation supports the "delete" operation.
-
generateResourceId
String generateResourceId()
Generates a resource ID.- Returns:
- resource ID
-
isReindexSupported
default boolean isReindexSupported()
Returns true iff the persistence layer implementation supports the "reindex" special operation- Returns:
-
reindex
int reindex(FHIRPersistenceContext context, OperationOutcome.Builder operationOutcomeResult, Instant tstamp, String resourceLogicalId) throws FHIRPersistenceException
Initiates reindexing for resources not yet processed. Limits the number of resources processed to resourceCount. The number processed is returned in the OperationOutcome. This can be used by a controller to continue processing until everything is complete. Increasing resourceCount reduces the number of calls required to reindex an entire database, but larger values risk exceeding the transaction timeout. Values around 100 are a good starting point for most systems.- Parameters:
context
- the FHIRPersistenceContext instance associated with the current request.operationOutcomeResult
- accumulate issues in thisBuilder
tstamp
- reindex any resources with an index_tstamp less than this.resourceLogicalId
- optional resourceType/logicalId value to reindex a specific resource- Returns:
- count of the number of resources reindexed by this call (0 or 1)
- Throws:
FHIRPersistenceException
-
fetchResourcePayloads
ResourcePayload fetchResourcePayloads(Class<? extends Resource> resourceType, Instant fromLastModified, Instant toLastModified, Function<ResourcePayload,Boolean> process) throws FHIRPersistenceException
Special function for high speed export of resource payloads. The process function must process the InputStream before returning. Result processing will be stopped if the process function returns Boolean FALSE.- Parameters:
resourceType
- the resource type which is the target of the searchfromLastModified
- start reading from this timestampfromResourceId
- start reading from this resourceId if provided (can be null)toLastModified
- do not read beyond this timestampspanSeconds
- max number of seconds to include fromLastModifiedprocess
- function to process each payload record- Returns:
- the last ResourcePayload processed, or null if no data was found
- Throws:
FHIRPersistenceException
-
-