-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
462 lines (397 loc) · 16.1 KB
/
index.html
File metadata and controls
462 lines (397 loc) · 16.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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bajaj Insurance Query Engine</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
font-size: 2.5rem;
margin-bottom: 10px;
}
.header p {
opacity: 0.9;
font-size: 1.1rem;
}
.content {
padding: 30px;
}
.upload-section, .query-section, .result-section {
margin-bottom: 30px;
}
.section-title {
font-size: 1.5rem;
color: #333;
margin-bottom: 15px;
display: flex;
align-items: center;
gap: 10px;
}
.file-upload {
border: 2px dashed #667eea;
border-radius: 10px;
padding: 30px;
text-align: center;
background: #f8f9ff;
cursor: pointer;
transition: all 0.3s;
}
.file-upload:hover {
border-color: #764ba2;
background: #f0f2ff;
}
.file-upload input[type="file"] {
display: none;
}
.file-upload-label {
display: inline-block;
padding: 12px 30px;
background: #667eea;
color: white;
border-radius: 25px;
cursor: pointer;
transition: all 0.3s;
}
.file-upload-label:hover {
background: #764ba2;
transform: translateY(-2px);
}
.query-input {
width: 100%;
padding: 15px;
border: 2px solid #e0e0e0;
border-radius: 10px;
font-size: 1rem;
transition: border-color 0.3s;
}
.query-input:focus {
outline: none;
border-color: #667eea;
}
.btn {
padding: 12px 30px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 25px;
font-size: 1rem;
cursor: pointer;
transition: all 0.3s;
margin-top: 15px;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.result-box {
background: #f8f9ff;
border-radius: 10px;
padding: 20px;
margin-top: 20px;
}
.result-approved {
border-left: 4px solid #4caf50;
}
.result-rejected {
border-left: 4px solid #f44336;
}
.result-title {
font-size: 1.2rem;
font-weight: bold;
margin-bottom: 10px;
}
.result-details {
display: grid;
gap: 10px;
margin-top: 15px;
}
.detail-row {
display: flex;
justify-content: space-between;
padding: 8px;
background: white;
border-radius: 5px;
}
.detail-label {
font-weight: 600;
color: #666;
}
.detail-value {
color: #333;
}
.status-badge {
display: inline-block;
padding: 5px 15px;
border-radius: 20px;
font-size: 0.9rem;
font-weight: bold;
}
.status-success {
background: #e8f5e9;
color: #2e7d32;
}
.status-error {
background: #ffebee;
color: #c62828;
}
.loading {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid #f3f3f3;
border-top: 3px solid #667eea;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.sample-queries {
margin-top: 15px;
padding: 15px;
background: #f8f9ff;
border-radius: 10px;
}
.sample-queries h4 {
color: #667eea;
margin-bottom: 10px;
}
.sample-query {
display: inline-block;
margin: 5px;
padding: 8px 15px;
background: white;
border: 1px solid #e0e0e0;
border-radius: 20px;
cursor: pointer;
transition: all 0.3s;
font-size: 0.9rem;
}
.sample-query:hover {
border-color: #667eea;
background: #f0f2ff;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🏥 Bajaj Insurance Query Engine</h1>
<p>AI-Powered Insurance Coverage Analysis</p>
</div>
<div class="content">
<!-- Upload Section -->
<div class="upload-section">
<h2 class="section-title">
📄 Step 1: Upload Policy Document
</h2>
<div class="file-upload" onclick="document.getElementById('fileInput').click()">
<input type="file" id="fileInput" accept=".pdf" onchange="uploadFile()">
<div id="uploadStatus">
<svg width="60" height="60" viewBox="0 0 24 24" fill="none" stroke="#667eea" stroke-width="2">
<path d="M7 18a4.6 4.4 0 0 1 0-9 5 4.5 0 0 1 11 2h1a3.5 3.5 0 0 1 0 7h-1"></path>
<polyline points="9 11 12 8 15 11"></polyline>
<line x1="12" y1="8" x2="12" y2="16"></line>
</svg>
<p style="margin-top: 15px; color: #666;">Click to upload PDF or drag and drop</p>
<label for="fileInput" class="file-upload-label">Choose File</label>
</div>
</div>
<div id="fileInfo" style="display:none; margin-top: 15px;"></div>
</div>
<!-- Query Section -->
<div class="query-section">
<h2 class="section-title">
💬 Step 2: Ask Your Question
</h2>
<textarea
id="queryInput"
class="query-input"
rows="3"
placeholder="Example: I am a 25F with 2 years active policy. Is IVF treatment covered?"
></textarea>
<div class="sample-queries">
<h4>Sample Queries:</h4>
<span class="sample-query" onclick="setQuery('25F with 2 years policy, need IVF treatment')">IVF Coverage</span>
<span class="sample-query" onclick="setQuery('45M requiring cardiac surgery')">Cardiac Surgery</span>
<span class="sample-query" onclick="setQuery('30F pregnant, maternity benefits?')">Maternity Benefits</span>
<span class="sample-query" onclick="setQuery('Emergency treatment coverage amount')">Emergency Care</span>
</div>
<button id="submitBtn" class="btn" onclick="submitQuery()">
🔍 Analyze Coverage
</button>
</div>
<!-- Result Section -->
<div class="result-section" id="resultSection" style="display:none;">
<h2 class="section-title">
📊 Analysis Result
</h2>
<div id="resultContent"></div>
</div>
</div>
</div>
<script>
let currentSessionId = null;
let apiBase = window.location.hostname === 'localhost' ? 'http://localhost:5000' : '';
async function uploadFile() {
const fileInput = document.getElementById('fileInput');
const file = fileInput.files[0];
if (!file) return;
if (!file.name.endsWith('.pdf')) {
alert('Please upload a PDF file');
return;
}
const formData = new FormData();
formData.append('file', file);
document.getElementById('uploadStatus').innerHTML = '<div class="loading"></div><p>Processing PDF...</p>';
try {
const response = await fetch(`${apiBase}/upload`, {
method: 'POST',
body: formData
});
const data = await response.json();
if (data.status === 'success' || data.session_id) {
currentSessionId = data.session_id;
document.getElementById('uploadStatus').innerHTML = `
<div class="status-badge status-success">✅ Upload Successful</div>
<p style="margin-top: 10px;">${data.filename}</p>
`;
document.getElementById('fileInfo').innerHTML = `
<div class="result-box">
<div class="detail-row">
<span class="detail-label">Policy Type:</span>
<span class="detail-value">${data.processing_result?.policy_type || 'Standard'}</span>
</div>
<div class="detail-row">
<span class="detail-label">Inclusions Found:</span>
<span class="detail-value">${data.processing_result?.inclusions_found || 0}</span>
</div>
<div class="detail-row">
<span class="detail-label">Exclusions Found:</span>
<span class="detail-value">${data.processing_result?.exclusions_found || 0}</span>
</div>
</div>
`;
document.getElementById('fileInfo').style.display = 'block';
} else {
throw new Error(data.error || 'Upload failed');
}
} catch (error) {
document.getElementById('uploadStatus').innerHTML = `
<div class="status-badge status-error">❌ Upload Failed</div>
<p style="margin-top: 10px; color: #c62828;">${error.message}</p>
<label for="fileInput" class="file-upload-label" style="margin-top: 15px;">Try Again</label>
`;
}
}
function setQuery(query) {
document.getElementById('queryInput').value = query;
}
async function submitQuery() {
const query = document.getElementById('queryInput').value.trim();
if (!query) {
alert('Please enter a query');
return;
}
document.getElementById('submitBtn').disabled = true;
document.getElementById('submitBtn').innerHTML = '<span class="loading"></span> Analyzing...';
try {
const response = await fetch(`${apiBase}/query`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: query,
session_id: currentSessionId
})
});
const data = await response.json();
const isApproved = data.decision === 'APPROVED';
const resultClass = isApproved ? 'result-approved' : 'result-rejected';
const statusIcon = isApproved ? '✅' : '❌';
document.getElementById('resultContent').innerHTML = `
<div class="result-box ${resultClass}">
<div class="result-title">
${statusIcon} ${data.decision}
</div>
<p style="margin: 10px 0;">${data.justification}</p>
<div class="result-details">
${data.amount > 0 ? `
<div class="detail-row">
<span class="detail-label">Coverage Amount:</span>
<span class="detail-value" style="font-weight: bold; color: #4caf50;">₹${data.amount.toLocaleString()}</span>
</div>
` : ''}
<div class="detail-row">
<span class="detail-label">Confidence:</span>
<span class="detail-value">${data.confidence}%</span>
</div>
<div class="detail-row">
<span class="detail-label">Classification:</span>
<span class="detail-value">${data.confusion_matrix}</span>
</div>
${data.extracted_info ? `
<div class="detail-row">
<span class="detail-label">Detected Info:</span>
<span class="detail-value">
${data.extracted_info.age ? `Age: ${data.extracted_info.age}, ` : ''}
${data.extracted_info.gender ? `Gender: ${data.extracted_info.gender}, ` : ''}
${data.extracted_info.procedure ? `Procedure: ${data.extracted_info.procedure}` : ''}
</span>
</div>
` : ''}
</div>
</div>
`;
document.getElementById('resultSection').style.display = 'block';
} catch (error) {
alert('Error: ' + error.message);
} finally {
document.getElementById('submitBtn').disabled = false;
document.getElementById('submitBtn').innerHTML = '🔍 Analyze Coverage';
}
}
// Check API health on load
window.onload = async function() {
try {
const response = await fetch(`${apiBase}/health`);
const data = await response.json();
console.log('API Status:', data);
} catch (error) {
console.error('API not available:', error);
}
};
</script>
</body>
</html>