Health Record Retrieval ($everything)

Application APIs

This workflow demonstrates how to retrieve a user's associated health records. The workflow combines a GraphQL getProfile query to access the user profile id for use within the $everything REST FHIR API for comprehensive health record retrieval across all connected data sources.


Prerequisites

Environment URLs:

  • Client-Sandbox: https://api.client-sandbox.icanbwell.com/v1/graphql

Workflow Steps

Step 1: Retrieve User Identifier

Use the getProfile GraphQL query to retrieve the user's identifier.

GraphQL Query:

query getProfile {
  userProfile {
    id
    name {
      family
      given
    }
    birthDate
  }
}

Step 2: Extract User Profile ID

From the userProfile response, extract the id for retrieving health records associated with a specific user. This identifier is used in the FHIR $everything operation in Step 3.


Step 3: Retrieve Health Records Using FHIR $everything

Once you have the id, use the FHIR $everything operation to retrieve all health records associated with that user. This operation uses the following REST endpoint:

REST Endpoints:

GET {baseURL}/v1/Person/{id}/$everything
GET {baseURL}/v1/Patient/person.{id}/$everything

Optional Query Parameters & Custom Headers:

ParameterTypeDescriptionDefault
_typeStringFilter for specific resource types (comma-separated)All types
_sinceDateTimeFetch resources updated after this date-timeNone

Note: The _type and _since parameters are recommended when testing in interactive API playgrounds to manage response payload size and prevent browser performance issues.


For large datasets, consider streaming responses using the following header:

NameValue
Acceptapplication/fhir+ndjson

Example (using streaming header & _since parameter):

curl --request GET \
  --url '{baseURL}/Person/{id}/$everything?_since=2025-11-01T00%3A00%3A00Z' \				
  --header 'accept: application/fhir+ndjson' \ 	
  --header 'authorization: Bearer {user-access-token}
GET /v1/Person/{id}/$everything?_since=2025-11-01T00%3A00%3A00Z HTTP/1.1
Accept: application/fhir+ndjson
Authorization: Bearer {user-access-token}
Host: {baseURL}

📘

Additional parameter and header details can be found on this page: $everything


Some resource types may include data derived from multiple sources:

  • MedicationStatement Resources: May aggregate data from multiple Medication, MedicationRequest, or MedicationStatement resources from the same data provider. Data provenance and meta.source values are retained, and a derivedFrom field references the original resources.
  • Composition Resources: Data provenance-aware reconciliation of multiple resources to maintain a single accurate event view.
  • Other Refined Resources: Have a 1:1 relationship with the original resource (e.g., a single Observation with normalized units).


Health Record Retrieval per Connected Data Source

This workflow demonstrates how to retrieve a user's data connections and each of their associated health records. The workflow combines GraphQL queries to access connection details through SubscriptionStatus resources and the Patient $everything REST API for comprehensive health record retrieval from each connected data source.



Prerequisites

Environment URLs:

  • Client-Sandbox: https://api.client-sandbox.icanbwell.com/v1/graphql

Workflow Steps

Step 1: Retrieve Connection Details

Use the subscriptionStatuses GraphQL query to retrieve SubscriptionStatus resources containing the user's data connection details.

GraphQL Query:

query ($security: SearchToken) { 
  subscriptionStatuses(_security: $security) { 
    entry { 
      resource {
        extension { 
          id 
          url 
          valueString 
        }
        notificationEvent { 
          id 
          timestamp 
        }
        error { 
          coding { 
            system 
            code 
            display 
          } 
        }
      } 
    } 
  } 
}

Response Properties:

The response returns a bundle of SubscriptionStatus FHIR resources with the following key properties:

PropertyDescriptionExample Value
source_patient_idUnique patient identifier specific to a data connectionUnique ID string
connection_nameHuman-readable connection name"BWell PROA Demo"
categoryType of connection"Provider"
token-statusCurrent connection status"CONNECTED"
data-connection-statusCurrent data synchronization status"RETRIEVED"
meta.lastUpdatedConnection last updatedISO 8601 timestamp
data-last-updatedData last updated dateISO 8601 timestamp
error.codingSpecific synchronization errors"PERSON_MATCHING_ERROR"
created-dateConnection creation dateISO 8601 timestamp

Step 2: Extract Source Patient ID

From the SubscriptionStatus response, extract the source_patient_id for retrieving health records associated with a specific connection. This identifier is used in the FHIR $everything operation in Step 3.


Step 3: Retrieve Health Records Using FHIR $everything

Once you have the source_patient_id, use the FHIR $everything operation to retrieve all health records associated with that connection. This operation uses the following REST endpoint:

REST Endpoint:

GET {baseURL}/v1/Patient/{source_patient_id}/$everything

Optional Query Parameters:

ParameterTypeDescriptionDefault
_includePatientLinkedOnlyBooleanIncludes only linked clinical resources; excludes non-clinical resourcesfalse
_typeStringFilter for specific resource types (comma-separated)All types
_sinceDateTimeFetch resources updated after this date-timeNone

Examples:

  • Clinical resources only: GET /v1/Patient/{id}/$everything?_includePatientLinkedOnly=true
  • Specific resource types: GET /v1/Patient/{id}/$everything?_type=Observation,Encounter
  • Recent updates: GET /v1/Patient/{id}/$everything?_since=2024-01-01T00:00:00Z

Resource Coverage:

The $everything operation returns a FHIR bundle containing:

  • Clinical Resources - Observation, Condition, Procedure, MedicationStatement, AllergyIntolerance, and other clinical data
  • Non-Clinical Resources - Practitioner, Location, Organization, and supporting data
  • Encounter Information - Healthcare visits and events
  • Patient Demographics - Patient demographic information
  • Referenced Resources - Related resources based on query parameters

Enriched Data Resources:

Some resource types may include data derived from multiple sources:

MedicationStatement Resources: May aggregate data from multiple Medication, MedicationRequest, or MedicationStatement resources from the same data provider. Data provenance and meta.source values are retained, and a derivedFrom field references the original resources.

Composition Resources: Aggregate multiple resources but are not returned by the patient $everything operation, so no special handling is required.

Other Enriched Resources: Have a 1:1 relationship with the original unenriched resource (e.g., a single Observation with normalized units).

Fetch Updated Resources:

The _since parameter retrieves only resources added or updated after the specified date-time. If no resources have been updated since the provided date, an empty bundle is returned.

Example:

GET /v1/Patient/{id}/$everything?_since=2024-11-01T00:00:00Z

Note: The _type parameter is recommended when testing in interactive API playgrounds to manage response payload size and prevent browser performance issues.