'use client'; /** * PatientListItem Component * * Reusable patient list item for search results, recent patients, etc. * Extracted from ZoekenBlock for DRY compliance. * * Epic: E0.S2 (Patient Selectie - Refactor) */ import { Loader2, Check } from 'lucide-react'; import { cn } from '@/lib/utils'; import type { PatientSearchResult } from '@/lib/cortex/hooks/use-patient-search'; import { getPatientInitials } from '@/lib/fhir/patient-mapper'; interface PatientListItemProps { /** Patient data */ patient: PatientSearchResult; /** Whether this item is currently selected/loading */ isLoading?: boolean; /** Click handler */ onClick: () => void; /** Size variant */ size?: 'sm' | 'md'; /** Show identifiers (BSN, client number) */ showIdentifiers?: boolean; /** Additional class names */ className?: string; } /** * Calculate age from birth date string */ function calculateAge(birthDate: string): number | null { if (!birthDate) return null; const birth = new Date(birthDate); if (isNaN(birth.getTime())) return null; const today = new Date(); let age = today.getFullYear() - birth.getFullYear(); const monthDiff = today.getMonth() - birth.getMonth(); if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birth.getDate())) { age--; } return age; } export function PatientListItem({ patient, isLoading = false, onClick, size = 'md', showIdentifiers = true, className, }: PatientListItemProps) { const age = calculateAge(patient.birthDate); const initials = getPatientInitials(patient.name); const isSm = size === 'sm'; return ( ); } /** * Empty state component for patient search */ export function PatientListEmpty({ message = 'Geen patienten gevonden', submessage, }: { message?: string; submessage?: string; }) { return (

{message}

{submessage &&

{submessage}

}
); } /** * Loading state component for patient search */ export function PatientListLoading({ message = 'Zoeken...' }: { message?: string }) { return (
{message}
); }