Commit Graph

46 Commits

Author SHA1 Message Date
colinislit
96848ecc81 chore(strip): verwijder behandelplan-module
AI-generatie negeerde de geregistreerde diagnose en ernst — elk plan was
generiek (reviewbevinding). Module komt terug bij de rebuild, gekoppeld
aan het nieuwe datamodel.

- app/epd/patients/[id]/behandelplan/ en /api/behandelplan/ verwijderd
- components/behandelplan/ (view, list, forms) verwijderd
- lib/ai/behandelplan-prompt.ts, lib/ai/intervention-mapping.ts,
  lib/types/behandelplan.ts verwijderd
- behandelplan-sectie uit patientdashboard, dashboard-API en
  Cortex patient-dashboard-block
- 'Doorzetten naar behandelplan' uit behandeladvies-formulier

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:47:58 +02:00
colinislit
a8b02c1ef3 chore(strip): verwijder kapotte intake-tabs anamnese, onderzoeken en ROM
Opslaan faalde altijd door label/code-mismatch met de database-constraints
(reviewbevinding). Tabs komen terug bij de rebuild op het nieuwe datamodel.

- tab-mappen anamnese/, examination/, rom/ verwijderd
- tabs uit intake-tabs.tsx, server actions uit actions.ts
- intake-status API telt de secties niet meer mee (voortgangsring klopt)
- Cortex-navigatiedoelen (regex, entity-mapping, prompt) bijgewerkt zodat
  'ga naar anamnese' geen 404 meer geeft

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:44:09 +02:00
colinislit
10c994b252 chore(strip): fase 0 — verwijder marketing, leads, archive en sitemap
Prototype-ballast verwijderd als eerste stap van de ECD-rebuild:
- app/(marketing) incl. blog, contact, documentatie + lib/mdx, lib/content, content/
- /api/leads en publieke marketing-routes uit middleware
- app/epd/_archive (backup van clients-module)
- sitemap.ts (verwees alleen naar blog), globals.css.backup
- root / redirect naar /login; robots.txt op disallow-all (afgeschermd systeem)

FHIR-routes blijven bewust staan: /api/fhir/Patient is de facto de
patienten-API voor dossier, agenda en Cortex — vervangen volgt in fase 3.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:21:20 +02:00
colinislit
924988dd15 feat(cortex): no-show casus — intent flow, brief-rescript en document artifact
Cortex handelt een no-show af vanuit één chatcommando: afspraak
annuleren (declarabiliteits-nudge), en de openstaande concept-
huisartsbrief wordt via LLM herschreven en ter review aangeboden
in een document artifact (human-in-the-loop, PATCH dispatch zet
status op verzendklaar).

- API-routes: context, rescript, cancel, dispatch
- NoShowDocumentBlock: review/edit UI met origineel-vergelijk
- Mock-data voor concept huisartsbrief
- PRD, FO, bouwplan en epics in docs/intent/noshow-case/

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 23:14:55 +02:00
colinislit
cdeea793bd feat(cortex): update chat/nudge flow, deepgram streaming and agenda form
Refines chat panel, nudge messages and artifact rendering, reworks
deepgram token/streaming handling, and adds test tooling deps
(playwright, cypress) to package.json.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-09 22:37:46 +02:00
colinislit
601ad8c3f0 fix(cortex): integrate intake intents into full chat + artifact flow
Fixes 4 bugs preventing intake blocks from working:

1. Chat API validation: Add 'nudge' to message type enum, allow empty
   content for streaming messages
2. AI chat recognition: Add P3 intake intents (intake_status,
   risico_query, diagnose_query, intake_navigeer) to system prompt
   with triggers, entities, and JSON examples
3. Artifact rendering: Add intake block imports and switch cases
   to artifact-container.tsx
4. API 400 error: Convert null to undefined for optional Zod params
   (searchParams.get returns null, Zod .optional() expects undefined)

Also adds:
- Testplan for E2E testing (60+ test cases)
- Session log with lessons learned and new intent checklist

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:07:10 +01:00
colinislit
b095b1e492 feat(cortex): add Intake Blocks MVP for voice/text commands
Adds 4 new intents for intake workflow:
- intake_status: shows completion percentage and section checklist
- intake_navigeer: navigation to specific intake tabs
- risico_query: displays risk assessments with severity indicators
- diagnose_query: shows primary/secondary diagnoses

New components:
- IntakeStatusBlock, RisicoBlock, DiagnoseBlock
- Shared block components (BlockLoading, BlockError, BlockEmpty, BlockSection, BlockItem, BlockFooter)
- useBlockData and useIntakeContext hooks

