External Accounts
Participants frequently have accounts with services external to MyDataHelps, such as their provider’s EHR, their health plan, or their wearable device manufacturer. For more information see the data overview. MyDataHelpsKit provides tools for your app to allow participants to link MyDataHelps to their external account(s), and to manage that link once it’s been established.
In the MyDataHelpsKit SDK, ExternalAccountProvider
identifies a provider supported by MyDataHelps, while ExternalAccount
represents a specific connection a participant has established to a provider within MyDataHelps.
Note
The topics below are for querying and managing external accounts and providers. Your can also use the SDK to implement a complete provider connection user experience within your app. See
External Account Connections for a detailed guide.
Retrieve External Account Providers
Construct an ExternalAccountProvidersQuery
to specify filtering criteria, and execute the query using ParticipantSession.queryExternalAccountProviders
. This query returns an ExternalAccountProvidersResultPage
containing ExternalAccountProvider
values.
Your app can use this query to construct a keyword search interface or categorized list view. Consult the programming guide for best practices on working with queries, search, and and paged results in MyDataHelpsKit.
See External Account Connections for using ExternalAccountProvider
data to implement a full account connection user experience in your app.
SDK Reference
Examples
let criteria = ExternalAccountProvidersQuery(search: "CareEvolution", category: .provider)
let result = try await session.queryExternalAccountProviders(criteria)
for provider in result.externalAccountProviders {
print(provider.name)
}
In the MyDataHelpsKit example app, see:
Retrieve Connected External Accounts
ParticipantSession.listExternalAccounts
fetches a list of all of the participant’s connected external accounts. This API is not paged: all of the available accounts are returned in a simple array.
SDK Reference
Examples
let accounts = try await session.listExternalAccounts()
for account in accounts {
print("Account for \(account.provider.name): \(account.status)")
}
In the MyDataHelpsKit example app, see:
Request the Refresh of Data from a Connected External Account
ParticipantSession.refreshExternalAccount
requests the refresh of data from a connected external account.
This API only begins the process of refreshing an account; the process may take additional time to complete. To track the status of a refresh, use ParticipantSession.listExternalAccounts
to poll the status value of an account, checking for fetchingData
or fetchComplete
status values.
SDK Reference
Examples
do {
// account is from the "Retrieving External Accounts" example above.
try await session.refreshExternalAccount(account)
print("Refresh initiated.")
} catch {
print("Error refreshing account: \(MyDataHelpsError(error))")
}
In the MyDataHelpsKit example app, see:
Delete an External Account Connection
ParticipantSession.deleteExternalAccount
deletes an external account.
SDK Reference
Examples
do {
// account is from the "Retrieving External Accounts" example above.
try await session.deleteExternalAccount(account)
print("Account connection deleted.")
} catch {
print("Error deleting account connection: \(MyDataHelpsError(error))")
}
In the MyDataHelpsKit example app, see: