Search Connections
Conducting a Connection Search
Overview
The searchConnections method in the b.well SDK is tailored for performing searches specifically for connections related to clinics, hospitals, health systems, and labs.
Method Signature
suspend fun searchConnections(providerSearchRequest: ProviderSearchRequest): BWellResult<Provider>providerSearchRequest: Encapsulates the search parameters for connections.BWellResult<Provider>: Returns a collection of matching connections, along with FHIR OperationOutcome and paging information.
Search Parameters
- Search Term:
- Central to filtering searches by terms like name, location, address, or phone number.
- Organization Type Filters:
- Filters results based on organization type.
PROVIDERused for hospitals, clinics, and health system connections.LABORATORYused for laboratory connections.INSURANCEused for insurance provider connectionsPHARMACYused for pharmacy connections
- Sort By Options:
- Default sorting is by relevance and is applied if no
sortByvalue is provided. Other options include distance and content. Content is only applicable when setting an organization filter.
- Pagination:
page: Specifies the results page number.pageSize: Determines the number of results per page.
Example Usage
The following example demonstrates how to use the searchConnections method and configure a ProviderSearchRequest specific to the Clinics, Hospitals, and Health Systems data connection category:
private fun getConnections() {
val searchTerm = "" // Define your search term here
val request = ProviderSearchRequest.Builder()
.searchTerm(searchTerm)
.organizationTypeFilters(listOf(OrganizationType.PROVIDER)) // Filter for provider organization
.page(0) // Specify the page number
.pageSize(100) // Specify the number of results per page
.build()
clinicsViewModel.searchConnections(request)
viewLifecycleOwner.lifecycleScope.launch {
clinicsViewModel.searchResults.collect { searchResult ->
if (searchResult != null) {
setDataConnectionClinicsAdapter(searchResult)
}
}
}
}The following example demonstrates how to use the searchConnections method and configure a ProviderSearchRequest specific to the Labs data connection category:
private fun getConnections() {
val searchTerm = "" // Define your search term here
val request = ProviderSearchRequest.Builder()
.searchTerm(searchTerm)
.organizationTypeFilters(listOf(OrganizationType.LABORATORY))
.build()
dataConnectionLabsViewModel.searchConnections(request)
viewLifecycleOwner.lifecycleScope.launch {
dataConnectionLabsViewModel.searchResults.collect { searchResult ->
if (searchResult != null) {
binding.noDataLl.visibility = View.GONE;
binding.dataLl.visibility = View.VISIBLE;
setDataConnectionLabsAdapter(searchResult)
}else{
binding.noDataLl.visibility = View.VISIBLE;
binding.dataLl.visibility = View.GONE;
}
}
}
}Best Practices
- Applicability of Filters: Choose filters like
organizationTypeFiltersthat are relevant to connection searches. - Sorting: Use default sorting for general searches; choose other options for more specific needs.
- Pagination: Adjust
pageandpageSizefor efficient navigation of search results.
Updated about 2 months ago
