Interface ResourceDAO
-
- All Superinterfaces:
FHIRDbDAO
- All Known Implementing Classes:
DerbyResourceDAO
,PostgresReindexResourceDAO
,PostgresResourceDAO
,PostgresResourceNoProcDAO
,ReindexResourceDAO
,ResourceDAOImpl
public interface ResourceDAO extends FHIRDbDAO
This Data Access Object interface provides methods creating, updating, and retrieving rows in the FHIR Resource tables.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addResourceTypeCacheCandidate(String resourceType, Integer resourceTypeId)
Adds a resource type / resource id pair to a candidate collection for population into the ResourceTypesCache.List<Resource>
history(String resourceType, String logicalId, Timestamp fromDateTime, int offset, int maxResults)
Reads and returns all versions of the Resource with the passed logicalId, ordered by descending version id.int
historyCount(String resourceType, String logicalId, Timestamp fromDateTime)
Reads and returns the COUNT of all versions of the Resource with the passed logicalId.Resource
insert(Resource resource, List<ExtractedParameterValue> parameters, ParameterDAO parameterDao)
Inserts the passed Resource DTO and its associated search parameters to the appropriate FHIR resource tables.Resource
read(String logicalId, String resourceType)
Reads and returns the latest version of the Resource with the passed logical id and resource type.Map<String,Integer>
readAllResourceTypeNames()
Reads all rows in the resource_types table and returns the data as a MapInteger
readResourceTypeId(String parameterName)
Reads the id associated with the name of the passed Resource type from the Resource_Types table.List<Resource>
search(SqlQueryData queryData)
Executes the search contained in the passed SqlQueryData, using it's encapsulated search string and bind variables.List<Resource>
search(String sqlSelect)
Executes the passed fully-formed SQL Select statement and returns the results If no matching resources are found, an empty collection is returned.List<Resource>
searchByIds(String resourceType, List<Long> resourceIds)
Searches for Resources that contain one of the passed ids.int
searchCount(SqlQueryData queryData)
Executes a count query based on the data contained in the passed SqlQueryData, using it's encapsulated search string and bind variables.int
searchCount(String sqlSelectCount)
Executes the passed fully-formed SQL Select COUNT statement and returns the integer count.List<Long>
searchForIds(SqlQueryData queryData)
This method supports the execution of a specialized query designed to return Resource ids, based on the contents of the passed select statement.List<String>
searchStringValues(SqlQueryData queryData)
Executes the search contained in the passed SqlQueryData, using it's encapsulated search string and bind variables.void
setPersistenceContext(FHIRPersistenceContext context)
Sets the current persistence contextResource
versionRead(String logicalId, String resourceType, int versionId)
Reads and returns the version of the Resource with the passed logical id, resource type, and version id.-
Methods inherited from interface com.ibm.fhir.persistence.jdbc.dao.api.FHIRDbDAO
getConnection, getFlavor, isDb2Database
-
-
-
-
Method Detail
-
read
Resource read(String logicalId, String resourceType) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Reads and returns the latest version of the Resource with the passed logical id and resource type. If no matching resource is found, null is returned.- Parameters:
logicalId
-resourceType
-- Returns:
- Resource - The most recent version of the Resource with the passed logical id and resource type, or null if not found.
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
versionRead
Resource versionRead(String logicalId, String resourceType, int versionId) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Reads and returns the version of the Resource with the passed logical id, resource type, and version id. If no matching resource is found, null is returned.- Parameters:
logicalId
-resourceType
-version
- id- Returns:
- Resource - The version of the Resource with the passed logical id, resource type, and version id or null if not found.
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
history
List<Resource> history(String resourceType, String logicalId, Timestamp fromDateTime, int offset, int maxResults) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Reads and returns all versions of the Resource with the passed logicalId, ordered by descending version id. If non-null, the passed fromDateTime is used to limit the returned Resource versions to those that were updated after the fromDateTime.- Parameters:
resourceType
- - The name of a FHIR Resource typelogicalId
- - The logical id of a FHIR ResourcefromDateTime
- - The starting date/time of the version history.- Returns:
- List
- An ordered list of Resource versions. - Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
historyCount
int historyCount(String resourceType, String logicalId, Timestamp fromDateTime) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Reads and returns the COUNT of all versions of the Resource with the passed logicalId. If non-null, the passed fromDateTime is used to limit the count of Resource versions to those that were updated after the fromDateTime.- Parameters:
resourceType
- - The name of a FHIR Resource typelogicalId
- - The logical id of a FHIR ResourcefromDateTime
- - The starting date/time of the version history.- Returns:
- int - The count of Resource versions.
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
search
List<Resource> search(SqlQueryData queryData) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Executes the search contained in the passed SqlQueryData, using it's encapsulated search string and bind variables.- Parameters:
queryData
- - Contains a search string and (optionally) bind variables.- Returns:
- List
A list of FHIR Resources satisfying the passed search. - Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
searchStringValues
List<String> searchStringValues(SqlQueryData queryData) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Executes the search contained in the passed SqlQueryData, using it's encapsulated search string and bind variables.- Parameters:
queryData
- - Contains a search string and (optionally) bind variables.- Returns:
- List
A list of strings satisfying the passed search. - Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
search
List<Resource> search(String sqlSelect) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Executes the passed fully-formed SQL Select statement and returns the results If no matching resources are found, an empty collection is returned.- Parameters:
sqlSelect
- - A fully formed SQL select statement.- Returns:
- List
- A List of Resources that satisfy the passed SQL query string. - Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
searchForIds
List<Long> searchForIds(SqlQueryData queryData) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
This method supports the execution of a specialized query designed to return Resource ids, based on the contents of the passed select statement. Note that the first column to be selected MUST be the Resource.id column.- Parameters:
sqlSelect
- - A select for Resource ids.- Returns:
- - A List of resource ids that satisfy the passed SQL query.
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
searchByIds
List<Resource> searchByIds(String resourceType, List<Long> resourceIds) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Searches for Resources that contain one of the passed ids.- Parameters:
resourceType
- - The type of the FHIR ResourceresourceIds
- - A List of resource ids.- Returns:
- List
- A List of resources matching the the passed list of ids. - Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
searchCount
int searchCount(SqlQueryData queryData) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Executes a count query based on the data contained in the passed SqlQueryData, using it's encapsulated search string and bind variables.- Parameters:
queryData
- - Contains a search string and (optionally) bind variables.- Returns:
- int A count of FHIR Resources satisfying the passed search.
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
searchCount
int searchCount(String sqlSelectCount) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException
Executes the passed fully-formed SQL Select COUNT statement and returns the integer count.- Parameters:
sqlSelect
- - A fully formed SQL select count statement.- Returns:
- int - The count of resources that fulfill the passed SQL select statement.
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
-
setPersistenceContext
void setPersistenceContext(FHIRPersistenceContext context)
Sets the current persistence context- Parameters:
context
-
-
readAllResourceTypeNames
Map<String,Integer> readAllResourceTypeNames() throws FHIRPersistenceDBConnectException, FHIRPersistenceDataAccessException
Reads all rows in the resource_types table and returns the data as a Map- Returns:
- Map
- A map containing key=parameter-name, value=parameter-name-id - Throws:
FHIRPersistenceDBConnectException
FHIRPersistenceDataAccessException
-
readResourceTypeId
Integer readResourceTypeId(String parameterName) throws FHIRPersistenceDBConnectException, FHIRPersistenceDataAccessException
Reads the id associated with the name of the passed Resource type from the Resource_Types table. If the id for the passed name is not present in the database, an id is generated, persisted, and returned.- Parameters:
String
- A valid FHIR resource type.- Returns:
- Integer - the id associated with the name of the passed Resource type.
- Throws:
FHIRPersistenceDBConnectException
FHIRPersistenceDataAccessException
-
addResourceTypeCacheCandidate
void addResourceTypeCacheCandidate(String resourceType, Integer resourceTypeId) throws FHIRPersistenceException
Adds a resource type / resource id pair to a candidate collection for population into the ResourceTypesCache. This pair must be present as a row in the FHIR DB RESOURCE_TYPES table.- Parameters:
resourceType
- A valid FHIR resource type.resourceTypeId
- The corresponding id for the resource type.- Throws:
FHIRPersistenceException
-
insert
Resource insert(Resource resource, List<ExtractedParameterValue> parameters, ParameterDAO parameterDao) throws FHIRPersistenceException
Inserts the passed Resource DTO and its associated search parameters to the appropriate FHIR resource tables. After insert, the generated primary key is acquired and set in the Resource object.- Parameters:
resource
- A Resource Data Transfer Objectparameters
- A collection of search parameters to be persisted along with the passed ResourceparameterDao
- The Parameter DAO- Returns:
- Resource The Resource DTO
- Throws:
FHIRPersistenceDataAccessException
FHIRPersistenceDBConnectException
FHIRPersistenceVersionIdMismatchException
FHIRPersistenceException
-
-