import { useState, useRef, useEffect } from 'react' import { ChevronDown } from 'lucide-react' import { consultations } from '@/data/consultations' import type { Consultation, ViewId } from '@/types/pmr' interface ConsultationsViewProps { onNavigate?: (view: ViewId, itemId?: string) => void initialExpandedId?: string } export function ConsultationsView({ initialExpandedId }: ConsultationsViewProps) { const [expandedId, setExpandedId] = useState(initialExpandedId ?? null) const prefersReducedMotion = typeof window !== 'undefined' ? window.matchMedia('(prefers-reduced-motion: reduce)').matches : false const handleToggle = (id: string) => { setExpandedId(prev => prev === id ? null : id) } return (

Consultation History

{consultations.length} entries
{consultations.map(consultation => ( handleToggle(consultation.id)} prefersReducedMotion={prefersReducedMotion} /> ))}
) } interface ConsultationEntryProps { consultation: Consultation isExpanded: boolean onToggle: () => void prefersReducedMotion: boolean } function ConsultationEntry({ consultation, isExpanded, onToggle, prefersReducedMotion, }: ConsultationEntryProps) { const contentRef = useRef(null) const expandedContentRef = useRef(null) const [height, setHeight] = useState(isExpanded ? undefined : 0) useEffect(() => { if (prefersReducedMotion) { setHeight(isExpanded ? undefined : 0) return } if (isExpanded) { const timer = setTimeout(() => { setHeight(undefined) }, 200) return () => clearTimeout(timer) } setHeight(0) }, [isExpanded, prefersReducedMotion]) useEffect(() => { if (isExpanded && expandedContentRef.current) { expandedContentRef.current.focus() } }, [isExpanded]) const keyCodedEntry = consultation.codedEntries[0] return (
{isExpanded && ( )}
) } interface StatusDotProps { isCurrent: boolean } function StatusDot({ isCurrent }: StatusDotProps) { return ( ) } interface ExpandedContentProps { consultation: Consultation prefersReducedMotion: boolean contentRef: React.RefObject } function ExpandedContent({ consultation, prefersReducedMotion, contentRef }: ExpandedContentProps) { const opacity = prefersReducedMotion ? 1 : undefined const transition = prefersReducedMotion ? 'none' : 'opacity 150ms ease-out' return (
Duration: {consultation.duration}
HISTORY

{consultation.history}

EXAMINATION
    {consultation.examination.map((item, index) => (
  • - {item}
  • ))}
PLAN
    {consultation.plan.map((item, index) => (
  • - {item}
  • ))}
CODED ENTRIES
{consultation.codedEntries.map(entry => ( ))}
) } function SectionHeader({ children }: { children: React.ReactNode }) { return (

{children}

) } interface CodedEntryProps { code: string description: string } function CodedEntry({ code, description }: CodedEntryProps) { return (
[{code}] {description}
) }