This is a complex healthcare analytics dashboard request. The user wants a hospital antimicrobial stewardship analytics "cockpit" (dashboard) that includes:
- DOT/DDD - Days of Therapy / Defined Daily Doses
- Bug–drug mismatches - When antibiotics don't match the culture/sensitivity results
- De-escalation windows - Opportunities to narrow antibiotic spectrum
- Feedback mechanisms - For stewardship interventions
Let me plan this out:
Design Approach
Visual Identity
- Medical/clinical feel - professional, clean, data-dense
- Color scheme: Deep navy/slate base, with clinical accent colors (teal, coral for alerts, green for positive outcomes)
- Typography: Something clean but distinctive - maybe Space Grotesk for headers, DM Sans for body
Layout Structure
- Header - Hospital name, date range selector, key metrics summary
- DOT/DDD Section - Antibiotic utilization metrics with trends
- Bug-Drug Mismatch Panel - Active mismatches requiring attention
- De-escalation Opportunities - Patients who could be stepped down
- Stewardship Feedback Loop - Intervention tracking and outcomes
Interactive Features
- Date range filtering
- Ward/unit selection
- Click to expand patient details
- Sortable tables
- Trend visualization
- Real-time alerts
Data Structure
I'll create realistic mock data for:
- Patient antibiotics data
- Culture results
- Sensitivity data
- Intervention records
- Historical trends
Let me build this comprehensive dashboard.
Hospital Antimicrobial Stewardship Analytics Cockpit
This is a comprehensive, clinically-focused dashboard for antimicrobial stewardship programs. It includes real-time metrics, interactive filtering, and actionable clinical insights.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AMS Analytics Cockpit | Antimicrobial Stewardship</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0a0f1a;
--bg-elevated: #111827;
--bg-card: #1a2234;
--fg: #f1f5f9;
--fg-muted: #64748b;
--fg-dim: #475569;
--accent: #14b8a6;
--accent-dim: rgba(20, 184, 166, 0.15);
--warning: #f59e0b;
--warning-dim: rgba(245, 158, 11, 0.15);
--danger: #ef4444;
--danger-dim: rgba(239, 68, 68, 0.15);
--success: #22c55e;
--success-dim: rgba(34, 197, 94, 0.15);
--border: #1e293b;
--border-accent: #334155;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
overflow-x: hidden;
}
.mono {
font-family: 'IBM Plex Mono', monospace;
}
/* Background atmosphere */
.bg-atmosphere {
position: fixed;
inset: 0;
background:
radial-gradient(ellipse 80% 50% at 20% 0%, rgba(20, 184, 166, 0.08) 0%, transparent 50%),
radial-gradient(ellipse 60% 40% at 80% 100%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
var(--bg);
z-index: -1;
}
.grid-pattern {
position: fixed;
inset: 0;
background-image:
linear-gradient(rgba(30, 41, 59, 0.3) 1px, transparent 1px),
linear-gradient(90deg, rgba(30, 41, 59, 0.3) 1px, transparent 1px);
background-size: 60px 60px;
z-index: -1;
opacity: 0.4;
}
/* Cards */
.card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 12px;
transition: all 0.2s ease;
}
.card:hover {
border-color: var(--border-accent);
}
.card-header {
padding: 16px 20px;
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: space-between;
}
.card-body {
padding: 20px;
}
/* Metric cards */
.metric-card {
background: linear-gradient(135deg, var(--bg-card) 0%, rgba(26, 34, 52, 0.8) 100%);
border: 1px solid var(--border);
border-radius: 12px;
padding: 20px;
position: relative;
overflow: hidden;
}
.metric-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3px;
background: var(--accent);
opacity: 0;
transition: opacity 0.2s;
}
.metric-card:hover::before {
opacity: 1;
}
.metric-card.warning::before { background: var(--warning); }
.metric-card.danger::before { background: var(--danger); }
.metric-card.success::before { background: var(--success); }
/* Tags */
.tag {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 4px 10px;
border-radius: 6px;
font-size: 12px;
font-weight: 500;
}
.tag-accent {
background: var(--accent-dim);
color: var(--accent);
}
.tag-warning {
background: var(--warning-dim);
color: var(--warning);
}
.tag-danger {
background: var(--danger-dim);
color: var(--danger);
}
.tag-success {
background: var(--success-dim);
color: var(--success);
}
/* Progress bars */
.progress-bar {
height: 6px;
background: var(--border);
border-radius: 3px;
overflow: hidden;
}
.progress-fill {
height: 100%;
border-radius: 3px;
transition: width 0.6s ease;
}
/* Table styles */
.data-table {
width: 100%;
border-collapse: collapse;
}
.data-table th {
text-align: left;
padding: 12px 16px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.5px;
color: var(--fg-muted);
border-bottom: 1px solid var(--border);
}
.data-table td {
padding: 14px 16px;
border-bottom: 1px solid var(--border);
font-size: 14px;
}
.data-table tbody tr {
transition: background 0.15s;
cursor: pointer;
}
.data-table tbody tr:hover {
background: rgba(20, 184, 166, 0.05);
}
/* Chart container */
.chart-container {
position: relative;
height: 200px;
display: flex;
align-items: flex-end;
gap: 8px;
padding: 20px 0;
}
.chart-bar {
flex: 1;
background: linear-gradient(180deg, var(--accent) 0%, rgba(20, 184, 166, 0.4) 100%);
border-radius: 4px 4px 0 0;
position: relative;
min-height: 20px;
transition: all 0.3s ease;
cursor: pointer;
}
.chart-bar:hover {
background: linear-gradient(180deg, var(--accent) 0%, rgba(20, 184, 166, 0.7) 100%);
transform: scaleY(1.02);
}
.chart-bar.warning {
background: linear-gradient(180deg, var(--warning) 0%, rgba(245, 158, 11, 0.4) 100%);
}
.chart-bar.danger {
background: linear-gradient(180deg, var(--danger) 0%, rgba(239, 68, 68, 0.4) 100%);
}
/* Timeline */
.timeline-item {
display: flex;
gap: 16px;
padding: 16px 0;
border-bottom: 1px solid var(--border);
position: relative;
}
.timeline-item:last-child {
border-bottom: none;
}
.timeline-dot {
width: 12px;
height: 12px;
border-radius: 50%;
background: var(--accent);
flex-shrink: 0;
margin-top: 4px;
box-shadow: 0 0 0 4px var(--accent-dim);
}
/* Select styling */
.select-styled {
appearance: none;
background: var(--bg-card);
border: 1px solid var(--border);
color: var(--fg);
padding: 10px 36px 10px 14px;
border-radius: 8px;
font-family: inherit;
font-size: 14px;
cursor: pointer;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 12px center;
transition: all 0.2s;
}
.select-styled:hover, .select-styled:focus {
border-color: var(--accent);
outline: none;
}
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 10px 18px;
border-radius: 8px;
font-family: inherit;
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
border: none;
}
.btn-primary {
background: var(--accent);
color: var(--bg);
}
.btn-primary:hover {
background: #0d9488;
transform: translateY(-1px);
}
.btn-ghost {
background: transparent;
color: var(--fg-muted);
border: 1px solid var(--border);
}
.btn-ghost:hover {
background: var(--bg-card);
color: var(--fg);
border-color: var(--border-accent);
}
/* Scrollbar */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: var(--bg);
}
::-webkit-scrollbar-thumb {
background: var(--border-accent);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--fg-dim);
}
/* Animations */
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.animate-in {
animation: fadeInUp 0.5s ease forwards;
opacity: 0;
}
.pulse {
animation: pulse 2s infinite;
}
/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
/* Modal */
.modal-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.7);
backdrop-filter: blur(4px);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
opacity: 0;
pointer-events: none;
transition: opacity 0.2s;
}
.modal-overlay.active {
opacity: 1;
pointer-events: auto;
}
.modal-content {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 16px;
max-width: 600px;
width: 90%;
max-height: 80vh;
overflow-y: auto;
transform: scale(0.95);
transition: transform 0.2s;
}
.modal-overlay.active .modal-content {
transform: scale(1);
}
/* Responsive */
@media (max-width: 1024px) {
.grid-cols-4 {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 640px) {
.grid-cols-4 {
grid-template-columns: 1fr;
}
.card-header {
flex-direction: column;
gap: 12px;
align-items: flex-start;
}
}
</style>
</head>
<body>
<div class="bg-atmosphere"></div>
<div class="grid-pattern"></div>
<!-- Header -->
<header class="sticky top-0 z-50 border-b border-[var(--border)] bg-[var(--bg)]/80 backdrop-blur-xl">
<div class="max-w-[1600px] mx-auto px-6 py-4">
<div class="flex items-center justify-between flex-wrap gap-4">
<div class="flex items-center gap-4">
<div class="w-10 h-10 rounded-lg bg-[var(--accent-dim)] flex items-center justify-center">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="var(--accent)" stroke-width="2">
<path d="M12 2L2 7l10 5 10-5-10-5z"/>
<path d="M2 17l10 5 10-5"/>
<path d="M2 12l10 5 10-5"/>
</svg>
</div>
<div>
<h1 class="text-lg font-bold">Antimicrobial Stewardship</h1>
<p class="text-xs text-[var(--fg-muted)] mono">AMS Analytics Cockpit v2.4</p>
</div>
</div>
<div class="flex items-center gap-3 flex-wrap">
<select id="wardFilter" class="select-styled">
<option value="all">All Wards</option>
<option value="icu">ICU</option>
<option value="micu">Medical ICU</option>
<option value="sicu">Surgical ICU</option>
<option value="general">General Medicine</option>
<option value="surgery">Surgery</option>
<option value="oncology">Oncology</option>
</select>
<select id="periodFilter" class="select-styled">
<option value="7">Last 7 Days</option>
<option value="14">Last 14 Days</option>
<option value="30" selected>Last 30 Days</option>
<option value="90">Last 90 Days</option>
</select>
<button class="btn btn-ghost" onclick="refreshData()">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M23 4v6h-6"/>
<path d="M1 20v-6h6"/>
<path d="M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"/>
</svg>
Refresh
</button>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="max-w-[1600px] mx-auto px-6 py-8">
<!-- Key Metrics Row -->
<section class="grid grid-cols-4 gap-4 mb-8 animate-in" style="animation-delay: 0.1s">
<div class="metric-card">
<div class="flex items-start justify-between mb-3">
<span class="text-xs font-medium text-[var(--fg-muted)] uppercase tracking-wide">Total DOT/1000 PD</span>
<span class="tag tag-accent">-8.2%</span>
</div>
<div class="text-3xl font-bold mono" id="totalDot">847.3</div>
<div class="text-xs text-[var(--fg-muted)] mt-2">Target: <span class="text-[var(--accent)]">800</span></div>
<div class="progress-bar mt-3">
<div class="progress-fill bg-[var(--accent)]" style="width: 94%"></div>
</div>
</div>
<div class="metric-card warning">
<div class="flex items-start justify-between mb-3">
<span class="text-xs font-medium text-[var(--fg-muted)] uppercase tracking-wide">Bug-Drug Mismatches</span>
<span class="tag tag-warning">Action Required</span>
</div>
<div class="text-3xl font-bold mono" id="mismatchCount">12</div>
<div class="text-xs text-[var(--fg-muted)] mt-2">Active patients needing review</div>
<div class="progress-bar mt-3">
<div class="progress-fill bg-[var(--warning)]" style="width: 24%"></div>
</div>
</div>
<div class="metric-card success">
<div class="flex items-start justify-between mb-3">
<span class="text-xs font-medium text-[var(--fg-muted)] uppercase tracking-wide">De-escalation Rate</span>
<span class="tag tag-success">+12.4%</span>
</div>
<div class="text-3xl font-bold mono" id="deescRate">68.5%</div>
<div class="text-xs text-[var(--fg-muted)] mt-2">Target: <span class="text-[var(--success)]">70%</span></div>
<div class="progress-bar mt-3">
<div class="progress-fill bg-[var(--success)]" style="width: 68.5%"></div>
</div>
</div>
<div class="metric-card">
<div class="flex items-start justify-between mb-3">
<span class="text-xs font-medium text-[var(--fg-muted)] uppercase tracking-wide">Intervention Acceptance</span>
<span class="tag tag-accent">Excellent</span>
</div>
<div class="text-3xl font-bold mono" id="intervAccept">84.2%</div>
<div class="text-xs text-[var(--fg-muted)] mt-2">142 of 169 recommendations</div>
<div class="progress-bar mt-3">
<div class="progress-fill bg-[var(--accent)]" style="width: 84.2%"></div>
</div>
</div>
</section>
<!-- Main Grid -->
<div class="grid grid-cols-12 gap-6">
<!-- DOT/DDD Chart -->
<section class="col-span-12 lg:col-span-8 card animate-in" style="animation-delay: 0.2s">
<div class="card-header">
<div>
<h2 class="font-semibold">DOT Trends by Antibiotic Class</h2>
<p class="text-xs text-[var(--fg-muted)] mt-1">Days of Therapy per 1000 Patient-Days</p>
</div>
<div class="flex gap-2">
<button class="btn btn-ghost text-xs py-2 px-3 dot-view active" data-view="class">By Class</button>
<button class="btn btn-ghost text-xs py-2 px-3 dot-view" data-view="ward">By Ward</button>
</div>
</div>
<div class="card-body">
<div class="chart-container" id="dotChart"></div>
<div class="flex justify-between text-xs text-[var(--fg-muted)] mono mt-2 px-1">
<span>Jan</span><span>Feb</span><span>Mar</span><span>Apr</span><span>May</span><span>Jun</span>
<span>Jul</span><span>Aug</span><span>Sep</span><span>Oct</span><span>Nov</span><span>Dec</span>
</div>
<div class="grid grid-cols-4 gap-4 mt-6 pt-6 border-t border-[var(--border)]">
<div>
<div class="text-xs text-[var(--fg-muted)] mb-1">Carbapenems</div>
<div class="flex items-center gap-2">
<div class="w-3 h-3 rounded bg-[var(--danger)]"></div>
<span class="mono text-sm font-medium">45.2</span>
<span class="text-xs text-[var(--danger)]">+12%</span>
</div>
</div>
<div>
<div class="text-xs text-[var(--fg-muted)] mb-1">Vancomycin IV</div>
<div class="flex items-center gap-2">
<div class="w-3 h-3 rounded bg-[var(--warning)]"></div>
<span class="mono text-sm font-medium">112.8</span>
<span class="text-xs text-[var(--success)]">-5%</span>
</div>
</div>
<div>
<div class="text-xs text-[var(--fg-muted)] mb-1">Piperacillin-Tazo</div>
<div class="flex items-center gap-2">
<div class="w-3 h-3 rounded bg-[var(--accent)]"></div>
<span class="mono text-sm font-medium">198.4</span>
<span class="text-xs text-[var(--success)]">-8%</span>
</div>
</div>
<div>
<div class="text-xs text-[var(--fg-muted)] mb-1">Fluoroquinolones</div>
<div class="flex items-center gap-2">
<div class="w-3 h-3 rounded bg-[var(--accent)]"></div>
<span class="mono text-sm font-medium">89.1</span>
<span class="text-xs text-[var(--success)]">-15%</span>
</div>
</div>
</div>
</div>
</section>
<!-- Mismatch Alert Panel -->
<section class="col-span-12 lg:col-span-4 card animate-in" style="animation-delay: 0.3s">
<div class="card-header border-b-0 pb-0">
<div>
<h2 class="font-semibold">Bug-Drug Mismatches</h2>
<p class="text-xs text-[var(--fg-muted)] mt-1">Requiring immediate review</p>
</div>
<span class="tag tag-danger pulse">12 Active</span>
</div>
<div class="card-body pt-4">
<div class="space-y-3" id="mismatchList"></div>
<button class="btn btn-primary w-full mt-4" onclick="openModal('mismatchDetail')">
View All Mismatches
</button>
</div>
</section>
<!-- De-escalation Opportunities -->
<section class="col-span-12 lg:col-span-6 card animate-in" style="animation-delay: 0.4s">
<div class="card-header">
<div>
<h2 class="font-semibold">De-escalation Windows</h2>
<p class="text-xs text-[var(--fg-muted)] mt-1">Patients ready for therapy optimization</p>
</div>
<span class="mono text-sm text-[var(--fg-muted)]">24 patients</span>
</div>
<div class="card-body p-0">
<table class="data-table">
<thead>
<tr>
<th>Patient / Ward</th>
<th>Current</th>
<th>Suggested</th>
<th>Window</th>
</tr>
</thead>
<tbody id="deescTable"></tbody>
</table>
</div>
</section>
<!-- Intervention Feedback -->
<section class="col-span-12 lg:col-span-6 card animate-in" style="animation-delay: 0.5s">
<div class="card-header">
<div>
<h2 class="font-semibold">Stewardship Interventions</h2>
<p class="text-xs text-[var(--fg-muted)] mt-1">Recent recommendations & outcomes</p>
</div>
<select class="select-styled text-sm py-2">
<option>All Types</option>
<option>De-escalation</option>
<option>Dose Optimization</option>
<option>IV to Oral</option>
<option>Duration Review</option>
</select>
</div>
<div class="card-body" id="interventionTimeline"></div>
</section>
<!-- Resistance Heatmap -->
<section class="col-span-12 lg:col-span-7 card animate-in" style="animation-delay: 0.6s">
<div class="card-header">
<div>
<h2 class="font-semibold">Local Resistance Patterns</h2>
<p class="text-xs text-[var(--fg-muted)] mt-1">% Non-susceptible isolates - Last 90 days</p>
</div>
</div>
<div class="card-body overflow-x-auto">
<table class="data-table text-sm" id="resistanceTable"></table>
</div>
</section>
<!-- Quick Actions -->
<section class="col-span-12 lg:col-span-5 card animate-in" style="animation-delay: 0.7s">
<div class="card-header">
<h2 class="font-semibold">Quick Actions</h2>
</div>
<div class="card-body">
<div class="grid grid-cols-2 gap-3">
<button class="btn btn-ghost justify-start" onclick="openModal('newIntervention')">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"/>
<path d="M12 8v8M8 12h8"/>
</svg>
New Intervention
</button>
<button class="btn btn-ghost justify-start" onclick="openModal('patientSearch')">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="11" cy="11" r="8"/>
<path d="M21 21l-4.35-4.35"/>
</svg>
Patient Search
</button>
<button class="btn btn-ghost justify-start" onclick="exportReport()">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/>
<polyline points="7,10 12,15 17,10"/>
<line x1="12" y1="15" x2="12" y2="3"/>
</svg>
Export Report
</button>
<button class="btn btn-ghost justify-start" onclick="openModal('guidelines')">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M4 19.5A2.5 2.5 0 016.5 17H20"/>
<path d="M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z"/>
</svg>
Guidelines
</button>
</div>
<div class="mt-6 p-4 rounded-lg bg-[var(--bg)] border border-[var(--border)]">
<div class="flex items-center gap-3 mb-3">
<div class="w-8 h-8 rounded-full bg-[var(--accent-dim)] flex items-center justify-center">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="var(--accent)" stroke-width="2">
<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>
</svg>
</div>
<div>
<div class="text-sm font-medium">Daily Census</div>
<div class="text-xs text-[var(--fg-muted)]">Patients on antimicrobials</div>
</div>
</div>
<div class="flex items-end justify-between">
<div>
<span class="text-2xl font-bold mono">147</span>
<span class="text-sm text-[var(--fg-muted)]">/ 412</span>
</div>
<span class="text-xs text-[var(--fg-muted)]">35.7% of capacity</span>
</div>
</div>
<div class="mt-4 p-4 rounded-lg bg-[var(--warning-dim)] border border-[var(--warning)]/20">
<div class="flex items-start gap-3">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="var(--warning)" stroke-width="2" class="flex-shrink-0 mt-0.5">
<path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"/>
<line x1="12" y1="9" x2="12" y2="13"/>
<line x1="12" y1="17" x2="12.01" y2="17"/>
</svg>
<div>
<div class="text-sm font-medium text-[var(--warning)]">Alert: CRE Screening</div>
<div class="text-xs text-[var(--fg-muted)] mt-1">3 new patients flagged for carbapenemase screening in ICU</div>
</div>
</div>
</div>
</div>
</section>
</div>
</main>
<!-- Modal -->
<div class="modal-overlay" id="modal">
<div class="modal-content">
<div class="card-header border-b">
<h3 class="font-semibold" id="modalTitle">Modal Title</h3>
<button class="btn btn-ghost p-2" onclick="closeModal()" aria-label="Close modal">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M18 6L6 18M6 6l12 12"/>
</svg>
</button>
</div>
<div class="card-body" id="modalBody"></div>
</div>
</div>
<script>
// ============================================
// DATA
// ============================================
const mismatches = [
{ id: 1, patient: 'MRN-4521', ward: 'ICU', organism: 'E. coli', drug: 'Vancomycin', issue: 'No gram-positive coverage needed', cultureDate: '2024-01-15', severity: 'high' },
{ id: 2, patient: 'MRN-3892', ward: 'MICU', organism: 'Klebsiella', drug: 'Ceftriaxone', issue: 'ESBL producer - resistant', cultureDate: '2024-01-15', severity: 'high' },
{ id: 3, patient: 'MRN-5103', ward: 'Surgery', organism: 'P. aeruginosa', drug: 'Cefazolin', issue: 'No anti-pseudomonal activity', cultureDate: '2024-01-14', severity: 'critical' },
{ id: 4, patient: 'MRN-2247', ward: 'General', organism: 'MRSA', drug: 'Cefepime', issue: 'No MRSA coverage', cultureDate: '2024-01-14', severity: 'high' },
{ id: 5, patient: 'MRN-6701', ward: 'Oncology', organism: 'E. cloacae', drug: 'Pip-Tazo', issue: 'AmpC producer - consider carbapenem', cultureDate: '2024-01-13', severity: 'moderate' },
];
const deescalations = [
{ patient: 'MRN-4521', ward: 'ICU', current: 'Meropenem', suggested: 'Ceftriaxone', window: '48h', culture: 'E. coli (ESBL neg)', reason: 'Sensitive to 3GC' },
{ patient: 'MRN-3892', ward: 'MICU', current: 'Vanc + Zosyn', suggested: 'Pip-Tazo only', window: '72h', culture: 'Klebsiella, VRE neg', reason: 'Vanc discontinued' },
{ patient: 'MRN-5103', ward: 'SICU', current: 'Meropenem', suggested: 'Cefepime', window: '24h', culture: 'P. aeruginosa', reason: 'Sensitive to Cefepime' },
{ patient: 'MRN-2247', ward: 'General', current: 'Vanc + Cefepime', suggested: 'Ceftriaxone', window: '96h', culture: 'E. coli', reason: 'No resistant organisms' },
{ patient: 'MRN-6701', ward: 'Oncology', current: 'Meropenem', suggested: 'Ertapenem', window: '48h', culture: 'E. coli', reason: 'Once daily dosing' },
{ patient: 'MRN-8834', ward: 'ICU', current: 'Vanc + Cefepime + Metro', suggested: 'Pip-Tazo', window: '24h', culture: 'Mixed anaerobes', reason: 'Single agent coverage' },
];
const interventions = [
{ time: '2h ago', type: 'deescalation', patient: 'MRN-4521', message: 'De-escalation from Meropenem to Ceftriaxone', status: 'accepted', pharmacist: 'Dr. Chen' },
{ time: '4h ago', type: 'dose', patient: 'MRN-3892', message: 'Vancomycin dose adjustment for AKI', status: 'accepted', pharmacist: 'Dr. Patel' },
{ time: '6h ago', type: 'ivtooral', patient: 'MRN-5103', message: 'IV to oral step-down for UTI', status: 'pending', pharmacist: 'Dr. Kim' },
{ time: '8h ago', type: 'duration', patient: 'MRN-2247', message: 'Duration review: 14d → 7d for pyelonephritis', status: 'accepted', pharmacist: 'Dr. Chen' },
{ time: '12h ago', type: 'deescalation', patient: 'MRN-6701', message: 'Discontinue Vancomycin - cultures negative', status: 'rejected', pharmacist: 'Dr. Patel' },
{ time: '1d ago', type: 'dose', patient: 'MRN-8834', message: 'Aminoglycoside extended interval dosing', status: 'accepted', pharmacist: 'Dr. Kim' },
];
const resistanceData = {
organisms: ['E. coli', 'Klebsiella', 'P. aeruginosa', 'Acinetobacter', 'Enterococcus'],
antibiotics: ['Ampicillin', 'Ceftriaxone', 'Cefepime', 'Pip-Tazo', 'Meropenem', 'Cipro', 'Vanc'],
values: [
[65, 18, 5, 3, 0, 22, null],
[85, 35, 15, 12, 2, 28, null],
[null, null, 12, 8, 4, 18, null],
[null, null, 35, 28, 15, 45, null],
[null, null, null, null, null, null, 28],
]
};
const dotMonthlyData = [
{ month: 'Jan', value: 920, target: 800 },
{ month: 'Feb', value: 895, target: 800 },
{ month: 'Mar', value: 878, target: 800 },
{ month: 'Apr', value: 902, target: 800 },
{ month: 'May', value: 856, target: 800 },
{ month: 'Jun', value: 834, target: 800 },
{ month: 'Jul', value: 889, target: 800 },
{ month: 'Aug', value: 867, target: 800 },
{ month: 'Sep', value: 845, target: 800 },
{ month: 'Oct', value: 823, target: 800 },
{ month: 'Nov', value: 812, target: 800 },
{ month: 'Dec', value: 847, target: 800 },
];
// ============================================
// INITIALIZATION
// ============================================
let chartBars = [];
document.addEventListener('DOMContentLoaded', () => {
renderMismatchList();
renderDeescTable();
renderInterventionTimeline();
renderResistanceTable();
renderDotChart();
setupEventListeners();
});
// ============================================
// RENDER FUNCTIONS
// ============================================
function renderMismatchList() {
const container = document.getElementById('mismatchList');
if (!container) return;
container.innerHTML = mismatches.slice(0, 5).map(m => {
const severityClass = m.severity === 'critical' ? 'tag-danger' :
m.severity === 'high' ? 'tag-warning' : 'tag-accent';
return `
<div class="p-3 rounded-lg bg-[var(--bg)] border border-[var(--border)] hover:border-[var(--border-accent)] transition-colors cursor-pointer" onclick="openPatientDetail('${m.patient}')">
<div class="flex items-center justify-between mb-2">
<span class="mono text-sm font-medium">${m.patient}</span>
<span class="tag ${severityClass}">${m.severity}</span>
</div>
<div class="text-sm">${m.organism} + ${m.drug}</div>
<div class="text-xs text-[var(--fg-muted)] mt-1">${m.issue}</div>
</div>
`;
}).join('');
}
function renderDeescTable() {
const tbody = document.getElementById('deescTable');
if (!tbody) return;
tbody.innerHTML = deescalations.slice(0, 6).map(d => `
<tr onclick="openPatientDetail('${d.patient}')">
<td>
<div class="mono text-sm">${d.patient}</div>
<div class="text-xs text-[var(--fg-muted)]">${d.ward}</div>
</td>
<td>
<div class="text-sm">${d.current}</div>
</td>
<td>
<div class="text-sm text-[var(--accent)]">${d.suggested}</div>
</td>
<td>
<span class="tag ${parseInt(d.window) <= 48 ? 'tag-success' : 'tag-warning'}">${d.window}</span>
</td>
</tr>
`).join('');
}
function renderInterventionTimeline() {
const container = document.getElementById('interventionTimeline');
if (!container) return;
container.innerHTML = interventions.map(i => {
const statusColor = i.status === 'accepted' ? 'var(--success)' :
i.status === 'rejected' ? 'var(--danger)' : 'var(--warning)';
const typeIcon = getInterventionIcon(i.type);
return `
<div class="timeline-item">
<div class="timeline-dot" style="background: ${statusColor}; box-shadow: 0 0 0 4px ${statusColor}33;"></div>
<div class="flex-1">
<div class="flex items-center justify-between mb-1">
<span class="text-xs text-[var(--fg-muted)]">${i.time}</span>
<span class="tag tag-accent text-xs">${i.type}</span>
</div>
<div class="text-sm mb-1">${i.message}</div>
<div class="flex items-center gap-2 text-xs text-[var(--fg-muted)]">
<span class="mono">${i.patient}</span>
<span>·</span>
<span>${i.pharmacist}</span>
</div>
</div>
</div>
`;
}).join('');
}
function getInterventionIcon(type) {
const icons = {
deescalation: '↓',
dose: '◐',
ivtooral: '→',
duration: '⏱'
};
return icons[type] || '•';
}
function renderResistanceTable() {
const table = document.getElementById('resistanceTable');
if (!table) return;
let html = '<thead><tr><th>Organism</th>';
resistanceData.antibiotics.forEach(ab => {
html += `<th class="text-center">${ab}</th>`;
});
html += '</tr></thead><tbody>';
resistanceData.organisms.forEach((org, i) => {
html += `<tr><td class="font-medium">${org}</td>`;
resistanceData.values[i].forEach(val => {
if (val === null) {
html += '<td class="text-center text-[var(--fg-dim)]">—</td>';
} else {
const color = val > 30 ? 'var(--danger)' : val > 15 ? 'var(--warning)' : 'var(--success)';
const bgColor = val > 30 ? 'var(--danger-dim)' : val > 15 ? 'var(--warning-dim)' : 'var(--success-dim)';
html += `<td class="text-center"><span class="inline-block px-2 py-1 rounded text-xs mono" style="background: ${bgColor}; color: ${color}">${val}%</span></td>`;
}
});
html += '</tr>';
});
html += '</tbody>';
table.innerHTML = html;
}
function renderDotChart() {
const container = document.getElementById('dotChart');
if (!container) return;
const maxValue = Math.max(...dotMonthlyData.map(d => d.value));
container.innerHTML = dotMonthlyData.map((d, i) => {
const height = Math.max(20, (d.value / maxValue) * 180);
const isOverTarget = d.value > d.target;
const barClass = isOverTarget ? 'warning' : '';
return `
<div class="chart-bar ${barClass}"
style="height: ${height}px;"
title="${d.month}: ${d.value} DOT/1000 PD"
data-month="${d.month}"
data-value="${d.value}">
</div>
`;
}).join('');
chartBars = container.querySelectorAll('.chart-bar');
}
// ============================================
// EVENT HANDLERS
// ============================================
function setupEventListeners() {
// DOT view toggle
document.querySelectorAll('.dot-view').forEach(btn => {
btn.addEventListener('click', (e) => {
document.querySelectorAll('.dot-view').forEach(b => b.classList.remove('active'));
e.target.classList.add('active');
// Would re-render chart with different data
animateChartBars();
});
});
// Filters
document.getElementById('wardFilter').addEventListener('change', filterData);
document.getElementById('periodFilter').addEventListener('change', filterData);
// Keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
closeModal();
}
});
// Scroll animations
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, { threshold: 0.1 });
document.querySelectorAll('.animate-in').forEach(el => {
observer.observe(el);
});
}
function animateChartBars() {
chartBars.forEach((bar, i) => {
bar.style.height = '0px';
setTimeout(() => {
const value = parseInt(bar.dataset.value);
const height = Math.max(20, (value / 920) * 180);
bar.style.height = height + 'px';
}, i * 50);
});
}
function filterData() {
const ward = document.getElementById('wardFilter').value;
const period = document.getElementById('periodFilter').value;
// Simulate data refresh
console.log(`Filtering: Ward=${ward}, Period=${period} days`);
// Animate metrics update
updateMetrics(ward, period);
}
function updateMetrics(ward, period) {
const multiplier = period / 30;
const wardMod = ward === 'all' ? 1 : ward === 'icu' ? 1.3 : 0.8;
animateValue('totalDot', 847.3 * multiplier * wardMod);
animateValue('deescRate', 68.5 + (Math.random() * 5 - 2.5));
}
function animateValue(elementId, targetValue) {
const el = document.getElementById(elementId);
if (!el) return;
const startValue = parseFloat(el.textContent);
const duration = 500;
const startTime = performance.now();
function update(currentTime) {
const elapsed = currentTime - startTime;
const progress = Math.min(elapsed / duration, 1);
const eased = 1 - Math.pow(1 - progress, 3);
const currentValue = startValue + (targetValue - startValue) * eased;
el.textContent = currentValue.toFixed(1);
if (progress < 1) {
requestAnimationFrame(update);
}
}
requestAnimationFrame(update);
}
function refreshData() {
const btn = event.target.closest('button');
btn.classList.add('animate-spin');
setTimeout(() => {
btn.classList.remove('animate-spin');
animateChartBars();
}, 1000);
}
// ============================================
// MODAL FUNCTIONS
// ============================================
function openModal(type) {
const modal = document.getElementById('modal');
const title = document.getElementById('modalTitle');
const body = document.getElementById('modalBody');
switch(type) {
case 'mismatchDetail':
title.textContent = 'All Bug-Drug Mismatches';
body.innerHTML = renderFullMismatchList();
break;
case 'newIntervention':
title.textContent = 'New Intervention';
body.innerHTML = renderInterventionForm();
break;
case 'patientSearch':
title.textContent = 'Patient Search';
body.innerHTML = renderPatientSearch();
break;
case 'guidelines':
title.textContent = 'Antimicrobial Guidelines';
body.innerHTML = renderGuidelines();
break;
}
modal.classList.add('active');
document.body.style.overflow = 'hidden';
}
function closeModal() {
document.getElementById('modal').classList.remove('active');
document.body.style.overflow = '';
}
function openPatientDetail(mrn) {
openModal('patientDetail');
document.getElementById('modalTitle').textContent = `Patient ${mrn}`;
document.getElementById('modalBody').innerHTML = renderPatientDetail(mrn);
}
function renderFullMismatchList() {
return `
<div class="space-y-3">
${mismatches.map(m => `
<div class="p-4 rounded-lg bg-[var(--bg)] border border-[var(--border)]">
<div class="flex items-center justify-between mb-3">
<span class="mono font-medium">${m.patient}</span>
<span class="tag ${m.severity === 'critical' ? 'tag-danger' : 'tag-warning'}">${m.severity}</span>
</div>
<div class="grid grid-cols-2 gap-4 text-sm">
<div>
<span class="text-[var(--fg-muted)]">Organism:</span>
<span class="ml-2">${m.organism}</span>
</div>
<div>
<span class="text-[var(--fg-muted)]">Current Drug:</span>
<span class="ml-2">${m.drug}</span>
</div>
<div>
<span class="text-[var(--fg-muted)]">Issue:</span>
<span class="ml-2">${m.issue}</span>
</div>
<div>
<span class="text-[var(--fg-muted)]">Culture Date:</span>
<span class="ml-2">${m.cultureDate}</span>
</div>
</div>
<div class="mt-4 flex gap-2">
<button class="btn btn-primary text-sm py-2">Contact Team</button>
<button class="btn btn-ghost text-sm py-2">Mark Reviewed</button>
</div>
</div>
`).join('')}
</div>
`;
}
function renderInterventionForm() {
return `
<form class="space-y-4" onsubmit="submitIntervention(event)">
<div>
<label class="block text-sm font-medium mb-2">Patient MRN</label>
<input type="text" class="w-full bg-[var(--bg)] border border-[var(--border)] rounded-lg px-4 py-3 text-[var(--fg)] focus:border-[var(--accent)] outline-none" placeholder="Enter MRN">
</div>
<div>
<label class="block text-sm font-medium mb-2">Intervention Type</label>
<select class="select-styled w-full">
<option>De-escalation</option>
<option>Dose Optimization</option>
<option>IV to Oral</option>
<option>Duration Review</option>
<option>Discontinuation</option>
</select>
</div>
<div>
<label class="block text-sm font-medium mb-2">Recommendation</label>
<textarea class="w-full bg-[var(--bg)] border border-[var(--border)] rounded-lg px-4 py-3 text-[var(--fg)] focus:border-[var(--accent)] outline-none h-32 resize-none" placeholder="Enter your recommendation..."></textarea>
</div>
<div>
<label class="block text-sm font-medium mb-2">Priority</label>
<div class="flex gap-3">
<label class="flex items-center gap-2 cursor-pointer">
<input type="radio" name="priority" value="routine" checked class="accent-[var(--accent)]">
<span class="text-sm">Routine</span>
</label>
<label class="flex items-center gap-2 cursor-pointer">
<input type="radio" name="priority" value="urgent" class="accent-[var(--warning)]">
<span class="text-sm">Urgent</span>
</label>
<label class="flex items-center gap-2 cursor-pointer">
<input type="radio" name="priority" value="critical" class="accent-[var(--danger)]">
<span class="text-sm">Critical</span>
</label>
</div>
</div>
<button type="submit" class="btn btn-primary w-full">Submit Intervention</button>
</form>
`;
}
function renderPatientSearch() {
return `
<div class="mb-4">
<div class="relative">
<input type="text" class="w-full bg-[var(--bg)] border border-[var(--border)] rounded-lg px-4 py-3 pl-12 text-[var(--fg)] focus:border-[var(--accent)] outline-none" placeholder="Search by MRN, name, or antibiotic...">
<svg class="absolute left-4 top-1/2 -translate-y-1/2" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="var(--fg-muted)" stroke-width="2">
<circle cx="11" cy="11" r="8"/>
<path d="M21 21l-4.35-4.35"/>
</svg>
</div>
</div>
<div class="text-sm text-[var(--fg-muted)] text-center py-8">
Enter search criteria to find patients
</div>
`;
}
function renderGuidelines() {
return `
<div class="space-y-4">
<div class="p-4 rounded-lg bg-[var(--bg)] border border-[var(--border)]">
<h4 class="font-medium mb-2">Empiric Therapy Guidelines</h4>
<ul class="text-sm space-y-2 text-[var(--fg-muted)]">
<li class="flex justify-between"><span>Community-Acquired Pneumonia</span><span class="tag tag-accent">Active</span></li>
<li class="flex justify-between"><span>Hospital-Acquired Pneumonia</span><span class="tag tag-accent">Active</span></li>
<li class="flex justify-between"><span>UTI - Complicated</span><span class="tag tag-accent">Active</span></li>
<li class="flex justify-between"><span>Sepsis Protocol</span><span class="tag tag-warning">Under Review</span></li>
</ul>
</div>
<div class="p-4 rounded-lg bg-[var(--bg)] border border-[var(--border)]">
<h4 class="font-medium mb-2">Restricted Antimicrobials</h4>
<ul class="text-sm space-y-1 text-[var(--fg-muted)]">
<li>• Meropenem - Requires ID approval after 48h</li>
<li>• Linezolid - Requires ID consult</li>
<li>• Colistin - Restricted to ICU only</li>
<li>• Daptomycin - Requires ID approval</li>
</ul>
</div>
</div>
`;
}
function renderPatientDetail(mrn) {
const patient = [...mismatches, ...deescalations].find(p => p.patient === mrn) || { patient: mrn, ward: 'Unknown' };
return `
<div class="space-y-4">
<div class="grid grid-cols-2 gap-4 p-4 rounded-lg bg-[var(--bg)] border border-[var(--border)]">
<div>
<div class="text-xs text-[var(--fg-muted)]">MRN</div>
<div class="mono font-medium">${patient.patient}</div>
</div>
<div>
<div class="text-xs text-[var(--fg-muted)]">Ward</div>
<div class="font-medium">${patient.ward}</div>
</div>
<div>
<div class="text-xs text-[var(--fg-muted)]">Current Antibiotic</div>
<div class="font-medium">${patient.current || patient.drug || 'Unknown'}</div>
</div>
<div>
<div class="text-xs text-[var(--fg-muted)]">Culture Result</div>
<div class="font-medium">${patient.organism || patient.culture || 'Pending'}</div>
</div>
</div>
<div class="flex gap-3">
<button class="btn btn-primary flex-1">Review Patient</button>
<button class="btn btn-ghost flex-1">View Full Record</button>
</div>
</div>
`;
}
function submitIntervention(e) {
e.preventDefault();
alert('Intervention submitted successfully!');
closeModal();
}
function exportReport() {
const btn = event.target.closest('button');
const originalText = btn.innerHTML;
btn.innerHTML = `
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="animate-spin">
<path d="M21 12a9 9 0 11-6.219-8.56"/>
</svg>
Exporting...
`;
setTimeout(() => {
btn.innerHTML = originalText;
alert('Report exported successfully!');
}, 1500);
}
// Add spin animation
const style = document.createElement('style');
style.textContent = `
@keyframes spin {
to { transform: rotate(360deg); }
}
.animate-spin svg {
animation: spin 1s linear infinite;
}
`;
document.head.appendChild(style);
</script>
</body>
</html>
Key Features
1. DOT/DDD Analytics
- Visual trend chart showing Days of Therapy per 1000 patient-days
- Antibiotic class breakdown with month-over-month comparisons
- Target vs actual performance indicators
2. Bug-Drug Mismatch Detection
- Real-time alerts for spectrum mismatches
- Severity grading (critical/high/moderate)
- Quick access to affected patient details
3. De-escalation Windows
- Time-sensitive opportunities for therapy optimization
- Current vs suggested antibiotic regimens
- Culture result integration
4. Intervention Tracking
- Timeline view of stewardship recommendations
- Acceptance rate monitoring
- Pharmacist attribution
5. Resistance Patterns
- Heat map of local susceptibility data
- Organism-specific resistance rates
- Color-coded clinical relevance
6. Interactions
- Ward and time-period filtering
- Expandable patient records
- New intervention form
- Export functionality
- Keyboard accessible (ESC to close modals)
The design uses a clinical dark theme with teal accents for positive outcomes, amber for warnings, and red for critical alerts - creating clear visual hierarchy for clinical decision-making.