import { useState, useEffect } from 'react'
import { AlertTriangle, Check, ChevronRight } from 'lucide-react'
import { patient } from '@/data/patient'
import { consultations } from '@/data/consultations'
import { problems } from '@/data/problems'
import { medications } from '@/data/medications'
import type { ViewId } from '@/types/pmr'
interface SummaryViewProps {
onNavigate?: (view: ViewId, itemId?: string) => void
}
export function SummaryView({ onNavigate }: SummaryViewProps) {
const [alertDismissed, setAlertDismissed] = useState(false)
const [alertAnimating, setAlertAnimating] = useState(false)
const [alertVisible, setAlertVisible] = useState(false)
const prefersReducedMotion = typeof window !== 'undefined'
? window.matchMedia('(prefers-reduced-motion: reduce)').matches
: false
useEffect(() => {
const timer = setTimeout(() => {
setAlertVisible(true)
}, prefersReducedMotion ? 0 : 300)
return () => clearTimeout(timer)
}, [prefersReducedMotion])
const handleDismissAlert = () => {
setAlertAnimating(true)
setTimeout(() => {
setAlertDismissed(true)
}, prefersReducedMotion ? 0 : 400)
}
const activeProblems = problems.filter(p => p.status === 'Active' || p.status === 'In Progress')
const topMedications = medications.filter(m => m.category === 'Active').slice(0, 5)
const lastConsultation = consultations[0]
return (
)
}
interface ClinicalAlertProps {
visible: boolean
animating: boolean
onDismiss: () => void
prefersReducedMotion: boolean
}
function ClinicalAlert({ visible, animating, onDismiss, prefersReducedMotion }: ClinicalAlertProps) {
const [showCheck, setShowCheck] = useState(false)
const handleClick = () => {
if (!prefersReducedMotion) {
setShowCheck(true)
setTimeout(onDismiss, 200)
} else {
onDismiss()
}
}
return (
ALERT: This patient has identified £14.6M in prescribing efficiency savings across Norfolk & Waveney ICS.
)
}
function DemographicsCard() {
return (
Patient Demographics
{patient.status}
}
/>
GPhC{' '}
{patient.nhsNumber.replace(/ /g, '')}
}
/>
)
}
interface DemographicsRowProps {
label: string
value: React.ReactNode
}
function DemographicsRow({ label, value }: DemographicsRowProps) {
return (
{label}:
{value}
)
}
interface ActiveProblemsCardProps {
problems: typeof problems
onNavigate?: (view: ViewId, itemId?: string) => void
}
function ActiveProblemsCard({ problems, onNavigate }: ActiveProblemsCardProps) {
return (
Active Problems
{problems.map((problem) => (
))}
)
}
interface TrafficLightProps {
status: 'Active' | 'In Progress' | 'Resolved'
}
function TrafficLight({ status }: TrafficLightProps) {
const colors = {
'Active': { bg: 'bg-green-500', label: 'Active' },
'In Progress': { bg: 'bg-amber-500', label: 'In Progress' },
'Resolved': { bg: 'bg-green-500', label: 'Resolved' },
}
const color = colors[status]
return (
)
}
interface QuickMedsCardProps {
medications: typeof medications
onNavigate?: (view: ViewId) => void
}
function QuickMedsCard({ medications, onNavigate }: QuickMedsCardProps) {
return (
Current Medications (Quick View)
|
Drug
|
Dose
|
Freq
|
Status
|
{medications.map((med, index) => (
|
{med.name}
|
{med.dose}%
|
{med.frequency}
|
{med.status}
|
))}
)
}
interface LastConsultationCardProps {
consultation: typeof consultations[0]
onNavigate?: (view: ViewId, itemId?: string) => void
}
function LastConsultationCard({ consultation, onNavigate }: LastConsultationCardProps) {
return (
Last Consultation
{consultation.date}
|
{consultation.organization}
{consultation.role}
{consultation.history}
)
}