feat(swift): implementeer AI-filtering psychiater voor overdracht (E5.S1)

E5.S1 compleet: AI filtert op behandelrelevantie voor psychiaters.
Voortgang: 56 SP / 72 SP (78%) - Epic 5 in progress!

Implementatie:
- Twee-staps filtering: Server (include_in_handover=true) → AI (psychiater: behandelrelevant)
- Role toggle UI: Verpleegkundige/Psychiater knoppen in OverdrachtBlock
- buildSystemPrompt(role) functie met psychiater-specifieke filtering regels
- filterForRole parameter toegevoegd aan GenerateOverdrachtSchema
- API route verwerkt role parameter en stuurt door naar Claude AI

Psychiater filtering regels:
 WEL RELEVANT:
- Medicatie-issues: weigering, bijwerkingen, dosisaanpassingen
- Stemming/gedrag: veranderingen, afwijkend gedrag, agitatie
- Risico-signalen: suïcidaliteit, automutilatie, agressie
- Psychotische symptomen: wanen, hallucinaties
- Crisis/dwang: separatie, fixatie, dwangmedicatie
- Afwijkende vitals: HH, LL met behandelimpact

 FILTER UIT:
- Routine medicatie ("volgens schema", "zonder problemen")
- ADL activiteiten (douchen, eten) tenzij significant afwijkend
- Sociale activiteiten ("groepstherapie", "gesprek gehad")
- Standaard observaties ("rustige dag", "geen bijzonderheden")
- Routine vitals (normaal bereik, N interpretatie)
- Dagstructuur ("dagprogramma gevolgd")

UI/UX verbeteringen:
- Role toggle met 2 knoppen (verpleegkundige/psychiater)
- Visual hints: "Alle gemarkeerde items" vs "Behandelrelevante items"
- Dynamic description tekst onder toggle
- filterRole state + useCallback dependency update

Files Changed:
- lib/types/overdracht.ts: +1 line (filterForRole in schema)
- lib/ai/overdracht-prompt.ts: +52 lines (buildSystemPrompt functie)
- app/api/overdracht/generate/route.ts: +8/-8 lines (role parameter)
- components/swift/blocks/overdracht-block.tsx: +43 lines (UI + logic)

Technische details:
- filterForRole default: 'verpleegkundige'
- Psychiater max: 3 aandachtspunten, 2 actiepunten
- Verpleegkundige max: 5 aandachtspunten, 3 actiepunten
- Role parameter propageert van UI → API → Claude prompt

Testing:
- Build succesvol (pnpm build)
- Geen nieuwe type errors
- UI toggle functioneel

Voortgang: 56 SP / 72 SP (78%) - E5.S1 compleet (5 SP)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
colinislit
2025-12-27 17:44:09 +01:00
parent 03f252d162
commit c6616d85b2
4 changed files with 104 additions and 8 deletions

View File

@@ -9,7 +9,7 @@ import { createClient } from '@/lib/auth/server';
import { NextRequest, NextResponse } from 'next/server';
import { z } from 'zod';
import {
OVERDRACHT_SYSTEM_PROMPT,
buildSystemPrompt,
buildOverdrachtUserPrompt,
calculateAge,
formatPatientName,
@@ -154,7 +154,10 @@ async function loadOverdrachtContext(
/**
* Call Claude API
*/
async function callClaudeAPI(context: OverdrachtContext): Promise<{
async function callClaudeAPI(
context: OverdrachtContext,
role: 'psychiater' | 'verpleegkundige' = 'verpleegkundige'
): Promise<{
samenvatting: string;
aandachtspunten: Aandachtspunt[];
actiepunten: string[];
@@ -164,6 +167,7 @@ async function callClaudeAPI(context: OverdrachtContext): Promise<{
throw new Error('ANTHROPIC_API_KEY ontbreekt in environment');
}
const systemPrompt = buildSystemPrompt(role);
const userPrompt = buildOverdrachtUserPrompt(context);
const response = await fetch('https://api.anthropic.com/v1/messages', {
@@ -177,7 +181,7 @@ async function callClaudeAPI(context: OverdrachtContext): Promise<{
model: 'claude-sonnet-4-20250514',
max_tokens: 2048,
temperature: 0.3,
system: OVERDRACHT_SYSTEM_PROMPT,
system: systemPrompt,
messages: [{ role: 'user', content: userPrompt }],
}),
});
@@ -277,7 +281,7 @@ export async function POST(request: NextRequest) {
);
}
const { patientId, period } = result.data;
const { patientId, period, filterForRole } = result.data;
const supabase = await createClient();
// Check auth
@@ -289,8 +293,8 @@ export async function POST(request: NextRequest) {
// Load context with period filter
const context = await loadOverdrachtContext(supabase, patientId, period);
// Call Claude API
const aiResult = await callClaudeAPI(context);
// Call Claude API with role-specific filtering
const aiResult = await callClaudeAPI(context, filterForRole);
const durationMs = Date.now() - startTime;