'use client'; /** * Diagnosis Overview Card Component * * Read-only weergave van een diagnose voor het patiënt-breed overzicht. * Toont ook de gekoppelde intake informatie. */ import { useState } from 'react'; import Link from 'next/link'; import { format } from 'date-fns'; import { nl } from 'date-fns/locale'; import { ChevronDown, ChevronUp, ExternalLink } from 'lucide-react'; import { Card, CardContent, CardHeader } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import type { DiagnosisWithIntake } from '../actions'; interface DiagnosisOverviewCardProps { diagnosis: DiagnosisWithIntake; patientId: string; } // Status badge configuratie const STATUS_CONFIG: Record = { active: { label: 'Actief', color: 'text-green-700', bgColor: 'bg-green-100 border-green-300', }, remission: { label: 'In remissie', color: 'text-blue-700', bgColor: 'bg-blue-100 border-blue-300', }, resolved: { label: 'Opgelost', color: 'text-slate-700', bgColor: 'bg-slate-100 border-slate-300', }, inactive: { label: 'Inactief', color: 'text-amber-700', bgColor: 'bg-amber-100 border-amber-300', }, }; // Severity labels const SEVERITY_LABELS: Record = { licht: 'Licht', matig: 'Matig', ernstig: 'Ernstig', }; export function DiagnosisOverviewCard({ diagnosis, patientId }: DiagnosisOverviewCardProps) { const [isNotesExpanded, setIsNotesExpanded] = useState(false); const code = diagnosis.code_code || ''; const description = diagnosis.code_display || ''; const severity = diagnosis.severity_display || ''; const status = diagnosis.clinical_status || 'active'; const notes = diagnosis.note || ''; const recordedDate = diagnosis.recorded_date ? new Date(diagnosis.recorded_date) : null; const isPrimary = diagnosis.category === 'primary-diagnosis'; const statusConfig = STATUS_CONFIG[status] || STATUS_CONFIG.active; const hasNotes = notes.trim().length > 0; // Intake informatie const intake = diagnosis.intake; const intakeUrl = intake ? `/epd/patients/${patientId}/intakes/${intake.id}/diagnosis` : null; return (
{/* Code + beschrijving */}

{code && description ? ( <> {code} {' — '} {description} ) : ( code || description || 'Geen diagnose code' )}

{/* Badges */}
{/* HOOFD badge */} {isPrimary && ( HOOFD )} {/* Status badge */} {statusConfig.label}
{/* Meta informatie */}
{severity && (
Ernst:{' '} {SEVERITY_LABELS[severity] || severity}
)} {recordedDate && (
Datum:{' '} {format(recordedDate, 'd MMM yyyy', { locale: nl })}
)}
{/* Intake link */} {intake && intakeUrl && (
Intake: {intake.title || intake.department || 'Intake'}
)} {/* Onderbouwing (expand/collapse) */} {hasNotes && (
{isNotesExpanded && (
{notes}
)}
)} {/* Bewerk link naar intake */} {intakeUrl && (
)}
); }