Fhir Engine
Provides an interface for managing FHIR resources in local storage.
The FHIR Engine allows you to create, read, update, and delete (CRUD) FHIR resources, as well as perform searches and synchronize data with a remote FHIR server. The FHIR resources are represented using HAPI FHIR Structures Resource and ResourceType.
To use a FHIR Engine instance, first call FhirEngineProvider.init with a FhirEngineConfiguration. This must be done only once; we recommend doing this in the onCreate()
function of your Application
class.
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
FhirEngineProvider.init(
FhirEngineConfiguration(
enableEncryptionIfSupported = true,
RECREATE_AT_OPEN
)
)
}
}
To get a FhirEngine
to interact with, use FhirEngineProvider.getInstance:
val fhirEngine = FhirEngineProvider.getInstance(this)
Functions
Clears all database tables without resetting the auto-increment value generated by PrimaryKey.autoGenerate.
Creates one or more FHIR Resources in the local storage. FHIR Engine requires all stored resources to have a logical Resource.id. If the id
is specified in the resource passed to create, the resource created in FhirEngine
will have the same id
. If no id
is specified, FhirEngine
will generate a UUID as that resource's id
and include it in the returned list of IDs.
Removes a FHIR resource given its ResourceType and logical ID.
Loads a FHIR resource given its ResourceType and logical ID.
Returns the timestamp when data was last synchronized, or null
if no synchronization has occurred yet.
Retrieves a list of LocalChanges for the Resource with the given type and ID. This can be used to select resources to purge from the database.
Purges a resource from the database without deleting data from the server.
Purges resources of the specified type from the database identified by their IDs without any deletion of data from the server.
Searches the database and returns a list of resources matching the Search specifications.
Synchronizes the download results with the database.
Synchronizes upload results with the database.
Adds support for performing actions on FhirEngine
as a single atomic transaction where the entire set of changes succeed or fail as a single entity