New API routes:
- GET /api/cortex/intake/status
- GET /api/cortex/intake/risico
- GET /api/cortex/intake/diagnose

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:21:18 +01:00
colinislit
e77a63f25e feat(cortex): droge humor persoonlijkheid voor Cortex Assistent
System prompt aangepast voor nuchtere, understated tone of voice:
- Kernkwaliteit "Nuchter" toegevoegd
- Tone of voice: droog en behulpzaam ipv vriendelijk
- Stijlvoorbeelden sectie met concrete frases
- 6 voorbeeldresponses aangepast naar kortere, drogere stijl
- Error messages menselijker ("Hmm, snap niet helemaal...")

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:30:58 +01:00
colinislit
43d4d095ce fix: case-insensitive voornaam zoeken door capitalize toe te passen
Voornaam zoeken werkte niet omdat name_given array case-sensitive is.
Capitalize nu de zoekterm (eerste letter hoofdletter) voordat deze
wordt gebruikt in de array search, zodat 'jan' matcht met 'Jan'.

Aangepast in beide search endpoints:
- /api/patients/search
- /api/cortex/patients/search
2026-01-03 11:47:12 +01:00
colinislit
52e07aaf80 fix(cortex): update date handling in API and UI components
- Adjusted date handling in the agenda API to ensure optional parameters for start, end, and label are correctly processed.
- Enhanced chat input and action parser to support optional date labels for relative dates.
- Updated agenda components to handle date ranges and loading states more effectively.
- Improved error handling and loading indicators in the agenda block for better user experience.

This commit ensures consistency in date handling across the application, aligning with the new requirements for relative date inputs.
2026-01-02 09:21:37 +01:00
colinislit
011815072b refactor(cortex): consistente datumbepaling met referenceDate parameter
SOC: Parser en entity-extractor accepteren nu optionele referenceDate
parameter. Caller bepaalt wat "nu" is, niet de functies intern.

Wijzigingen:
- parseRelativeDate(input, referenceDate?) - referenceDate parameter
- extractEntities(input, intent, referenceDate?) - doorgeeft aan parser
- API routes gebruiken new Date() als referenceDate

Verwijderd (YAGNI):
- lib/utils/server-date.ts - wrapper om new Date() was overbodig

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-02 08:49:20 +01:00
colinislit
b36df63d03 feat(cortex): Epic 2 - Intent Orchestrator (Layer 2) complete
Implements AI-powered multi-intent classification for Cortex V2.
When Reflex Arc (Layer 1) detects complexity, it escalates to
the Orchestrator for intelligent classification using Claude 3.5 Haiku.

E2.S1 - System prompt for Orchestrator
- ORCHESTRATOR_SYSTEM_PROMPT constant with Dutch instructions
- Multi-intent detection (en, daarna, ook, eerst, vervolgens)
- Pronoun resolution rules (hij/zij → active patient)
- JSON-only output format specification

E2.S2 - Context formatting for AI
- formatContextForPrompt() with emoji structure
- Dutch labels for shifts and views
- Graceful null handling, token limiting (max 5 agenda, 3 recent)

E2.S3 - AI classification endpoint
- classifyWithOrchestrator() calling Claude 3.5 Haiku
- Builds IntentChain from AI response
- Tracks tokens used and processing time

E2.S4 - IntentChain parsing with Zod
- parseAIResponse() with Zod schema validation
- Strips markdown code blocks
- Partial extraction for malformed responses
- Graceful fallback to intent: 'unknown'

E2.S5 - POST /api/cortex/classify hybrid endpoint
- Reflex first, escalate to Orchestrator if needed
- Response includes handledBy: 'reflex' | 'orchestrator'
- Auth check, feature flag check, request validation

E2.S6 - Graceful fallback
- buildFallbackChain() with confidence cap (0.6)
- buildChainFromReflex() for simple chains
- classifyWithTimeout() wrapper (5s default)

New files:
- lib/cortex/orchestrator.ts (~780 lines)
- app/api/cortex/classify/route.ts (~180 lines)

Key deliverable: "Zeg Jan af en maak notitie" correctly
parsed into 2 actions in an IntentChain.

Progress: 27 SP / 48 SP (56%) - E0, E1, E2 complete

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 11:28:14 +01:00
colinislit
cf26022583 feat(cortex): Epic 0 - Foundation & Context voor V2 architectuur
Implementeert de basis voor de Cortex V2 three-layer architecture.

E0.S1 - CortexContext Types (lib/cortex/types.ts):
- EscalationReason type voor Reflex → Orchestrator
- LocalClassificationResult met ambiguity detection
- CortexContext voor AI classificatie context
- IntentChain en IntentAction voor multi-intent flows
- NudgeSuggestion voor proactieve suggesties
- CONFIDENCE_THRESHOLD (0.7) en AMBIGUITY_THRESHOLD (0.1)
- getCurrentShift() utility (DRY - herbruikbaar)

