Spaces:
Runtime error
Runtime error
feat: consolidate medications into table, add patient/doctor/date header
Browse files- templates/dashboard.html +70 -104
templates/dashboard.html
CHANGED
|
@@ -115,8 +115,48 @@
|
|
| 115 |
<span class="material-symbols-outlined text-sm">download</span>
|
| 116 |
</button>
|
| 117 |
</div>
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
</section>
|
| 121 |
|
| 122 |
<section id="recent-activity" class="mt-16">
|
|
@@ -147,85 +187,20 @@
|
|
| 147 |
</section>
|
| 148 |
</main>
|
| 149 |
|
| 150 |
-
<template id="medication-
|
| 151 |
-
<
|
| 152 |
-
<
|
| 153 |
-
<div class="
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
</div>
|
| 165 |
-
<a href="#" class="med-details-link bg-slate-50 dark:bg-slate-800 hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors text-slate-700 dark:text-slate-200 px-4 py-2 rounded-xl text-sm font-semibold border border-slate-200 dark:border-slate-700">
|
| 166 |
-
Open Analysis
|
| 167 |
-
</a>
|
| 168 |
-
</div>
|
| 169 |
-
</div>
|
| 170 |
-
<div class="flex flex-col gap-6 p-8">
|
| 171 |
-
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-5 gap-4">
|
| 172 |
-
<div class="p-4 rounded-2xl bg-slate-50 dark:bg-slate-800/60 border border-slate-100 dark:border-slate-800">
|
| 173 |
-
<p class="text-[10px] uppercase font-semibold text-slate-400 mb-1 tracking-[0.08em]">Dosage</p>
|
| 174 |
-
<p class="med-dosage text-sm font-bold text-slate-800 dark:text-slate-200"></p>
|
| 175 |
-
</div>
|
| 176 |
-
<div class="p-4 rounded-2xl bg-slate-50 dark:bg-slate-800/60 border border-slate-100 dark:border-slate-800">
|
| 177 |
-
<p class="text-[10px] uppercase font-semibold text-slate-400 mb-1 tracking-[0.08em]">Frequency</p>
|
| 178 |
-
<p class="med-frequency text-sm font-bold text-slate-800 dark:text-slate-200"></p>
|
| 179 |
-
</div>
|
| 180 |
-
<div class="p-4 rounded-2xl bg-slate-50 dark:bg-slate-800/60 border border-slate-100 dark:border-slate-800">
|
| 181 |
-
<p class="text-[10px] uppercase font-semibold text-slate-400 mb-1 tracking-[0.08em]">Duration</p>
|
| 182 |
-
<p class="med-duration text-sm font-bold text-slate-800 dark:text-slate-200"></p>
|
| 183 |
-
</div>
|
| 184 |
-
<div class="p-4 rounded-2xl bg-slate-50 dark:bg-slate-800/60 border border-slate-100 dark:border-slate-800">
|
| 185 |
-
<p class="text-[10px] uppercase font-semibold text-slate-400 mb-1 tracking-[0.08em]">Therapeutic Class</p>
|
| 186 |
-
<p class="med-therapeutic text-sm font-bold text-slate-800 dark:text-slate-200"></p>
|
| 187 |
-
</div>
|
| 188 |
-
<div class="p-4 rounded-2xl bg-slate-50 dark:bg-slate-800/60 border border-slate-100 dark:border-slate-800">
|
| 189 |
-
<p class="text-[10px] uppercase font-semibold text-slate-400 mb-1 tracking-[0.08em]">Pack / Manufacturer</p>
|
| 190 |
-
<p class="med-pack text-sm font-bold text-slate-800 dark:text-slate-200"></p>
|
| 191 |
-
</div>
|
| 192 |
-
</div>
|
| 193 |
-
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4">
|
| 194 |
-
<section class="med-composition-wrap rounded-2xl border border-slate-200 dark:border-slate-800 bg-slate-50/70 dark:bg-slate-800/30 p-5">
|
| 195 |
-
<p class="text-[10px] uppercase font-semibold text-slate-400 tracking-[0.08em]">Composition</p>
|
| 196 |
-
<p class="med-composition mt-3 text-sm leading-6 text-slate-700 dark:text-slate-300"></p>
|
| 197 |
-
</section>
|
| 198 |
-
<section class="med-classes-wrap rounded-2xl border border-slate-200 dark:border-slate-800 bg-slate-50/70 dark:bg-slate-800/30 p-5">
|
| 199 |
-
<p class="text-[10px] uppercase font-semibold text-slate-400 tracking-[0.08em]">Reference Classes</p>
|
| 200 |
-
<div class="mt-3 space-y-2 text-sm text-slate-700 dark:text-slate-300">
|
| 201 |
-
<p><span class="font-semibold text-slate-900 dark:text-white">Chemical:</span> <span class="med-chemical"></span></p>
|
| 202 |
-
<p><span class="font-semibold text-slate-900 dark:text-white">Action:</span> <span class="med-action"></span></p>
|
| 203 |
-
</div>
|
| 204 |
-
</section>
|
| 205 |
-
<section class="med-substitutes-wrap rounded-2xl border border-slate-200 dark:border-slate-800 bg-slate-50/70 dark:bg-slate-800/30 p-5">
|
| 206 |
-
<div class="flex items-center justify-between gap-3">
|
| 207 |
-
<p class="text-[10px] uppercase font-semibold text-slate-400 tracking-[0.08em]">Substitutes</p>
|
| 208 |
-
<span class="med-substitutes-count text-xs font-bold text-slate-500"></span>
|
| 209 |
-
</div>
|
| 210 |
-
<div class="med-substitutes mt-3 flex flex-wrap gap-2"></div>
|
| 211 |
-
</section>
|
| 212 |
-
<section class="med-uses-wrap rounded-2xl border border-slate-200 dark:border-slate-800 bg-slate-50/70 dark:bg-slate-800/30 p-5">
|
| 213 |
-
<p class="text-[10px] uppercase font-semibold text-slate-400 tracking-[0.08em]">Common Uses</p>
|
| 214 |
-
<div class="med-uses mt-3 flex flex-wrap gap-2"></div>
|
| 215 |
-
</section>
|
| 216 |
-
</div>
|
| 217 |
-
<div class="grid grid-cols-1 lg:grid-cols-[1fr_0.9fr] gap-4">
|
| 218 |
-
<div class="p-5 rounded-2xl bg-primary/5 border border-primary/10">
|
| 219 |
-
<p class="text-xs font-semibold text-primary uppercase tracking-[0.08em] mb-2">Medication Note</p>
|
| 220 |
-
<p class="med-insight text-sm text-slate-700 dark:text-slate-300 leading-relaxed"></p>
|
| 221 |
-
</div>
|
| 222 |
-
<div class="med-effects-wrap p-5 rounded-2xl bg-slate-50 dark:bg-slate-800/30 border border-slate-200 dark:border-slate-800">
|
| 223 |
-
<p class="text-[10px] uppercase font-semibold text-slate-400 tracking-[0.08em]">Side Effects Snapshot</p>
|
| 224 |
-
<div class="med-effects mt-3 flex flex-wrap gap-2"></div>
|
| 225 |
-
</div>
|
| 226 |
-
</div>
|
| 227 |
-
</div>
|
| 228 |
-
</div>
|
| 229 |
</template>
|
| 230 |
|
| 231 |
<footer class="mt-20 border-t border-slate-200 dark:border-slate-800 py-10 bg-white dark:bg-slate-950">
|
|
@@ -252,8 +227,8 @@
|
|
| 252 |
const pdfPreviewLabel = document.getElementById('pdf-preview-label');
|
| 253 |
const processingOverlay = document.getElementById('processing-overlay');
|
| 254 |
const resultsArea = document.getElementById('results-area');
|
| 255 |
-
const medicationsContainer = document.getElementById('medications-
|
| 256 |
-
const template = document.getElementById('medication-
|
| 257 |
let lastAnalysis = null;
|
| 258 |
|
| 259 |
const pdfPlaceholderSvg = `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(`
|
|
@@ -358,30 +333,21 @@
|
|
| 358 |
medicationsContainer.innerHTML = '';
|
| 359 |
|
| 360 |
if (data.medications && data.medications.length > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
data.medications.forEach(med => {
|
| 362 |
const clone = template.content.cloneNode(true);
|
|
|
|
| 363 |
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
clone.querySelector('.med-source').textContent = med.source || 'OCR only';
|
| 372 |
-
clone.querySelector('.med-therapeutic').textContent = med.therapeutic_class || med.category || 'Not available';
|
| 373 |
-
clone.querySelector('.med-pack').textContent = formatPackAndManufacturer(med);
|
| 374 |
-
setText(clone.querySelector('.med-composition'), med.composition);
|
| 375 |
-
setText(clone.querySelector('.med-chemical'), med.chemical_class);
|
| 376 |
-
setText(clone.querySelector('.med-action'), med.action_class);
|
| 377 |
-
renderChips(clone.querySelector('.med-substitutes'), safeList(med.substitutes).slice(0, 6), 'No mapped substitutes');
|
| 378 |
-
renderChips(clone.querySelector('.med-uses'), safeList(med.uses), 'No mapped uses');
|
| 379 |
-
renderChips(clone.querySelector('.med-effects'), safeList(med.side_effects).slice(0, 6), 'No side-effect snapshot');
|
| 380 |
-
const substitutes = safeList(med.substitutes);
|
| 381 |
-
clone.querySelector('.med-substitutes-count').textContent = substitutes.length ? `${substitutes.length} mapped` : 'None mapped';
|
| 382 |
-
const badgeText = (med.name || 'M').slice(0, 2).toUpperCase();
|
| 383 |
-
clone.querySelector('.med-badge').textContent = badgeText;
|
| 384 |
-
clone.querySelector('.med-details-link').href = data.analysis_id ? `/details/${data.analysis_id}` : '/history';
|
| 385 |
|
| 386 |
medicationsContainer.appendChild(clone);
|
| 387 |
});
|
|
|
|
| 115 |
<span class="material-symbols-outlined text-sm">download</span>
|
| 116 |
</button>
|
| 117 |
</div>
|
| 118 |
+
<div class="mb-6 grid grid-cols-1 md:grid-cols-3 gap-4">
|
| 119 |
+
<div class="p-4 rounded-xl bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 shadow-sm flex items-center gap-4">
|
| 120 |
+
<div class="w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center text-primary"><span class="material-symbols-outlined">person</span></div>
|
| 121 |
+
<div>
|
| 122 |
+
<p class="text-[10px] uppercase tracking-wider font-bold text-slate-400">Patient Name</p>
|
| 123 |
+
<p id="patient-name-display" class="font-semibold text-slate-900 dark:text-white">N/A</p>
|
| 124 |
+
</div>
|
| 125 |
+
</div>
|
| 126 |
+
<div class="p-4 rounded-xl bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 shadow-sm flex items-center gap-4">
|
| 127 |
+
<div class="w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center text-primary"><span class="material-symbols-outlined">medical_services</span></div>
|
| 128 |
+
<div>
|
| 129 |
+
<p class="text-[10px] uppercase tracking-wider font-bold text-slate-400">Doctor Name</p>
|
| 130 |
+
<p id="doctor-name-display" class="font-semibold text-slate-900 dark:text-white">N/A</p>
|
| 131 |
+
</div>
|
| 132 |
+
</div>
|
| 133 |
+
<div class="p-4 rounded-xl bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 shadow-sm flex items-center gap-4">
|
| 134 |
+
<div class="w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center text-primary"><span class="material-symbols-outlined">calendar_today</span></div>
|
| 135 |
+
<div>
|
| 136 |
+
<p class="text-[10px] uppercase tracking-wider font-bold text-slate-400">Date</p>
|
| 137 |
+
<p id="date-display" class="font-semibold text-slate-900 dark:text-white">N/A</p>
|
| 138 |
+
</div>
|
| 139 |
+
</div>
|
| 140 |
+
</div>
|
| 141 |
+
|
| 142 |
+
<div class="bg-white dark:bg-slate-900 rounded-2xl border border-slate-200 dark:border-slate-800 shadow-sm overflow-hidden">
|
| 143 |
+
<div class="overflow-x-auto">
|
| 144 |
+
<table class="w-full text-left border-collapse">
|
| 145 |
+
<thead>
|
| 146 |
+
<tr class="bg-slate-50 dark:bg-slate-800/50 border-b border-slate-200 dark:border-slate-800">
|
| 147 |
+
<th class="px-6 py-4 text-xs font-bold uppercase tracking-wider text-slate-500 whitespace-nowrap">Medicine Name</th>
|
| 148 |
+
<th class="px-6 py-4 text-xs font-bold uppercase tracking-wider text-slate-500 whitespace-nowrap">Composition</th>
|
| 149 |
+
<th class="px-6 py-4 text-xs font-bold uppercase tracking-wider text-slate-500 whitespace-nowrap">Dosage</th>
|
| 150 |
+
<th class="px-6 py-4 text-xs font-bold uppercase tracking-wider text-slate-500 whitespace-nowrap">Frequency</th>
|
| 151 |
+
<th class="px-6 py-4 text-xs font-bold uppercase tracking-wider text-slate-500 whitespace-nowrap">Duration</th>
|
| 152 |
+
<th class="px-6 py-4 text-xs font-bold uppercase tracking-wider text-slate-500">Note</th>
|
| 153 |
+
</tr>
|
| 154 |
+
</thead>
|
| 155 |
+
<tbody id="medications-table-body" class="divide-y divide-slate-100 dark:divide-slate-800/60">
|
| 156 |
+
</tbody>
|
| 157 |
+
</table>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
</section>
|
| 161 |
|
| 162 |
<section id="recent-activity" class="mt-16">
|
|
|
|
| 187 |
</section>
|
| 188 |
</main>
|
| 189 |
|
| 190 |
+
<template id="medication-row-template">
|
| 191 |
+
<tr class="hover:bg-slate-50/50 dark:hover:bg-slate-800/20 transition-colors">
|
| 192 |
+
<td class="px-6 py-4 align-top">
|
| 193 |
+
<div class="font-bold text-slate-900 dark:text-white med-name text-sm"></div>
|
| 194 |
+
<div class="text-xs text-slate-500 mt-1 med-type uppercase tracking-wide font-semibold"></div>
|
| 195 |
+
</td>
|
| 196 |
+
<td class="px-6 py-4 align-top text-sm text-slate-600 dark:text-slate-300 med-composition"></td>
|
| 197 |
+
<td class="px-6 py-4 align-top whitespace-nowrap">
|
| 198 |
+
<span class="inline-flex items-center px-2.5 py-1 rounded-md bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300 text-xs font-bold med-dosage"></span>
|
| 199 |
+
</td>
|
| 200 |
+
<td class="px-6 py-4 align-top text-sm font-medium text-slate-800 dark:text-slate-200 med-frequency"></td>
|
| 201 |
+
<td class="px-6 py-4 align-top text-sm font-medium text-slate-800 dark:text-slate-200 med-duration whitespace-nowrap"></td>
|
| 202 |
+
<td class="px-6 py-4 align-top text-xs text-slate-500 leading-relaxed med-insight"></td>
|
| 203 |
+
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
</template>
|
| 205 |
|
| 206 |
<footer class="mt-20 border-t border-slate-200 dark:border-slate-800 py-10 bg-white dark:bg-slate-950">
|
|
|
|
| 227 |
const pdfPreviewLabel = document.getElementById('pdf-preview-label');
|
| 228 |
const processingOverlay = document.getElementById('processing-overlay');
|
| 229 |
const resultsArea = document.getElementById('results-area');
|
| 230 |
+
const medicationsContainer = document.getElementById('medications-table-body');
|
| 231 |
+
const template = document.getElementById('medication-row-template');
|
| 232 |
let lastAnalysis = null;
|
| 233 |
|
| 234 |
const pdfPlaceholderSvg = `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(`
|
|
|
|
| 333 |
medicationsContainer.innerHTML = '';
|
| 334 |
|
| 335 |
if (data.medications && data.medications.length > 0) {
|
| 336 |
+
if (document.getElementById('patient-name-display')) document.getElementById('patient-name-display').textContent = data.patient_name || 'N/A';
|
| 337 |
+
if (document.getElementById('doctor-name-display')) document.getElementById('doctor-name-display').textContent = data.doctor_name || 'N/A';
|
| 338 |
+
if (document.getElementById('date-display')) document.getElementById('date-display').textContent = data.date || 'N/A';
|
| 339 |
+
|
| 340 |
data.medications.forEach(med => {
|
| 341 |
const clone = template.content.cloneNode(true);
|
| 342 |
+
const qs = (sel) => clone.querySelector(sel);
|
| 343 |
|
| 344 |
+
if (qs('.med-name')) qs('.med-name').textContent = med.name || 'Unknown';
|
| 345 |
+
if (qs('.med-type')) qs('.med-type').textContent = med.type || 'MEDICATION';
|
| 346 |
+
if (qs('.med-composition')) setText(qs('.med-composition'), med.composition);
|
| 347 |
+
if (qs('.med-dosage')) qs('.med-dosage').textContent = med.dosage || 'N/A';
|
| 348 |
+
if (qs('.med-frequency')) qs('.med-frequency').textContent = med.frequency || 'N/A';
|
| 349 |
+
if (qs('.med-duration')) qs('.med-duration').textContent = med.duration || 'N/A';
|
| 350 |
+
if (qs('.med-insight')) qs('.med-insight').textContent = med.insight || 'Follow doctor\'s instructions carefully.';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
|
| 352 |
medicationsContainer.appendChild(clone);
|
| 353 |
});
|