From d9340ba2969d7b6a61a8c9ad52880dbfec9a5b61 Mon Sep 17 00:00:00 2001 From: colinislit Date: Sat, 6 Dec 2025 01:05:38 +0100 Subject: [PATCH] fix(overdracht): Filter op rapportages i.p.v. encounters + report types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Overdracht dashboard: - PatiΓ«nten nu gefilterd op rapportages (laatste 24u) i.p.v. encounters - Reports-block toont correcte type labels en kleuren Rapportage module: - Alle report types toegevoegd aan centrale lib/types/report.ts - Quick actions met alle 8 rapportage types en icons - Default type gewijzigd naar 'voortgang' πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../[patientId]/components/reports-block.tsx | 17 +++++++++++---- app/epd/overdracht/page.tsx | 21 +++++++++---------- .../rapportage/components/quick-actions.tsx | 19 ++++++++++++----- .../components/rapportage-workspace-v2.tsx | 2 +- lib/types/report.ts | 12 ++++++++++- 5 files changed, 49 insertions(+), 22 deletions(-) diff --git a/app/epd/overdracht/[patientId]/components/reports-block.tsx b/app/epd/overdracht/[patientId]/components/reports-block.tsx index dbc8cc9..76292aa 100644 --- a/app/epd/overdracht/[patientId]/components/reports-block.tsx +++ b/app/epd/overdracht/[patientId]/components/reports-block.tsx @@ -15,9 +15,12 @@ function getReportTypeLabel(type: string): string { voortgang: 'Voortgang', observatie: 'Observatie', incident: 'Incident', - overdracht: 'Overdracht', + medicatie: 'Medicatie', contact: 'Contact', - algemeen: 'Algemeen', + crisis: 'Crisis', + intake: 'Intake', + behandeladvies: 'Behandeladvies', + vrije_notitie: 'Vrije notitie', }; return types[type] || type; } @@ -25,15 +28,21 @@ function getReportTypeLabel(type: string): string { function getReportTypeStyle(type: string): { bg: string; text: string } { switch (type) { case 'incident': + case 'crisis': return { bg: 'bg-red-100', text: 'text-red-700' }; case 'observatie': return { bg: 'bg-blue-100', text: 'text-blue-700' }; case 'voortgang': return { bg: 'bg-green-100', text: 'text-green-700' }; - case 'overdracht': + case 'medicatie': return { bg: 'bg-purple-100', text: 'text-purple-700' }; case 'contact': return { bg: 'bg-amber-100', text: 'text-amber-700' }; + case 'intake': + return { bg: 'bg-teal-100', text: 'text-teal-700' }; + case 'behandeladvies': + return { bg: 'bg-indigo-100', text: 'text-indigo-700' }; + case 'vrije_notitie': default: return { bg: 'bg-slate-100', text: 'text-slate-700' }; } @@ -65,7 +74,7 @@ function truncateContent(content: string, maxLength: number = 150): string { } export function ReportsBlock({ reports }: ReportsBlockProps) { - const incidentCount = reports.filter(r => r.type === 'incident').length; + const incidentCount = reports.filter(r => r.type === 'incident' || r.type === 'crisis').length; return (
diff --git a/app/epd/overdracht/page.tsx b/app/epd/overdracht/page.tsx index e6750ba..08a7df4 100644 --- a/app/epd/overdracht/page.tsx +++ b/app/epd/overdracht/page.tsx @@ -16,13 +16,14 @@ async function getOverdrachtPatients(date?: string): Promise<{ const supabase = await createClient(); const targetDate = date || new Date().toISOString().split('T')[0]; - // Get start and end of day for date filtering + // Get start and end of day for date filtering (last 24 hours for reports) const dayStart = `${targetDate}T00:00:00.000Z`; const dayEnd = `${targetDate}T23:59:59.999Z`; + const last24h = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString(); - // 1. Get patients with encounters today - const { data: encounterData, error: encounterError } = await supabase - .from('encounters') + // 1. Get patients with reports in the last 24 hours + const { data: reportsData, error: reportsError } = await supabase + .from('reports') .select(` patient_id, patients!inner ( @@ -33,12 +34,10 @@ async function getOverdrachtPatients(date?: string): Promise<{ gender ) `) - .gte('period_start', dayStart) - .lte('period_start', dayEnd) - .in('status', ['planned', 'in-progress', 'completed']); + .gte('created_at', last24h); - if (encounterError) { - console.error('Error fetching encounters:', encounterError); + if (reportsError) { + console.error('Error fetching reports:', reportsError); return { patients: [], total: 0, date: targetDate }; } @@ -51,8 +50,8 @@ async function getOverdrachtPatients(date?: string): Promise<{ gender: string; }>(); - for (const encounter of encounterData || []) { - const patient = encounter.patients as unknown as { + for (const report of reportsData || []) { + const patient = report.patients as unknown as { id: string; name_given: string[]; name_family: string; diff --git a/app/epd/patients/[id]/rapportage/components/quick-actions.tsx b/app/epd/patients/[id]/rapportage/components/quick-actions.tsx index ec3c364..2d7629f 100644 --- a/app/epd/patients/[id]/rapportage/components/quick-actions.tsx +++ b/app/epd/patients/[id]/rapportage/components/quick-actions.tsx @@ -1,19 +1,22 @@ 'use client' -import { FileText, ClipboardList } from 'lucide-react' +import { FileText, ClipboardList, Activity, AlertTriangle, Pill, TrendingUp, Phone, Zap } from 'lucide-react' import { cn } from '@/lib/utils' +import type { ReportType } from '@/lib/types/report' + +// Re-export for backwards compatibility +export type { ReportType } from '@/lib/types/report' // ───────────────────────────────────────────────────────────────────────────── // Types // ───────────────────────────────────────────────────────────────────────────── -export type ReportType = 'vrije_notitie' | 'behandeladvies' - interface QuickAction { id: string label: string icon: typeof FileText type: ReportType + color?: string } export interface QuickActionsProps { @@ -32,8 +35,14 @@ export interface QuickActionsProps { // ───────────────────────────────────────────────────────────────────────────── const QUICK_ACTIONS: QuickAction[] = [ - { id: 'vrije-notitie', label: '+ Vrije notitie', icon: FileText, type: 'vrije_notitie' }, - { id: 'behandeladvies', label: '+ Behandeladvies', icon: ClipboardList, type: 'behandeladvies' }, + { id: 'voortgang', label: 'Voortgang', icon: TrendingUp, type: 'voortgang', color: 'emerald' }, + { id: 'observatie', label: 'Observatie', icon: Activity, type: 'observatie', color: 'blue' }, + { id: 'medicatie', label: 'Medicatie', icon: Pill, type: 'medicatie', color: 'purple' }, + { id: 'incident', label: 'Incident', icon: AlertTriangle, type: 'incident', color: 'red' }, + { id: 'contact', label: 'Contact', icon: Phone, type: 'contact', color: 'amber' }, + { id: 'crisis', label: 'Crisis', icon: Zap, type: 'crisis', color: 'red' }, + { id: 'vrije-notitie', label: 'Vrije notitie', icon: FileText, type: 'vrije_notitie', color: 'slate' }, + { id: 'behandeladvies', label: 'Behandeladvies', icon: ClipboardList, type: 'behandeladvies', color: 'indigo' }, ] // ───────────────────────────────────────────────────────────────────────────── diff --git a/app/epd/patients/[id]/rapportage/components/rapportage-workspace-v2.tsx b/app/epd/patients/[id]/rapportage/components/rapportage-workspace-v2.tsx index 332b114..f7ce924 100644 --- a/app/epd/patients/[id]/rapportage/components/rapportage-workspace-v2.tsx +++ b/app/epd/patients/[id]/rapportage/components/rapportage-workspace-v2.tsx @@ -49,7 +49,7 @@ export function RapportageWorkspaceV2({ linkedEncounterId, }: RapportageWorkspaceV2Props) { const [reports, setReports] = useState(initialReports) - const [selectedType, setSelectedType] = useState('vrije_notitie') + const [selectedType, setSelectedType] = useState('voortgang') const [selectedReport, setSelectedReport] = useState(null) const [isModalOpen, setIsModalOpen] = useState(false) const [duplicateContent, setDuplicateContent] = useState(null) diff --git a/lib/types/report.ts b/lib/types/report.ts index 236f63c..6bdac16 100644 --- a/lib/types/report.ts +++ b/lib/types/report.ts @@ -5,7 +5,17 @@ export type Report = Database['public']['Tables']['reports']['Row']; export type ReportInsert = Database['public']['Tables']['reports']['Insert']; export type ReportUpdate = Database['public']['Tables']['reports']['Update']; -export const REPORT_TYPES = ['behandeladvies', 'vrije_notitie'] as const; +export const REPORT_TYPES = [ + 'voortgang', + 'observatie', + 'incident', + 'medicatie', + 'contact', + 'crisis', + 'intake', + 'behandeladvies', + 'vrije_notitie', +] as const; export type ReportType = (typeof REPORT_TYPES)[number]; export const CreateReportSchema = z.object({