Encounters

Retrieving Encounter Groups

Overview

The getEncounterGroups method in the b.well SDK is designed to fetch a list of EncounterGroup resources, which is pivotal for tracking patient visit history. It utilizes the EncounterGroupsRequest object to define search criteria.

Method Signature

suspend fun getEncounterGroups(request: EncounterGroupsRequest?): BWellResult<EncounterGroup>
  • request: An object defining the search criteria for EncounterGroup resources.
  • BWellResult<EncounterGroup>: Represents the list of Encounter Groups retrieved.

Example Usage

if (selectedList.category.toString() == resources.getString(R.string.visit_history)) {
    val encounterGroupsRequest = EncounterGroupsRequest.Builder()
    		.page() //Specify the page number
        .pageSize() //Specify the number of results per page
        .build()

    val encounterGroupsResult = BWellSdk.health.getEncounterGroups(encounterGroupsRequest)
    // Handle the retrieved Encounter Groups
}

This code snippet demonstrates how to create an EncounterGroupsRequest and fetch encounter groups based on the specified criteria.

Best Practices

  • Utilize the EncounterGroupsRequest to tailor the search to specific needs.
  • Handle the response to process the list of Encounter Groups effectively.

Retrieving Encounter Resources

Overview

The getEncounters method in the b.well SDK fetches a list of Encounter records, crucial for understanding patient interactions with healthcare services.

Method Signature

suspend fun getEncounters(request: EncounterRequest?): BWellResult<Encounter>
  • request: Optional EncounterRequest object for specific search parameters.
  • BWellResult<Encounter>: Represents the list of encounters retrieved.

Data Class: Encounter

  • id: Unique identifier of the Encounter.
  • meta: Metadata about the Encounter, including version and tags.
  • type: Specifies the type of Encounter, like outpatient or inpatient.
  • status: Current state of the Encounter, defined by EncounterStatusCode.
  • participant: Individuals who participated in the Encounter.
  • period: Time period of the Encounter with start and end dates.
  • reasonCode: Reason for the Encounter, expressed as a CodeableConcept.
  • class: Classification of the Encounter, such as emergency or pediatric.

Example Usage

The following example retrieves base encounter resources based on groupCode while also setting the .lastUpdated parameter.

val encountersRequest = EncounterRequest.Builder()
    .groupCode(listOf(Coding(code = groupCode, system = groupSystem)))
		.lastUpdated(lastUpdatedSearchDate)
		.build()

GlobalScope.launch {
    val encounters = BWellSdk.health.getEncounters(encountersRequest) as BWellResult.ResourceCollection
    // Process retrieved Encounter records
}

Best Practices

  • Set appropriate filters and pagination in EncounterRequest.
  • Handle the response to effectively use the fetched Encounter records.