import React, { useState, useEffect } from 'react'; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, AreaChart, Area } from 'recharts'; import { Heart, Calendar, Pill, TestTube, MessageSquare, Bell, User, LogOut, Clock, FileText, Download, Plus, ChevronRight, CheckCircle, AlertCircle, Activity, Stethoscope, Mail, Shield, TrendingUp } from 'lucide-react'; // Mock Data (since connections are pending credentials) const mockAppointments = [ { id: 'apt-001', date: '2026-01-18', time: '10:00 AM', provider: 'Dr. Chen', specialty: 'Primary Care', location: 'Main Clinic', type: 'Follow-up', status: 'confirmed' }, { id: 'apt-002', date: '2026-02-02', time: '2:30 PM', provider: 'Lab Services', specialty: 'Diagnostics', location: 'Lab Wing', type: 'Blood Draw', status: 'pending' }, { id: 'apt-003', date: '2026-02-15', time: '11:00 AM', provider: 'Dr. Patel', specialty: 'Endocrinology', location: 'Specialty Clinic', type: 'Consultation', status: 'confirmed' }, ]; const mockPrescriptions = [ { id: 'rx-001', medication: 'Metformin', dosage: '500mg', frequency: 'Twice daily', prescriber: 'Dr. Chen', refillsRemaining: 3, nextRefillDate: '2026-01-20', status: 'active', refillable: true }, { id: 'rx-002', medication: 'Lisinopril', dosage: '10mg', frequency: 'Once daily', prescriber: 'Dr. Chen', refillsRemaining: 1, nextRefillDate: '2026-01-17', status: 'refill-needed', refillable: true }, { id: 'rx-003', medication: 'Atorvastatin', dosage: '20mg', frequency: 'Once daily at bedtime', prescriber: 'Dr. Patel', refillsRemaining: 5, nextRefillDate: '2026-02-01', status: 'active', refillable: true }, ]; const mockLabResults = [ { id: 'lab-001', testName: 'HbA1c', date: '2025-12-15', value: '6.8', unit: '%', referenceRange: '4.0-5.6', status: 'borderline', category: 'Chemistry', trend: [6.5, 6.6, 6.7, 6.8, 6.8] }, { id: 'lab-002', testName: 'Fasting Glucose', date: '2025-12-15', value: '112', unit: 'mg/dL', referenceRange: '70-100', status: 'borderline', category: 'Chemistry', trend: [105, 108, 110, 112, 112] }, { id: 'lab-003', testName: 'Total Cholesterol', date: '2025-12-15', value: '195', unit: 'mg/dL', referenceRange: '<200', status: 'normal', category: 'Lipid Panel', trend: [210, 205, 198, 195, 195] }, { id: 'lab-004', testName: 'LDL Cholesterol', date: '2025-12-15', value: '118', unit: 'mg/dL', referenceRange: '<100', status: 'borderline', category: 'Lipid Panel', trend: [130, 125, 120, 118, 118] }, { id: 'lab-005', testName: 'HDL Cholesterol', date: '2025-12-15', value: '58', unit: 'mg/dL', referenceRange: '>40', status: 'normal', category: 'Lipid Panel', trend: [52, 54, 56, 57, 58] }, ]; const mockMessages = [ { id: 'msg-001', sender: 'Dr. Chen', subject: 'Lab Results Review', date: '2026-01-14', read: false, preview: 'Hi Sarah, I reviewed your recent lab results...' }, { id: 'msg-002', sender: 'Billing Department', subject: 'Insurance Verification', date: '2026-01-12', read: true, preview: 'We have successfully verified your insurance...' }, { id: 'msg-003', sender: 'Pharmacy Team', subject: 'Prescription Ready', date: '2026-01-10', read: true, preview: 'Your prescription refill is ready for pickup...' }, ]; const mockTrendData = [ { date: 'Aug', hba1c: 6.5, glucose: 105 }, { date: 'Sep', hba1c: 6.6, glucose: 108 }, { date: 'Oct', hba1c: 6.7, glucose: 110 }, { date: 'Nov', hba1c: 6.8, glucose: 112 }, { date: 'Dec', hba1c: 6.8, glucose: 112 }, ]; export default function App() { const [activeTab, setActiveTab] = useState('appointments'); const [selectedLab, setSelectedLab] = useState(null); const [selectedAppointment, setSelectedAppointment] = useState(null); const [selectedMessage, setSelectedMessage] = useState(null); const [showRefillModal, setShowRefillModal] = useState(null); const [calendarView, setCalendarView] = useState('month'); const [notifications, setNotifications] = useState(2); // Get status badge color const getStatusColor = (status) => { switch (status) { case 'normal': case 'confirmed': case 'active': return 'bg-emerald-500/10 text-emerald-400 border-emerald-500/20'; case 'borderline': case 'pending': case 'refill-needed': return 'bg-amber-500/10 text-amber-400 border-amber-500/20'; case 'abnormal': case 'critical': return 'bg-red-500/10 text-red-400 border-red-500/20'; default: return 'bg-slate-500/10 text-slate-400 border-slate-500/20'; } }; const getStatusIcon = (status) => { switch (status) { case 'normal': case 'confirmed': case 'active': return ; case 'borderline': case 'pending': case 'refill-needed': return ; default: return ; } }; // Health Summary Cards Data const nextAppointment = mockAppointments[0]; const medsDueThisWeek = mockPrescriptions.filter(rx => { const refillDate = new Date(rx.nextRefillDate); const weekFromNow = new Date(); weekFromNow.setDate(weekFromNow.getDate() + 7); return refillDate <= weekFromNow; }); const pendingLabs = mockLabResults.filter(lab => lab.status !== 'normal'); const unreadMessages = mockMessages.filter(msg => !msg.read); const tabs = [ { id: 'appointments', label: 'Appointments', icon: Calendar }, { id: 'prescriptions', label: 'Prescriptions', icon: Pill }, { id: 'lab-results', label: 'Lab Results', icon: TestTube }, { id: 'messages', label: 'Messages', icon: MessageSquare }, { id: 'health-records', label: 'Health Records', icon: FileText }, ]; return (
{/* Header */}

