anannyavyas1 commited on
Commit
9073588
·
verified ·
1 Parent(s): c1266c3

Upload folder using huggingface_hub (part 2)

Browse files
Files changed (2) hide show
  1. test_gen.pdf +3 -0
  2. web_dashboard/app.js +25 -50
test_gen.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56c50eea43a0af1f0b117f6894d0e2c9e065e8b728f8c6523b9251794125f5f7
3
+ size 3127
web_dashboard/app.js CHANGED
@@ -2425,58 +2425,33 @@ async function downloadPatientPDF() {
2425
  }
2426
  try {
2427
  const r = window.currentPatientReport;
2428
- const verdict = r.verdict === 'no_tumor' ? 'No abnormalities detected.' : 'Region requiring medical review detected.';
2429
- const riskBadgeColor = r.verdict === 'no_tumor' ? '#10b981' : (r.risk_score > 60 ? '#ef4444' : '#f39c12');
2430
- const riskLevel = r.verdict === 'no_tumor' ? 'Low Risk' : (r.risk_score > 60 ? 'High Risk' : 'Medium Risk');
2431
 
2432
- const win = window.open('', '_blank');
2433
- win.document.write(`
2434
- <!DOCTYPE html>
2435
- <html>
2436
- <head>
2437
- <title>Medical Report</title>
2438
- <style>
2439
- body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; padding: 40px; color: #333; line-height: 1.6; }
2440
- .header { text-align: center; margin-bottom: 30px; border-bottom: 2px solid #f48fb1; padding-bottom: 20px; }
2441
- .header h1 { color: #880e4f; margin: 0; font-size: 28px; }
2442
- .header p { color: #666; margin-top: 5px; }
2443
- .card { border: 1px solid #ddd; border-radius: 8px; padding: 20px; margin-bottom: 20px; background: #fafafa; }
2444
- .row { display: flex; justify-content: space-between; margin-bottom: 10px; }
2445
- .label { font-weight: bold; color: #555; }
2446
- .badge { display: inline-block; padding: 5px 12px; border-radius: 20px; color: white; font-weight: bold; background: ${riskBadgeColor}; }
2447
- .disclaimer { margin-top: 40px; font-size: 11px; color: #888; text-align: justify; border-top: 1px solid #eee; padding-top: 20px; }
2448
- </style>
2449
- </head>
2450
- <body>
2451
- <div class="header">
2452
- <h1>Tri-Netra AI</h1>
2453
- <p>Patient Scan Analysis Report</p>
2454
- </div>
2455
-
2456
- <div class="card">
2457
- <h2>Diagnostic Summary</h2>
2458
- <div class="row"><span class="label">Result:</span> <span>${verdict}</span></div>
2459
- <div class="row"><span class="label">AI Confidence:</span> <span>${r.confidence || '99.9'}%</span></div>
2460
- <div class="row"><span class="label">Risk Level:</span> <span class="badge">${riskLevel}</span></div>
2461
- <div class="row"><span class="label">Estimated Volume:</span> <span>${r.volume_cm3 || "0.0"} cm³</span></div>
2462
- <div class="row"><span class="label">Date:</span> <span>${new Date().toLocaleString()}</span></div>
2463
- </div>
2464
-
2465
- <div class="disclaimer">
2466
- <strong>CLINICAL DISCLAIMER:</strong> This report is generated by an AI research prototype (Tri-Netra 4-Detector Ensemble). It is NOT a verified clinical diagnosis. The risk scores and follow-up recommendations are for informational purposes only. Do not make medical decisions based on this report. Please consult a qualified healthcare professional.
2467
- </div>
2468
-
2469
- <script>
2470
- window.onload = function() {
2471
- window.print();
2472
- };
2473
- </script>
2474
- </body>
2475
- </html>
2476
- `);
2477
- win.document.close();
2478
  } catch (e) {
2479
  console.error(e);
2480
- alert('Failed to generate PDF view. Please try again.');
2481
  }
2482
  }
 
2425
  }
2426
  try {
2427
  const r = window.currentPatientReport;
 
 
 
2428
 
2429
+ const res = await fetch('/generate_pdf', {
2430
+ method: 'POST',
2431
+ headers: {'Content-Type': 'application/json'},
2432
+ body: JSON.stringify({
2433
+ confidence: r.confidence,
2434
+ verdict: r.verdict,
2435
+ volume_cm3: r.volume_cm3,
2436
+ risk_level: r.verdict === 'no_tumor' ? 'Low Risk' : (r.risk_score > 60 ? 'High Risk' : 'Medium Risk'),
2437
+ risk_score: r.risk_score,
2438
+ follow_up: r.follow_up
2439
+ })
2440
+ });
2441
+
2442
+ if (!res.ok) throw new Error('PDF generation failed');
2443
+
2444
+ const blob = await res.blob();
2445
+ const url = window.URL.createObjectURL(blob);
2446
+ const a = document.createElement('a');
2447
+ a.style.display = 'none';
2448
+ a.href = url;
2449
+ a.download = 'Tri_Netra_Report.pdf';
2450
+ document.body.appendChild(a);
2451
+ a.click();
2452
+ window.URL.revokeObjectURL(url);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2453
  } catch (e) {
2454
  console.error(e);
2455
+ alert('Failed to generate PDF report. Please try again.');
2456
  }
2457
  }