The user wants a dialysis adequacy and outcomes dashboard. This is a medical/clinical dashboard that needs to track:
Let me design a professional, dynamic, and visually appealing dashboard that's not the typical bland template.
I'll create a single HTML file with embedded CSS and JS.
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dialysis Adequacy Dashboard</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=DM+Sans:wght@400;500;600&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0a0f14;
--bg-elevated: #111921;
--card: #151d27;
--card-hover: #1a2633;
--border: #243142;
--fg: #e8edf3;
--fg-muted: #7a8b9d;
--accent: #00d4aa;
--accent-dim: rgba(0, 212, 170, 0.15);
--warning: #f59e0b;
--danger: #ef4444;
--info: #3b82f6;
}
[data-theme="light"] {
--bg: #f0f4f8;
--bg-elevated: #ffffff;
--card: #ffffff;
--card-hover: #f8fafc;
--border: #d1dce8;
--fg: #1a2332;
--fg-muted: #5a6a7a;
--accent: #00a88a;
--accent-dim: rgba(0, 168, 138, 0.12);
}
* {
box-sizing: border-box;
}
body {
font-family: 'DM Sans', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
transition: background 0.3s ease, color 0.3s ease;
}
h1, h2, h3, h4, .font-display {
font-family: 'Space Grotesk', sans-serif;
}
.bg-pattern {
background-image:
radial-gradient(ellipse at 20% 0%, rgba(0, 212, 170, 0.08) 0%, transparent 50%),
radial-gradient(ellipse at 80% 100%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0v60M0 30h60' stroke='%23243142' stroke-width='0.5' fill='none' opacity='0.3'/%3E%3C/svg%3E");
background-size: 100% 100%, 100% 100%, 60px 60px;
}
.card {
background: var(--card);
border: 1px solid var(--border);
border-radius: 12px;
transition: all 0.25s ease;
}
.card:hover {
background: var(--card-hover);
border-color: var(--accent);
transform: translateY(-2px);
}
.metric-card {
position: relative;
overflow: hidden;
}
.metric-card::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3px;
background: linear-gradient(90deg, var(--accent), transparent);
opacity: 0;
transition: opacity 0.3s ease;
}
.metric-card:hover::before {
opacity: 1;
}
.gauge-container {
position: relative;
width: 140px;
height: 140px;
}
.gauge-bg {
stroke: var(--border);
}
.gauge-fill {
stroke-linecap: round;
transform: rotate(-90deg);
transform-origin: center;
transition: stroke-dashoffset 1s ease-out;
}
.tab-btn {
position: relative;
padding: 0.5rem 1rem;
color: var(--fg-muted);
font-weight: 500;
transition: all 0.2s ease;
border-radius: 8px;
}
.tab-btn:hover {
color: var(--fg);
background: var(--accent-dim);
}
.tab-btn.active {
color: var(--accent);
background: var(--accent-dim);
}
.status-badge {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 4px 10px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
}
.status-good {
background: rgba(0, 212, 170, 0.15);
color: var(--accent);
}
.status-warning {
background: rgba(245, 158, 11, 0.15);
color: var(--warning);
}
.status-danger {
background: rgba(239, 68, 68, 0.15);
color: var(--danger);
}
.action-item {
border-left: 3px solid transparent;
transition: all 0.2s ease;
}
.action-item:hover {
background: var(--card-hover);
}
.action-item.priority-high {
border-left-color: var(--danger);
}
.action-item.priority-medium {
border-left-color: var(--warning);
}
.action-item.priority-low {
border-left-color: var(--info);
}
.chart-bar {
transition: all 0.3s ease;
transform-origin: bottom;
}
.chart-bar:hover {
filter: brightness(1.2);
}
.patient-row {
transition: all 0.2s ease;
}
.patient-row:hover {
background: var(--accent-dim);
}
.fade-in {
opacity: 0;
transform: translateY(20px);
animation: fadeIn 0.6s ease forwards;
}
@keyframes fadeIn {
to {
opacity: 1;
transform: translateY(0);
}
}
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
@media (prefers-reduced-motion: reduce) {
.fade-in {
animation: none;
opacity: 1;
transform: none;
}
.gauge-fill {
transition: none;
}
}
.scroll-indicator {
width: 4px;
background: var(--border);
border-radius: 2px;
overflow: hidden;
}
.scroll-indicator::after {
content: '';
display: block;
width: 100%;
height: var(--scroll-progress, 0%);
background: var(--accent);
border-radius: 2px;
transition: height 0.1s ease;
}
:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
input[type="text"], input[type="search"] {
background: var(--bg-elevated);
border: 1px solid var(--border);
color: var(--fg);
transition: all 0.2s ease;
}
input[type="text"]:focus, input[type="search"]:focus {
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-dim);
}
.pulse-dot {
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
</style>
</head>
<body class="bg-pattern">
<!-- Header -->
<header class="sticky top-0 z-50 backdrop-blur-xl bg-opacity-80" style="background: var(--bg);">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between h-16">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-lg flex items-center justify-center" style="background: var(--accent-dim);">
<svg class="w-6 h-6" style="color: var(--accent);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/>
</svg>
</div>
<div>
<h1 class="font-display text-lg font-bold" style="color: var(--fg);">Dialysis Adequacy</h1>
<p class="text-xs" style="color: var(--fg-muted);">Outcomes Dashboard</p>
</div>
</div>
<div class="flex items-center gap-4">
<!-- Search -->
<div class="relative hidden sm:block">
<input type="search" id="patientSearch" placeholder="Search patients..."
class="w-64 px-4 py-2 pl-10 rounded-lg text-sm"
aria-label="Search patients">
<svg class="w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2" style="color: var(--fg-muted);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
</div>
<!-- Theme Toggle -->
<button id="themeToggle" class="p-2 rounded-lg hover:bg-opacity-10"
style="background: var(--accent-dim);" aria-label="Toggle theme">
<svg id="sunIcon" class="w-5 h-5 hidden" style="color: var(--fg);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/>
</svg>
<svg id="moonIcon" class="w-5 h-5" style="color: var(--fg);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/>
</svg>
</button>
<!-- Live indicator -->
<div class="flex items-center gap-2 px-3 py-1 rounded-full" style="background: var(--accent-dim);">
<span class="w-2 h-2 rounded-full pulse-dot" style="background: var(--accent);"></span>
<span class="text-xs font-medium" style="color: var(--accent);">Live</span>
</div>
</div>
</div>
</div>
</header>
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Time Period Tabs -->
<div class="flex items-center justify-between mb-8 fade-in">
<div class="flex items-center gap-2" role="tablist" aria-label="Time period">
<button class="tab-btn active" data-period="week" role="tab" aria-selected="true">This Week</button>
<button class="tab-btn" data-period="month" role="tab" aria-selected="false">This Month</button>
<button class="tab-btn" data-period="quarter" role="tab" aria-selected="false">Quarter</button>
<button class="tab-btn" data-period="year" role="tab" aria-selected="false">Year</button>
</div>
<div class="text-sm" style="color: var(--fg-muted);">
Last updated: <span id="lastUpdate">Just now</span>
</div>
</div>
<!-- Key Metrics -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-8">
<!-- Kt/V Gauge -->
<div class="card metric-card p-5 fade-in stagger-1">
<div class="flex items-start justify-between">
<div>
<p class="text-sm font-medium" style="color: var(--fg-muted);">Mean Kt/V</p>
<p class="font-display text-3xl font-bold mt-1" id="meanKtv">1.42</p>
<p class="text-xs mt-1" style="color: var(--accent);">Target: ≥1.2</p>
</div>
<div class="gauge-container">
<svg viewBox="0 0 100 100" class="w-full h-full">
<circle class="gauge-bg" cx="50" cy="50" r="42" fill="none" stroke-width="8"/>
<circle class="gauge-fill" cx="50" cy="50" r="42" fill="none" stroke-width="8"
style="stroke: var(--accent); stroke-dasharray: 264; stroke-dashoffset: 79;"
id="ktvGauge"/>
</svg>
<div class="absolute inset-0 flex items-center justify-center">
<span class="font-display font-bold text-lg" style="color: var(--accent);">70%</span>
</div>
</div>
</div>
</div>
<!-- Below Target -->
<div class="card metric-card p-5 fade-in stagger-2">
<div class="flex items-center gap-3 mb-3">
<div class="w-10 h-10 rounded-lg flex items-center justify-center" style="background: rgba(239, 68, 68, 0.15);">
<svg class="w-5 h-5" style="color: var(--danger);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
</svg>
</div>
<div>
<p class="text-sm" style="color: var(--fg-muted);">Below Target</p>
<p class="font-display text-2xl font-bold" id="belowTarget">8</p>
</div>
</div>
<div class="w-full h-2 rounded-full" style="background: var(--border);">
<div class="h-full rounded-full transition-all duration-500" style="width: 16%; background: var(--danger);"></div>
</div>
<p class="text-xs mt-2" style="color: var(--fg-muted);">8 of 50 patients</p>
</div>
<!-- Access Events -->
<div class="card metric-card p-5 fade-in stagger-3">
<div class="flex items-center gap-3 mb-3">
<div class="w-10 h-10 rounded-lg flex items-center justify-center" style="background: rgba(245, 158, 11, 0.15);">
<svg class="w-5 h-5" style="color: var(--warning);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
</svg>
</div>
<div>
<p class="text-sm" style="color: var(--fg-muted);">Access Events</p>
<p class="font-display text-2xl font-bold" id="accessEvents">3</p>
</div>
</div>
<div class="flex items-center gap-2">
<span class="status-badge status-warning">2 Thrombosis</span>
<span class="status-badge status-danger">1 Infection</span>
</div>
</div>
<!-- Hospitalizations -->
<div class="card metric-card p-5 fade-in stagger-4">
<div class="flex items-center gap-3 mb-3">
<div class="w-10 h-10 rounded-lg flex items-center justify-center" style="background: rgba(59, 130, 246, 0.15);">
<svg class="w-5 h-5" style="color: var(--info);" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/>
</svg>
</div>
<div>
<p class="text-sm" style="color: var(--fg-muted);">Hospitalizations</p>
<p class="font-display text-2xl font-bold" id="hospitalizations">5</p>
</div>
</div>
<p class="text-xs" style="color: var(--fg-muted);">Avg stay: <span class="font-medium" style="color: var(--fg);">4.2 days</span></p>
</div>
</div>
<!-- Charts Row -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
<!-- Kt/V Trend Chart -->
<div class="card p-6 lg:col-span-2 fade-in stagger-4">
<div class="flex items-center justify-between mb-6">
<h2 class="font-display text-lg font-semibold">Kt/V Trend (12 Weeks)</h2>
<div class="flex items-center gap-4 text-xs">
<span class="flex items-center gap-1">
<span class="w-3 h-3 rounded-full" style="background: var(--accent);"></span>
Actual
</span>
<span class="flex items-center gap-1">
<span class="w-3 h-3 rounded-full" style="background: var(--border);"></span>
Target
</span>
</div>
</div>
<div class="relative h-48">
<canvas id="ktvChart" class="w-full h-full"></canvas>
</div>
</div>
<!-- Access Type Distribution -->
<div class="card p-6 fade-in stagger-5">
<h2 class="font-display text-lg font-semibold mb-6">Access Type Distribution</h2>
<div class="space-y-4">
<div>
<div class="flex justify-between text-sm mb-1">
<span>AV Fistula</span>
<span class="font-medium">62%</span>
</div>
<div class="w-full h-3 rounded-full" style="background: var(--border);">
<div class="h-full rounded-full chart-bar" style="width: 62%; background: var(--accent);"></div>
</div>
</div>
<div>
<div class="flex justify-between text-sm mb-1">
<span>AV Graft</span>
<span class="font-medium">24%</span>
</div>
<div class="w-full h-3 rounded-full" style="background: var(--border);">
<div class="h-full rounded-full chart-bar" style="width: 24%; background: var(--info);"></div>
</div>
</div>
<div>
<div class="flex justify-between text-sm mb-1">
<span>Catheter</span>
<span class="font-medium">14%</span>
</div>
<div class="w-full h-3 rounded-full" style="background: var(--border);">
<div class="h-full rounded-full chart-bar" style="width: 14%; background: var(--warning);"></div>
</div>
</div>
</div>
<div class="mt-6 pt-4" style="border-top: 1px solid var(--border);">
<p class="text-xs" style="color: var(--fg-muted);">Catheter target: <10%</p>
<p class="text-xs mt-1" style="color: var(--warning);">Currently above target</p>
</div>
</div>
</div>
<!-- Tables Row -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
<!-- Patients Below Target -->
<div class="card overflow-hidden fade-in stagger-4">
<div class="p-5 flex items-center justify-between" style="border-bottom: 1px solid var(--border);">
<h2 class="font-display text-lg font-semibold">Patients Below Kt/V Target</h2>
<span class="status-badge status-danger">8 Patients</span>
</div>
<div class="overflow-x-auto max-h-80 overflow-y-auto">
<table class="w-full">
<thead class="sticky top-0" style="background: var(--card);">
<tr style="border-bottom: 1px solid var(--border);">
<th class="text-left text-xs font-medium px-5 py-3" style="color: var(--fg-muted);">Patient</th>
<th class="text-left text-xs font-medium px-5 py-3" style="color: var(--fg-muted);">Kt/V</th>
<th class="text-left text-xs font-medium px-5 py-3" style="color: var(--fg-muted);">Access</th>
<th class="text-left text-xs font-medium px-5 py-3" style="color: var(--fg-muted);">Trend</th>
</tr>
</thead>
<tbody id="patientsTable">
<!-- Populated by JS -->
</tbody>
</table>
</div>
</div>
<!-- Recent Events -->
<div class="card overflow-hidden fade-in stagger-5">
<div class="p-5 flex items-center justify-between" style="border-bottom: 1px solid var(--border);">
<h2 class="font-display text-lg font-semibold">Recent Events</h2>
<button class="text-xs font-medium px-3 py-1 rounded-lg transition-colors hover:bg-opacity-20"
style="color: var(--accent); background: var(--accent-dim);">
View All
</button>
</div>
<div class="divide-y" style="border-color: var(--border);" id="eventsTimeline">
<!-- Populated by JS -->
</div>
</div>
</div>
<!-- Actions Panel -->
<div class="card overflow-hidden fade-in stagger-5">
<div class="p-5 flex items-center justify-between" style="border-bottom: 1px solid var(--border);">
<div class="flex items-center gap-3">
<h2 class="font-display text-lg font-semibold">Required Actions</h2>
<span class="px-2 py-0.5 text-xs font-bold rounded-full" style="background: var(--danger); color: white;">4</span>
</div>
<div class="flex items-center gap-2">
<button class="tab-btn active text-xs" data-filter="all">All</button>
<button class="tab-btn text-xs" data-filter="high">High</button>
<button class="tab-btn text-xs" data-filter="medium">Medium</button>
</div>
</div>
<div class="divide-y" style="border-color: var(--border);" id="actionsList">
<!-- Populated by JS -->
</div>
</div>
</main>
<!-- Footer -->
<footer class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6 mt-8" style="border-top: 1px solid var(--border);">
<div class="flex flex-col sm:flex-row items-center justify-between gap-4">
<p class="text-sm" style="color: var(--fg-muted);">Dialysis Adequacy Dashboard v2.4</p>
<div class="flex items-center gap-6 text-sm" style="color: var(--fg-muted);">
<span>50 Active Patients</span>
<span>Last sync: <span id="syncTime">2 min ago</span></span>
</div>
</div>
</footer>
<script>
// ========== DATA ==========
const patientsBelowTarget = [
{ id: 'P001', name: 'Maria Santos', ktv: 0.98, access: 'Catheter', trend: 'down', age: 62 },
{ id: 'P002', name: 'James Wilson', ktv: 1.05, access: 'AV Graft', trend: 'stable', age: 58 },
{ id: 'P003', name: 'Linda Chen', ktv: 1.08, access: 'AV Fistula', trend: 'up', age: 71 },
{ id: 'P004', name: 'Robert Kim', ktv: 1.12, access: 'Catheter', trend: 'down', age: 65 },
{ id: 'P005', name: 'Patricia Moore', ktv: 1.15, access: 'AV Graft', trend: 'stable', age: 69 },
{ id: 'P006', name: 'David Johnson', ktv: 1.10, access: 'Catheter', trend: 'down', age: 55 },
{ id: 'P007', name: 'Susan Martinez', ktv: 1.18, access: 'AV Fistula', trend: 'up', age: 73 },
{ id: 'P008', name: 'Michael Brown', ktv: 1.14, access: 'AV Graft', trend: 'stable', age: 61 }
];
const recentEvents = [
{ type: 'hospitalization', patient: 'Maria Santos', detail: 'Fluid overload admission', date: '2024-01-15', severity: 'high' },
{ type: 'access', patient: 'Robert Kim', detail: 'Catheter infection suspected', date: '2024-01-14', severity: 'high' },
{ type: 'access', patient: 'James Wilson', detail: 'Graft thrombosis cleared', date: '2024-01-13', severity: 'medium' },
{ type: 'ktv', patient: 'Linda Chen', detail: 'Kt/V improved to 1.08', date: '2024-01-12', severity: 'low' },
{ type: 'hospitalization', patient: 'David Johnson', detail: 'Discharged after 3 days', date: '2024-01-11', severity: 'low' }
];
const actions = [
{ id: 1, priority: 'high', action: 'Schedule fistulogram for Robert Kim', patient: 'Robert Kim', due: 'Today', category: 'access' },
{ id: 2, priority: 'high', action: 'Review dry weight for Maria Santos', patient: 'Maria Santos', due: 'Today', category: 'ktv' },
{ id: 3, priority: 'high', action: 'Contact surgery for catheter evaluation', patient: 'David Johnson', due: 'Tomorrow', category: 'access' },
{ id: 4, priority: 'medium', action: 'Increase treatment time to 4.5 hrs', patient: 'James Wilson', due: 'This week', category: 'ktv' },
{ id: 5, priority: 'medium', action: 'Nutritional counseling referral', patient: 'Patricia Moore', due: 'This week', category: 'nutrition' },
{ id: 6, priority: 'low', action: 'Schedule vascular surgery consult', patient: 'Susan Martinez', due: 'Next week', category: 'access' }
];
const ktvTrendData = [1.38, 1.42, 1.40, 1.35, 1.44, 1.41, 1.39, 1.45, 1.43, 1.40, 1.42, 1.42];
// ========== INITIALIZATION ==========
let currentFilter = 'all';
function init() {
renderPatientsTable();
renderEventsTimeline();
renderActionsList();
drawKtvChart();
setupEventListeners();
updateTimestamps();
}
// ========== RENDER FUNCTIONS ==========
function renderPatientsTable() {
const tbody = document.getElementById('patientsTable');
if (!tbody) return;
tbody.innerHTML = patientsBelowTarget.map(p => `
<tr class="patient-row cursor-pointer" style="border-bottom: 1px solid var(--border);" tabindex="0" role="button" aria-label="View ${p.name}">
<td class="px-5 py-3">
<div class="flex items-center gap-3">
<div class="w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium"
style="background: var(--accent-dim); color: var(--accent);">
${p.name.split(' ').map(n => n[0]).join('')}
</div>
<div>
<p class="font-medium text-sm">${p.name}</p>
<p class="text-xs" style="color: var(--fg-muted);">${p.age}y, ${p.id}</p>
</div>
</div>
</td>
<td class="px-5 py-3">
<span class="font-display font-bold" style="color: var(--danger);">${p.ktv}</span>
</td>
<td class="px-5 py-3">
<span class="status-badge ${p.access === 'Catheter' ? 'status-warning' : 'status-good'}">${p.access}</span>
</td>
<td class="px-5 py-3">
${getTrendIcon(p.trend)}
</td>
</tr>
`).join('');
}
function getTrendIcon(trend) {
const icons = {
up: `<svg class="w-4 h-4" style="color: var(--accent);" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 10l7-7m0 0l7 7m-7-7v18"/></svg>`,
down: `<svg class="w-4 h-4" style="color: var(--danger);" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 14l-7 7m0 0l-7-7m7 7V3"/></svg>`,
stable: `<svg class="w-4 h-4" style="color: var(--fg-muted);" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14"/></svg>`
};
return icons[trend] || icons.stable;
}
function renderEventsTimeline() {
const container = document.getElementById('eventsTimeline');
if (!container) return;
container.innerHTML = recentEvents.map(e => {
const iconMap = {
hospitalization: `<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/></svg>`,
access: `<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/></svg>`,
ktv: `<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"/></svg>`
};
const severityClass = e.severity === 'high' ? 'status-danger' : e.severity === 'medium' ? 'status-warning' : 'status-good';
return `
<div class="flex items-start gap-4 p-4 transition-colors hover:bg-opacity-50" style="border-color: var(--border);">
<div class="w-10 h-10 rounded-lg flex items-center justify-center shrink-0"
style="background: ${e.severity === 'high' ? 'rgba(239, 68, 68, 0.15)' : e.severity === 'medium' ? 'rgba(245, 158, 11, 0.15)' : 'var(--accent-dim)'};
color: ${e.severity === 'high' ? 'var(--danger)' : e.severity === 'medium' ? 'var(--warning)' : 'var(--accent)'};">
${iconMap[e.type]}
</div>
<div class="flex-1 min-w-0">
<div class="flex items-center justify-between gap-2">
<p class="font-medium text-sm truncate">${e.patient}</p>
<span class="status-badge ${severityClass} shrink-0">${e.severity}</span>
</div>
<p class="text-sm mt-1" style="color: var(--fg-muted);">${e.detail}</p>
<p class="text-xs mt-1" style="color: var(--fg-muted);">${formatDate(e.date)}</p>
</div>
</div>
`;
}).join('');
}
function renderActionsList(filter = 'all') {
const container = document.getElementById('actionsList');
if (!container) return;
const filtered = filter === 'all' ? actions : actions.filter(a => a.priority === filter);
container.innerHTML = filtered.map(a => {
const priorityColors = {
high: 'var(--danger)',
medium: 'var(--warning)',
low: 'var(--info)'
};
return `
<div class="action-item priority-${a.priority} p-4 flex items-center gap-4 transition-colors" style="border-color: var(--border);">
<div class="w-2 h-2 rounded-full shrink-0" style="background: ${priorityColors[a.priority]};"></div>
<div class="flex-1 min-w-0">
<p class="font-medium text-sm">${a.action}</p>
<p class="text-xs mt-1" style="color: var(--fg-muted);">Patient: ${a.patient}</p>
</div>
<div class="text-right shrink-0">
<p class="text-xs font-medium" style="color: ${priorityColors[a.priority]};">${a.due}</p>
<button class="text-xs mt-1 px-2 py-1 rounded transition-colors hover:bg-opacity-20"
style="color: var(--accent); background: var(--accent-dim);">
Complete
</button>
</div>
</div>
`;
}).join('');
}
function drawKtvChart() {
const canvas = document.getElementById('ktvChart');
if (!canvas) return;
const ctx = canvas.getContext('2d');
const dpr = window.devicePixelRatio || 1;
const rect = canvas.getBoundingClientRect();
canvas.width = rect.width * dpr;
canvas.height = rect.height * dpr;
ctx.scale(dpr, dpr);
const width = rect.width;
const height = rect.height;
const padding = { top: 20, right: 20, bottom: 30, left: 40 };
const chartWidth = width - padding.left - padding.right;
const chartHeight = height - padding.top - padding.bottom;
ctx.clearRect(0, 0, width, height);
// Draw grid lines
ctx.strokeStyle = getComputedStyle(document.documentElement).getPropertyValue('--border').trim() || '#243142';
ctx.lineWidth = 0.5;
for (let i = 0; i <= 4; i++) {
const y = padding.top + (chartHeight / 4) * i;
ctx.beginPath();
ctx.moveTo(padding.left, y);
ctx.lineTo(width - padding.right, y);
ctx.stroke();
}
// Y-axis labels
ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--fg-muted').trim() || '#7a8b9d';
ctx.font = '11px DM Sans';
ctx.textAlign = 'right';
const yLabels = ['1.6', '1.4', '1.2', '1.0', '0.8'];
yLabels.forEach((label, i) => {
const y = padding.top + (chartHeight / 4) * i;
ctx.fillText(label, padding.left - 8, y + 4);
});
// X-axis labels
ctx.textAlign = 'center';
const weeks = ['W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9', 'W10', 'W11', 'W12'];
weeks.forEach((week, i) => {
const x = padding.left + (chartWidth / 11) * i;
ctx.fillText(week, x, height - 8);
});
// Target line at 1.2
const targetY = padding.top + chartHeight * ((1.6 - 1.2) / 0.8);
ctx.strokeStyle = getComputedStyle(document.documentElement).getPropertyValue('--border').trim() || '#243142';
ctx.setLineDash([5, 5]);
ctx.beginPath();
ctx.moveTo(padding.left, targetY);
ctx.lineTo(width - padding.right, targetY);
ctx.stroke();
ctx.setLineDash([]);
// Draw line chart
const accentColor = getComputedStyle(document.documentElement).getPropertyValue('--accent').trim() || '#00d4aa';
ctx.strokeStyle = accentColor;
ctx.lineWidth = 2.5;
ctx.lineCap = 'round';
ctx.lineJoin = 'round';
ctx.beginPath();
ktvTrendData.forEach((value, i) => {
const x = padding.left + (chartWidth / 11) * i;
const y = padding.top + chartHeight * ((1.6 - value) / 0.8);
if (i === 0) {
ctx.moveTo(x, y);
} else {
ctx.lineTo(x, y);
}
});
ctx.stroke();
// Draw gradient fill
const gradient = ctx.createLinearGradient(0, padding.top, 0, height - padding.bottom);
gradient.addColorStop(0, accentColor + '40');
gradient.addColorStop(1, accentColor + '00');
ctx.fillStyle = gradient;
ctx.beginPath();
ktvTrendData.forEach((value, i) => {
const x = padding.left + (chartWidth / 11) * i;
const y = padding.top + chartHeight * ((1.6 - value) / 0.8);
if (i === 0) {
ctx.moveTo(x, y);
} else {
ctx.lineTo(x, y);
}
});
ctx.lineTo(padding.left + chartWidth, height - padding.bottom);
ctx.lineTo(padding.left, height - padding.bottom);
ctx.closePath();
ctx.fill();
// Draw data points
ktvTrendData.forEach((value, i) => {
const x = padding.left + (chartWidth / 11) * i;
const y = padding.top + chartHeight * ((1.6 - value) / 0.8);
ctx.fillStyle = accentColor;
ctx.beginPath();
ctx.arc(x, y, 4, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--card').trim() || '#151d27';
ctx.beginPath();
ctx.arc(x, y, 2, 0, Math.PI * 2);
ctx.fill();
});
}
// ========== EVENT LISTENERS ==========
function setupEventListeners() {
// Theme toggle
const themeToggle = document.getElementById('themeToggle');
const sunIcon = document.getElementById('sunIcon');
const moonIcon = document.getElementById('moonIcon');
if (themeToggle) {
themeToggle.addEventListener('click', () => {
const isDark = !document.documentElement.hasAttribute('data-theme');
document.documentElement.setAttribute('data-theme', isDark ? 'light' : '');
if (sunIcon && moonIcon) {
sunIcon.classList.toggle('hidden', !isDark);
moonIcon.classList.toggle('hidden', isDark);
}
// Redraw chart with new colors
setTimeout(drawKtvChart, 100);
});
}
// Period tabs
document.querySelectorAll('[data-period]').forEach(btn => {
btn.addEventListener('click', (e) => {
document.querySelectorAll('[data-period]').forEach(b => {
b.classList.remove('active');
b.setAttribute('aria-selected', 'false');
});
e.target.classList.add('active');
e.target.setAttribute('aria-selected', 'true');
});
});
// Action filters
document.querySelectorAll('[data-filter]').forEach(btn => {
btn.addEventListener('click', (e) => {
document.querySelectorAll('[data-filter]').forEach(b => b.classList.remove('active'));
e.target.classList.add('active');
currentFilter = e.target.dataset.filter;
renderActionsList(currentFilter);
});
});
// Search
const searchInput = document.getElementById('patientSearch');
if (searchInput) {
searchInput.addEventListener('input', (e) => {
const query = e.target.value.toLowerCase();
const rows = document.querySelectorAll('.patient-row');
rows.forEach(row => {
const text = row.textContent.toLowerCase();
row.style.display = text.includes(query) ? '' : 'none';
});
});
}
// Window resize
let resizeTimeout;
window.addEventListener('resize', () => {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(drawKtvChart, 100);
});
}
// ========== UTILITIES ==========
function formatDate(dateStr) {
const date = new Date(dateStr);
const options = { month: 'short', day: 'numeric' };
return date.toLocaleDateString('en-US', options);
}
function updateTimestamps() {
const now = new Date();
const lastUpdateEl = document.getElementById('lastUpdate');
const syncTimeEl = document.getElementById('syncTime');
if (lastUpdateEl) {
lastUpdateEl.textContent = now.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' });
}
if (syncTimeEl) {
syncTimeEl.textContent = '2 min ago';
}
}
// Initialize when DOM is ready
document.addEventListener('DOMContentLoaded', init);
</script>
</body>
</html>