E0.S2 - Context API (app/api/cortex/context/route.ts):
- GET endpoint voor huidige context
- Haalt agenda vandaag op uit database
- Retourneert CortexContext object

E0.S3 - Feature Flags (lib/config/feature-flags.ts):
- CORTEX_V2_ENABLED, CORTEX_MULTI_INTENT
- CORTEX_NUDGE, CORTEX_LOGGING
- isFeatureEnabled() helper
- Dev mode: default true

E0.S4 - CortexStore V2 (stores/cortex-store.ts):
- Types geïmporteerd uit lib/cortex (DRY)
- ChatEntities type voor AI responses (string-based)
- V2 state: context, activeChain, chainHistory, suggestions
- V2 actions: chain management, nudge management, clarification

E0.S5 - Classification Logging (lib/cortex/logger.ts):
- PII sanitization (BSN, tel, namen, email)
- logClassification(), logEscalation(), logNudge()
- logPerformance() met threshold checks

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 12:46:35 +01:00
colinislit
2170b23348 refactor: rename swift → cortex in code and documentation
Complete rename of "swift" terminology to "cortex" across the codebase:

Code Changes:
- Rename directories: lib/swift → lib/cortex, components/swift → components/cortex
- Rename API routes: /api/swift/* → /api/cortex/*
- Rename page routes: /epd/swift → /epd/cortex
- Rename store: swift-store.ts → cortex-store.ts

Type Renames:
- SwiftIntent → CortexIntent
- SwiftStore → CortexStore
- useSwiftStore → useCortexStore
- SwiftContext → CortexContext
- useSwiftVoice → useCortexVoice

Documentation Updates (docs/intent/):
- Safety Net → Nudge (Layer 3 rename)
- SafetySuggestion → NudgeSuggestion
- evaluateSafetyNet → evaluateNudge
- SWIFT_* feature flags → CORTEX_*
- All path references updated to match new structure

Files affected: 47 files, ~700 lines changed

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 09:18:06 +01:00
colinislit
c8aaba657e refactor(swift): update references from Medical Scribe to Swift Assistent
- Updated comments and documentation to reflect the new branding of the chat API and related components.
- Renamed functions and variables to align with the Swift Assistent terminology.
- Enhanced UI components with animations using Framer Motion for a smoother user experience.
- Removed outdated architecture documentation related to the Medical Scribe system.

This change is part of the transition to the Swift Assistent branding, ensuring consistency across the application.
2025-12-29 22:40:34 +01:00
colinislit
14a9d34337 feat(swift): voeg chat orchestration toe (E5)
Epic 5 compleet: Chat orchestration voor Swift Agenda Planning.
Alle agenda intents worden nu correct gerouteerd naar AgendaBlock
met user-friendly error handling en fallback opties.

E5.S1 - Action Routing (2 SP)
- routeIntentToArtifact() functie in action-parser
- Maps agenda intents naar juiste AgendaBlock mode
- Confidence threshold enforcement (< 0.7 → fallback)
- Required entity validation (patient voor create, identifier voor reschedule)
- Command-input gebruikt nieuwe routing ipv legacy openBlock
- Migratie naar modern artifact systeem (openArtifact)

E5.S2 - Chat Prompt Update (2 SP)
- 4 agenda intents toegevoegd aan Swift chat system prompt
- agenda_query: afspraken opvragen op datumrange
- create_appointment: nieuwe afspraak maken (required: patient, datetime)
- cancel_appointment: afspraak annuleren (disambiguation support)
- reschedule_appointment: afspraak verzetten (required: identifier)
- Entity extraction rules gedocumenteerd (dateRange, datetime, identifier)
- 4 complete voorbeelden met JSON action format
- Clarification questions voor incomplete data
- Prompt size: ~325 → ~525 regels (+60%)

E5.S3 - Error States (2 SP)
- AgendaErrorState component voor full-page errors
- AgendaErrorAlert component voor inline form errors
- getUserFriendlyMessage() vertaalt technical → user-friendly Dutch
- Auto-redirect bij auth errors (401 → /login)
- Fallback link naar /epd/agenda in alle error states
- Context-aware messaging (query/create/cancel/reschedule)
- Retry functionaliteit voor recoverable errors
- Dev-only technical details collapsible

Error message mapping:
- 401 → "Je sessie is verlopen. Log opnieuw in." + auto-redirect
- 403 → "Je hebt geen toegang tot deze afspraak."
- 404 → "De gevraagde afspraak kon niet worden gevonden."
- 500 → "Er ging iets mis op de server. Probeer het opnieuw."
- Network → "Geen internetverbinding. Controleer je netwerkverbinding."
- Timeout → "De aanvraag duurde te lang. Probeer het opnieuw."

Components updated:
- command-input: gebruikt routeIntentToArtifact + openArtifact
- agenda-create-form: gebruikt AgendaErrorAlert met fallback link
- chat/route: uitgebreide system prompt met agenda sectie

Nieuwe files:
- lib/swift/action-parser.ts: routeIntentToArtifact() functie
- components/swift/artifacts/blocks/agenda-error-state.tsx (225 regels)
- docs/swift/implementation-e5-s1-action-routing.md
- docs/swift/implementation-e5-s2-chat-prompt.md
- docs/swift/implementation-e5-s3-error-states.md

Documentatie:
- Bouwplan bijgewerkt: Epic 5 → Done
- 3 implementation docs met API specs en testing scenarios
- Error handling best practices gedocumenteerd

Progress: 48 SP / 51 SP (94%) - Epic 6 (QA) remaining

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 22:44:18 +01:00
colinislit
d2ffccc22b feat(swift): voeg agenda backend API's toe (E3)
Epic 3 compleet: Backend integratie voor Swift Agenda Planning.

Nieuwe endpoints:
- GET /api/swift/agenda - Query afspraken op datumrange
- POST /api/swift/agenda/create - Nieuwe afspraak aanmaken
- POST /api/swift/agenda/cancel - Afspraak annuleren
- POST /api/swift/agenda/reschedule - Afspraak verzetten
- GET /api/swift/patients/search - Fuzzy patiënt zoeken

Alle endpoints bevatten:
- Supabase authenticatie + resource ownership checks
- Zod validatie met Nederlandse foutmeldingen
- Hergebruik van bestaande agenda server actions

Test documentatie: docs/swift/test-plan-epic3-backend.md

Progress: 3/7 Epics compleet (E0, E1, E2, E3)
Story points: 11 SP (E3.S1: 3, E3.S2: 3, E3.S3: 3, E3.S4: 2)
2025-12-27 22:12:01 +01:00
colinislit
43467f07fa feat: show patient dashboard artifact on selection 2025-12-27 20:50:39 +01:00
colinislit
adf6c3fb96 feat(swift): implementeer linked evidence UI voor overdracht (E5.S2)
E5.S2 compleet: Bronnotitie links met hover preview in OverdrachtBlock.
Voortgang: 66 SP / 82 SP (80%) - Epic 5 40% compleet!

Implementatie:
- Bronverwijzingen nu klikbaar met hover popover voor volledige content
- Source data enrichment in API response
- Type-specific content display (observaties, rapportages, risico's)
- Visual feedback met icons en kleuren per bron type

Components & Types:
- LinkedEvidence component (160 regels) - Reusable popover voor alle bron types
- Aandachtspunt type extended met optionele sourceData field
- enrichWithSourceData() functie in API route (48 regels)

LinkedEvidence Features:
- Hover popover met volledige bron content
- Type-specific icons: Activity (observatie), FileText (rapportage), AlertTriangle (risico)
- Click/hover trigger met underline-dotted styling
- ExternalLink icon voor visual affordance
- Popover positioning: top-start voor beste UX

Source Data per Type:
- Observaties: value + unit + interpretation (HH/H/N/L/LL) met kleuren
- Rapportages/Verpleegkundig: content + createdBy
- Risico's: riskLevel + rationale met severity kleuren

API Enrichment Logic:
- enrichWithSourceData() lookup in context (vitals, reports, risks)
- Source data toegevoegd aan aandachtspunten vóór response
- Type-safe matching op bron.id en bron.type
- Backwards compatible: werkt met/zonder sourceData

UI/UX Improvements:
- Color-coded interpretations: Red (HH/LL kritiek), Amber (H/L), Teal (N)
- Color-coded risk levels: Red (zeer hoog/hoog), Amber (gemiddeld), Teal (laag)
- Formatted text display met bg-slate-50 border
- Responsive popover met max-width 96 (384px)
- Fallback: geen sourceData = plain text zonder popover

Integration in OverdrachtBlock:
- AandachtspuntItem gebruikt LinkedEvidence component
- Replaced: "bron.label • bron.datum" plain text
- Now: LinkedEvidence met hover preview

Files Changed:
- lib/types/overdracht.ts: +12 lines (sourceData interface)
- app/api/overdracht/generate/route.ts: +58 lines (enrichWithSourceData)
- components/swift/blocks/overdracht-block.tsx: +1/-3 lines (LinkedEvidence import/usage)
- components/swift/shared/linked-evidence.tsx: +160 lines (NEW)

Technical Details:
- Popover from shadcn/ui (@/components/ui/popover)
- Icons from lucide-react (Activity, FileText, AlertTriangle, ExternalLink)
- Type guards voor safe property access (sourceData?.value)
- Underline decoration-dotted cursor-help voor accessibility

Testing:
- Build succesvol (pnpm build)
- /epd/swift: 143 kB (+24 kB door LinkedEvidence component)
- Geen nieuwe type errors
- Popover trigger werkt met keyboard (accessible)

Voortgang: 66 SP / 82 SP (80%) - E5.S2 compleet (3 SP)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 18:38:45 +01:00
colinislit
c6616d85b2 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>
2025-12-27 17:44:09 +01:00
colinislit
8efac8483f feat(swift): implementeer medical scribe system prompt (E3.S3)
Epic 3 Story 3 compleet: Volledige medical scribe prompt v1.0 geïmplementeerd.

E3.S3 - Medical Scribe System Prompt (3 SP)
- buildMedicalScribePrompt() functie (243 regels)
- Intent detection voor P1 intents: dagnotitie, zoeken, overdracht
- P2 intents: rapportage, agenda
- Confidence thresholds (>0.9, 0.7-0.9, 0.5-0.7, <0.5)
- JSON action object format met artifact prefill
- Context injection (activePatient, shift)
- Verduidelijkingsvragen en error handling
- Nederlands tone of voice (vriendelijk, professioneel, to-the-point)
- 4 voorbeelden: happy path, zoeken, verduidelijking, onduidelijke intent

Key Features:
- Intent herkenning met triggers en entities
- Automatische category detection (medicatie/adl/gedrag/incident/observatie)
- Slim gebruik van context (activePatient als default)
- Follow-up conversatie support
- Error handling met Nederlandse messages

Prompt Structuur:
- Je rol: medical scribe voor Swift GGZ EPD
- Wat je doet: intents herkennen, verduidelijken, actions genereren
- Wat je NIET doet: medisch advies, aannames, lange uitleg
- Context: activePatient, shift injection
- Voorbeelden: 4 concrete user flows

Components Updated:
- app/api/swift/chat/route.ts: buildMedicalScribePrompt() functie

Documentatie:
- docs/swift/e0-medical-scribe-system-prompt.md (519 regels)
- docs/swift/e0-design-tokens-and-components.md (E0.S1 & E0.S2)
- docs/swift/bouwplan-swift-v3.md: E3.S3  compleet

Build Status:
-  pnpm build succesvol (geen type errors)
- Alleen bekende Supabase realtime warnings

Voortgang: 41 SP / 85 SP (48%) - E3.S3 compleet

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 14:46:26 +01:00
colinislit
a51acf6214 feat(swift): voeg chat API met Claude streaming toe (E3.S1-S2)
E3.S1 - Chat API endpoint skeleton (3 SP)
- /api/swift/chat route met SSE setup
- Zod validation (message, messages, context)
- Authentication check (session required)
- Rate limiting (20 requests per minute)
- Request body schema voor chat messages en context

E3.S2 - Streaming response logic (5 SP)
- Claude API integration (Anthropic Sonnet 4)
- Real-time streaming via Server-Sent Events
- Event parsing (content_block_delta, message_stop, error)
- Simple system prompt met context injection
- Error handling voor API failures

API Route Features:
- Model: claude-sonnet-4-20250514
- Max tokens: 2048, Temperature: 0.7
- Conversation history: max 20 messages
- Rate limiting per user (20 req/min)
- Request cancellation support
- Context: activePatient + shift

SSE Event Format:
- content_block_delta → {"type":"content","text":"..."}
- message_stop → {"type":"done"}
- error → {"type":"error","error":"..."}

Client Helper (lib/swift/chat-api.ts):
- sendChatMessage() function voor frontend
- SSE stream parsing met TextDecoder
- Callbacks: onChunk, onDone, onError
- Error handling en retry logic

ChatPanel Integration:
- Real-time streaming met updateLastMessage()
- isStreaming state voor UI feedback
- Context injection (patient, shift)
- Error messages in chat

System Prompt (Simple):
- Nederlandse medische assistent voor Swift GGZ EPD
- Context-aware (patiënt + dienst)
- Vriendelijk en professioneel
- Medical scribe functionaliteit komt in E3.S3

Files Created:
- app/api/swift/chat/route.ts (279 regels)
- lib/swift/chat-api.ts (113 regels)

Files Updated:
- components/swift/chat/chat-panel.tsx (+52 regels) - Streaming integration

Epic 3 Progress: 2/6 stories compleet (8 SP / 21 SP = 38%)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 14:26:16 +01:00
ikbenlit
2a67a0a2d9 git commit -m "feat(swift): implement Epic 3 - P1 Blocks (E3.S0-S6)" -m "Epic 3 compleet: Alle P1 blocks geïmplementeerd met volledige functionaliteit." -m "E3.S0 - CanvasArea block rendering" -m "- Switch/case voor block types met prefill data" -m "- AnimatePresence voor smooth transitions" -m "- PatientContextCard auto-display wanneer activePatient is gezet" -m "" -m "E3.S1 - Block Container animaties" -m "- Framer Motion animaties voor container, content en close button" -m "- Stagger effecten voor content children" -m "- Hover/tap animaties voor close button" -m "" -m "E3.S2 - DagnotatieBlock" -m "- Patient search met debounced FHIR API integratie" -m "- Category selector (medicatie, adl, gedrag, incident, observatie)" -m "- Textarea met character counter (max 500)" -m "- Opslaan naar /api/reports met validatie en error handling" -m "" -m "E3.S3 - Patient search API" -m "- GET /api/patients/search?q= met fuzzy search" -m "- Match score berekening voor resultaten" -m "- Auth check en error handling" -m "" -m "E3.S4 - ZoekenBlock" -m "- Debounced patient search met dropdown" -m "- Patient selectie → setActivePatient in store" -m "- Auto-close na selectie + recent action" -m "" -m "E3.S5 - PatientContextCard" -m "- Auto-open na patient selectie" -m "- Notities, vitals, diagnoses en risico's secties" -m "- API integratie met /api/overdracht/[patientId]" -m "" -m "E3.S6 - OverdrachtBlock" -m "- Lijst van patiënten met activiteit" -m "- Period selector (1d, 3d, 7d, 14d)" -m "- AI samenvatting generatie per patiënt" -m "- Aandachtspunten en actiepunten weergave" -m "" -m "Technische verbeteringen:" -m "- Technische debt opgelost: BlockContainer animaties, CanvasArea rendering" -m "- PatientContextCard toegevoegd aan blocks" -m "- Alle blocks gebruiken BlockContainer voor consistente styling" -m "" -m "Voortgang: 56 SP / 72 SP (78%) - Epic 3 compleet" 2025-12-24 09:06:39 +01:00
colinislit
db036a3d92 feat(swift): E2 Intent Classification voltooid
Epic 2 - Intent Classification (10 SP):
- E2.S1: Local classifier met regex patterns (<50ms)
- E2.S2: Entity extraction (patientName, category, content)
- E2.S3: AI fallback met Claude Haiku bij confidence <0.8
- E2.S4: POST /api/intent/classify API route

Two-tier systeem:
1. Lokale regex classificatie (snel, offline)
2. AI fallback voor lage confidence of complexe input

Bouwplan bijgewerkt naar v1.4 (31/68 SP, 46% done)

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

Co-Authored-By: Colin Lit <colin@example.com>
2025-12-23 22:59:30 +01:00
colinislit
56bea91d10 fix: Add dynamic export to overdracht/patients route
Next.js requires explicit dynamic marking for routes using request.url

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-12 15:29:20 +01:00
colinislit
0b2f55c1e4 perf: Performance optimalisaties (4 iteraties)
Iteratie 1 - Parallel Fetching:
- Patient dashboard: Promise.all voor 3 data fetches
- Resultaat: ~45% sneller (800ms → 440ms)

Iteratie 2 - Loading States:
- Skeleton loaders voor EPD, patient, agenda, rapportage
- Betere perceived performance tijdens laden

Iteratie 3 - Lazy Load FullCalendar:
- Dynamic import met next/dynamic (ssr: false)
- ~150KB minder in initiële bundle

Iteratie 4 - Reports API Optimalisatie:
- Selectieve kolommen (10 i.p.v. 20)
- Server-side pagination (limit/offset)
- Database indexes voor timeline queries
- Resultaat: 89% sneller (1671ms → 188ms)

Overige fixes:
- Type casts voor Json → Behandelstructuur/SmartGoal/etc.
- Metadata template fix in layout.tsx

Documentatie:
- docs/audit-rapport.md - PO-vriendelijk audit rapport
- docs/performance/baseline-2025-12-12.md - Metingen + resultaten

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-12 15:24:38 +01:00
colinislit
593bef4dcf feat(overdracht): Incident badges + expandable rapportage content
Incident telling:
- Nieuwe incident_count in PatientOverzicht alerts
- Telt type='incident', 'crisis' én verpleegkundig category='incident'
- Oranje badge in patiëntenlijst
- "Met alerts" filter includeert nu ook incidenten

Expandable content:
- Rapportages in timeline tonen nu volledige tekst
- "Lees meer" / "Minder tonen" toggle voor berichten >5 regels
- Behoudt whitespace/regeleinden in tekst

Opruiming:
- Oude screenshots verwijderd

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-08 14:26:07 +01:00
colinislit
75c7e284b9 feat(verpleegrapportage): Nieuwe module + opruiming codebase
Verpleegrapportage module:
- Nieuwe /epd/verpleegrapportage met patiëntenoverzicht
- Rapportage invoer workspace met timeline view
- Overdracht overzicht met AI-samenvatting
- API endpoints voor verpleegrapportage data

Opruiming:
- Oude /epd/overdracht en /epd/dagregistratie verwijderd (vervangen)
- Oude /api/nursing-logs verwijderd (geconsolideerd naar reports)
- Verouderde design docs en reports verwijderd
- Fonts verplaatst van docs/ naar public/fonts/

Bugfixes:
- Risk-manager: fix constraint violation (db values vs display labels)
- Overdracht API: filter op rapportages i.p.v. encounters

Database:
- Migratie voor consolidatie nursing_logs naar reports tabel

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-08 11:19:48 +01:00
colinislit
d622ac8035 feat(overdracht): E2 + E3 - API overdracht en dagregistratie UI
Epic 2 - API Overdracht:
- GET /api/overdracht/patients (patiënten met alerts)
- GET /api/overdracht/[patientId] (detail met vitals, reports, logs, risks)
- POST /api/overdracht/generate (AI samenvatting met bronverwijzingen)
- lib/ai/overdracht-prompt.ts (system + user prompt)
- lib/types/overdracht.ts (TypeScript types)

Epic 3 - Dagregistratie UI:
- /epd/dagregistratie/[patientId] pagina
- Quick entry form (categorie, tijd, tekst, overdracht checkbox)
- Edit/Delete functionaliteit met inline editing
- Confirm delete dialog
- Summary cards (totaal, overdracht, incidenten)

Bouwplan bijgewerkt naar v1.2 (10/19 stories voltooid)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 00:18:06 +01:00
colinislit
08cffd0245 feat(overdracht): E0 + E1 - Database setup en API nursing logs
Epic 0 - Database Setup:
- nursing_logs tabel met indexes en constraints
- RLS policies (SELECT/INSERT/UPDATE/DELETE)
- TypeScript types gegenereerd

Epic 1 - API Nursing Logs:
- GET/POST /api/nursing-logs (lijst + aanmaken)
- PATCH/DELETE /api/nursing-logs/[id] (bewerken + verwijderen)
- Zod validatie schemas
- Automatische shift_date berekening

Documentatie:
- PRD, FO, TO en Bouwplan voor Overdracht Dashboard

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 00:03:18 +01:00
colinislit
ac98070fe4 | E2.S1 | Prompt engineering | System prompt + user prompt templates, evidence-based mapping
| E2.S2 | Generate endpoint | `POST /api/behandelplan/generate` retourneert JSON, < 8 sec response
| E2.S3 | AI event logging | Calls loggen naar `ai_events` tabel

new file:   app/api/behandelplan/generate/route.ts
modified:   docs/specs/behandelplan/bouwplan-behandelplan-v1.md
modified:   docs/templates/bouwplan_template.md
new file:   lib/ai/behandelplan-prompt.ts
new file:   lib/ai/intervention-mapping.ts
modified:   lib/supabase/database.types.ts
2025-12-04 09:27:12 +01:00
colinislit
b7b5a0888b feat(agenda): Epic 4 - EPD Koppeling (appointment-report integration)
Implements bidirectional linking between appointments and reports:
- E4.S1: Create report from appointment modal with encounter pre-linked
- E4.S2: Link existing reports to appointments via EncounterSelector
- E4.S3: Show linked reports in appointment modal edit view
- E4.S4: Navigation between appointments and reports with deep linking

Also includes bug fixes for patient search:
- Fix FHIR to internal format mapping for patient data
- Fix debounced search interference after patient selection
- Fix UUID handling for optional practitioner_id

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 19:34:07 +01:00
colinislit
e661c97491 feat(agenda): Epic 1 - Calendar views with FullCalendar
- E1.S1: FullCalendar setup with React wrapper
- E1.S2: Day view (timeGridDay) with hourly slots
- E1.S3: Week view (timeGridWeek) with 7-day grid
- E1.S4: Workweek view (timeGridWorkWeek, Mon-Fri)

Features:
- View switcher toolbar (Dag/Week/Werkweek)
- Date navigation (prev/next/today)
- Dutch localization (nl)
- Business hours highlighting (08:00-18:00)
- Color-coded appointments by type
- Drag-and-drop rescheduling support
- Server actions for encounter CRUD

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 17:13:55 +01:00
colinislit
aacada2197 chat suggestions, SEo integration, and more 2025-12-02 13:37:45 +01:00
colinislit
9dc2b4f216 feat: add rate limiting with countdown timer for docs chat
- Add in-memory rate limiter (10 requests/minute per user)
- Show informative message when limit reached explaining demo context
- Display countdown timer showing when chat becomes available again
- Auto-reset rate limit when timer expires
- Update documentation with rate limit FAQ and category selection flow

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 18:00:51 +01:00
colinislit
54f2c36eba finalize ai assistenat 2025-12-01 16:14:30 +01:00
colinislit
183021718a feat: add docs chat api 2025-12-01 15:29:29 +01:00
colinislit
56b66ae6ff feat: improve streaming mic and deepgram token handling 2025-11-25 22:53:04 +01:00
colinislit
dce3943963 feat: rapportage UI refactor, speech streaming, docs & seed data
Rapportage:
- Refactor workspace into modular components (quick-actions, timeline-card, timeline-sidebar)
- Add updateReport action for inline editing
- Improve report timeline with better UX

Speech:
- Add Deepgram token API endpoint
- Add use-deepgram-streaming hook
- Add confidence-text component

Docs:
- Add architecture documentation
- Add performance optimization plan
- Add speech specs and seed data docs

Scripts & Data:
- Add seed-reports script and migration
- Update AGENTS.md guidelines

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 14:07:08 +01:00
colinislit
7033329e0f feat: add speech telemetry and bundle guard 2025-11-25 13:37:00 +01:00
colinislit
a789bebe96 feat: rapportage API, speech recorder refactor, docs reorganisatie
Multiple features and improvements:

Reports/Rapportage API:
- Created REST API endpoints: /api/reports (GET/POST), /api/reports/[id] (GET/PATCH/DELETE)
- Added /api/reports/classify endpoint for AI classification
- Supabase migrations: reports table + RLS policies
- Server utilities: api-client.ts for DRY fetch logic
- Type definitions: lib/types/report.ts with Zod schemas
- Removed old rapportage-modal component (replaced by split-view)

Speech Recorder Refactor:
- Moved speech-recorder from intake-specific to shared components/
- Updated treatment-advice-form to use new location
- Updated intake actions for speech functionality

UI Components (shadcn):
- Added dialog, dropdown-menu, toast, toaster components
- Added use-toast hook for toast notifications

Documentation:
- Reorganized docs/release/ → docs/reports/ for better structure
- Archived old specs to docs/specs/archive/
- Added screening-system.mdx documentation
- Added rapportage-split-view-design.md
- Added UI screenshots for troubleshooting

Dependencies:
- Updated package.json and pnpm-lock.yaml
- Regenerated database.types.ts from Supabase

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 14:14:06 +01:00
colinislit
00ca026382 fix: stabilize build and archive configs 2025-11-23 11:42:40 +01:00
colinislit
6fcb9a0e7b feat: migrate clients module to patients + add docs 2025-11-23 10:13:00 +01:00
colinislit
86995a4466 feat: implement patient list and new patient form (E2.S1 & E2.S2)
Epic 2 - Cliëntenbeheer: Complete implementation of patient list with
search/filter functionality and comprehensive new patient form with
John Doe crisis admission support.

E2.S1 - Cliëntenlijst:
- Add client-side search bar with form submission
- Implement status filter dropdown (all/screening/active/finished/cancelled)
- Create StatusBadge component with color-coded status indicators
- Update table columns: Status, Name, BSN, Last Updated
- Add status filtering support to FHIR Patient API route
- Update FHIR patient transform to include episode-status extension
- Sort patients by updated_at descending (newest first)

E2.S2 - Nieuwe Cliënt Flow:
- Complete rewrite of patient form with all FO-required fields
- Implement John Doe checkbox with conditional BSN requirement
- Add BSN validation with Dutch Modulo-11 check algorithm
- Add comprehensive form fields:
  * Name fields: prefix, given name, family name
  * BSN with 9-digit pattern validation
  * Birth date with max date validation
  * Gender selection
  * Address: street, postal code, city
  * Contact: phone, email
  * Insurance: company, policy number
- Add warning messages for John Doe crisis admissions
- Set default episode status to 'planned' for all new patients
- Redirect to patient detail page after successful creation
- Update FHIR transform bidirectional insurance extension support:
  * dbPatientToFHIR: serialize insurance to JSON extension
  * fhirPatientToDB: parse insurance from JSON extension
- Pre-populate form fields when editing existing patients

Technical changes:
- app/api/fhir/Patient/route.ts: Add status query param and sorting
- app/epd/patients/actions.ts: Add status filter parameter
- app/epd/patients/page.tsx: Pass status searchParam
- app/epd/patients/components/patient-list.tsx: Complete UI rewrite
- app/epd/patients/components/patient-form.tsx: Complete form rewrite
- lib/fhir/transforms/patient.ts: Add insurance extension handling
- docs/specs/screening-intake/bouwplan-screening-intake-v1.0.md: Update status

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 13:58:31 +01:00
colinislit
d5c6cf208b FHIR, API, datamodel 2025-11-21 22:32:29 +01:00
colinislit
99804656d7 RLS policies implementeren, Demo auth flow 2025-11-15 23:59:38 +01:00