Skip to content

Commit fe98d19

Browse files
committed
Overload FhirEngine.get()
1 parent b59acf2 commit fe98d19

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

engine/src/main/java/com/google/android/fhir/FhirEngine.kt

+11
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ interface FhirEngine {
8383
@Throws(ResourceNotFoundException::class)
8484
suspend fun get(type: ResourceType, id: String): Resource
8585

86+
/**
87+
* Loads multiple FHIR resources given [ResourceType] and logical IDs.
88+
*
89+
* @param type The type of the resource to load.
90+
* @param ids The logical IDs of the resources.
91+
* @return The requested FHIR resources.
92+
* @throws ResourceNotFoundException if the resources are not found.
93+
*/
94+
@Throws(ResourceNotFoundException::class)
95+
suspend fun get(type: ResourceType, vararg ids: String): List<Resource>
96+
8697
/**
8798
* Updates one or more FHIR [Resource]s in the local storage.
8899
*

engine/src/main/java/com/google/android/fhir/impl/FhirEngineImpl.kt

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ internal class FhirEngineImpl(private val database: Database, private val contex
5252
override suspend fun get(type: ResourceType, id: String) =
5353
withContext(Dispatchers.IO) { database.select(type, id) }
5454

55+
override suspend fun get(type: ResourceType, vararg ids: String) =
56+
withContext(Dispatchers.IO) { ids.map { id -> database.select(type, id) } }
57+
5558
override suspend fun update(vararg resource: Resource) =
5659
withContext(Dispatchers.IO) { database.update(*resource) }
5760

0 commit comments

Comments
 (0)