-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
281 lines (251 loc) · 14.1 KB
/
index.html
File metadata and controls
281 lines (251 loc) · 14.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>ClaimPilot</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: {
50: "#eff6ff",
100: "#dbeafe",
300: "#93c5fd",
500: "#3b82f6",
600: "#2563eb",
700: "#1d4ed8",
}
}
}
}
}
</script>
<!-- React & ReactDOM -->
<script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<!-- Babel for in-browser JSX -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<!-- Lucide Icons -->
<script src="https://unpkg.com/lucide@latest"></script>
</head>
<body class="bg-gray-50 text-gray-900 antialiased font-sans">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="text/babel">
const { useState, useEffect } = React;
const API_BASE_URL = "http://localhost:8000/api";
// Mock API call since we cant easily import axios in this setup
const analyzeClaim = async (claim) => {
const response = await fetch(`${API_BASE_URL}/claims/analyze`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(claim)
});
if (!response.ok) throw new Error("API Failed");
return await response.json();
};
const DEFAULT_CLAIM = {
patient_id: "P-10042",
procedure_code: "99214",
diagnosis_codes: ["E11.65", "E11.9"],
payer: "Medicare",
denial_code: "CO-50",
denial_reason: "Services not deemed medically necessary",
date_of_service: "01/15/2026",
provider_name: "Dr. Sarah Smith, MD",
clinical_notes: "Patient with uncontrolled T2DM, A1c 9.2%, on metformin and glipizide. Experiencing neuropathy. Increasing dosage and scheduling frequent follow-ups.",
};
function ClaimInput({ onSubmit, isLoading }) {
const [claim, setClaim] = useState(DEFAULT_CLAIM);
const handleChange = (e) => {
const { name, value } = e.target;
if (name === "diagnosis_codes") {
setClaim(prev => ({ ...prev, [name]: value.split(",").map(s => s.trim()) }));
} else {
setClaim(prev => ({ ...prev, [name]: value }));
}
};
const handleSubmit = (e) => {
e.preventDefault();
onSubmit(claim);
};
return (
<div className="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
<div className="p-6 border-b border-gray-100 bg-gray-50/50">
<h2 className="text-xl font-semibold text-gray-900">Claim Details</h2>
<p className="text-sm text-gray-500 mt-1">Input the denied claim information to generate an appeal.</p>
</div>
<form onSubmit={handleSubmit} className="p-6 space-y-6">
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Procedure Code</label>
<input type="text" name="procedure_code" value={claim.procedure_code} onChange={handleChange} className="w-full px-4 py-2 rounded-lg border border-gray-200 focus:ring-2 focus:ring-primary-500 outline-none" required />
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Diagnosis Codes (comma separated)</label>
<input type="text" name="diagnosis_codes" value={claim.diagnosis_codes.join(", ")} onChange={handleChange} className="w-full px-4 py-2 rounded-lg border border-gray-200 focus:ring-2 focus:ring-primary-500 outline-none" required />
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Denial Code</label>
<input type="text" name="denial_code" value={claim.denial_code} onChange={handleChange} className="w-full px-4 py-2 rounded-lg border border-gray-200 focus:ring-2 focus:ring-primary-500 outline-none" required />
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Payer</label>
<input type="text" name="payer" value={claim.payer} onChange={handleChange} className="w-full px-4 py-2 rounded-lg border border-gray-200 focus:ring-2 focus:ring-primary-500 outline-none" required />
</div>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Denial Reason (from EOB)</label>
<textarea name="denial_reason" value={claim.denial_reason} onChange={handleChange} rows="2" className="w-full px-4 py-2 rounded-lg border border-gray-200 focus:ring-2 focus:ring-primary-500 outline-none resize-none" required />
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">Clinical Notes</label>
<textarea name="clinical_notes" value={claim.clinical_notes || ""} onChange={handleChange} rows="4" className="w-full px-4 py-2 rounded-lg border border-gray-200 focus:ring-2 focus:ring-primary-500 outline-none resize-none" placeholder="..." />
</div>
<div className="pt-2">
<button type="submit" disabled={isLoading} className="w-full bg-primary-600 hover:bg-primary-700 disabled:bg-primary-300 text-white font-medium py-3 px-6 rounded-lg shadow-sm transition-all flex justify-center items-center gap-2">
{isLoading ? <span>Analyzing Claim...</span> : <span>Generate Appeal</span>}
</button>
</div>
</form>
</div>
);
}
function StatusTracker({ steps }) {
return (
<div className="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
<div className="p-4 border-b border-gray-100 bg-gray-50 flex items-center gap-2">
<i data-lucide="loader-2" className="w-5 h-5 text-blue-600 animate-spin"></i>
<h3 className="font-semibold text-gray-900">Agent Progress</h3>
</div>
<div className="p-6">
<ul className="space-y-4">
{steps.map((step, idx) => (
<li key={step.id} className="flex items-center gap-3">
<div className={`w-3 h-3 rounded-full ${step.status === "complete" ? "bg-primary-500" : step.status === "active" ? "bg-blue-400 animate-pulse" : step.status === "error" ? "bg-red-500" : "bg-gray-200"}`}></div>
<span className={`text-sm ${step.status === "active" ? "text-blue-700 font-medium" : step.status === "complete" ? "text-gray-900" : "text-gray-500"}`}>{step.label}</span>
</li>
))}
</ul>
</div>
</div>
);
}
function App() {
const [isLoading, setIsLoading] = useState(false);
const [result, setResult] = useState(null);
const [steps, setSteps] = useState([
{ id: "1", label: "Classify Denial", status: "pending" },
{ id: "2", label: "Retrieve Policy Context", status: "pending" },
{ id: "3", label: "Analyze Medical Necessity", status: "pending" },
{ id: "4", label: "Draft Appeal Letter", status: "pending" },
{ id: "5", label: "Self-Critique & Refine", status: "pending" },
]);
useEffect(() => {
lucide.createIcons();
});
const handleSubmitClaim = async (claim) => {
setIsLoading(true);
setResult(null);
setSteps(steps.map(s => ({ ...s, status: "pending" })));
setTimeout(() => setSteps(s => s.map((step, i) => i === 0 ? { ...step, status: "active" } : step)), 500);
setTimeout(() => setSteps(s => s.map((step, i) => i === 0 ? { ...step, status: "complete" } : i === 1 ? { ...step, status: "active" } : step)), 1500);
setTimeout(() => setSteps(s => s.map((step, i) => i === 1 ? { ...step, status: "complete" } : i === 2 ? { ...step, status: "active" } : step)), 3000);
setTimeout(() => setSteps(s => s.map((step, i) => i === 2 ? { ...step, status: "complete" } : i === 3 ? { ...step, status: "active" } : step)), 4500);
setTimeout(() => setSteps(s => s.map((step, i) => i === 3 ? { ...step, status: "complete" } : i === 4 ? { ...step, status: "active" } : step)), 6500);
try {
const response = await analyzeClaim(claim);
setResult(response);
setSteps(s => s.map(step => ({ ...step, status: "complete" })));
} catch (error) {
console.error(error);
alert("Failed to analyze claim. Ensure the backend is running.");
setSteps(s => s.map(step => step.status === "active" ? { ...step, status: "error" } : step));
} finally {
setIsLoading(false);
}
};
return (
<div className="min-h-screen bg-gray-50 flex flex-col">
<header className="bg-white border-b border-gray-200 sticky top-0 z-10">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center gap-3">
<div className="w-8 h-8 bg-primary-600 rounded-lg flex items-center justify-center shadow-lg">
<i data-lucide="activity" className="text-white w-5 h-5"></i>
</div>
<h1 className="text-xl font-bold bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent">ClaimPilot</h1>
</div>
</header>
<main className="flex-1 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 w-full grid grid-cols-1 lg:grid-cols-12 gap-8 items-start">
<div className="lg:col-span-5 space-y-6">
<ClaimInput onSubmit={handleSubmitClaim} isLoading={isLoading} />
</div>
<div className="lg:col-span-7 space-y-6">
{isLoading && <StatusTracker steps={steps} />}
{!isLoading && !result && (
<div className="bg-white rounded-xl shadow-sm border border-gray-100 p-12 flex flex-col items-center justify-center text-center">
<i data-lucide="file-text" className="text-gray-400 w-12 h-12 mb-4"></i>
<h3 className="text-lg font-medium text-gray-900">Waiting for Data</h3>
<p className="text-gray-500 mt-2">Enter claim details. ClaimPilot will classify the denial and draft an appeal.</p>
</div>
)}
{result && (
<div className="space-y-6">
<div className="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<div className="flex items-center justify-between mb-4">
<h3 className="font-semibold text-gray-900 flex items-center gap-2">
<i data-lucide="activity" className="w-5 h-5 text-green-600"></i> Appeal Success Probability
</h3>
<span className="font-bold text-lg text-green-600">{result.appeal.success_score_1_to_100}%</span>
</div>
<div className="w-full bg-gray-200 rounded-full h-2.5">
<div className="bg-green-600 h-2.5 rounded-full" style={{ width: `${result.appeal.success_score_1_to_100}%` }}></div>
</div>
</div>
{result.analysis.track === 'clinical' && result.appeal.missing_evidence && result.appeal.missing_evidence.length > 0 && (
<div className="bg-amber-50 rounded-xl shadow-sm border border-amber-200 p-6">
<h3 className="font-semibold text-amber-900 mb-3 flex items-center gap-2">
<i data-lucide="alert-triangle" className="w-5 h-5 text-amber-600"></i> Missing Evidence Gap Analysis
</h3>
<p className="text-sm text-amber-800 mb-3">The AI detected that the following required policy elements are missing from your clinical notes:</p>
<ul className="list-disc list-inside space-y-1">
{result.appeal.missing_evidence.map((item, idx) => (
<li key={idx} className="text-sm text-amber-900">{item}</li>
))}
</ul>
</div>
)}
{result.analysis.track === 'administrative' && result.appeal.attachments_needed && result.appeal.attachments_needed.length > 0 && (
<div className="bg-blue-50 rounded-xl shadow-sm border border-blue-200 p-6 mt-6">
<h3 className="font-semibold text-blue-900 mb-3 flex items-center gap-2">
<i data-lucide="paperclip" className="w-5 h-5 text-blue-600"></i> Suggested Administrative Attachments
</h3>
<p className="text-sm text-blue-800 mb-3">For this administrative/billing denial, the AI recommends gathering and attaching the following technical proof:</p>
<ul className="list-disc list-inside space-y-1">
{result.appeal.attachments_needed.map((item, idx) => (
<li key={idx} className="text-sm text-blue-900">{item}</li>
))}
</ul>
</div>
)}
<div className="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<h3 className="font-semibold text-gray-900 mb-4 flex items-center gap-2">
<i data-lucide="mail" className="w-5 h-5 text-primary-600"></i> Appeal Letter
</h3>
<pre className="text-sm font-sans text-gray-800 whitespace-pre-wrap leading-relaxed">{result.appeal.full_text}</pre>
</div>
</div>
)}
</div>
</main>
</div>
);
}
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
</script>
</body>
</html>