Inspiration

My mother waited 11 days for insulin approval while her blood sugar hit 400 mg/dL. The doctor's office faxed forms three times. The payer "lost" the first two. By day 8, she was in the ER.

This isn't rare — it's the norm. 93% of physicians report care delays due to prior authorization (AMA 2025 Survey). Doctors waste $34,000/year and 700+ hours per provider on PA paperwork. Patients sit at home, getting sicker, while paper shuffles between fax machines.

Then CMS-0057-F hit on January 1, 2026 — mandating electronic PA with 72-hour urgent decisions. But the government mandated speed without giving doctors any new tools. We thought: what if we could turn a 45-minute PA request into a 60-second conversation?

What it does

Prior Auth Autopilot is the first MCP-native clinical AI agent that generates submission-ready prior authorization letters — not drafts, not templates, not "fill in the blanks." Every field is complete. Every criterion is addressed. Every lab value is cited with dates.

The 60-Second Workflow:

  1. Doctor opens patient in Prompt Opinion
  2. Says: "I need prior auth for Ozempic through Aetna"
  3. Agent reads live FHIR data from the EHR automatically
  4. Fetches Aetna's exact criteria for Ozempic
  5. Runs a proactive gap check"⚠️ HbA1c is 8 months old — Aetna requires within 6 months"
  6. Calculates approval probability: "78% — here's the breakdown"
  7. Generates a 6-section clinical letter with CMS-0057-F compliance
  8. Creates a downloadable PDF with color-coded criteria analysis
  9. If probability is low: auto-generates a peer-to-peer call script

Denial handling: Doctor pastes a denial letter → agent detects denial type → generates targeted appeal → cites regulatory grounds → produces PDF.

How we built it

  • FastMCP server (Python) deployed on Render — matches Prompt Opinion's official po-fastmcp reference architecture
  • MethodType-based FHIR extension for ai.promptopinion/fhir-context — reads x-fhir-server-url, x-fhir-access-token, and x-patient-id headers for real EHR integration
  • Dual-mode FHIR: automatically uses real EHR data from Prompt Opinion, falls back to HAPI FHIR R4 sandbox for demos — zero PHI
  • ReportLab PDF engine with professional clinical formatting — color-coded criteria (✅🟡❌), structured sections, regulatory footer
  • Starlette static file serving for PDF downloads alongside the MCP endpoint
  • 19+ drug criteria database across 4 major payers with generic fallback
  • 7 denial type classifiers — step therapy, medical necessity, missing docs, experimental, quantity limit, expired PA, non-formulary
  • 6 MCP tools: get_payer_criteria(), list_supported_drugs(), get_patient_fhir_data(), generate_prior_auth(), analyze_denial_letter(), generate_pdf_letter()

Challenges we ran into

  • The Silent Deprecation: FastMCP v3.2.4 silently deprecated the description constructor parameter. Server crashed on deploy with zero useful error message. Took hours of debugging to find a one-word fix.
  • The Lifespan Trap: Mounting FastMCP inside Starlette causes RuntimeError: Task group is not initialized unless you pass lifespan from the MCP app to Starlette — completely undocumented behavior.
  • The Capabilities Binding Bug: Our FHIR extension used *args, **kwargs which silently failed. We reverse-engineered Prompt Opinion's reference repo and discovered MethodType binding with explicit parameters is required.
  • The Header Blindspot: Without reading x-fhir-server-url headers, the agent always hit the HAPI sandbox instead of real EHR data. We discovered these headers only by reading PO's source code line by line.

Accomplishments that we're proud of

  • 45 minutes → 60 seconds: A complete prior auth workflow that used to take nearly an hour now happens in one conversation turn
  • Proactive gap detection: No other PA tool warns doctors about weak spots BEFORE submission. We calculate exactly what's missing and how it impacts approval odds
  • Approval probability scoring: Quantified 0-100% with per-criterion breakdown — doctors see exactly where they're strong and where they need more evidence
  • Peer-to-peer call scripts: When the letter isn't enough, we generate word-for-word scripts with anticipated objections and counter-arguments for the payer's medical director
  • 100% submission-ready output: Zero placeholders, zero blanks, zero "fill this in later." Every letter is ready to fax or upload immediately
  • Dual-mode FHIR: Seamlessly switches between real EHR data in production and HAPI sandbox for demos without changing a single line of code
  • Full regulatory compliance: Every letter cites CMS-0057-F, CMS-0062-P, and 45 CFR 147.136 — we don't just generate letters, we arm doctors with federal regulations

What we learned

  • Prior authorization isn't a technology problem — it's an automation gap. The clinical data exists in FHIR. The criteria exist in payer policies. Nobody connected them until now.
  • Proactive gap detection is the killer feature. Doctors don't just want a letter — they want to know if it will get approved BEFORE they submit it.
  • CMS-0057-F changed the legal landscape, but only tools like this make the mandate actually work for doctors on the ground.
  • The MCP protocol is the perfect abstraction for clinical AI tools — it separates the intelligence (LLM) from the capabilities (FHIR queries, PDF generation, criteria lookup) cleanly.

What's next for Prior Auth Autopilot

  • Live EHR pilot with a health system partner to measure real-world approval rate improvement
  • Expand to 20+ payers with real-time formulary and benefit verification
  • Auto-submission via payer FHIR APIs when CMS-0062-P finalizes
  • Outcome learning — track which letter patterns, evidence combinations, and phrasings get approved, then continuously optimize
  • Multi-language support — generate letters in Spanish for underserved patient populations
  • Integration with pharmacy benefit managers for real-time formulary checks before writing the letter

Built With

Share this project:

Updates