AI Patient Advocate — Medicare Claims Auditing
Alpha Development Privacy Terms
Active Development — CMS Blue Button 2.0

Medicare claims auditing,
built for the people it serves.

A local-first tool that helps Medicare beneficiaries and their caregivers review Explanation of Benefit records, surface billing discrepancies, and generate formal appeal documentation — without sending a single byte of health data to a cloud server.

API CMS Blue Button 2.0
Data Standard FHIR R4 / CARIN Blue Button IG
Architecture Local-First / Zero Cloud PHI
Status Alpha — Sandbox Validated
"As a caregiver to a disabled Medicare beneficiary, we spend an enormous amount of time reviewing and adjudicating claims. This tool exists to change that."

The Problem

Medicare beneficiaries with complex medical histories receive dozens of Explanation of Benefit records per year. Billing errors, miscoded procedures, and wrongful denials are common — but identifying and appealing them requires technical knowledge most beneficiaries and caregivers simply don't have time to develop. The administrative burden falls hardest on those least able to bear it.

Our Approach

AI Patient Advocate connects directly to Medicare's official Blue Button 2.0 API, analyzes every EOB against a structured rules engine, classifies patient liability into three actionable categories, and generates CMS-20027 Redetermination Request letters pre-filled with the applicable regulatory basis. Everything runs locally. No intermediaries. No data ever leaves the device.

✓  Completed

Foundation

  • CMS Blue Button 2.0 OAuth + PKCE integration
  • FHIR EOB parser for all 8 Medicare claim types
  • BB variable-aware adjudication engine
  • Three-tier triage: Cost Sharing / Appealable / Billing Error
  • 291-code CARC database with patient guidance
  • Denial-type-specific appeal letter templates
  • PDF download and local file storage
  • CMS-compliant privacy policy and consent flow
  • Sandbox validation against all BBUser10000 claim types
▶  Alpha — Now

Validation & Hardening

  • Field-level audit trail — every value traceable to its CMS source field
  • Live CMS API verification with response header proof
  • Automated audit script with engine-vs-raw comparison
  • Collapsible claim detail: care team, diagnoses, procedures, admin flags
  • Field help system — BB variable, formula, and CFR citation per field
  • Production access application submitted to CMS
  • Local LLM integration (Ollama/phi4-mini) for plain-language explanations

Built on the official CMS data standard

Every component was designed around the actual Blue Button 2.0 API specification, the CARIN Blue Button Implementation Guide, and the BB2 data dictionary. Nothing is assumed. Everything is sourced.

📥

CMS Blue Button 2.0 API

OAuth 2.0 + PKCE authorization flow to Medicare's official FHIR R4 endpoint. Paginated EOB retrieval across all 8 claim types with auto token refresh.

FHIR R4 OAuth + PKCE ExplanationOfBenefit

Adjudication Engine

Per-claim-type parsing keyed on Blue Button variable URLs, not generic FHIR category codes. Handles the multi-entry adjudication structure that causes double and triple counting with naive implementations.

Python BB variable routing CARIN IG formula
📋

Rules & Triage Engine

291 CARC codes with triage classification, denial type routing, and patient-facing guidance. Deterministic — every classification decision is traceable to a specific code and CFR citation.

291 CARC codes 42 CFR citations CMS-20027 templates
🏠

Local-First Storage

All PHI is stored exclusively on the user's machine. Flask serves only localhost. No database. No cloud sync. No telemetry. The user can delete all data with a single confirmed action.

Flask / localhost JSON flat files Zero cloud PHI
🤖

Local LLM Integration

Ollama running phi4-mini locally generates plain-language claim explanations. The model receives structured data from the engine — never raw PHI. No API calls to external AI services.

Ollama phi4-mini Structured prompts
🔎

Audit Trail

Every displayed value is traceable to its source BB variable, the formula applied, and the CMS field definition. Live CMS API verification shows actual response headers as proof of a real-time data fetch.

BB variable trace Live API verification Field help modal

