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 External Accounts. The external accounts API gives you a way for participants to link MyDataHelps to their external account(s), and to manage that link once it’s been established.

When you use the API to connect an external account, MyDataHelps will initiate an OAuth connection to the external service so the participant can authorize MyDataHelps to retrieve data. Applications are in control of how they present this functionality, such as by creating a generic form for any new connection, or with a button which connects to a specific service that is associated with your project.

MyDataHelps periodically polls and persists data from connected external accounts. Removing a connected external account deletes all related data. Refreshes can be manually triggered using the operation documented below. On iOS and Android devices, refreshes can also be triggered using the externalAccountSyncComplete event.

Account Status

The external account’s status reflects whether MyDataHelps was able to successfully retrieve data.

  • unauthorized - The external account connection failed because MyDataHelps is not authorized to access the account. This can happen if the authorization has expired or the participant has revoked authorization.

  • fetchingData - The connected external account is in the process of fetching data.

  • error - An error occurred while fetching data.

  • fetchComplete - The connected external account has successfully retrieved data.

Get External Account Providers

MyDataHelps.getExternalAccountProviders(search, category, pageSize, pageNumber)

Retrieves the list of external account providers supported by MyDataHelps.

In addition to basic information about the provider, this method will indicate if the provider is enabled, which means the participant is allowed to add a connection to the provider. A provider may be disabled if an existing provider connection already grants access to the same data. This is usually the case for providers part of the same organization. The message field indicates why a provider is not available. For example: “You already have a connection to ProviderA through ProviderB (YourEHR).”

Parameters

search string

Limit search results to account providers whose keyword, postal code, city, or state begins with the search string. Case-insensitive.

category string

Limit search results to account providers with a category exactly matching the search string. Case-insensitive. one of “Provider”, “Health Plan” or “Device Manufacturer”.

pageSize integer (required)

Specifies how many entries per page to return.

pageNumber integer (required)

Specifies which page of the paginated output to access. Zero-indexed.

Returns

Promise<ExternalAccountProviderResult[]>

Resolves to a results collection containing a list of external account providers.

results[n].totalExternalAccountProviders int

The total number of providers available.

results[n].externalAccountProviders

The list of providers.

results[n].externalAccountProviders.id int

Assigned identifier for this external account provider.

results[n].externalAccountProviders.name string

Name of the external account provider.

results[n].externalAccountProviders.category string

The type of provider. One of: Provider, Health Plan or Device Manufacturer.

results[n].externalAccountProviders.logoUrl string

Full URL from which the logo can be retrieved. Undefined if no logo is available for the provider.

results[n].externalAccountProviders.enabled boolean

If the participant is not already connected to the provider, this indicates if they are able to connect.

results[n].externalAccountProviders.message string

If the provider is not enabled, this message explains why. It is suitable for display to the participant.

results[n].externalAccountProviders.relatedProvider string

If the provider is not enabled because there is already a connection through another provider, this is the name of that other provider.

results[n].externalAccountProviders.managingOrganization string

If the provider is not enabled, and it is managed through an organization, this is the name of that organization.

results[n].externalAccountProviders.successorID int

If the provider offers a newer/different connection that participants may want to migrate to (e.g., a new FHIR R4 endpoint replacing an old STU3 one), this is the id field of the successor provider.

Availability

MyDataHelps Views
MyDataHelps Embeddables
Web View Steps
Retrieving an External Account Provider
MyDataHelps.getExternalAccountProviders("careevolution", "provider")
	.then( function(result) {
		console.log(result);
	} );
MyDataHelps.getExternalAccountProviders("careevolution", "provider") .then( function(result) { console.log(result); } );
Console Output
{
  externalAccountProviders: [
    {
      "id": 1,
      "name": "CareEvolution FHIR",
      "category": "Provider",
      "logoUrl": "https://mydatahelps.org/api/v1/delegated/externalaccountproviders/1/logo"
    },
    ...
  ],
  totalExternalAccountProviders: 1719
}
{ externalAccountProviders: [ { "id": 1, "name": "CareEvolution FHIR", "category": "Provider", "logoUrl": "https://mydatahelps.org/api/v1/delegated/externalaccountproviders/1/logo" }, ... ], totalExternalAccountProviders: 1719 }

Connect an External Account

MyDataHelps.connectExternalAccount(externalAccountProviderID)

This will initiate a secure OAuth connection to the specified external account provider, where the participant will be prompted to provide their credentials and authorize MyDataHelps to retrieve data from the account.

Parameters

externalAccountProviderID int (required)

The ID of the external account provider, available from the Retrieve External Account Providers API.

Availability

MyDataHelps Views
MyDataHelps Embeddables
Web View Steps

Retrieve Connected External Accounts

MyDataHelps.getExternalAccounts()

Returns

Promise<ExternalAccount[]>

Resolves to a results collection containing a list of connected external accounts.

results[n].id int

Assigned identifier for this connected external account.

results[n].status string

Account status. See account status values.

results[n].provider ExternalAccountProvider

The provider for this external account.

results[n].provider.id int

Assigned identifier for this external account provider.

results[n].provider.name string

Name of the external account provider.

results[n].provider.category string

The type of provider. One of: Provider, Health Plan or Device Manufacturer.

results[n].provider.logoUrl string

Full URL from which the logo can be retrieved. Undefined if no logo is available for the provider.

results[n].provider.enabled boolean

If the participant is not already connected to the provider, this indicates if they are able to connect.

results[n].provider.message string

If the provider is not enabled, this message explains why. It is suitable for display to the participant.

results[n].provider.relatedProvider string

If the provider is not enabled because there is already a connection through another provider, this is the name of that other provider.

results[n].provider.managingOrganization string

If the provider is not enabled, and it is managed through an organization, this is the name of that organization.

results[n].provider.successorID int

If the provider offers a newer/different connection that participants may want to migrate to (e.g., a new FHIR R4 endpoint replacing an old STU3 one), this is the id field of the successor provider.

results[n].providerUserID string

The user ID used within the external provider’s system.

results[n].lastRefreshDate date

Date (in UTC) when the account last successfully refreshed.

results[n].connectionDate date

Date (in UTC) when the account initially connected.

results[n].dataScopes string

A space-delimited list specifying which types of data the participant has elected to share with MyDataHelps. Scope names are determined by the provider, and may include things like HEALTH_EXPORT (Garmin) or cardio_fitness (Fitbit). This is only available for providers in the “Device Manufacturer” category.

Availability

MyDataHelps Views
MyDataHelps Embeddables
Web View Steps
Retrieving All Connected External Accounts
MyDataHelps.getExternalAccounts()
	.then( function(result) {
		console.log(result);
	} );
MyDataHelps.getExternalAccounts() .then( function(result) { console.log(result); } );
Console Output
[ 
  {
    "id": 5,
    "status": "fetchingData",
    "provider":
    {
      "id": 1,
      "name": "CareEvolution FHIR",
      "category": "Provider",
      "logoUrl": "https://mydatahelps.org/api/v1/delegated/externalaccountproviders/1/logo"
    },
    "lastRefreshDate": "2021-05-03T20:16:44.873Z"
  }
]
[ { "id": 5, "status": "fetchingData", "provider": { "id": 1, "name": "CareEvolution FHIR", "category": "Provider", "logoUrl": "https://mydatahelps.org/api/v1/delegated/externalaccountproviders/1/logo" }, "lastRefreshDate": "2021-05-03T20:16:44.873Z" } ]

Request the Refresh of Data from a Connected External Account

MyDataHelps.refreshExternalAccount(accountId)

This will initiate an asynchronous data refresh from the specified external account. If you need to know when the refresh has completed, you can poll the getExternalAccounts API and wait for the status to change to fetchComplete.

Parameters

accountId int (required)

The ID for the external account to refresh, available from the Retrieve Connected External Accounts API.

Returns

Promise

A promise which resolves if the operation succeeded.

Availability

MyDataHelps Views
MyDataHelps Embeddables
Web View Steps
Requesting the Refresh of an External Account
var accountId = 5;

MyDataHelps.refreshExternalAccount(accountId)
	.then( function() {
		console.log("Successfully requested refresh");
	} );
var accountId = 5; MyDataHelps.refreshExternalAccount(accountId) .then( function() { console.log("Successfully requested refresh"); } );

Delete an External Account Connection

MyDataHelps.deleteExternalAccount(accountID)

Parameters

accountID int (required)

The ID of the account to disconnect, available from the Retrieve Connected External Accounts API.

Returns

Promise

A promise which resolves if the operation succeeded.

Availability

MyDataHelps Views
MyDataHelps Embeddables
Web View Steps
Deleting an External Account
var accountId = 5;

MyDataHelps.deleteExternalAccount(accountId)
	.then( function() {
		console.log("Successfully deleted the connected external account.");
	} );
var accountId = 5; MyDataHelps.deleteExternalAccount(accountId) .then( function() { console.log("Successfully deleted the connected external account."); } );