import React, { useState, useEffect } from ‘react’;
import { AlertTriangle, FileText, Calculator, Shield, ArrowRight, CheckCircle, Lock, Activity, DollarSign, Search, Copy, RefreshCw } from ‘lucide-react’;
// — Gemini API Helper —
const generateContent = async (prompt, systemInstruction) => {
const apiKey = “”; // Provided by environment
const url = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-09-2025:generateContent?key=${apiKey}`;
const payload = {
contents: [{ parts: [{ text: prompt }] }],
systemInstruction: { parts: [{ text: systemInstruction }] }
};
try {
const response = await fetch(url, {
method: ‘POST’,
headers: { ‘Content-Type’: ‘application/json’ },
body: JSON.stringify(payload)
});
const data = await response.json();
if (data.error) throw new Error(data.error.message);
return data.candidates?.[0]?.content?.parts?.[0]?.text || “No response generated.”;
} catch (error) {
console.error(“API Error:”, error);
return `Error: ${error.message}. Please try again.`;
}
};
// — Components —
const Header = ({ setView, currentView }) => (
PATIENT’S PLAYBOOK
);
const Hero = ({ setView }) => (
BE THE CEO OF
YOUR HEALTH
The system relies on your fatigue. Use these AI-powered tools to fight denials, audit your policy, and calculate your true costs.
);
const AppealGenerator = () => {
const [formData, setFormData] = useState({
patientName: ”,
claimNumber: ”,
denialReason: ‘not_medically_necessary’,
treatment: ”,
doctorName: ”,
details: ”
});
const [generatedAppeal, setGeneratedAppeal] = useState(”);
const [loading, setLoading] = useState(false);
const handleGenerate = async () => {
setLoading(true);
const systemPrompt = `You are an expert medical billing advocate specializing in ERISA appeals and overturning insurance denials.
Write a formal, aggressive, legalistic appeal letter.
Do not use emotional language. Use regulatory citations (ERISA, ACA, No Surprises Act) where applicable.
The tone should be: “I am auditing your failure to comply with the plan documents.”
Structure:
1. Header with claim details.
2. Procedural challenge (automated denial violation).
3. Request for the full claim file (ERISA citation).
4. Clinical argument (Standard of Care vs Internal Guidelines).
5. Demand for reviewer credentials.
6. Closing threat of state complaint.`;
const userPrompt = `Write an appeal for:
Patient: ${formData.patientName}
Claim #: ${formData.claimNumber}
Treatment Denied: ${formData.treatment}
Doctor: ${formData.doctorName}
Reason Given: ${formData.denialReason}
Additional Context: ${formData.details}`;
const result = await generateContent(userPrompt, systemPrompt);
setGeneratedAppeal(result);
setLoading(false);
};
return (
AI Appeal Generator
Generate a regulatory-grade appeal letter to challenge automated denials.
setFormData({…formData, claimNumber: e.target.value})}
/>
setFormData({…formData, treatment: e.target.value})}
/>
{generatedAppeal ? (
<>
>
) : (
Fill out the form to generate your legal appeal.
)}
);
};
const PolicyDecoder = () => {
const [policyText, setPolicyText] = useState(”);
const [analysis, setAnalysis] = useState(null);
const [loading, setLoading] = useState(false);
const handleAnalyze = async () => {
if (!policyText) return;
setLoading(true);
const systemPrompt = `You are a health insurance contract auditor.
Analyze the user’s policy text for:
1. “Copay Accumulator” or “Benefit Protection” clauses (where coupons don’t count toward deductibles).
2. “Exclusion” lists (specifically for GLP-1s or specialty drugs).
3. “Prior Authorization” requirements that look unusually strict.
Output formatted as a risk report. Use Markdown. Highlight danger zones with ⚠️ emojis.`;
const result = await generateContent(policyText, systemPrompt);
setAnalysis(result);
setLoading(false);
};
return (
Policy Decoder
Paste your insurance contract text to find hidden traps like accumulators.
Risk Analysis
{analysis ? (
) : (
Waiting for policy text…
)}
);
};
const CashCalculator = () => {
const [inputs, setInputs] = useState({
deductible: 6000,
insurancePrice: 150,
cashPrice: 40,
monthsLeft: 12,
riskLevel: ‘low’ // low, high
});
const annualInsuranceCost = inputs.insurancePrice * inputs.monthsLeft;
const annualCashCost = inputs.cashPrice * inputs.monthsLeft;
const savings = annualInsuranceCost – annualCashCost;
const deductibleProgress = Math.min(inputs.deductible, annualInsuranceCost);
const gapRemaining = Math.max(0, inputs.deductible – annualInsuranceCost);
// Simple logic for the recommendation
let recommendation = “”;
let recommendationColor = “”;
if (inputs.riskLevel === ‘high’) {
recommendation = “USE INSURANCE. Because you are high risk, you will likely hit your deductible anyway. Every dollar spent on cash slows you down from hitting your limit.”;
recommendationColor = “text-red-400”;
} else if (savings > (inputs.deductible * 0.5)) {
recommendation = “PAY CASH. The savings are massive. Even if you have an emergency later, the money you saved covers most of the deductible.”;
recommendationColor = “text-green-400”;
} else {
recommendation = “USE INSURANCE. The savings aren’t worth the risk of leaving your deductible untouched.”;
recommendationColor = “text-yellow-400”;
}
return (
Tipping Point Calculator
Math for the “Cash vs. Insurance” dilemma.
setInputs({…inputs, deductible: Number(e.target.value)})} className=”w-full bg-slate-950 text-white p-3 rounded border border-slate-700″ />
setInputs({…inputs, insurancePrice: Number(e.target.value)})} className=”w-full bg-slate-950 text-white p-3 rounded border border-slate-700″ />
setInputs({…inputs, cashPrice: Number(e.target.value)})} className=”w-full bg-slate-950 text-white p-3 rounded border border-slate-700″ />
Gap: ${gapRemaining}
);
};
const App = () => {
const [view, setView] = useState(‘home’);
return (
{view === ‘home’ &&
{view === ‘appeal_generator’ &&
{view === ‘policy_decoder’ &&
{view === ‘cash_calculator’ &&
);
};
export default App;
