Interface FHIRResourceHelpers
-
- All Known Implementing Classes:
FHIRRestHelper
public interface FHIRResourceHelpers
This interface describes the set of helper methods from the FHIR REST layer that are used by custom operation implementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
FHIRResourceHelpers.Interaction
-
Field Summary
Fields Modifier and Type Field Description static boolean
DO_VALIDATION
static Integer
IF_NOT_MATCH_NULL
static boolean
SKIPPABLE_UPDATE
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Map<String,Object>
buildPersistenceEventProperties(String type, String id, String version, FHIRSearchContext searchContext)
Builds a collection of properties that will be passed to the persistence interceptors.Bundle
doBundle(Bundle bundle, boolean skippableUpdates)
Processes a bundled request (batch or transaction type).default FHIRRestOperationResponse
doCreate(String type, Resource resource, String ifNoneExist)
Performs the heavy lifting associated with a 'create' interaction.FHIRRestOperationResponse
doCreate(String type, Resource resource, String ifNoneExist, boolean doValidation)
Performs the heavy lifting associated with a 'create' interaction.FHIRRestOperationResponse
doCreateMeta(FHIRPersistenceEvent event, List<OperationOutcome.Issue> warnings, String type, Resource resource, String ifNoneExist)
1st phase of CREATE.FHIRRestOperationResponse
doCreatePersist(FHIRPersistenceEvent event, List<OperationOutcome.Issue> warnings, Resource resource)
3rd phase of resource create.FHIRRestOperationResponse
doDelete(String type, String id, String searchQueryString)
Performs a 'delete' operation on the specified resource.default ResourceEraseRecord
doErase(FHIROperationContext operationContext, EraseDTO eraseDto)
Invoke the FHIR Persistence erase operation for a specific instance of the erase.Bundle
doHistory(String type, String id, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri)
Performs the work of retrieving versions of a Resource.Bundle
doHistory(javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri)
Implement the system level history operation to obtain a list of changes to resourcesResource
doInvoke(FHIROperationContext operationContext, String resourceTypeName, String logicalId, String versionId, Resource resource, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters)
Helper method which invokes a custom operation.FHIRRestOperationResponse
doPatch(String type, String id, FHIRPatch patch, String ifMatchValue, String searchQueryString, boolean skippableUpdate)
Performs a patch operation (a new version of the Resource will be stored).FHIRRestOperationResponse
doPatchOrUpdatePersist(FHIRPersistenceEvent event, String type, String id, boolean isPatch, Resource newResource, Resource prevResource, List<OperationOutcome.Issue> warnings, boolean isDeleted, Integer ifNoneMatch)
Persist the newResource value for patch or update interactionsdefault SingleResourceResult<? extends Resource>
doRead(String type, String id, boolean throwExcOnNull, boolean includeDeleted, Resource contextResource)
Performs a 'read' operation to retrieve a Resource.SingleResourceResult<? extends Resource>
doRead(String type, String id, boolean throwExcOnNull, boolean includeDeleted, Resource contextResource, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters)
Performs a 'read' operation to retrieve a Resource with select query parameters.int
doReindex(FHIROperationContext operationContext, OperationOutcome.Builder operationOutcomeResult, Instant tstamp, List<Long> indexIds, String resourceLogicalId)
Invoke the FHIR persistence reindex operation for either a specified list of indexIds, or a randomly chosen resource, last reindexed before the given timestamp.List<Long>
doRetrieveIndex(FHIROperationContext operationContext, String resourceTypeName, int count, Instant notModifiedAfter, Long afterIndexId)
Invoke the FHIR persistence retrieve index operation to retrieve a list of indexIds available for reindexing.Bundle
doSearch(String type, String compartment, String compartmentId, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri, Resource contextResource)
Performs heavy lifting associated with a 'search' operation.Bundle
doSearch(String type, String compartment, String compartmentId, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri, Resource contextResource, boolean checkIfInteractionAllowed)
Performs heavy lifting associated with a 'search' operation.FHIRRestOperationResponse
doUpdate(String type, String id, Resource newResource, String ifMatchValue, String searchQueryString, boolean skippableUpdate, boolean doValidation, Integer ifNoneMatch)
Performs an update operation (a new version of the Resource will be stored).default FHIRRestOperationResponse
doUpdate(String type, String id, Resource newResource, String ifMatchValue, String searchQueryString, boolean skippableUpdate, Integer ifNoneMatch)
Performs an update operation (a new version of the Resource will be stored).FHIRRestOperationResponse
doUpdateMeta(FHIRPersistenceEvent event, String type, String id, FHIRPatch patch, Resource newResource, String ifMatchValue, String searchQueryString, boolean skippableUpdate, boolean doValidation, List<OperationOutcome.Issue> warnings)
1st phase of update interaction.default Resource
doVRead(String type, String id, String versionId)
Performs a 'vread' operation by retrieving the specified version of a Resource with no query parametersResource
doVRead(String type, String id, String versionId, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters)
Performs a 'vread' operation by retrieving the specified version of a Resource.String
generateResourceId()
Generate a new resource id.FHIRPersistenceTransaction
getTransaction()
Future<PayloadKey>
storePayload(Resource resource, String logicalId, int newVersionNumber)
If the underlying persistence layer supports offloading payload storage, initiate the request here.void
validateInteraction(FHIRResourceHelpers.Interaction interaction, String resourceType)
Validate an interaction for a specified resource type.List<OperationOutcome.Issue>
validateResource(Resource resource)
Validate a resource.
-
-
-
Field Detail
-
DO_VALIDATION
static final boolean DO_VALIDATION
- See Also:
- Constant Field Values
-
SKIPPABLE_UPDATE
static final boolean SKIPPABLE_UPDATE
- See Also:
- Constant Field Values
-
IF_NOT_MATCH_NULL
static final Integer IF_NOT_MATCH_NULL
-
-
Method Detail
-
validateInteraction
void validateInteraction(FHIRResourceHelpers.Interaction interaction, String resourceType) throws FHIROperationException
Validate an interaction for a specified resource type.- Parameters:
interaction
- the interaction to be performedresourceType
- the resource type against which the interaction is to be performed- Throws:
FHIROperationException
-
doCreate
FHIRRestOperationResponse doCreate(String type, Resource resource, String ifNoneExist, boolean doValidation) throws Exception
Performs the heavy lifting associated with a 'create' interaction.- Parameters:
type
- the resource type specified as part of the request URLresource
- the Resource to be stored.ifNoneExist
- whether to create the resource if none existsdoValidation
- if true, validate the resource; if false, assume the resource has already been validated- Returns:
- a FHIRRestOperationResponse object containing the results of the operation
- Throws:
Exception
-
doCreate
default FHIRRestOperationResponse doCreate(String type, Resource resource, String ifNoneExist) throws Exception
Performs the heavy lifting associated with a 'create' interaction. Validates the resource.- Parameters:
type
- the resource type specified as part of the request URLresource
- the Resource to be stored.ifNoneExist
- whether to create the resource if none exists- Returns:
- a FHIRRestOperationResponse object containing the results of the operation
- Throws:
Exception
-
doCreateMeta
FHIRRestOperationResponse doCreateMeta(FHIRPersistenceEvent event, List<OperationOutcome.Issue> warnings, String type, Resource resource, String ifNoneExist) throws Exception
1st phase of CREATE. Perform the search for conditional create (ifNoneExist) interactions. Any validation (if required) should be performed before this call.- Parameters:
event
-warnings
-type
-resource
-ifNoneExist
-- Returns:
- Throws:
Exception
-
doCreatePersist
FHIRRestOperationResponse doCreatePersist(FHIRPersistenceEvent event, List<OperationOutcome.Issue> warnings, Resource resource) throws Exception
3rd phase of resource create. Persist the resource using the configured persistence layer. Does not modify the resource.- Parameters:
event
-warnings
-resource
-- Returns:
- Throws:
Exception
-
doUpdateMeta
FHIRRestOperationResponse doUpdateMeta(FHIRPersistenceEvent event, String type, String id, FHIRPatch patch, Resource newResource, String ifMatchValue, String searchQueryString, boolean skippableUpdate, boolean doValidation, List<OperationOutcome.Issue> warnings) throws Exception
1st phase of update interaction.- Parameters:
event
-type
-id
-patch
-newResource
-ifMatchValue
-searchQueryString
-skippableUpdate
-doValidation
-warnings
-- Returns:
- Throws:
Exception
-
doPatchOrUpdatePersist
FHIRRestOperationResponse doPatchOrUpdatePersist(FHIRPersistenceEvent event, String type, String id, boolean isPatch, Resource newResource, Resource prevResource, List<OperationOutcome.Issue> warnings, boolean isDeleted, Integer ifNoneMatch) throws Exception
Persist the newResource value for patch or update interactions- Parameters:
event
-type
-id
-isPatch
-newResource
-prevResource
-warnings
-isDeleted
-ifNoneMatch
-- Returns:
- Throws:
Exception
-
buildPersistenceEventProperties
Map<String,Object> buildPersistenceEventProperties(String type, String id, String version, FHIRSearchContext searchContext) throws FHIRPersistenceException
Builds a collection of properties that will be passed to the persistence interceptors.- Parameters:
type
- the resource typeid
- the resource logical IDversion
- the resource versionsearchContext
- the request search context- Returns:
- a map of persistence event properties
- Throws:
FHIRPersistenceException
-
doUpdate
default FHIRRestOperationResponse doUpdate(String type, String id, Resource newResource, String ifMatchValue, String searchQueryString, boolean skippableUpdate, Integer ifNoneMatch) throws Exception
Performs an update operation (a new version of the Resource will be stored). Validates the resource.- Parameters:
type
- the type of the resource to be updatedid
- the id of the Resource being updatednewResource
- the new resource to be storedifMatchValue
- an optional "If-Match" header value to request a version-aware updatesearchQueryString
- an optional search query string to request a conditional updateskippableUpdate
- if true, and the resource content in the update matches the existing resource on the server, then skip the update; if false, then always attempt the updateifNoneMatch
- conditional create-on-update- Returns:
- a FHIRRestOperationResponse that contains the results of the operation
- Throws:
Exception
-
doUpdate
FHIRRestOperationResponse doUpdate(String type, String id, Resource newResource, String ifMatchValue, String searchQueryString, boolean skippableUpdate, boolean doValidation, Integer ifNoneMatch) throws Exception
Performs an update operation (a new version of the Resource will be stored).- Parameters:
type
- the type of the resource to be updatedid
- the id of the Resource being updatednewResource
- the new resource to be storedifMatchValue
- an optional "If-Match" header value to request a version-aware updatesearchQueryString
- an optional search query string to request a conditional updateskippableUpdate
- if true, and the resource content in the update matches the existing resource on the server, then skip the update; if false, then always attempt the updatedoValidation
- if true, validate the resource; if false, assume the resource has already been validatedifNoneMatch
- conditional create-on-update- Returns:
- a FHIRRestOperationResponse that contains the results of the operation
- Throws:
Exception
-
doPatch
FHIRRestOperationResponse doPatch(String type, String id, FHIRPatch patch, String ifMatchValue, String searchQueryString, boolean skippableUpdate) throws Exception
Performs a patch operation (a new version of the Resource will be stored).- Parameters:
type
- the type of the resource to be updatedid
- the id of the Resource being updatedpatch
- the patch to applyifMatchValue
- an optional "If-Match" header value to request a version-aware updatesearchQueryString
- an optional search query string to request a conditional updateskippableUpdate
- if true, and the result of the patch matches the existing resource on the server, then skip the update; if false, then always attempt the update- Returns:
- a FHIRRestOperationResponse that contains the results of the operation
- Throws:
Exception
-
doDelete
FHIRRestOperationResponse doDelete(String type, String id, String searchQueryString) throws Exception
Performs a 'delete' operation on the specified resource.- Parameters:
type
- the resource type associated with the Resource to be deletedid
- the id of the Resource to be deleted- Returns:
- a FHIRRestOperationResponse that contains the results of the operation
- Throws:
Exception
-
doRead
default SingleResourceResult<? extends Resource> doRead(String type, String id, boolean throwExcOnNull, boolean includeDeleted, Resource contextResource) throws Exception
Performs a 'read' operation to retrieve a Resource.- Parameters:
type
- the resource type associated with the Resource to be retrievedid
- the id of the Resource to be retrievedthrowExcOnNull
- whether to throw an exception on nullincludeDeleted
- allow the read, even if the resource has been deletedcontextResource
- the resourcequeryParameters
- for supporting _elements and _summary for resource read- Returns:
- a SingleResourceResult wrapping the resource and including its deletion status
- Throws:
Exception
-
doRead
SingleResourceResult<? extends Resource> doRead(String type, String id, boolean throwExcOnNull, boolean includeDeleted, Resource contextResource, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters) throws Exception
Performs a 'read' operation to retrieve a Resource with select query parameters.- Parameters:
type
- the resource type associated with the Resource to be retrievedid
- the id of the Resource to be retrievedthrowExcOnNull
- whether to throw an exception on nullincludeDeleted
- allow the read, even if the resource has been deletedcontextResource
- the resourcequeryParameters
- for supporting _elements and _summary for resource read- Returns:
- a SingleResourceResult wrapping the resource and including its deletion status
- Throws:
Exception
-
doVRead
default Resource doVRead(String type, String id, String versionId) throws Exception
Performs a 'vread' operation by retrieving the specified version of a Resource with no query parameters- Parameters:
type
- the resource type associated with the Resource to be retrievedid
- the id of the Resource to be retrievedversionId
- the version id of the Resource to be retrieved- Returns:
- the Resource
- Throws:
Exception
-
doVRead
Resource doVRead(String type, String id, String versionId, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters) throws Exception
Performs a 'vread' operation by retrieving the specified version of a Resource.- Parameters:
type
- the resource type associated with the Resource to be retrievedid
- the id of the Resource to be retrievedversionId
- the version id of the Resource to be retrievedqueryParameters
- for supporting _elements and _summary for resource vread- Returns:
- the Resource
- Throws:
Exception
-
doHistory
Bundle doHistory(String type, String id, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri) throws Exception
Performs the work of retrieving versions of a Resource.- Parameters:
type
- the resource type associated with the Resource to be retrievedid
- the id of the Resource to be retrievedqueryParameters
- a Map containing the query parameters from the request URLrequestUri
-- Returns:
- a Bundle containing the history of the specified Resource
- Throws:
Exception
-
doHistory
Bundle doHistory(javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri) throws Exception
Implement the system level history operation to obtain a list of changes to resources- Parameters:
queryParameters
- a Map containing the query parameters from the request URLrequestUri
- the request URI- Returns:
- a Bundle containing the history of the specified Resource
- Throws:
Exception
-
doSearch
Bundle doSearch(String type, String compartment, String compartmentId, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri, Resource contextResource) throws Exception
Performs heavy lifting associated with a 'search' operation.- Parameters:
type
- the resource type associated with the searchcompartment
- the compartment type to search in, or null if not a compartment searchcompartmentId
- the specific compartment to search in, or null if not a compartment searchqueryParameters
- a Map containing the query parameters from the request URLrequestUri
- the request URIcontextResource
- the resource context- Returns:
- a Bundle containing the search result set
- Throws:
Exception
-
doSearch
Bundle doSearch(String type, String compartment, String compartmentId, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters, String requestUri, Resource contextResource, boolean checkIfInteractionAllowed) throws Exception
Performs heavy lifting associated with a 'search' operation.- Parameters:
type
- the resource type associated with the searchcompartment
- the compartment type to search in, or null if not a compartment searchcompartmentId
- the specific compartment to search in, or null if not a compartment searchqueryParameters
- a Map containing the query parameters from the request URLrequestUri
- the request URIcontextResource
- the resource contextcheckIfInteractionAllowed
- if true, check that the search interaction is permitted- Returns:
- a Bundle containing the search result set
- Throws:
Exception
-
doInvoke
Resource doInvoke(FHIROperationContext operationContext, String resourceTypeName, String logicalId, String versionId, Resource resource, javax.ws.rs.core.MultivaluedMap<String,String> queryParameters) throws Exception
Helper method which invokes a custom operation.- Parameters:
operationContext
- the FHIROperationContext associated with the requestresourceTypeName
- the resource type associated with the requestlogicalId
- the resource logical id associated with the requestversionId
- the resource version id associated with the requestresource
- the input resource associated with the custom operation to be invokedqueryParameters
- query parameters may be passed instead of a Parameters resource for certain custom operations invoked via GET- Returns:
- a Resource that represents the response to the custom operation
- Throws:
Exception
-
doBundle
Bundle doBundle(Bundle bundle, boolean skippableUpdates) throws Exception
Processes a bundled request (batch or transaction type).- Parameters:
bundle
- the request BundleskippableUpdates
- if true, and the bundle contains an update for which the resource content in the update matches the existing resource on the server, then skip the update; if false, then always attempt the updates specified in the bundle- Returns:
- the response Bundle
- Throws:
Exception
-
getTransaction
FHIRPersistenceTransaction getTransaction() throws Exception
- Throws:
Exception
-
doReindex
int doReindex(FHIROperationContext operationContext, OperationOutcome.Builder operationOutcomeResult, Instant tstamp, List<Long> indexIds, String resourceLogicalId) throws Exception
Invoke the FHIR persistence reindex operation for either a specified list of indexIds, or a randomly chosen resource, last reindexed before the given timestamp.- Parameters:
operationContext
- the operation contextoperationOutcomeResult
- accumulate issues in thisOperationOutcome.Builder
tstamp
- only reindex resources with a reindex_tstamp less than thisindexIds
- list of index IDs of resources to reindex, or nullresourceLogicalId
- resourceType (e.g. "Patient"), or resourceType/logicalId a specific resource (e.g. "Patient/abc123"), to reindex, or null; this parameter is ignored if the indexIds parameter value is non-null- Returns:
- count of the number of resources reindexed by this call
- Throws:
Exception
-
doErase
default ResourceEraseRecord doErase(FHIROperationContext operationContext, EraseDTO eraseDto) throws FHIROperationException
Invoke the FHIR Persistence erase operation for a specific instance of the erase.- Parameters:
operationContext
-eraseDto
-- Returns:
- Throws:
Exception
FHIROperationException
-
doRetrieveIndex
List<Long> doRetrieveIndex(FHIROperationContext operationContext, String resourceTypeName, int count, Instant notModifiedAfter, Long afterIndexId) throws Exception
Invoke the FHIR persistence retrieve index operation to retrieve a list of indexIds available for reindexing.- Parameters:
operationContext
- the operation contextresourceTypeName
- the resource type of index IDs to return, or nullcount
- the maximum nuber of index IDs to retrievenotModifiedAfter
- only retrieve index IDs for resources not last updated after the specified timestampafterIndexId
- retrieve index IDs starting after this specified ID, or null to start with first ID- Returns:
- list of index IDs available for reindexing
- Throws:
Exception
-
generateResourceId
String generateResourceId()
Generate a new resource id. This is typically delegated to the persistence layer, which may want to create FHIR-compliant ids optimized for a certain type of storage.- Returns:
-
storePayload
Future<PayloadKey> storePayload(Resource resource, String logicalId, int newVersionNumber) throws Exception
If the underlying persistence layer supports offloading payload storage, initiate the request here.- Parameters:
resource
- the resource to store (with correct Meta fields)logicalId
- the logical id of the resourcenewVersionNumber
- the version number to use- Returns:
- a Future response to the payload store operation, or null if it is not supported
- Throws:
Exception
-
validateResource
List<OperationOutcome.Issue> validateResource(Resource resource) throws FHIROperationException
Validate a resource. First validate profile assertions for the resource if configured to do so, then validate the resource itself.- Parameters:
resource
- the resource to be validated- Returns:
- A list of validation errors and warnings
- Throws:
FHIROperationException
-
-