'use client'; /** * Client Header Component * E2.S3: Context-aware header showing client name, status, last modified en acties */ import { Mic } from 'lucide-react'; import { useRouter, usePathname } from 'next/navigation'; import type { FHIRPatient } from '@/lib/fhir'; import { Button } from '@/components/ui/button'; interface ClientHeaderProps { patient: FHIRPatient; focusElementId?: string; } // Status badge component function StatusBadge({ status }: { status?: string }) { const badges = { planned: { label: 'Screening', className: 'bg-amber-100 text-amber-800 border-amber-200' }, active: { label: 'Actief', className: 'bg-emerald-100 text-emerald-800 border-emerald-200' }, finished: { label: 'Afgerond', className: 'bg-slate-100 text-slate-800 border-slate-200' }, cancelled: { label: 'Afgemeld', className: 'bg-red-100 text-red-800 border-red-200' }, }; const badge = status && status in badges ? badges[status as keyof typeof badges] : null; if (!badge) { return -; } return ( {badge.label} ); } export function ClientHeader({ patient, focusElementId = 'rapportage-composer' }: ClientHeaderProps) { const router = useRouter(); const pathname = usePathname(); const handleNewReportClick = (patientId?: string) => { if (!patientId) return; const rapportagePath = `/epd/patients/${patientId}/rapportage`; const onRapportagePage = pathname?.startsWith(rapportagePath); if (onRapportagePage) { handleScrollToComposer(focusElementId); return; } const hash = focusElementId ? `#${focusElementId}` : ''; router.push(`${rapportagePath}${hash}`); }; // Extract name const name = patient.name?.[0]; const fullName = [ ...(name?.prefix || []), ...(name?.given || []), name?.family, ] .filter(Boolean) .join(' '); // Extract status from extension const statusExtension = (patient as any).extension?.find( (ext: any) => ext.url === 'http://mini-epd.local/fhir/StructureDefinition/episode-status' ); const status = statusExtension?.valueCode; // Extract last modified const lastModified = patient.meta?.lastUpdated ? new Date(patient.meta.lastUpdated).toLocaleString('nl-NL', { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit', }) : null; // Check if John Doe const isJohnDoe = (patient as any).extension?.find( (ext: any) => ext.url === 'http://mini-epd.local/fhir/StructureDefinition/john-doe' )?.valueBoolean; return (