Patient Portal

Healthcare Dashboard

Sarah Johnson

Patient

{/* Welcome Banner */}

Welcome back, Sarah

Here's your health overview for today

Monday, January 15, 2026

{/* Health Summary Grid */}
{/* Next Appointment Card */}
setActiveTab('appointments')} >
Next Appointment

{nextAppointment.date.split('-')[1]}/{nextAppointment.date.split('-')[2]}

{nextAppointment.time}

{nextAppointment.provider}

{/* Medications Due Card */}
setActiveTab('prescriptions')} >
Meds to Refill

{medsDueThisWeek.length}

due this week

{medsDueThisWeek.length > 0 && (

{medsDueThisWeek[0].medication}

)}
{/* Pending Labs Card */}
setActiveTab('lab-results')} >
Pending Results

{pendingLabs.length}

need attention

{pendingLabs.length > 0 && (

Ready to review

)}
{/* Messages Card */}
setActiveTab('messages')} >
Messages

{unreadMessages.length}

unread

{unreadMessages.length > 0 && (

From: {unreadMessages[0].sender}

)}
{/* Navigation Tabs */}
{tabs.map((tab) => { const Icon = tab.icon; return ( ); })}
{/* Main Content Area */}
{/* Main Content */}
{/* Appointments Tab */} {activeTab === 'appointments' && (

Upcoming Appointments

{mockAppointments.map((apt) => (
setSelectedAppointment(apt)} className="flex items-center gap-4 p-4 rounded-xl bg-white/[0.02] border border-white/[0.05] mb-3 cursor-pointer hover:border-cyan-500/30 transition-all" >
{apt.date.split('-')[2]} {apt.date.split('-')[1]}

{apt.provider}

{apt.specialty} • {apt.type}

{apt.time} • {apt.location}

{getStatusIcon(apt.status)} {apt.status}
))}
)} {/* Prescriptions Tab */} {activeTab === 'prescriptions' && (

Current Medications

{mockPrescriptions.map((rx) => ( ))}
Medication Dosage Frequency Next Refill Status Action

{rx.medication}

{rx.prescriber}

{rx.dosage} {rx.frequency} {rx.nextRefillDate} {getStatusIcon(rx.status)} {rx.status.replace('-', ' ')} {rx.refillable && ( )}
)} {/* Lab Results Tab */} {activeTab === 'lab-results' && (

Lab Results

{mockLabResults.map((lab) => (
setSelectedLab(lab)} className="flex items-center gap-4 p-4 rounded-xl bg-white/[0.02] border border-white/[0.05] mb-3 cursor-pointer hover:border-amber-500/30 transition-all" >

{lab.testName}

{lab.date} • {lab.category}

{lab.value} {lab.unit}

Ref: {lab.referenceRange}

{getStatusIcon(lab.status)} {lab.status}
))}
)} {/* Messages Tab */} {activeTab === 'messages' && (

Secure Messages

{mockMessages.map((msg) => (
setSelectedMessage(msg)} className={`flex items-center gap-4 p-4 rounded-xl border mb-3 cursor-pointer transition-all ${ msg.read ? 'bg-white/[0.02] border-white/[0.05] hover:border-blue-500/30' : 'bg-blue-500/5 border-blue-500/20 hover:border-blue-500/40' }`} >
{msg.sender.charAt(0)}

{msg.sender}

{msg.date}

{msg.subject}

{msg.preview}

{!msg.read && (
)}
))}
)} {/* Health Records Tab */} {activeTab === 'health-records' && (

Health Records

{[ { title: 'Visit Summaries', count: 12, icon: FileText, color: 'cyan' }, { title: 'Immunizations', count: 8, icon: Shield, color: 'emerald' }, { title: 'Allergies', count: 3, icon: AlertCircle, color: 'amber' }, { title: 'Vitals History', count: 24, icon: Activity, color: 'blue' }, ].map((record, idx) => { const Icon = record.icon; const colorClasses = { cyan: 'bg-cyan-500/10 border-cyan-500/20 text-cyan-400', emerald: 'bg-emerald-500/10 border-emerald-500/20 text-emerald-400', amber: 'bg-amber-500/10 border-amber-500/20 text-amber-400', blue: 'bg-blue-500/10 border-blue-500/20 text-blue-400', }; return (

{record.title}

{record.count} records

); })}
)}
{/* Quick Actions Panel */}

