Skip to content

Commit

Permalink
Overload FhirEngine.get()
Browse files Browse the repository at this point in the history
  • Loading branch information
qiarie committed Nov 27, 2024
1 parent b59acf2 commit fe98d19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions engine/src/main/java/com/google/android/fhir/FhirEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ interface FhirEngine {
@Throws(ResourceNotFoundException::class)
suspend fun get(type: ResourceType, id: String): Resource

/**
* Loads multiple FHIR resources given [ResourceType] and logical IDs.
*
* @param type The type of the resource to load.
* @param ids The logical IDs of the resources.
* @return The requested FHIR resources.
* @throws ResourceNotFoundException if the resources are not found.
*/
@Throws(ResourceNotFoundException::class)
suspend fun get(type: ResourceType, vararg ids: String): List<Resource>

/**
* Updates one or more FHIR [Resource]s in the local storage.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ internal class FhirEngineImpl(private val database: Database, private val contex
override suspend fun get(type: ResourceType, id: String) =
withContext(Dispatchers.IO) { database.select(type, id) }

override suspend fun get(type: ResourceType, vararg ids: String) =
withContext(Dispatchers.IO) { ids.map { id -> database.select(type, id) } }

override suspend fun update(vararg resource: Resource) =
withContext(Dispatchers.IO) { database.update(*resource) }

Expand Down

0 comments on commit fe98d19

Please sign in to comment.