Retrieve Individual Access Connections & Status
Retrieving a User's Individual Access Records
Overview
The b.well SDK will fetch all Individual Access Service (IAS) connection records associated with a user once the user is IAL2 verified and has provided the appropriate consent.
Returned IAS connections will be one of two types depending on the data source:
- Connections that are automatically established on the user’s behalf using the IAL2 token (viewable in
getMemberConnections, additional documentation found in the Retrieve a User's Data Connections method guide) - Connections that require the user to authenticate (viewable in
getCareTeams, see documentation below)
Method Signature
suspend fun getCareTeams(request: CareTeamsRequest?): BWellResult<CareTeam>request: Defines thecategorywithin theCareTeamobject for fetching the desired resources.BWellResult<CareTeam>: Returns an object containing a list ofCareTeamobjects.- The
CareTeamobject includes:
id: string
name: string
meta: Meta
identifier: List<Identifier>
category: List<CodeableConcept>
participant: List<CareTeamParticipant>
Sample Code
Here's an example demonstrating how to use the getCareTeams method:
val careTeamsRequest = CareTeamsRequest.Builder()
.category("recommended-connections")
.page(0)
.pageSize(10)
.build()
getCareTeams(careTeamsRequest)Detailed Explanation
- CareTeamsRequest Builder:
- A builder pattern is used to construct a
CareTeamsRequestobject, allowing for easy setting of various CareTeam properties:category: Use the category property shown in the sample code above to filter the response to only includerecommended-connections. This will return a list of connections found by the network record location service that need user authentication to establish the connection.
- A builder pattern is used to construct a
- Handling Indirect Connections:
- The method
getCareTeamsreturns aCareTeamobject. Theparticipantproperty can be used to compile the list of recommended (indirect) IAS connections:participant.member.aliascontains thedatasourceIdthat can be used to Retrieve an OAuth URL.
- The method
- Handling Direct Connections:
- Direct connections returned within
getMemberConnectionshave successfully retrieved data and the status will automatically be set to Retrieved so that the connection can be shown as "active" or "connected".
- Direct connections returned within
Best Practices
- Validating Input: Ensure that the fields set in
CareTeamsRequestare validated for correctness before calling thegetCareTeamsmethod. - Error Handling: Implement robust error handling to manage potential failures, such as invalid data or network issues.
- Pre-Requisites for Successful Retrieval: The user must have been IAL2 verified and then have granted Consent:
- Use the
IAS_IMPORT_RECORDSConsentCategory like this example code
- Use the
val createConsentRequest = ConsentCreateRequest.Builder()
.category(ConsentCategoryCode.IAS_IMPORT_RECORDS)
.provision(ConsentProvisionType.PERMIT)
.status(ConsentStatus.ACTIVE)
.build()- See the Individual Access Service Flow diagram for full flow details
Retrieving User Individual Access Status
Overview
The b.well SDK provides a mechanism to fetch the status of IAS network request for the user. This uses the same underlying Task infrastructure that powers Insights.
Method Signature
suspend fun getTasks(request: TasksRequest): BWellResult<Task>request: ATasksRequestobject containing search criteria.BWellResult<Task>: Returns a collection of FHIR Task resources, FHIR OperationOutcome, and paging information.
See Retrieve Tasks for a User for full details of this method.
Sample Code
To retrieve the status of the IAS Network request, filter the Tasks by network-data-retrieval as seen in this sample code:
val taskRequest = TasksRequest.Builder()
.activityType(listOf("network-data-retrieval"))
.performerType(listOf("system"))
.build()
getTasks(taskRequest)The Task status represents the current state of IAS Network request:
READY: Data pull not started but consent has been grantedIN_PROGRESS: Data pull in progressCOMPLETED: Data pull completed successfullyFAILED: Data pull encountered an issueREJECTED: User has revoked consent, no further data pulls will occur
Best Practices
- Note: These tasks are distinct from the Insights a user sees in the UI.
enrichContentis not supported. - Pre-Requisites: There will not be a Task created until a Consent is granted
Updated about 2 months ago
