FhirEngine

interface FhirEngine

The FHIR Engine interface that handles the local storage of FHIR resources.

Functions

Link copied to clipboard
abstract suspend fun count(search: Search): Long

Returns the total count of entities available for given search.

Link copied to clipboard
abstract suspend fun create(vararg resource: <ERROR CLASS>): List<String>

Creates one or more FHIR resources in the local storage.

Link copied to clipboard
abstract suspend fun getLastSyncTimeStamp(): OffsetDateTime?

Returns the timestamp when data was last synchronized.

Link copied to clipboard
abstract suspend fun <R> load(clazz: Class<R>, id: String): R

Loads a FHIR resource given the class and the logical ID.

Link copied to clipboard
abstract suspend fun <R> remove(clazz: Class<R>, id: String)

Removes a FHIR resource given the class and the logical ID.

Link copied to clipboard
abstract suspend fun <R> search(search: Search): List<R>

Searches the database and returns a list resources according to the search specifications.

Link copied to clipboard
abstract suspend fun syncDownload(download: suspend (SyncDownloadContext) -> <ERROR CLASS><List<<ERROR CLASS>>>)

Synchronizes the download result in the database. The database will be updated to reflect the result of the download operation.

Link copied to clipboard
abstract suspend fun syncUpload(upload: suspend (List<SquashedLocalChange>) -> <ERROR CLASS><<ERROR CLASS><LocalChangeToken, <ERROR CLASS>>>)

Synchronizes the upload result in the database. upload operation may result in multiple calls to the server to upload the data. Result of each call will be emitted by upload and the api caller should Flow.collect it.

Link copied to clipboard
abstract suspend fun update(vararg resource: <ERROR CLASS>)

Updates a FHIR resource in the local storage.

Extensions

Link copied to clipboard
inline suspend fun <R> FhirEngine.count(init: Search.() -> Unit): Long
Link copied to clipboard
inline suspend fun <R> FhirEngine.delete(id: String)

Deletes a FHIR resource of type R with id from the local storage.

Link copied to clipboard
inline suspend fun <R> FhirEngine.get(id: String): R

Returns a FHIR resource of type R with id from the local storage.

Link copied to clipboard
inline suspend fun <R> FhirEngine.search(init: Search.() -> Unit): List<R>