Why BB variable routing matters

Blue Button 2.0 emits multiple adjudication entries with the same generic FHIR category code. A naive implementation sums them all and produces values 2–5× too high. This engine keys on the specific BB variable URL in the secondary coding system, which is the only way to correctly identify each financial component.

Eight claim types, eight parsers

Each Medicare claim type (Outpatient, Inpatient, Carrier, DME, SNF, HHA, Hospice, PDE) has a structurally different adjudication schema. Patient liability lives in line-item adjudications for some types and in benefitBalance for others. Each type has a dedicated parsing path built from the BB2 field catalog.

AI at every layer — with clear boundaries

Artificial intelligence plays a defined, auditable role in this project. Development is AI-assisted. Runtime explanations are AI-generated but grounded in deterministic engine output. The rules engine itself is deterministic — every triage decision traces to a specific code and regulation.

Layer 1 — Development

AI-Assisted Engineering

  • Claude (Anthropic) used as primary development assistant throughout build
  • All engine logic reviewed against actual CMS API samples before shipping
  • Data-first discipline — no logic written before the field catalog is complete
  • Every calculation verified against raw BB variable values in source JSON
  • Automated audit script validates engine against source data on each test run
Layer 2 — Runtime

Local AI Explanations

  • Ollama running phi4-mini locally — no external API calls
  • LLM receives structured engine output, never raw PHI or free-form text
  • Plain-language summaries of triage decisions and patient guidance
  • Model accuracy improvements planned as a dedicated roadmap phase
  • Deterministic triage engine is authoritative — LLM is supplementary
Layer 3 — Maintenance

AI-Managed Rules

  • CARC code database designed for AI-assisted updates as CMS publishes changes
  • Rules update system with versioned JSON push to deployed instances
  • Centralized rules endpoint at ai-patientadvocate.com/rules/
  • Future: automated ingestion of CMS policy updates and LCD changes
  • Future: AI-generated appeal letter refinements based on denial patterns

From Medicare to appeal letter in three steps

The application handles the entire workflow — authorization, data retrieval, analysis, and document generation — without the user needing to understand FHIR, CARC codes, or Medicare appeals regulations.

Connect to Medicare

Authorize access through Medicare.gov using the Blue Button 2.0 API. OAuth + PKCE secures the flow. Claims data is downloaded directly to your device. You can revoke access at any time.

Audit Every Claim

The engine analyzes each Explanation of Benefit against 291 CARC codes, classifies patient liability, detects anomalies, and prioritizes claims by financial risk and actionability. Every number traces to its CMS source field.

Generate & Submit

For flagged claims, generate a draft CMS-20027 Redetermination Request pre-filled with claim details, denial codes, and the applicable 42 CFR regulatory basis. Download as PDF. Submit to your MAC.

Your data never leaves your device

Medicare data is among the most sensitive personal information that exists. This application was architected from the ground up around the principle that no health data should ever transit a third-party server.

Local storage only

All downloaded claims data, tokens, reports, and appeal letters are stored exclusively on your personal machine. The application serves only localhost — it is not accessible from outside your device.

No cloud, no telemetry

There is no backend server, no database, no analytics, no crash reporting, and no usage tracking. The only external connections are to Medicare's own Blue Button API and the local Ollama model server.

Full data deletion

A single confirmed action permanently deletes all claims data, tokens, reports, and appeal documents from your device. You can also revoke Medicare API access at any time from within the application.

CMS-compliant consent

Active opt-in to Privacy Policy and Terms of Service is required before any Medicare connection is initiated, per CMS Blue Button 2.0 developer requirements. Consent is logged locally with timestamp.

👤
About the Builder

Richard Scheipe

20-year Solutions Architect with DoD and Fortune 500 credentials. AI Patient Advocate is one of 25 AI projects built in the past year — and the most personal. As a caregiver to a disabled Medicare beneficiary, this tool solves a problem I live with every day.

View full background & project portfolio →