DefaultRepository

open class DefaultRepository @Inject constructor(val fhirEngine: FhirEngine, val dispatcherProvider: DispatcherProvider, val sharedPreferencesHelper: SharedPreferencesHelper, val configurationRegistry: ConfigurationRegistry, val configService: ConfigService, val configRulesExecutor: ConfigRulesExecutor, val fhirPathDataExtractor: FhirPathDataExtractor, val parser: IParser, val context: Context)

Inheritors

Constructors

Link copied to clipboard
@Inject
constructor(fhirEngine: FhirEngine, dispatcherProvider: DispatcherProvider, sharedPreferencesHelper: SharedPreferencesHelper, configurationRegistry: ConfigurationRegistry, configService: ConfigService, configRulesExecutor: ConfigRulesExecutor, fhirPathDataExtractor: FhirPathDataExtractor, parser: IParser, context: Context)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class RelatedResourceWrapper(val relatedResourceMap: MutableMap<String, List<Resource>> = mutableMapOf(), val relatedResourceCountMap: MutableMap<String, List<RelatedResourceCount>> = mutableMapOf())

A wrapper data class to hold search results. All related resources are flattened into one Map including the nested related resources as required by the Rules Engine facts.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val context: Context
Link copied to clipboard
Link copied to clipboard
open val fhirEngine: FhirEngine
Link copied to clipboard
open val parser: IParser

Functions

Link copied to clipboard
suspend fun <R : Resource> addOrUpdate(addMandatoryTags: Boolean = true, resource: R)

This function upserts a resource into the database. This function also updates the Resource.meta and generates the Resource.id if it is missing before upserting the resource. The resource needs to already have a Resource.id.

suspend fun Search.applyFilterByRelatedEntityLocationMetaTag(baseResourceType: ResourceType, filterByRelatedEntityLocation: Boolean)
Link copied to clipboard
suspend fun changeManagingEntity(newManagingEntityId: String, groupId: String, managingEntityConfig: ManagingEntityConfig?)
Link copied to clipboard
suspend fun closeResource(resource: Resource, eventWorkflow: EventWorkflow)
Link copied to clipboard
inline suspend fun count(search: Search): Long
Link copied to clipboard
suspend fun create(addResourceTags: Boolean = true, vararg resource: Resource): List<String>

Saves a resource in the database. It also updates the Resource.meta _lastUpdated and generates the Resource.id if it is missing before saving the resource.

Link copied to clipboard
suspend fun createRemote(addResourceTags: Boolean = true, vararg resource: Resource)
Link copied to clipboard
suspend fun delete(resource: Resource, softDelete: Boolean = false)
suspend fun delete(resourceType: ResourceType, resourceId: String, softDelete: Boolean = false)
Link copied to clipboard
fun filterRelatedResource(resource: Resource, resourceConfig: ResourceConfig): Boolean

Filtering the Related Resources is achieved by use of the filterFhirPathExpression configuration. It specifies which field and values to filter the resources by.

Link copied to clipboard
suspend fun loadManagingEntity(group: Group): Patient?
Link copied to clipboard
inline suspend fun <T : Resource> loadResource(resourceId: String): T?
suspend fun loadResource(reference: Reference): Resource
suspend fun loadResource(resourceId: String, resourceType: ResourceType): Resource
Link copied to clipboard
suspend fun purge(resource: Resource, forcePurge: Boolean)
Link copied to clipboard
suspend fun removeGroup(groupId: String, isDeactivateMembers: Boolean?, configComputedRuleValues: Map<String, Any>)
Link copied to clipboard
suspend fun removeGroupMember(memberId: String, groupId: String?, groupMemberResourceType: ResourceType?, configComputedRuleValues: Map<String, Any>)

Remove member of a group using the provided memberId and groupMemberResourceType

Link copied to clipboard
suspend fun retrieveFlattenedSubLocations(locationId: String): LinkedList<Location>
Link copied to clipboard
suspend fun retrieveUniqueIdAssignmentResource(uniqueIdAssignmentConfig: UniqueIdAssignmentConfig?, computedValuesMap: Map<String, Any>): Resource?
Link copied to clipboard
inline suspend fun <R : Resource> search(search: Search): List<R>
Link copied to clipboard
inline suspend fun <T : Resource> searchResourceFor(token: TokenClientParam, subjectType: ResourceType, subjectId: String, dataQueries: List<DataQuery> = listOf(), configComputedRuleValues: Map<String, Any>): List<T>
Link copied to clipboard
suspend fun searchResourcesRecursively(filterByRelatedEntityLocationMetaTag: Boolean, filterActiveResources: List<ActiveResourceFilterConfig>?, fhirResourceConfig: FhirResourceConfig, secondaryResourceConfigs: List<FhirResourceConfig>?, currentPage: Int? = null, pageSize: Int? = null, configRules: List<RuleConfig>?): List<RepositoryResourceData>
Link copied to clipboard
suspend fun <R : Resource> update(resource: R)
Link copied to clipboard
suspend fun updateResourcesRecursively(resourceConfig: ResourceConfig, subject: Resource? = null, eventWorkflow: EventWorkflow)

Data queries for retrieving resources require the id to be provided in the format ResourceType/UUID e.g Group/0acda8c9-3fa3-40ae-abcd-7d1fba7098b4. When resources are synced up to the server the id is updated with history information e.g Group/0acda8c9-3fa3-40ae-abcd-7d1fba7098b4/_history/1 This needs to be formatted to ResourceType/UUID format and updated in the computedValuesMap