Skip to main content

Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you've safely connected to the .gov website. Share sensitive information only on official, secure websites.

Fetching patient data

Scope of Access

Applications receive permission to access Medicare enrollee data on a per-user basis. The Integrated Data Repository (IDR) updates enrollee claims data nearly daily . Access starts when each enrollee approves it through the Blue Button API’s authorization flow.

Duration of Access

There are 3 categories for data access duration:

CategoryDescriptionAccess duration details
1 hourOne-time use apps (e.g., an app that pulls data once to recommend insurance plans).1 hour, without token refresh.
13 monthsApps that pull data continuously (e.g., a personal health aggregator).13 months; the app must prompt the user to re-authorize upon expiry.
ResearchApps facilitating IRB-approved clinical research studies.Never expires unless revoked by the enrollee or due to app inactivity. Apps reviewed every 2 years.

Make a request

Blue Button has three main FHIR resources. Here’s how to fetch each one:

Terminal
# Patient — demographics
curl "https://sandbox.bluebutton.cms.gov/v2/fhir/Patient" \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
# Coverage — insurance and plan info
curl "https://sandbox.bluebutton.cms.gov/v2/fhir/Coverage" \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
# ExplanationOfBenefit — 10 claims at a time
curl "https://sandbox.bluebutton.cms.gov/v2/fhir/ExplanationOfBenefit" \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
EnvironmentBase URL
Sandboxhttps://sandbox.bluebutton.cms.gov/v3/fhir/
Productionhttps://api.bluebutton.cms.gov/v3/fhir/

For the full list of endpoints and parameters, see the Guides or the Swagger docs.

Read the response

Search operations (/Patient, /ExplanationOfBenefit) return a FHIR Bundle. A Bundle is a container that holds a list of matching resources.

{
"resourceType": "Bundle",
"type": "searchset",
"total": 99,
"entry": [
{
"resource": {
"resourceType": "ExplanationOfBenefit",
"id": "carrier--123"
}
},
{
"resource": {
"resourceType": "ExplanationOfBenefit",
"id": "carrier--456"
}
}
]
}

Use the following fields to work with the response:

  • total the number of resources that match your query.
  • entry the list of matching resources. Results are paginated; the default page size is 10 resources.
  • entry[].resource a complete FHIR resource

Read operations with an ID (/Patient/-9985028219431) return a single resource directly, not wrapped in a Bundle.

Note: you can only access data for the enrollee who authorized your application

The FHIR ID in your request must match the enrollee who authorized your application. You cannot substitute another enrollee’s FHIR ID and retrieve their data. If you request an unauthorized FHIR ID, the API returns an error, not another enrollee’s records. Each enrollee authorizes access only to their own data.

Tip: EOB bundles can be large: some enrollees have hundreds of claims. See Handling Pagination for how to retrieve all pages.

Working with identifiers

In FHIR, the difference between the Resource.id (resource ID) and identifier attributes within a resource can be confusing.

  • Resource ID: In the Blue Button API, the resource ID is an internal identifier from the source database, the Integrated Data Repository (IDR). The resource ID is a system-level resource, held outside the resource. The Resource ID is guaranteed to be unique to a particular resource and will always be a single value.
  • Identifier: The identifier attribute typically provides business identifiers (or externally recognized identifiers). In the Blue Button API, the Patient.identifier attribute provides the Medicare Beneficiary ID (MBI). The MBI is the number on an enrollee’s Medicare card.

In FHIR, the identifier attribute is a list element that could supply multiple identifiers. Use discriminators to distinguish between the entries to pull your desired identifier.

For example, you can use discriminators to pull the current MBI from a Patient resource. (Enrollees are sometimes given new or replacement MBIs in situations such as identity theft.) In the Patient resource snippet below, there are two identifiers in the list. Use the following discriminators to pull the current MBI:

  • identifier.system = http://hl7.org/fhir/sid/us-mbi (ensures that the entry is an MBI)
  • identifier.type.coding[n].extension.valueCoding.code = “current”

Patient identifier example:

{
"identifier": [
{
"system": "http://hl7.org/fhir/sid/us-mbi",
"type": {
"coding": [
{
"code": "MC",
"extension": [
{
"url": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency",
"valueCoding": {
"code": "current"
}
}
]
}
]
},
"value": "<CURRENT_MBI_HERE>"
},
{
"system": "http://hl7.org/fhir/sid/us-mbi",
"type": {
"coding": [
{
"code": "MC",
"extension": [
{
"url": "https://bluebutton.cms.gov/resources/codesystem/identifier-currency",
"valueCoding": {
"code": "historic"
}
}
]
}
]
},
"value": "<HISTORIC_MBI_HERE>"
}
]
}

