Query the CMS Blue Button 2.0 FHIR API to retrieve a Medicare beneficiary's ExplanationOfBenefit resources and extract claims history

domain: bluebutton.cms.gov · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Register your application on the Blue Button 2.0 developer portal; obtain client ID and secret for the OAuth2 authorization code flow; configure your redirect URI and request the 'patient/ExplanationOfBenefit.read' and 'patient/Patient.read' scopes
  2. Initiate the OAuth2 authorization code flow: redirect the beneficiary to the Blue Button authorization endpoint with your client ID, requested scopes, state parameter, and PKCE code challenge; handle the callback to exchange the authorization code for an access token using YOUR_TOKEN
  3. GET the beneficiary's Patient resource to confirm identity and retrieve the FHIR patient ID; then GET ExplanationOfBenefit resources with a search by patient: GET /v2/fhir/ExplanationOfBenefit?patient={patient_id}&_count=50
  4. Paginate through Bundle.link[rel='next'] links to retrieve the full claims history; Blue Button returns Part A (inpatient), Part B (outpatient and professional), and Part D (drug) claims as distinct ExplanationOfBenefit profiles — distinguish by ExplanationOfBenefit.type coding
  5. For each EOB parse: EOB.item for service lines with procedureSequence, productOrService (CPT/HCPCS/NDC), adjudication amounts (submitted, allowed, paid, patient liability); EOB.payment for total claim payment; EOB.diagnosis for ICD-10 codes
  6. Store the access token securely; Blue Button tokens have an expiration — implement refresh token logic to maintain access across multi-step workflows without requiring the beneficiary to re-authorize

Known gotchas

Related routes

Access CMS Blue Button 2.0 API to retrieve Medicare claims data for a beneficiary
fhir · 6 steps · unrated
Retrieve a Medicare beneficiary's Part A, B, and D claims history using the CMS Blue Button 2.0 FHIR API
bluebutton.cms.gov · 6 steps · unrated
pull Medicare claims data via the CMS Blue Button 2.0 API
cms-blue-button · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans