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

  1. Search Term:
  • Central to filtering searches by terms like name, location, address, or phone number.
  1. Organization Type Filters:
  • Filters results based on organization type.
    • PROVIDER used for hospitals, clinics, and health system connections.
    • LABORATORY used for laboratory connections.
    • INSURANCE used for insurance provider connections
    • PHARMACY used for pharmacy connections
  1. Sort By Options:
  • Default sorting is by relevance and is applied if no sortBy value is provided. Other options include distance and content. Content is only applicable when setting an organization filter.
  1. 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 organizationTypeFilters that are relevant to connection searches.
  • Sorting: Use default sorting for general searches; choose other options for more specific needs.
  • Pagination: Adjust page and pageSize for efficient navigation of search results.