fix(overdracht): Filter op rapportages i.p.v. encounters + report types

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 <noreply@anthropic.com>
This commit is contained in:
colinislit
2025-12-06 01:05:38 +01:00
parent 9e4e16035b
commit d9340ba296
5 changed files with 49 additions and 22 deletions

View File

@@ -15,9 +15,12 @@ function getReportTypeLabel(type: string): string {
voortgang: 'Voortgang', voortgang: 'Voortgang',
observatie: 'Observatie', observatie: 'Observatie',
incident: 'Incident', incident: 'Incident',
overdracht: 'Overdracht', medicatie: 'Medicatie',
contact: 'Contact', contact: 'Contact',
algemeen: 'Algemeen', crisis: 'Crisis',
intake: 'Intake',
behandeladvies: 'Behandeladvies',
vrije_notitie: 'Vrije notitie',
}; };
return types[type] || type; return types[type] || type;
} }
@@ -25,15 +28,21 @@ function getReportTypeLabel(type: string): string {
function getReportTypeStyle(type: string): { bg: string; text: string } { function getReportTypeStyle(type: string): { bg: string; text: string } {
switch (type) { switch (type) {
case 'incident': case 'incident':
case 'crisis':
return { bg: 'bg-red-100', text: 'text-red-700' }; return { bg: 'bg-red-100', text: 'text-red-700' };
case 'observatie': case 'observatie':
return { bg: 'bg-blue-100', text: 'text-blue-700' }; return { bg: 'bg-blue-100', text: 'text-blue-700' };
case 'voortgang': case 'voortgang':
return { bg: 'bg-green-100', text: 'text-green-700' }; return { bg: 'bg-green-100', text: 'text-green-700' };
case 'overdracht': case 'medicatie':
return { bg: 'bg-purple-100', text: 'text-purple-700' }; return { bg: 'bg-purple-100', text: 'text-purple-700' };
case 'contact': case 'contact':
return { bg: 'bg-amber-100', text: 'text-amber-700' }; 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: default:
return { bg: 'bg-slate-100', text: 'text-slate-700' }; 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) { 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 ( return (
<div className="bg-white rounded-xl border border-slate-200 p-6"> <div className="bg-white rounded-xl border border-slate-200 p-6">

View File

@@ -16,13 +16,14 @@ async function getOverdrachtPatients(date?: string): Promise<{
const supabase = await createClient(); const supabase = await createClient();
const targetDate = date || new Date().toISOString().split('T')[0]; 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 dayStart = `${targetDate}T00:00:00.000Z`;
const dayEnd = `${targetDate}T23:59:59.999Z`; const dayEnd = `${targetDate}T23:59:59.999Z`;
const last24h = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
// 1. Get patients with encounters today // 1. Get patients with reports in the last 24 hours
const { data: encounterData, error: encounterError } = await supabase const { data: reportsData, error: reportsError } = await supabase
.from('encounters') .from('reports')
.select(` .select(`
patient_id, patient_id,
patients!inner ( patients!inner (
@@ -33,12 +34,10 @@ async function getOverdrachtPatients(date?: string): Promise<{
gender gender
) )
`) `)
.gte('period_start', dayStart) .gte('created_at', last24h);
.lte('period_start', dayEnd)
.in('status', ['planned', 'in-progress', 'completed']);
if (encounterError) { if (reportsError) {
console.error('Error fetching encounters:', encounterError); console.error('Error fetching reports:', reportsError);
return { patients: [], total: 0, date: targetDate }; return { patients: [], total: 0, date: targetDate };
} }
@@ -51,8 +50,8 @@ async function getOverdrachtPatients(date?: string): Promise<{
gender: string; gender: string;
}>(); }>();
for (const encounter of encounterData || []) { for (const report of reportsData || []) {
const patient = encounter.patients as unknown as { const patient = report.patients as unknown as {
id: string; id: string;
name_given: string[]; name_given: string[];
name_family: string; name_family: string;

View File

@@ -1,19 +1,22 @@
'use client' '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 { cn } from '@/lib/utils'
import type { ReportType } from '@/lib/types/report'
// Re-export for backwards compatibility
export type { ReportType } from '@/lib/types/report'
// ───────────────────────────────────────────────────────────────────────────── // ─────────────────────────────────────────────────────────────────────────────
// Types // Types
// ───────────────────────────────────────────────────────────────────────────── // ─────────────────────────────────────────────────────────────────────────────
export type ReportType = 'vrije_notitie' | 'behandeladvies'
interface QuickAction { interface QuickAction {
id: string id: string
label: string label: string
icon: typeof FileText icon: typeof FileText
type: ReportType type: ReportType
color?: string
} }
export interface QuickActionsProps { export interface QuickActionsProps {
@@ -32,8 +35,14 @@ export interface QuickActionsProps {
// ───────────────────────────────────────────────────────────────────────────── // ─────────────────────────────────────────────────────────────────────────────
const QUICK_ACTIONS: QuickAction[] = [ const QUICK_ACTIONS: QuickAction[] = [
{ id: 'vrije-notitie', label: '+ Vrije notitie', icon: FileText, type: 'vrije_notitie' }, { id: 'voortgang', label: 'Voortgang', icon: TrendingUp, type: 'voortgang', color: 'emerald' },
{ id: 'behandeladvies', label: '+ Behandeladvies', icon: ClipboardList, type: 'behandeladvies' }, { 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' },
] ]
// ───────────────────────────────────────────────────────────────────────────── // ─────────────────────────────────────────────────────────────────────────────

View File

@@ -49,7 +49,7 @@ export function RapportageWorkspaceV2({
linkedEncounterId, linkedEncounterId,
}: RapportageWorkspaceV2Props) { }: RapportageWorkspaceV2Props) {
const [reports, setReports] = useState(initialReports) const [reports, setReports] = useState(initialReports)
const [selectedType, setSelectedType] = useState<ReportType>('vrije_notitie') const [selectedType, setSelectedType] = useState<ReportType>('voortgang')
const [selectedReport, setSelectedReport] = useState<Report | null>(null) const [selectedReport, setSelectedReport] = useState<Report | null>(null)
const [isModalOpen, setIsModalOpen] = useState(false) const [isModalOpen, setIsModalOpen] = useState(false)
const [duplicateContent, setDuplicateContent] = useState<string | null>(null) const [duplicateContent, setDuplicateContent] = useState<string | null>(null)

View File

@@ -5,7 +5,17 @@ export type Report = Database['public']['Tables']['reports']['Row'];
export type ReportInsert = Database['public']['Tables']['reports']['Insert']; export type ReportInsert = Database['public']['Tables']['reports']['Insert'];
export type ReportUpdate = Database['public']['Tables']['reports']['Update']; 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 type ReportType = (typeof REPORT_TYPES)[number];
export const CreateReportSchema = z.object({ export const CreateReportSchema = z.object({