Example FHIRPath expression for pulling the current MBI:

Patient.identifier
.where(type.coding.extension('https://bluebutton.cms.gov/resources/codesystem/identifier-currency').valueCoding.code='current')
.where(system='http://hl7.org/fhir/sid/us-mbi')
.value

Working with references

The Blue Button API uses both literal and logical (FHIR references to refer to other resources/data external to the resource.

Literal references

For literal references, relative URLs are provided. In the sample EOB resource below, the Eob.patient attribute contains a relative URL reference, Patient/123. Append this path to the base FHIR URL to perform a Patient read operation.

Literal reference example:

{
"resource": {
"resourceType": "ExplanationOfBenefit",
"id": "carrier--10045426206",
// ...
"patient": {
"reference": "Patient/123"
}
}
}

Contained resources

The Blue Button API also uses fragments and contained resources. A resource that does not have independent existence is embedded inside another resource as a contained resource. For example, the Organization resource does not have its own endpoint. Instead, it is supplied as a contained resource with EOB. In the example EOB resource below, the Organization resource is within the Eob.contained attribute, and the Eob.provider attribute has a # reference to contained.id (#provider-org).

Contained resource example:

{
"contained": [
{
"active": true,
"id": "provider-org",
"identifier": [
{
"type": {
"coding": [
{
"code": "PRN",
"system": "http://terminology.hl7.org/CodeSystem/v2-0203"
}
]
}
}
]
}
],
// ...
"provider": {
"reference": "#provider-org"
}
},

Logical references

Logical references usually provide a business identifier rather than a URL to an endpoint or a contained resource.

In the example below, the Eob.careTeam.provider attribute contains a reference to the National Provider Identifier (NPI) for the practitioner. (Note: The Blue Button API does not support a /Practitioner endpoint.)

Logical reference example:

{
"careTeam": [
{
"provider": {
"identifier": {
"type": {
"coding": [
{
"code": "npi",
"display": "National Provider Identifier",
"system": "http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBIdentifierType"
}
]
},
"value": "123"
}
}
}
]
}

Extensions and SupportingInfo

The Blue Button API supplies many data points using FHIR extensions. Extensions are information that is not part of the basic definition of the FHIR resource. They’re often very specific to a use case or situation. For example, the Blue Button API uses extensions to provide Medicare-specific data points not included in the standard FHIR specification.

All Blue Button API resources include extensions. Extensions are like a key-value list, where the extension URL is the key. In an extension, the value attribute is defined as a Choice of Types, and the data type depends on the extension’s definition.

In the example below, there are two extensions:

Note: In the Blue Button API, the extension URL points to an underlying valueset rather than the standard FHIR practice of pointing to the StructureDefinition of the extension. This is due to historical reasons and will be revisited in future versions of Blue Button.

Extension example:

{
"extension": [
{
"url": "https://bluebutton.cms.gov/resources/variables/nch_near_line_rec_ident_cd",
"valueCoding": {
"code": "O",
"display": "Part B physician/supplier claim record (processed by local carriers; can include DMEPOS services)",
"system": "https://bluebutton.cms.gov/resources/variables/nch_near_line_rec_ident_cd"
}
},
{
"url": "https://bluebutton.cms.gov/resources/variables/carr_num",
"valueIdentifier": {
"system": "https://bluebutton.cms.gov/resources/variables/carr_num",
"value": "15202"
}
}
]
}

SupportingInfo attribute

The supportingInfo attribute is a standard element in the FHIR EOB resource. Similar to extensions, supportingInfo is like a key-value list. supportingInfo.category serves as the key and supportingInfo.code is the value. Other attributes in supportingInfo include timing[x], value[x], and reason.

Note: The CARIN Implementation Guide uses supportingInfo instead of extensions. The CARIN IG does not define any extensions. For historical and backward compatibility reasons, the Blue Button API provides data in both extensions and supportingInfo.

Determine claim type

The Blue Button API provides claims data in the ExplanationOfBenefit resource for all claim types (e.g., Inpatient, Outpatient, Carrier, DME).

To determine the type of a given claim, inspect the Eob.type attribute. Eob.type is a CodeableConcept, which provides data as a list of codings. There are multiple entries in the list.

Each entry is a code from a given codesystem or valueset with information about the type of claim. For example, the NCHCLMTYPECD codesystem uses the code 71 for a carrier claim. The Blue Button API eob-type valueset uses a code of CARRIER for a carrier claim.

Claim type example:

{
"type": {
"coding": [
{
"code": "71",
"display": "Local carrier non-durable medical equipment, prosthetics, orthotics, and supplies (DMEPOS) claim",
"system": "https://bluebutton.cms.gov/resources/variables/nch_clm_type_cd"
},
{
"code": "CARRIER",
"system": "https://bluebutton.cms.gov/resources/codesystem/eob-type"
}
// ...
]
}
}

For more information about determining claim types, see the following coding system reference links:

Linking items

The item data element in the EOB resource supplies a list of entries describing products/services provided. You can link each entry in the list to other parts of the EOB using the item.*sequence elements.

For example, Eob.item.diagnosisSequence links to Eob.diagnosis.sequence, indicating that this product/service is linked to the corresponding diagnosis. In the partial EOB example below, the item is linked to diagnosis 1 and careTeam member 3.

Linking item example:

{
"item": [
{
"adjudication": [
// ...
],
"diagnosisSequence": [
1
],
"careTeamSequence": [
3
]
// ...
}
],
"diagnosis": [
{
"sequence": 1,
"diagnosisCodeableConcept": {
"coding": [
{
"code": "Z0000",
"display": "ENCNTR FOR GENERAL ADULT MEDICAL EXAM W/O ABNORMAL FINDINGS"
}
]
// ...
}
}
],
"careTeam": [
{
"sequence": 1
// ...
},
{
"sequence": 2
// ...
},
{
"sequence": 3,
"provider": {
"identifier": {}
// ...
},
"role": {
"coding": [
{
"code": "performing",
"display": "Performing provider"
// ...
}
]
}
}
]
}

Understanding the payload

Blue Button API search operations such as /Patient, /ExplanationOfBenefit, and /ExplanationOfBenefit?patient=123, return data in FHIR Bundles . A FHIR bundle is a container resource that includes a collection of FHIR resources. You can grab each resource by looping through the Bundle.entry list attribute.

Read calls such as /Patient/123 return a single resource.

FHIR Bundle example:

{
"resourceType": "Bundle",
"id": "123",
// ...
"type": "searchset",
"total": 99,
"entry": [
{
"resource": {
"resourceType": "ExplanationOfBenefit",
"id": "carrier--123"
// ...
}
},
{
"resource": {
"resourceType": "ExplanationOfBenefit",
"id": "carrier--456"
// ...
}
}
]
}

FHIR search results are paginated with a default of 10 records per call. You can override the default of 10 with a count parameter in the request. The maximum number of records allowed is 50.

To navigate forward and backward through the bundle, use the URLs provided in Bundle.link, as described in the table below. For instance, to get the next X records, use the URL provided in Bundle.link where relation = next.

RelationDescription
firstRetrieve the first X records in the resultset
nextRetrieve the next X records in the resultset
previousRetrieve the previous X records in the resultset

In the example below, the Bundle.total attribute shows that there are 89 records in the results. However, only the first 10 records are delivered in the Bundle.entry array.

For more information on Bundles and FHIR search results, see FHIR v4.3.0 Bundle and FHIR v4.3.0 Managing Returned Resources Bundle navigation example:

{
"resourceType": "Bundle",
"id": "5e5844c4-d3e2-44ca-8c87-77efccc5d60d",
// ...
"total": 89,
"link": [
{
"relation": "first",
"url": "{host}/v3/fhir/ExplanationOfBenefit?startIndex=0&_count=10&patient=..."
},
{
"relation": "next",
"url": "{host}/v3/fhir/ExplanationOfBenefit?startIndex=10&_count=10&patient=..."
},
{
"relation": "self",
"url": "{host}/v3/fhir/ExplanationOfBenefit?&startIndex=..."
}
],
}

Working with partially adjudicated claims

Partially adjudicated claims are also called non-Final Action claims, and show the progress of a claim throughout the adjudication process. CARIN Blue Button 2.1.0 profiles, the format the Blue Button API uses, represent partially adjudicated claims (also called non-Final Action claims) using the ExplanationOfBenefit resource.

Disclaimers for non-Final Action claims:

  • Claims with outcome = partial may contain nonsensical values in coded elements, such as invalid CPT/HCPCS codes and invalid diagnosis codes, due to their non-finalized nature. This is more likely in claims with a claim type code of 1XXX. Use ExplanationOfBenefit.outcome to determine the processing stage of a claim.
  • Not all fields are available in non-Final Action claims. Most of these relate to benefit balance information that isn’t available until a claim has been fully adjudicated. There is ongoing work to improve parity between data from the Shared Systems and the National Claims History.

Blue Button exposes three search parameters for filtering metadata.

The metadata field, source, identifies the CMS system from which the information originated:

  • NCH = National Claims History (All adjudicated claims for Parts A + B)
    • FISS = Fiscal Intermediary Shared System (Partially Adjudicated Institutional Claims)
    • MCS = Multi-Carrier System (Partially Adjudicated Professional Claims)
    • VMS = Viable Information Processing Systems (ViPS) Medicare Shared System (Partially Adjudicated DME claims)
    • DDPS = Drug Data Processing System (All Part D claims)
    • MAP = Medicare Adjudication Portal (some professional claims)

source

Filtering by source filters on the Meta.source key. Blue Button supports both AND and OR operations. (Filtering by AND is useless, however.)

The sources to filter on, and their constituent data, are below.

Meta.sourceData Explanation
NCHNational Claims History (All claims for Parts A + B)
FISSInstitutional claims from Shared Systems
MCSCarrier claims from Shared Systems
VMSDME claims from Shared Systems
DDPSPart D Data from DDPS
MAP (Not yet implemented)[some] Carrier claims from Shared Systems.
CWF (Not yet implemented)Prior Authorization data

tag

Blue Button supports two tags, System-Type and Final-Action, which need to be sent in token format (e.g., system|code). Blue Button supports both AND and OR operations.

tagWhat’s returned?
https://bluebutton.cms.gov/fhir/CodeSystem/System-Type|SharedSystemA + B claims from the Shared Systems (FISS,MCS,VMS,MAP,CWF)
https://bluebutton.cms.gov/fhir/CodeSystem/System-Type|NationalClaimsHistoryA + B claims from the National Claims History
https://bluebutton.cms.gov/fhir/CodeSystem/System-Type|DDPSPart D claims
https://bluebutton.cms.gov/fhir/CodeSystem/Final-Action|FinalActionClaims marked Final Action. (Note: While this tag exists, it is not recommended for filtering claims by processing status)
https://bluebutton.cms.gov/fhir/CodeSystem/Final-Action|NotFinalActionClaims not marked Final Action. (Note: While this tag exists, it is not recommended for filtering claims by processing status)

security

Use security to allow for targeting of SAMHSA-related data. v3 populates a Meta.security token on data that is “sensitive” on the basis of the ACO-OS sensitive data list.

security queryWhat does this do?
security:not=42CFRPart2Filters out claims that have a Meta.security element of 42CFRPart2
security=42CFRPart2Filters out claims without a Meta.security element of 42CFRPart2

The default behavior is based on the API team certificate.

  • BlueButton - Yes
Note: Blue Button should still pass in this parameter.

How to use Shared Systems data

Without any filters applied, Blue Button returns Part A, B, and D data from both the Shared Systems and the National Claims History (NCH) by default. Use the metadata filters described above to change this behavior, set API-specific defaults, etc.

Filtering Part A / B data using source and tag

Filtering data by a claim’s source system is possible using either the source or tag parameter.

sourceData retrieved
NCHClaims for Part A + B from the National Claims History
VMSClaims for Part B from VMS
FISSClaims for Part A + B from FISS
MCSClaims for Part B from MCS
MAPClaims for Part B (for now) from MAP
DDPSPart D claims from DDPS

vs.

tag (don’t forget system!)Data retrieved
NationalClaimsHistoryClaims for Part A + B from the National Claims History
SharedSystemClaims for Part A + B from VMS, FISS, MCS, and MAP
DDPSPart D claims from DDPS

Working with digital insurance card data

The endpoint, /v3/fhir/Patient/{patient}/$generate-insurance-card allows developers to surface digital proof of Medicare coverage to enrollees, providing details on the types of coverage available.

This endpoint references the CARIN Digital Insurance Card Implementation Guide . It returns a bundle that includes /Patient (LINK: TBD) and /Coverage (LINK: TBD) resources conformant to the Digital Insurance Guide profile . You can find examples of this on the Digital Insurance Card page (LINK: TBD) and in the Blue Button Swagger resource.

Working with SAMHSA data

Substance abuse data (also known as SAMHSA data) comes from the Substance Abuse and Mental Health Services Information. It may be included on a claim unless the enrollee opts out.

Looking for U.S. government information and services?
Visit USA.gov