Intelligent patient advocacy platform that demystifies medical bills through OCR, LLM analysis, and automated dispute generation.
🏆 Winner - AI For Good Hackathon, University at Buffalo
Over 80% of medical bills in the US contain errors — duplicate charges, incorrect CPT codes, upcoded procedures. Patients receive complex itemized statements they can't interpret, overpay by thousands of dollars, and have no easy way to dispute charges. The system is designed to be opaque.
MediFriend acts as an AI-powered patient advocate. Upload a medical bill (PDF), and it will:
- Extract every line item, CPT/ICD code, and charge using OCR
- Analyze for billing errors — duplicates, upcoding, mismatched codes
- Generate a legally-structured dispute letter ready to send to the provider
- Connect patients with legal representation and financial assistance if needed
Track all your analyzed bills, spending patterns, and potential savings in one place.
Privacy-first design with full HIPAA consent flow before any document is processed.
Upload a PDF medical bill — the system extracts and displays the original document alongside structured data.
Extracted CPT codes, service descriptions, and charges are parsed into a reviewable summary. Each line item is individually expandable.
The system flags potential billing errors — duplicate entries, same-day charges, and codes that may require medical necessity review. Patients can confirm or dispute each finding.
One click generates a formal, legally-structured dispute letter referencing specific account numbers, dates of service, and flagged discrepancies — ready to send to the provider's billing department.
flowchart LR
A["📄 PDF Upload"] --> B["🔒 HIPAA Consent"]
B --> C["👁️ OCR Extraction"]
C --> D["🤖 Gemini LLM"]
D --> E["⚠️ Error Detection"]
E --> F["📝 Dispute Letter"]
F --> G["⚖️ Legal / Financial Aid"]
subgraph D["🤖 Gemini LLM"]
direction TB
D1["Entity Extraction"]
D2["CPT/ICD Validation"]
D3["Duplicate Detection"]
end
style A fill:#1a1a2e,stroke:#3b82f6,color:#fff
style B fill:#16213e,stroke:#10b981,color:#fff
style C fill:#16213e,stroke:#3b82f6,color:#fff
style E fill:#0f3460,stroke:#f59e0b,color:#fff
style F fill:#0f3460,stroke:#3b82f6,color:#fff
style G fill:#1a1a2e,stroke:#10b981,color:#fff
style D1 fill:#533483,stroke:#3b82f6,color:#fff
style D2 fill:#533483,stroke:#3b82f6,color:#fff
style D3 fill:#533483,stroke:#3b82f6,color:#fff
AI-Driven Bill Analysis
- OCR ingestion of PDF medical bills (up to 5 pages)
- Extracts line items, CPT/ICD codes, dates of service, and provider details
- Cross-references codes against standard billing rules to flag overcharges, duplicates, and upcoding
Automated Advocacy
- Generates legally-structured dispute letters with specific account numbers and discrepancy details
- Connects high-complexity cases with legal representation
- Integrated financial assistance for patients needing urgent debt relief
Financial Intelligence
- Spending visualization by category (hospital stays, specialist visits, prescriptions, lab work)
- Bill status tracking across the full lifecycle (Analyzed → Disputed → Resolved)
- Lifetime savings tracker across all analyzed bills
| Layer | Technology |
|---|---|
| Frontend | React 18 (TypeScript) |
| Build System | Vite |
| Styling | Tailwind CSS |
| Visualization | Recharts |
| AI / LLM | Google Gemini API |
| State Management | React Hooks |
-
Clone the repository
git clone https://github.com/MuditNautiyal-21/MediFriend.git cd MediFriend -
Install dependencies
npm install
-
Set up environment variables
Create a
.envfile in the root directory:GEMINI_API_KEY=your_key_hereGoogle Gemini API offers a free tier — get your key here.
-
Run the development server
npm run dev
-
Open
http://localhost:5173in your browser
MediFriend/
├── components/
│ ├── FileUpload.tsx # PDF upload with drag-and-drop
│ ├── BillStatusChart.tsx # Bill lifecycle status tracker
│ ├── DonutChart.tsx # Spending breakdown visualization
│ ├── MedicalCodesDisplay.tsx # CPT/ICD code renderer
│ ├── DisputeLetter.tsx # AI-generated dispute letter view
│ └── RepresentationConsent.tsx # Legal consent flow
├── services/
│ └── geminiService.ts # Google Gemini API integration
├── mock/
│ └── ... # Demo data for presentation mode
├── App.tsx # Main application entry
├── types.ts # TypeScript type definitions
└── index.html
Built as part of a 3-person team at the AI For Good Hackathon (University at Buffalo). I was one of two developers, responsible for:
- Planning the end-to-end data flow: PDF upload → OCR → Gemini entity extraction → error detection → dispute generation
- Co-building the Gemini API integration layer (
geminiService.ts) for structured medical data extraction - Co-building the CPT/ICD code validation and duplicate charge detection logic
- Co-building the automated dispute letter generation pipeline
🏆 Winner - AI For Good Hackathon, University at Buffalo
Recognized for the innovative use of Agentic AI in solving real-world healthcare transparency issues.
Note
This application uses mock data for demonstration purposes. The OCR and Gemini analysis pipeline is fully functional when provided with a valid API key.