Quick Actions

{/* HbA1c Trend Chart */}

HbA1c Trend

Target: <5.7% Current: 6.8%
{/* Footer */} {/* Lab Result Detail Modal */} {selectedLab && (
setSelectedLab(null)} >
e.stopPropagation()} >

{selectedLab.testName}

{selectedLab.date} • {selectedLab.category}

Result Value

{selectedLab.value} {selectedLab.unit}

Reference Range

{selectedLab.referenceRange}

{getStatusIcon(selectedLab.status)} Status: {selectedLab.status}

Historical Trend

What This Means

{selectedLab.status === 'normal' ? `Your ${selectedLab.testName} level is within the normal range. Continue following your current health plan.` : selectedLab.status === 'borderline' ? `Your ${selectedLab.testName} level is slightly elevated. Consider discussing lifestyle modifications with your healthcare provider.` : `Your ${selectedLab.testName} level is outside the normal range. Please schedule a follow-up appointment with your doctor.` }

)} {/* Appointment Detail Modal */} {selectedAppointment && (
setSelectedAppointment(null)} >
e.stopPropagation()} >

{selectedAppointment.type}

{selectedAppointment.date} at {selectedAppointment.time}

Provider

{selectedAppointment.provider}

{selectedAppointment.specialty}

Date & Time

{selectedAppointment.date} at {selectedAppointment.time}

Location

{selectedAppointment.location}

{getStatusIcon(selectedAppointment.status)} Status: {selectedAppointment.status}
)} {/* Message Detail Modal */} {selectedMessage && (
setSelectedMessage(null)} >
e.stopPropagation()} >
{selectedMessage.sender.charAt(0)}

{selectedMessage.subject}

From: {selectedMessage.sender} • {selectedMessage.date}

{selectedMessage.preview}

Please review your recent lab results and let me know if you have any questions. I recommend scheduling a follow-up appointment to discuss the borderline HbA1c levels.

Best regards,
Dr. Chen

)} {/* Refill Request Modal */} {showRefillModal && (
setShowRefillModal(null)} >
e.stopPropagation()} >

Request Refill

Medication

{showRefillModal.medication} ({showRefillModal.dosage})

Current Refills Remaining

{showRefillModal.refillsRemaining}

Pharmacy

CVS Pharmacy #1234

✓ This medication is eligible for refill. Your request will be sent to {showRefillModal.prescriber} for approval.

)}
); }