Content loader utility, Content directory structuur
This commit is contained in:
979
docs/specs/archive/bouwplan.md
Normal file
979
docs/specs/archive/bouwplan.md
Normal file
@@ -0,0 +1,979 @@
|
||||
# 🚀 Mission Control — Bouwplan Mini-EPD Prototype
|
||||
|
||||
**Projectnaam:** Mini-EPD Prototype
|
||||
**Versie:** v1.0
|
||||
**Datum:** 10-11-2025
|
||||
**Auteur:** Development Team PinkRoccade GGZ
|
||||
|
||||
---
|
||||
|
||||
## 1. Doel en context
|
||||
|
||||
🎯 **Doel:** Een werkend mini-EPD prototype bouwen dat tijdens de AI-inspiratiesessie bij PinkRoccade GGZ de kernprocessen uit de GGZ demonstreert: **intake → probleemclassificatie → behandelplan**.
|
||||
|
||||
📘 **Toelichting:** Dit project focust op het zichtbaar maken van AI-waarde (samenvatten, structureren, plan genereren) in een herkenbare GGZ-workflow. De demo duurt maximaal 10 minuten en toont hoe AI zorgmedewerkers kan ondersteunen bij administratieve taken. Het systeem wordt gebouwd met fictieve data voor demonstratiedoeleinden.
|
||||
|
||||
**Belangrijkste doelen:**
|
||||
- Demonstreren van AI-toegevoegde waarde in ECD-processen
|
||||
- Herkenbare workflow voor GGZ-professionals
|
||||
- Inspiratie bieden voor AI-integratie in bestaande systemen
|
||||
- Direct bruikbare output (samenvattingen, behandelplannen) genereren
|
||||
|
||||
---
|
||||
|
||||
## 2. Uitgangspunten
|
||||
|
||||
### 2.1 Technische Stack
|
||||
|
||||
🎯 **Doel:** Complete technologie stack voor het mini-EPD prototype.
|
||||
|
||||
**Frontend:**
|
||||
- **Framework:** Next.js 14+ (App Router)
|
||||
- **Styling:** Tailwind CSS v3.4 (fallback vanaf v4 bij problemen)
|
||||
- **UI Componenten:** shadcn/ui of eigen headless componenten
|
||||
- **Rich Text Editor:** TipTap (ProseMirror basis)
|
||||
- **Iconen:** lucide-react
|
||||
- **State Management:** Zustand + React Context API
|
||||
|
||||
**Backend:**
|
||||
- **API:** Next.js Route Handlers (server-side)
|
||||
- **Database:** Supabase (PostgreSQL)
|
||||
- **Auth:** Supabase Auth
|
||||
- **Storage:** Supabase Storage
|
||||
- **AI Integration:** Claude API (Anthropic)
|
||||
|
||||
**DevOps & Tooling:**
|
||||
- **Hosting:** Vercel (EU region)
|
||||
- **Version Control:** Git/GitHub
|
||||
- **Type Safety:** TypeScript
|
||||
- **Validation:** Zod
|
||||
- **Testing:** Vitest (unit) + Playwright (E2E)
|
||||
- **PDF Export (stretch):** Chromium via Playwright/Puppeteer
|
||||
|
||||
### 2.2 Projectkaders
|
||||
|
||||
🎯 **Doel:** Vaste kaders waarbinnen het project wordt ontwikkeld.
|
||||
|
||||
- **Tijd:** 3 weken totale bouwtijd voor MVP
|
||||
- **Demo deadline:** Augustus 2025 (AI-inspiratiesessie)
|
||||
- **Budget:** Beperkt voor externe API calls (Claude AI)
|
||||
- **Team:** 1-2 developers + 1 consultant/product owner
|
||||
- **Data:** Uitsluitend fictieve demo-data (geen productiegegevens)
|
||||
- **Scope:** MVP features voor 10-minuten demo
|
||||
- **Gebruikers:** Demo-users met volledige toegang (simplified auth)
|
||||
- **Compliance:** Geen medische certificering vereist (demo only)
|
||||
|
||||
### 2.3 Programmeer Uitgangspunten
|
||||
|
||||
🎯 **Doel:** Code-kwaliteit principes en development best practices.
|
||||
|
||||
**Core Principles:**
|
||||
|
||||
- **DRY (Don't Repeat Yourself)**
|
||||
- Herbruikbare React componenten in `/src/components/ui/`
|
||||
- Shared utility functions in `/src/lib/utils/`
|
||||
- Centrale API client voor Supabase queries
|
||||
- Gedeelde prompt templates voor AI calls
|
||||
|
||||
- **SOC (Separation of Concerns)**
|
||||
- UI componenten gescheiden van business logic
|
||||
- Database queries in dedicated service layers (`/src/lib/services/`)
|
||||
- AI prompts in `/src/lib/ai/prompts/`
|
||||
- Styling via Tailwind classes, geen inline styles
|
||||
- Route handlers voor server-side operaties
|
||||
|
||||
- **KISS (Keep It Simple, Stupid)**
|
||||
- Directe Supabase queries zonder ORM overhead
|
||||
- Eenvoudige state management met Zustand
|
||||
- Minimale abstractie voor MVP scope
|
||||
- Clear component naming (e.g., `ClientList`, `IntakeEditor`)
|
||||
|
||||
- **YAGNI (You Aren't Gonna Need It)**
|
||||
- Geen multi-tenant setup voor demo
|
||||
- Basis auth zonder rollenbeheer
|
||||
- Skip complex caching voor MVP
|
||||
- Geen realtime features voor eerste versie
|
||||
|
||||
- **Security**
|
||||
- API keys alleen server-side (`ANTHROPIC_API_KEY`, `SUPABASE_SERVICE_ROLE_KEY`)
|
||||
- Input sanitization met Zod schemas
|
||||
- Row Level Security (RLS) policies in Supabase
|
||||
- CORS configuratie voor API endpoints
|
||||
- XSS protection via React's default escaping
|
||||
|
||||
---
|
||||
|
||||
## 3. Epics & Stories Overzicht
|
||||
|
||||
🎯 **Doel:** Complete overzicht van alle development epics met technische details.
|
||||
|
||||
| Epic ID | Epic Naam | Stories | Points | Status | Priority | Dependencies |
|
||||
|---------|-----------|---------|--------|--------|----------|--------------|
|
||||
| EP00 | Project Setup & Configuration | 5 | 13 | Done | Critical | - |
|
||||
| EP01 | Database & Data Model | 4 | 21 | Not Started | Critical | EP00 |
|
||||
| EP02 | Authentication & Authorization | 3 | 8 | Not Started | High | EP00, EP01 |
|
||||
| EP03 | Client Management | 5 | 21 | Not Started | High | EP01, EP02 |
|
||||
| EP04 | Intake Module | 6 | 34 | Not Started | Critical | EP03 |
|
||||
| EP05 | Problem Profile (DSM-light) | 4 | 21 | Not Started | High | EP04 |
|
||||
| EP06 | Treatment Plan Module | 5 | 34 | Not Started | High | EP05 |
|
||||
| EP07 | AI Integration | 5 | 34 | Not Started | Critical | EP04 |
|
||||
| EP08 | Dashboard & Navigation | 4 | 13 | Not Started | Medium | EP03 |
|
||||
| EP09 | UI Components & Styling | 5 | 21 | Not Started | Medium | EP00 |
|
||||
| EP10 | Testing & Quality Assurance | 4 | 13 | Not Started | High | All |
|
||||
| EP11 | Deployment & Demo Prep | 4 | 13 | Not Started | Critical | All |
|
||||
| EP12 | Stretch Features | 3 | 21 | Not Started | Low | EP06 |
|
||||
|
||||
**Totaal:** 57 stories | 257 story points
|
||||
|
||||
---
|
||||
|
||||
## 4. Epics & Stories (Uitwerking)
|
||||
|
||||
### Epic EP00 — Project Setup & Configuration
|
||||
**Epic Doel:** Complete development omgeving met alle tools en dependencies geconfigureerd.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP00-ST01 | Next.js project opzetten | 3 | Done | - |
|
||||
| EP00-ST02 | Tailwind CSS en UI libraries installeren | 3 | Done | EP00-ST01 |
|
||||
| EP00-ST03 | Supabase project aanmaken | 3 | Done | EP00-ST01 |
|
||||
| EP00-ST04 | Environment variables configureren | 2 | Done | EP00-ST03 |
|
||||
| EP00-ST05 | Git repository opzetten | 2 | Done | EP00-ST01 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP00-ST01:** Als developer wil ik een Next.js project opzetten zodat ik kan beginnen met development
|
||||
- ✅ Next.js 14+ met App Router
|
||||
- ✅ TypeScript configuratie
|
||||
- ✅ Folder structuur volgens conventions
|
||||
- ✅ Development server draait op localhost:3000
|
||||
|
||||
**EP00-ST02:** Als developer wil ik Tailwind CSS en UI libraries installeren zodat ik consistent kan stylen
|
||||
- ✅ Tailwind CSS v3.4 werkend
|
||||
- ✅ tailwind.config.ts met custom theme
|
||||
- ✅ lucide-react icons beschikbaar
|
||||
- ✅ shadcn/ui setup (components.json, utils.ts)
|
||||
|
||||
**EP00-ST03:** Als developer wil ik Supabase project aanmaken zodat ik database en auth kan gebruiken
|
||||
- ✅ Supabase project in EU region (dqugbrpwtisgyxscpefg)
|
||||
- ✅ Connection string in .env.local
|
||||
- ✅ Supabase client configured (lib/supabase/client.ts + server.ts)
|
||||
- ✅ TypeScript types generation script (pnpm run types:generate)
|
||||
|
||||
**EP00-ST04:** Als developer wil ik environment variables configureren zodat services veilig verbonden zijn
|
||||
- ✅ .env.local met alle keys (SUPABASE_URL, ANON_KEY, SERVICE_ROLE_KEY)
|
||||
- ✅ .env.example voor team
|
||||
- ⏳ Vercel environment variables (bij deployment EP11)
|
||||
- ✅ Validation bij startup (throws error if missing)
|
||||
|
||||
**EP00-ST05:** Als developer wil ik Git repository opzetten zodat code versiebeheerd is
|
||||
- ✅ GitHub repository
|
||||
- ✅ .gitignore configuratie
|
||||
- ⏳ Branch protection rules
|
||||
- ✅ Initial commit met setup
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **Database:** Gebruik Supabase EU-region (Frankfurt/London)
|
||||
- **Environment variables:**
|
||||
```
|
||||
NEXT_PUBLIC_SUPABASE_URL
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||
SUPABASE_SERVICE_ROLE_KEY
|
||||
ANTHROPIC_API_KEY
|
||||
```
|
||||
- **Folder structuur:**
|
||||
```
|
||||
/src
|
||||
/app (routes)
|
||||
/components
|
||||
/lib (utilities, services)
|
||||
/types
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Epic EP01 — Database & Data Model
|
||||
**Epic Doel:** Complete database schema met alle tabellen en relaties volgens TO specificatie.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP01-ST01 | Database tabellen creëren | 8 | Not Started | EP00-ST03 |
|
||||
| EP01-ST02 | Row Level Security policies implementeren | 5 | Not Started | EP01-ST01 |
|
||||
| EP01-ST03 | Database migrations opzetten | 3 | Not Started | EP01-ST01 |
|
||||
| EP01-ST04 | Demo data seeden | 5 | Not Started | EP01-ST01 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP01-ST01:** Als developer wil ik database tabellen creëren zodat data opgeslagen kan worden
|
||||
- ⏳ Tables: clients, intake_notes, problem_profiles, treatment_plans, ai_events
|
||||
- ⏳ Correct data types (UUID, JSONB, etc.)
|
||||
- ⏳ Foreign key constraints
|
||||
- ⏳ Timestamps (created_at, updated_at)
|
||||
|
||||
**EP01-ST02:** Als developer wil ik Row Level Security policies implementeren zodat data veilig is
|
||||
- ⏳ RLS enabled op alle tables
|
||||
- ⏳ Policies voor authenticated users
|
||||
- ⏳ Test queries werken correct
|
||||
- ⏳ Service role bypass werkt
|
||||
|
||||
**EP01-ST03:** Als developer wil ik database migrations opzetten zodat schema versiebeheerd is
|
||||
- ⏳ Supabase migrations folder
|
||||
- ⏳ Initial migration script
|
||||
- ⏳ Rollback mogelijk
|
||||
- ⏳ Documentation
|
||||
|
||||
**EP01-ST04:** Als developer wil ik demo data seeden zodat er test content beschikbaar is
|
||||
- ⏳ 3+ test cliënten
|
||||
- ⏳ Intake notes per cliënt
|
||||
- ⏳ Minimaal 1 compleet dossier
|
||||
- ⏳ Seed script: `npm run seed`
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **Database Schema (zie TO §2.3):**
|
||||
- `clients`: id (UUID), first_name, last_name, birth_date, created_at, updated_at
|
||||
- `intake_notes`: id, client_id (FK), title, tag (CHECK), content_json (JSONB), content_text
|
||||
- `problem_profiles`: id, client_id (FK), category (CHECK), severity (CHECK), remarks
|
||||
- `treatment_plans`: id, client_id (FK), version, status (CHECK), plan (JSONB)
|
||||
- `ai_events`: id, kind, client_id, request, response, duration_ms
|
||||
|
||||
- **RLS Policies (zie TO §2.4):**
|
||||
```sql
|
||||
CREATE POLICY "Allow all for authenticated users" ON [table]
|
||||
FOR ALL USING (auth.uid() IS NOT NULL);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Epic EP02 — Authentication & Authorization
|
||||
**Epic Doel:** Werkende authenticatie met Supabase Auth voor demo gebruikers.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP02-ST01 | Login implementeren | 3 | Not Started | EP00-ST03, EP01-ST02 |
|
||||
| EP02-ST02 | Protected routes implementeren | 3 | Not Started | EP02-ST01 |
|
||||
| EP02-ST03 | Logout functionaliteit | 2 | Not Started | EP02-ST01 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP02-ST01:** Als gebruiker wil ik kunnen inloggen zodat ik toegang krijg tot het systeem
|
||||
- ⏳ Login pagina op /auth/login
|
||||
- ⏳ Email/password of magic link
|
||||
- ⏳ Session management
|
||||
- ⏳ Redirect naar dashboard
|
||||
|
||||
**EP02-ST02:** Als developer wil ik protected routes implementeren zodat alleen ingelogde users toegang hebben
|
||||
- ⏳ Middleware voor auth check
|
||||
- ⏳ Redirect naar login indien nodig
|
||||
- ⏳ Loading states tijdens auth
|
||||
- ⏳ Session refresh
|
||||
|
||||
**EP02-ST03:** Als gebruiker wil ik kunnen uitloggen zodat mijn sessie beëindigd wordt
|
||||
- ⏳ Logout button in header
|
||||
- ⏳ Session cleanup
|
||||
- ⏳ Redirect naar login
|
||||
- ⏳ Clear local state
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **Auth flow:** Email/password voor demo (magic link als backup)
|
||||
- **Middleware:** Check auth in `middleware.ts`
|
||||
- **Protected routes:** Alles behalve `/auth/*`
|
||||
- **Session:** Supabase JWT tokens
|
||||
|
||||
---
|
||||
|
||||
### Epic EP03 — Client Management
|
||||
**Epic Doel:** Complete CRUD functionaliteit voor cliëntbeheer.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP03-ST01 | Cliëntenlijst tonen | 5 | Not Started | EP01-ST01, EP02-ST02 |
|
||||
| EP03-ST02 | Nieuwe cliënt aanmaken | 5 | Not Started | EP03-ST01 |
|
||||
| EP03-ST03 | Cliëntgegevens bekijken | 5 | Not Started | EP03-ST01 |
|
||||
| EP03-ST04 | Cliëntgegevens bewerken | 3 | Not Started | EP03-ST03 |
|
||||
| EP03-ST05 | Zustand store voor client state | 3 | Not Started | EP00-ST01 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP03-ST01:** Als behandelaar wil ik een cliëntenlijst zien zodat ik overzicht heb
|
||||
- ⏳ Tabel met: ClientID, Naam, Geboortedatum, Laatste update
|
||||
- ⏳ Zoekbalk voor naam/ID
|
||||
- ⏳ Pagination bij >20 items
|
||||
- ⏳ Loading skeleton
|
||||
|
||||
**EP03-ST02:** Als behandelaar wil ik een nieuwe cliënt aanmaken zodat ik kan starten met intake
|
||||
- ⏳ Modal/drawer met formulier
|
||||
- ⏳ Velden: Voornaam, Achternaam, Geboortedatum
|
||||
- ⏳ Auto-generated UUID
|
||||
- ⏳ Validatie met Zod
|
||||
- ⏳ Success toast
|
||||
|
||||
**EP03-ST03:** Als behandelaar wil ik cliëntgegevens bekijken zodat ik het dossier kan inzien
|
||||
- ⏳ Route: /clients/[id]
|
||||
- ⏳ Breadcrumb navigatie
|
||||
- ⏳ Tabs: Overzicht, Intakes, Profiel, Plan
|
||||
- ⏳ 404 handling
|
||||
|
||||
**EP03-ST04:** Als behandelaar wil ik cliëntgegevens bewerken zodat ik updates kan maken
|
||||
- ⏳ Edit mode in detail view
|
||||
- ⏳ Form validation
|
||||
- ⏳ Optimistic updates
|
||||
- ⏳ Error handling
|
||||
|
||||
**EP03-ST05:** Als developer wil ik Zustand store voor client state zodat data consistent blijft
|
||||
- ⏳ clientStore.ts setup
|
||||
- ⏳ Actions: setSelectedClient, updateClient
|
||||
- ⏳ Persistent state waar nodig
|
||||
- ⏳ TypeScript types
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **API endpoints:**
|
||||
- `POST /api/clients` - Create
|
||||
- `GET /api/clients` - List with search
|
||||
- `GET /api/clients/[id]` - Get single
|
||||
- `PATCH /api/clients/[id]` - Update
|
||||
- **Zustand store:** Central state voor selected client
|
||||
- **Validatie:** Zod schemas voor alle forms
|
||||
|
||||
---
|
||||
|
||||
### Epic EP04 — Intake Module
|
||||
**Epic Doel:** Rich text editor voor intake verslagen met TipTap integratie.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP04-ST01 | TipTap editor implementeren | 8 | Not Started | EP03-ST03 |
|
||||
| EP04-ST02 | Intake verslagen opslaan | 5 | Not Started | EP04-ST01 |
|
||||
| EP04-ST03 | Tags toevoegen aan verslagen | 3 | Not Started | EP04-ST02 |
|
||||
| EP04-ST04 | Oude intakes bekijken | 5 | Not Started | EP04-ST02 |
|
||||
| EP04-ST05 | Tekst extractie voor search | 5 | Not Started | EP04-ST02 |
|
||||
| EP04-ST06 | AI-rail implementeren | 8 | Not Started | EP04-ST01 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP04-ST01:** Als behandelaar wil ik TipTap editor gebruiken zodat ik rijk opgemaakte notities kan maken
|
||||
- ⏳ TipTap met StarterKit
|
||||
- ⏳ Toolbar: Bold, Italic, Lists, etc.
|
||||
- ⏳ Placeholder text
|
||||
- ⏳ Content als ProseMirror JSON
|
||||
|
||||
**EP04-ST02:** Als behandelaar wil ik intake verslagen opslaan zodat ze bewaard blijven
|
||||
- ⏳ Save button + Ctrl/Cmd+S
|
||||
- ⏳ Store in intake_notes table
|
||||
- ⏳ Auto-save indicator
|
||||
- ⏳ Success/error toasts
|
||||
|
||||
**EP04-ST03:** Als behandelaar wil ik tags toevoegen aan verslagen zodat ik ze kan categoriseren
|
||||
- ⏳ Tag dropdown: Intake/Evaluatie/Plan
|
||||
- ⏳ Tag badge in lijst
|
||||
- ⏳ Filter op tag mogelijk
|
||||
- ⏳ Validation
|
||||
|
||||
**EP04-ST04:** Als behandelaar wil ik oude intakes bekijken zodat ik historie kan inzien
|
||||
- ⏳ Lijst van intakes per cliënt
|
||||
- ⏳ Sorteer op datum
|
||||
- ⏳ Click to view/edit
|
||||
- ⏳ Read-only mode optie
|
||||
|
||||
**EP04-ST05:** Als developer wil ik tekst extractie implementeren voor search
|
||||
- ⏳ Extract plain text van ProseMirror
|
||||
- ⏳ Store in content_text field
|
||||
- ⏳ Full-text search mogelijk
|
||||
- ⏳ Performance optimization
|
||||
|
||||
**EP04-ST06:** Als behandelaar wil ik de AI-rail zien zodat AI-resultaten preview kan bekijken
|
||||
- ⏳ Rechter paneel (40% breedte)
|
||||
- ⏳ Collapsible/expandable
|
||||
- ⏳ Preview area voor AI output
|
||||
- ⏳ Action buttons: Invoegen/Annuleren
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **TipTap setup:**
|
||||
```typescript
|
||||
import StarterKit from '@tiptap/starter-kit'
|
||||
const editor = useEditor({
|
||||
extensions: [StarterKit],
|
||||
content: prosemirrorJSON
|
||||
})
|
||||
```
|
||||
- **Storage:** content_json (JSONB) + content_text (TEXT)
|
||||
- **API:** `/api/intakes` endpoints
|
||||
|
||||
---
|
||||
|
||||
### Epic EP05 — Problem Profile (DSM-light)
|
||||
**Epic Doel:** DSM-light categorisatie systeem met severity bepaling.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP05-ST01 | Probleem categorie selecteren | 5 | Not Started | EP04-ST02 |
|
||||
| EP05-ST02 | Severity aangeven | 3 | Not Started | EP05-ST01 |
|
||||
| EP05-ST03 | Opmerkingen toevoegen | 3 | Not Started | EP05-ST01 |
|
||||
| EP05-ST04 | AI-suggestie paneel | 10 | Not Started | EP04-ST02, EP07-ST03 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP05-ST01:** Als behandelaar wil ik een probleem categorie selecteren zodat ik kan classificeren
|
||||
- ⏳ Dropdown met 6 categorieën (zie FO §4.4)
|
||||
- ⏳ Beschrijving per categorie
|
||||
- ⏳ Validation required field
|
||||
- ⏳ Store in problem_profiles
|
||||
|
||||
**EP05-ST02:** Als behandelaar wil ik severity aangeven zodat ernst duidelijk is
|
||||
- ⏳ Button group: Laag/Middel/Hoog
|
||||
- ⏳ Kleur-coded badges
|
||||
- ⏳ Hover tooltips met uitleg
|
||||
- ⏳ Required validation
|
||||
|
||||
**EP05-ST03:** Als behandelaar wil ik opmerkingen toevoegen zodat ik context kan geven
|
||||
- ⏳ Textarea voor vrije tekst
|
||||
- ⏳ Character limit (500)
|
||||
- ⏳ Optional field
|
||||
- ⏳ Markdown support
|
||||
|
||||
**EP05-ST04:** Als behandelaar wil ik AI-suggestie paneel gebruiken zodat classificatie sneller gaat
|
||||
- ⏳ Knop "AI > Analyseer intake"
|
||||
- ⏳ Suggestie paneel rechts
|
||||
- ⏳ Shows: categorie, severity, rationale
|
||||
- ⏳ Accepteer/Negeer buttons
|
||||
- ⏳ Source highlighting in intake (zie TO §5.4)
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **Categorieën (enum):**
|
||||
- stemming_depressie
|
||||
- angst
|
||||
- gedrag_impuls
|
||||
- middelen_gebruik
|
||||
- cognitief
|
||||
- context_psychosociaal
|
||||
- **Severity badges:** Tailwind classes volgens UX stylesheet
|
||||
- **AI highlighting:** TipTap Decorations API
|
||||
|
||||
---
|
||||
|
||||
### Epic EP06 — Treatment Plan Module
|
||||
**Epic Doel:** Genereren en beheren van gestructureerde behandelplannen.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP06-ST01 | Behandelplan genereren | 10 | Not Started | EP05-ST01, EP07-ST04 |
|
||||
| EP06-ST02 | Doelen bewerken | 8 | Not Started | EP06-ST01 |
|
||||
| EP06-ST03 | Interventies specificeren | 5 | Not Started | EP06-ST01 |
|
||||
| EP06-ST04 | Meetmomenten plannen | 5 | Not Started | EP06-ST01 |
|
||||
| EP06-ST05 | Plan publiceren | 6 | Not Started | EP06-ST02 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP06-ST01:** Als behandelaar wil ik een behandelplan genereren zodat ik snel een opzet heb
|
||||
- ⏳ Knop "AI > Genereer behandelplan"
|
||||
- ⏳ Uses intake + profile als context
|
||||
- ⏳ Genereert 4 secties
|
||||
- ⏳ Loading state tijdens generatie
|
||||
|
||||
**EP06-ST02:** Als behandelaar wil ik doelen bewerken zodat ze SMART geformuleerd zijn
|
||||
- ⏳ Lijst van doelen (bullets)
|
||||
- ⏳ Inline editing mogelijk
|
||||
- ⏳ Add/remove doelen
|
||||
- ⏳ Regenerate per doel optie
|
||||
|
||||
**EP06-ST03:** Als behandelaar wil ik interventies specificeren zodat behandeling duidelijk is
|
||||
- ⏳ Interventie lijst
|
||||
- ⏳ Type + frequentie + duur
|
||||
- ⏳ Voorgestelde interventies
|
||||
- ⏳ Custom toevoegen
|
||||
|
||||
**EP06-ST04:** Als behandelaar wil ik meetmomenten plannen zodat voortgang gemeten wordt
|
||||
- ⏳ Timeline met meetmomenten
|
||||
- ⏳ Na X sessies format
|
||||
- ⏳ Evaluatie types
|
||||
- ⏳ Calendar integration (stretch)
|
||||
|
||||
**EP06-ST05:** Als behandelaar wil ik plan publiceren zodat het definitief wordt
|
||||
- ⏳ Concept vs Gepubliceerd status
|
||||
- ⏳ Versioning (v1, v2, etc.)
|
||||
- ⏳ Published timestamp
|
||||
- ⏳ Read-only na publicatie
|
||||
- ⏳ Nieuwe versie mogelijk
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **Plan structuur (JSONB):**
|
||||
```typescript
|
||||
{
|
||||
doelen: string[],
|
||||
interventies: string[],
|
||||
frequentie: string,
|
||||
meetmomenten: string[]
|
||||
}
|
||||
```
|
||||
- **Status flow:** concept → gepubliceerd → nieuwe versie
|
||||
- **API:** `/api/treatment-plan` endpoints
|
||||
|
||||
---
|
||||
|
||||
### Epic EP07 — AI Integration
|
||||
**Epic Doel:** Claude AI integratie voor alle AI-powered features.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP07-ST01 | Claude API client configureren | 5 | Not Started | EP00-ST04 |
|
||||
| EP07-ST02 | Intake samenvatten met AI | 8 | Not Started | EP07-ST01, EP04-ST06 |
|
||||
| EP07-ST03 | Problemen extraheren met AI | 8 | Not Started | EP07-ST01 |
|
||||
| EP07-ST04 | Behandelplan genereren met AI | 8 | Not Started | EP07-ST01 |
|
||||
| EP07-ST05 | AI events loggen | 5 | Not Started | EP07-ST01, EP01-ST01 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP07-ST01:** Als developer wil ik Claude API client configureren zodat AI calls mogelijk zijn
|
||||
- ⏳ Anthropic SDK setup
|
||||
- ⏳ Server-side only implementation
|
||||
- ⏳ Error handling
|
||||
- ⏳ Rate limiting logic
|
||||
|
||||
**EP07-ST02:** Als behandelaar wil ik intake samenvatten met AI zodat ik snel overzicht heb
|
||||
- ⏳ Endpoint: /api/ai/summarize
|
||||
- ⏳ 5-8 bullet points output
|
||||
- ⏳ Nederlands, klinisch neutraal
|
||||
- ⏳ Max 5 sec response time
|
||||
|
||||
**EP07-ST03:** Als behandelaar wil ik problemen extraheren met AI zodat classificatie sneller gaat
|
||||
- ⏳ Endpoint: /api/ai/extract
|
||||
- ⏳ Returns: category, severity, rationale
|
||||
- ⏳ Source sentences identificatie
|
||||
- ⏳ Highlighting support
|
||||
|
||||
**EP07-ST04:** Als behandelaar wil ik behandelplan genereren met AI zodat ik een goede basis heb
|
||||
- ⏳ Endpoint: /api/ai/generate-plan
|
||||
- ⏳ SMART doelen formulering
|
||||
- ⏳ Evidence-based interventies
|
||||
- ⏳ Structured JSON output
|
||||
|
||||
**EP07-ST05:** Als developer wil ik AI events loggen zodat gebruik gemonitord wordt
|
||||
- ⏳ Store in ai_events table
|
||||
- ⏳ Track: prompt, response, duration
|
||||
- ⏳ Cost calculation
|
||||
- ⏳ Error logging
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **Claude model:** claude-3-5-sonnet-20241022
|
||||
- **Prompt templates:** `/src/lib/ai/prompts/`
|
||||
- **Temperature:** 0.3 (deterministic)
|
||||
- **Max tokens:** Per endpoint verschillend
|
||||
- **Security:** API key alleen server-side
|
||||
|
||||
---
|
||||
|
||||
### Epic EP08 — Dashboard & Navigation
|
||||
**Epic Doel:** Configureerbaar dashboard met tegels en navigatie.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP08-ST01 | Dashboard met tegels | 5 | Not Started | EP03-ST03 |
|
||||
| EP08-ST02 | Tegels configureren | 3 | Not Started | EP08-ST01 |
|
||||
| EP08-ST03 | Breadcrumb navigatie | 2 | Not Started | EP03-ST03 |
|
||||
| EP08-ST04 | Sidebar navigatie | 3 | Not Started | EP03-ST03 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP08-ST01:** Als behandelaar wil ik een dashboard zien zodat ik overzicht heb per cliënt
|
||||
- ⏳ 5 tegels (zie FO §4.2)
|
||||
- ⏳ Responsive grid layout
|
||||
- ⏳ Data uit verschillende tables
|
||||
- ⏳ Click naar detail
|
||||
|
||||
**EP08-ST02:** Als behandelaar wil ik tegels configureren zodat ik kan personaliseren
|
||||
- ⏳ Settings icon → modal
|
||||
- ⏳ Checkboxes per tegel
|
||||
- ⏳ LocalStorage persistence
|
||||
- ⏳ Instant preview
|
||||
|
||||
**EP08-ST03:** Als gebruiker wil ik breadcrumb navigatie zodat ik weet waar ik ben
|
||||
- ⏳ Breadcrumb in header
|
||||
- ⏳ Clickable segments
|
||||
- ⏳ Current page highlight
|
||||
- ⏳ Responsive truncation
|
||||
|
||||
**EP08-ST04:** Als gebruiker wil ik sidebar navigatie zodat ik tussen modules kan wisselen
|
||||
- ⏳ Vertical navigation
|
||||
- ⏳ Active state indicator
|
||||
- ⏳ Icons + labels
|
||||
- ⏳ Collapsible op mobile
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **Tegels:** Basisgegevens, Laatste Intake, Probleemprofiel, Behandelplan, Afspraken
|
||||
- **Grid:** Tailwind Grid met responsive breakpoints
|
||||
- **State:** Zustand voor tegel configuratie
|
||||
|
||||
---
|
||||
|
||||
### Epic EP09 — UI Components & Styling
|
||||
**Epic Doel:** Consistente UI componenten volgens UX stylesheet.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP09-ST01 | Basis componenten bouwen | 5 | Not Started | EP00-ST02 |
|
||||
| EP09-ST02 | Toast notificaties | 3 | Not Started | EP09-ST01 |
|
||||
| EP09-ST03 | Loading states | 3 | Not Started | EP09-ST01 |
|
||||
| EP09-ST04 | Formulier componenten | 5 | Not Started | EP09-ST01 |
|
||||
| EP09-ST05 | Dark mode (stretch) | 5 | Not Started | EP09-ST01 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP09-ST01:** Als developer wil ik basis componenten bouwen zodat UI consistent is
|
||||
- ⏳ Button, Card, Input, Select
|
||||
- ⏳ Consistent met UX stylesheet
|
||||
- ⏳ TypeScript props
|
||||
- ⏳ Storybook (optional)
|
||||
|
||||
**EP09-ST02:** Als developer wil ik toast notificaties implementeren zodat feedback duidelijk is
|
||||
- ⏳ Success/Error/Info/Warning
|
||||
- ⏳ Auto-dismiss na 5 sec
|
||||
- ⏳ Queue multiple toasts
|
||||
- ⏳ Accessible (aria-live)
|
||||
|
||||
**EP09-ST03:** Als developer wil ik loading states implementeren zodat gebruiker weet dat er geladen wordt
|
||||
- ⏳ Skeleton loaders
|
||||
- ⏳ Spinners voor buttons
|
||||
- ⏳ Progress bars voor AI
|
||||
- ⏳ Consistent animation
|
||||
|
||||
**EP09-ST04:** Als developer wil ik formulier componenten maken zodat input consistent is
|
||||
- ⏳ Form wrapper met validation
|
||||
- ⏳ Error messages styling
|
||||
- ⏳ Required field indicators
|
||||
- ⏳ Help text support
|
||||
|
||||
**EP09-ST05:** Als developer wil ik dark mode ondersteunen (stretch) zodat gebruikers kunnen kiezen
|
||||
- ⏳ Theme toggle button
|
||||
- ⏳ System preference detect
|
||||
- ⏳ Persist preference
|
||||
- ⏳ All components support
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **Kleuren:** Zie UX stylesheet (§2-4)
|
||||
- **Component library:** shadcn/ui of custom
|
||||
- **Icons:** lucide-react consistent gebruik
|
||||
|
||||
---
|
||||
|
||||
### Epic EP10 — Testing & Quality Assurance
|
||||
**Epic Doel:** Comprehensive testing voor stabiele demo.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP10-ST01 | Unit tests schrijven | 5 | Not Started | All features |
|
||||
| EP10-ST02 | E2E tests schrijven | 5 | Not Started | All features |
|
||||
| EP10-ST03 | Smoke tests uitvoeren | 2 | Not Started | All features |
|
||||
| EP10-ST04 | Accessibility testen | 1 | Not Started | EP09 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP10-ST01:** Als developer wil ik unit tests schrijven zodat business logic getest is
|
||||
- ⏳ Vitest setup
|
||||
- ⏳ Utils & services tests
|
||||
- ⏳ 80% coverage /lib folder
|
||||
- ⏳ CI integration
|
||||
|
||||
**EP10-ST02:** Als developer wil ik E2E tests schrijven zodat kritieke flows werken
|
||||
- ⏳ Playwright setup
|
||||
- ⏳ Happy path: intake → profile → plan
|
||||
- ⏳ Error scenarios
|
||||
- ⏳ Cross-browser
|
||||
|
||||
**EP10-ST03:** Als team wil ik smoke tests uitvoeren zodat demo stabiel is
|
||||
- ⏳ Manual test checklist
|
||||
- ⏳ All features tested
|
||||
- ⏳ Performance acceptable
|
||||
- ⏳ No console errors
|
||||
|
||||
**EP10-ST04:** Als developer wil ik accessibility testen zodat app toegankelijk is
|
||||
- ⏳ Keyboard navigation
|
||||
- ⏳ Screen reader support
|
||||
- ⏳ WCAG AA contrast
|
||||
- ⏳ Focus management
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **Test scenarios:** Zie FO §9 demo-scenario
|
||||
- **Performance:** <3s initial load, <5s AI responses
|
||||
- **Browser support:** Chrome, Firefox, Safari latest
|
||||
|
||||
---
|
||||
|
||||
### Epic EP11 — Deployment & Demo Prep
|
||||
**Epic Doel:** Production-ready deployment en demo voorbereiding.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP11-ST01 | Vercel deployment configureren | 3 | Not Started | All features |
|
||||
| EP11-ST02 | Demo data prepareren | 5 | Not Started | EP01-ST04 |
|
||||
| EP11-ST03 | Demo script schrijven | 3 | Not Started | All features |
|
||||
| EP11-ST04 | Dry-run uitvoeren | 2 | Not Started | EP11-ST01 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP11-ST01:** Als developer wil ik Vercel deployment configureren zodat app live is
|
||||
- ⏳ Vercel project setup
|
||||
- ⏳ EU region (Amsterdam)
|
||||
- ⏳ Environment variables
|
||||
- ⏳ Custom domain (optional)
|
||||
|
||||
**EP11-ST02:** Als team wil ik demo data prepareren zodat presentatie smooth verloopt
|
||||
- ⏳ 3 complete test cliënten
|
||||
- ⏳ Realistic intake texts
|
||||
- ⏳ Pre-generated AI responses
|
||||
- ⏳ Backup data ready
|
||||
|
||||
**EP11-ST03:** Als presenter wil ik demo script hebben zodat presentatie gestructureerd is
|
||||
- ⏳ 10-minute script
|
||||
- ⏳ Key talking points
|
||||
- ⏳ Backup scenarios
|
||||
- ⏳ Q&A anticipatie
|
||||
|
||||
**EP11-ST04:** Als team wil ik dry-run doen zodat demo succesvol verloopt
|
||||
- ⏳ Complete run-through
|
||||
- ⏳ Timing verified (< 10 min)
|
||||
- ⏳ Technical issues fixed
|
||||
- ⏳ Feedback processed
|
||||
|
||||
**Technische implementatie details:**
|
||||
- **Deployment checklist:**
|
||||
- Environment variables set
|
||||
- Database migrations run
|
||||
- Seed data loaded
|
||||
- SSL certificate active
|
||||
- Monitoring enabled
|
||||
|
||||
---
|
||||
|
||||
### Epic EP12 — Stretch Features (Optional)
|
||||
**Epic Doel:** Extra features indien tijd beschikbaar.
|
||||
|
||||
| Story ID | Story Title | Points | Status | Dependencies |
|
||||
|----------|-------------|--------|--------|--------------|
|
||||
| EP12-ST01 | Afspraken plannen | 8 | Not Started | EP08-ST01 |
|
||||
| EP12-ST02 | PDF export | 8 | Not Started | EP06-ST05 |
|
||||
| EP12-ST03 | Leesbaarheid verbeteren met AI | 5 | Not Started | EP07-ST01 |
|
||||
|
||||
**Story Details:**
|
||||
|
||||
**EP12-ST01:** Als behandelaar wil ik afspraken kunnen plannen zodat agenda gekoppeld is
|
||||
- ⏳ Calendar view
|
||||
- ⏳ Create/edit appointments
|
||||
- ⏳ Link to client
|
||||
- ⏳ Dashboard widget
|
||||
|
||||
**EP12-ST02:** Als behandelaar wil ik PDF export zodat ik rapporten kan delen
|
||||
- ⏳ Export button
|
||||
- ⏳ Professional layout
|
||||
- ⏳ All sections included
|
||||
- ⏳ Download trigger
|
||||
|
||||
**EP12-ST03:** Als behandelaar wil ik leesbaarheid verbeteren met AI zodat tekst B1-niveau wordt
|
||||
- ⏳ Endpoint: /api/ai/readability
|
||||
- ⏳ B1 niveau output
|
||||
- ⏳ Preserve medical accuracy
|
||||
- ⏳ Preview before apply
|
||||
|
||||
---
|
||||
|
||||
## 5. Kwaliteit & Testplan
|
||||
|
||||
🎯 **Doel:** Borging van kwaliteit voor stabiele demo.
|
||||
|
||||
### Test Types
|
||||
| Test Type | Scope | Tools | Coverage Target |
|
||||
|-----------|-------|-------|-----------------|
|
||||
| Unit Tests | Services, utilities, validators | Vitest | 80% /lib folder |
|
||||
| Integration Tests | API endpoints, database queries | Vitest + MSW | All critical endpoints |
|
||||
| E2E Tests | Complete user flows | Playwright | 3 happy paths, 2 error paths |
|
||||
| Performance Tests | Load time, API response | Lighthouse | LCP <2.5s, FID <100ms |
|
||||
| Accessibility Tests | WCAG compliance | axe-core | AA compliance |
|
||||
| Security Tests | Auth, XSS, SQL injection | Manual + automated | OWASP top 10 |
|
||||
|
||||
### Critical Test Scenarios
|
||||
1. **New Client Flow**
|
||||
- Create client → Add intake → Generate summary → Extract problems → Create plan
|
||||
- Expected time: <2 minutes
|
||||
- All data persisted correctly
|
||||
|
||||
2. **AI Integration Flow**
|
||||
- Large intake text (2000+ words) → All AI features work
|
||||
- Response time <5 seconds per call
|
||||
- Graceful degradation if AI fails
|
||||
|
||||
3. **Error Handling**
|
||||
- Network failure → Appropriate error messages
|
||||
- Invalid input → Clear validation feedback
|
||||
- AI timeout → Fallback behavior
|
||||
|
||||
### Demo Checklist
|
||||
- [ ] Login with demo account works
|
||||
- [ ] Create new client (auto-generated ID)
|
||||
- [ ] Write intake with TipTap editor
|
||||
- [ ] AI summarize returns Dutch bullets
|
||||
- [ ] Problem extraction with highlighting
|
||||
- [ ] Treatment plan generation (SMART goals)
|
||||
- [ ] Publish plan (version 1)
|
||||
- [ ] Dashboard shows all data correctly
|
||||
- [ ] Navigation breadcrumbs work
|
||||
- [ ] No console errors
|
||||
- [ ] Performance acceptable (<3s loads)
|
||||
- [ ] Mobile view responsive
|
||||
|
||||
---
|
||||
|
||||
## 6. Demo & Presentatieplan
|
||||
|
||||
🎯 **Doel:** Succesvolle 10-minuten demo tijdens AI-inspiratiesessie.
|
||||
|
||||
### Demo Timeline
|
||||
| Time | Activity | Key Points | Backup Plan |
|
||||
|------|----------|------------|-------------|
|
||||
| 0:00-1:00 | **Intro** | Context mini-EPD, AI-toegevoegde waarde | Slides ready |
|
||||
| 1:00-2:30 | **Nieuwe cliënt** | Quick entry, auto ClientID, immediate start | Pre-created client |
|
||||
| 2:30-5:00 | **Intake + AI** | TipTap editor, AI summarize, source highlighting | Cached AI response |
|
||||
| 5:00-7:00 | **Profile + Plan** | DSM categorization, AI-generated plan, SMART goals | Manual input ready |
|
||||
| 7:00-8:30 | **Publiceren** | Version control, status change, dashboard update | Screenshots |
|
||||
| 8:30-10:00 | **Q&A** | Interactive discussion, next steps | FAQ prepared |
|
||||
|
||||
### Technical Setup
|
||||
- **Primary:** Live on Vercel (stable internet required)
|
||||
- **Backup 1:** Local development server
|
||||
- **Backup 2:** Recorded video demo
|
||||
- **Backup 3:** Static screenshots
|
||||
|
||||
### Key Messages
|
||||
1. AI vermindert administratieve last met 50%
|
||||
2. Consistente kwaliteit van documentatie
|
||||
3. Meer tijd voor cliëntcontact
|
||||
4. Evidence-based suggesties
|
||||
5. Privacy-first design (geen echte data)
|
||||
|
||||
---
|
||||
|
||||
## 7. Risico's & Mitigatie
|
||||
|
||||
🎯 **Doel:** Proactieve risico management voor succesvolle oplevering.
|
||||
|
||||
| Risico | Kans | Impact | Mitigatie | Owner |
|
||||
|--------|------|--------|-----------|-------|
|
||||
| **Claude API rate limits** | Hoog | Hoog | Response caching, queue implementation, fallback to OpenAI | Developer |
|
||||
| **TipTap complexiteit** | Medium | Hoog | Start simple, incremental features, fallback to textarea | Developer |
|
||||
| **Supabase RLS policies fout** | Medium | Hoog | Extensive testing, service role fallback, monitoring | Developer |
|
||||
| **AI output inconsistent** | Hoog | Medium | Prompt versioning, temperature tuning, validation layer | Developer |
|
||||
| **Demo internet uitval** | Laag | Hoog | Local setup ready, mobile hotspot backup, video recording | Presenter |
|
||||
| **Tijd tekort voor features** | Medium | Medium | MoSCoW prioritization, MVP focus, stretch clearly marked | PM |
|
||||
| **Browser compatibility** | Laag | Medium | Test on Chrome/Safari/Firefox, polyfills where needed | QA |
|
||||
| **Performance issues** | Medium | Medium | Lazy loading, code splitting, CDN for assets | Developer |
|
||||
| **Security vulnerability** | Laag | Hoog | Pen test, OWASP checklist, security headers | Developer |
|
||||
|
||||
---
|
||||
|
||||
## 8. Referenties
|
||||
|
||||
🎯 **Doel:** Koppeling naar alle relevante projectdocumentatie.
|
||||
|
||||
### Mission Control Documents
|
||||
- **PRD** — [Product Requirements Document](./prd-mini-ecd.md) - Business requirements en scope
|
||||
- **FO** — [Functioneel Ontwerp](./fo-mini-ecd.md) - User flows en functionele specificaties
|
||||
- **TO** — [Technisch Ontwerp](./to-mini-ecd.md) - Architectuur en database design
|
||||
- **UX/UI** — [Stylesheet](./ux-stylesheet.md) - Kleuren en design system
|
||||
- **API** — [API Access Document](./api-acces-mini-ecd.md) - Endpoints en authenticatie
|
||||
|
||||
### External Resources
|
||||
- **Repository:** `https://github.com/pinkroccade/mini-epd-prototype`
|
||||
- **Deployment:** `https://mini-epd.vercel.app`
|
||||
- **Supabase:** `https://app.supabase.com/project/[project-id]`
|
||||
- **Claude AI:** `https://docs.anthropic.com/claude/reference`
|
||||
- **TipTap Docs:** `https://tiptap.dev`
|
||||
- **Next.js Docs:** `https://nextjs.org/docs`
|
||||
|
||||
### Development Resources
|
||||
- **Component Library:** `https://ui.shadcn.com`
|
||||
- **Icons:** `https://lucide.dev`
|
||||
- **Tailwind:** `https://tailwindcss.com`
|
||||
|
||||
---
|
||||
|
||||
## 9. Technische Notities
|
||||
|
||||
### Database Queries Examples
|
||||
```typescript
|
||||
// Get client with full dossier
|
||||
const { data: client } = await supabase
|
||||
.from('clients')
|
||||
.select(`
|
||||
*,
|
||||
intake_notes (*),
|
||||
problem_profiles (*),
|
||||
treatment_plans (*)
|
||||
`)
|
||||
.eq('id', clientId)
|
||||
.single()
|
||||
|
||||
// Search clients
|
||||
const { data: clients } = await supabase
|
||||
.from('clients')
|
||||
.select('*')
|
||||
.ilike('last_name', `%${searchQuery}%`)
|
||||
.order('updated_at', { ascending: false })
|
||||
```
|
||||
|
||||
### AI Prompt Templates
|
||||
```typescript
|
||||
// Summarize prompt
|
||||
const SUMMARIZE_PROMPT = `
|
||||
Vat het onderstaande intake-verslag samen in 5-8 bullets.
|
||||
Schrijf in Nederlands, klinisch neutraal, zonder persoonlijke informatie.
|
||||
|
||||
Intake verslag:
|
||||
{intakeText}
|
||||
`
|
||||
|
||||
// Extract problems prompt
|
||||
const EXTRACT_PROMPT = `
|
||||
Analyseer de intake en bepaal:
|
||||
1. DSM-light categorie (kies uit: stemming_depressie, angst, gedrag_impuls, middelen_gebruik, cognitief, context_psychosociaal)
|
||||
2. Severity (laag, middel, hoog)
|
||||
3. Rationale (2-3 zinnen)
|
||||
4. Bronzinnen uit de tekst
|
||||
|
||||
Intake:
|
||||
{intakeText}
|
||||
`
|
||||
```
|
||||
|
||||
### Component Structure
|
||||
```typescript
|
||||
// Example component with proper typing
|
||||
interface ClientCardProps {
|
||||
client: Client
|
||||
onClick?: (id: string) => void
|
||||
isSelected?: boolean
|
||||
}
|
||||
|
||||
export function ClientCard({ client, onClick, isSelected }: ClientCardProps) {
|
||||
return (
|
||||
<Card
|
||||
className={cn(
|
||||
"cursor-pointer transition-shadow",
|
||||
isSelected && "ring-2 ring-primary"
|
||||
)}
|
||||
onClick={() => onClick?.(client.id)}
|
||||
>
|
||||
<CardHeader>
|
||||
<CardTitle>{client.first_name} {client.last_name}</CardTitle>
|
||||
<CardDescription>
|
||||
{format(new Date(client.birth_date), 'dd-MM-yyyy')}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Versiehistorie:**
|
||||
|
||||
| Versie | Datum | Auteur | Wijziging |
|
||||
|--------|-------|--------|-----------|
|
||||
| v1.0 | 10-11-2025 | Development Team | Initiële versie met complete epic breakdown |
|
||||
493
docs/specs/archive/fo-mini-ecd.md
Normal file
493
docs/specs/archive/fo-mini-ecd.md
Normal file
@@ -0,0 +1,493 @@
|
||||
# 🧩 Functioneel Ontwerp (FO) – Mini-ECD Prototype
|
||||
|
||||
**Projectnaam:** Mini-ECD Prototype
|
||||
**Versie:** v1.0 (MVP)
|
||||
**Datum:** 09-11-2025
|
||||
**Auteur:** Ontwikkelteam PinkRoccade GGZ
|
||||
|
||||
---
|
||||
|
||||
## 1. Doel en relatie met het PRD
|
||||
|
||||
🎯 **Doel van dit document:**
|
||||
Het Functioneel Ontwerp (FO) beschrijft **hoe** de Mini-ECD applicatie functioneel werkt — wat de gebruiker ziet, doet en ervaart tijdens de AI-inspiratiesessie. Waar het PRD uitlegt *wat en waarom*, laat het FO zien *hoe dit in de praktijk werkt*.
|
||||
|
||||
📘 **Context:**
|
||||
Dit FO ondersteunt de demo van max. 10 minuten waarbij we de kernflow **intake → probleemclassificatie → behandelplan** demonstreren met AI-ondersteuning. Het richt zich op de herkenbare ECD-workflow voor GGZ-professionals, met fictieve data en vereenvoudigde autorisatie.
|
||||
|
||||
**Relatie met andere documenten:**
|
||||
- **PRD**: definieert de vereisten en scope
|
||||
- **TO (Technisch Ontwerp)**: beschrijft de technische implementatie (Next.js, Supabase, Claude AI)
|
||||
- **UX Stylesheet**: specificeert kleuren en styling
|
||||
- **API Access**: documenteert de AI endpoints
|
||||
|
||||
---
|
||||
|
||||
## 2. Overzicht van de belangrijkste onderdelen
|
||||
|
||||
De applicatie bestaat uit de volgende hoofdonderdelen:
|
||||
|
||||
1. **Cliëntenlijst** — overzicht van alle cliënten met zoek- en filterfunctionaliteit
|
||||
2. **Cliëntdossier / Dashboard** — configureerbare tegels met overzicht per cliënt
|
||||
3. **Intakeverslag** — rich text editor met AI-ondersteuning
|
||||
4. **Probleemprofiel (DSM-light)** — categorisatie en severity-bepaling
|
||||
5. **Behandelplan** — gestructureerd plan met doelen, interventies en meetmomenten
|
||||
6. *(Stretch)* **Mini-agenda** — afspraken koppelen aan cliënt
|
||||
7. *(Stretch)* **Rapportage** — PDF export van dossier
|
||||
|
||||
---
|
||||
|
||||
## 3. User Stories
|
||||
|
||||
### Primaire User Stories (MVP)
|
||||
|
||||
| ID | Rol | Doel / Actie | Verwachte waarde | Prioriteit |
|
||||
|----|------|---------------|------------------|-------------|
|
||||
| US-01 | Behandelaar | Nieuwe cliënt aanmaken met basisgegevens | Kan direct starten met intake | Hoog |
|
||||
| US-02 | Behandelaar | Intakeverslag schrijven in rich text editor | Flexibel notuleren met opmaak | Hoog |
|
||||
| US-03 | Behandelaar | Intakeverslag samenvatten met AI | Tijdbesparing, sneller overzicht | Hoog |
|
||||
| US-04 | Behandelaar | Leesbaarheid verbeteren naar B1-niveau met AI | Cliëntvriendelijke communicatie | Middel |
|
||||
| US-05 | Behandelaar | AI-suggestie krijgen voor DSM-light categorie en severity | Snellere en consistentere classificatie | Hoog |
|
||||
| US-06 | Behandelaar | Behandelplan genereren op basis van intake/profiel | Efficiënter plannen, SMART-doelen | Hoog |
|
||||
| US-07 | Behandelaar | Gegenereerd plan bewerken en publiceren | Controle over eindresultaat | Hoog |
|
||||
| US-08 | Behandelaar | Configureren welke dashboard-tegels zichtbaar zijn | Personalisatie werkruimte | Laag |
|
||||
|
||||
### Secundaire User Stories (Stakeholders)
|
||||
|
||||
| ID | Rol | Doel / Actie | Verwachte waarde | Prioriteit |
|
||||
|----|------|---------------|------------------|-------------|
|
||||
| US-09 | Product Owner | Demo-flow doorlopen tijdens workshop | Begrijpt AI-toegevoegde waarde | Hoog |
|
||||
| US-10 | Developer | Zien hoe AI in ECD-proces geïntegreerd is | Inspiratie voor eigen implementaties | Middel |
|
||||
| US-11 | Manager | Overzicht van cliëntdossiers bekijken | Inzicht in werkprocessen | Laag |
|
||||
|
||||
---
|
||||
|
||||
## 4. Functionele werking per onderdeel
|
||||
|
||||
### 4.1 Cliëntenlijst
|
||||
|
||||
**Doel:** Overzicht van alle geregistreerde cliënten met mogelijkheid om nieuwe cliënten toe te voegen.
|
||||
|
||||
**Functionaliteit:**
|
||||
- **Weergave:**
|
||||
- Tabel met kolommen: ClientID, Naam (Voornaam + Achternaam), Geboortedatum, Laatste update
|
||||
- Zoekbalk bovenaan voor filteren op naam of ClientID
|
||||
- Knop **+ Nieuwe cliënt** rechtsboven
|
||||
|
||||
- **Acties:**
|
||||
- Klik op rij → navigeert naar Cliëntdossier (Dashboard)
|
||||
- Klik **+ Nieuwe cliënt** → opent modal/drawer met formulier:
|
||||
- Velden: Voornaam (verplicht), Achternaam (verplicht), Geboortedatum (datum picker)
|
||||
- Knop **Annuleren** | **Opslaan**
|
||||
- Bij opslaan: ClientID wordt automatisch gegenereerd (UUID)
|
||||
|
||||
- **States:**
|
||||
- **Leeg-staat:** "Nog geen cliënten. Klik op '+ Nieuwe cliënt' om te starten."
|
||||
- **Laden:** Skeleton loaders voor tabelrijen
|
||||
- **Fout:** Toast-melding "Kon cliënten niet laden. Probeer opnieuw."
|
||||
|
||||
---
|
||||
|
||||
### 4.2 Cliëntdossier / Dashboard
|
||||
|
||||
**Doel:** Overzichtspagina per cliënt met configureerbare informatie-tegels.
|
||||
|
||||
**Structuur:**
|
||||
- **Topbalk:**
|
||||
- Breadcrumb: Cliënten > [Naam cliënt]
|
||||
- Rechtsboven: Knop **Instellingen** (tandwiel-icoon) → opent tegel-configuratie modal
|
||||
|
||||
- **Linkernavigatie (verticaal):**
|
||||
- Menu-items: Overzicht (actief) | Intakes | Probleemprofiel | Behandelplan | *(Afspraken)*
|
||||
- Actieve item heeft blauwe accent-bar en lichte achtergrond
|
||||
|
||||
- **Middenpaneel (tegels):**
|
||||
- Configureerbare tegels (via instellingen aan/uit te zetten):
|
||||
1. **Basisgegevens** — ClientID, Naam, Geboortedatum
|
||||
2. **Laatste Intake** — titel, datum, eerste 3 regels + "Lees meer..."
|
||||
3. **Probleemprofiel** — DSM-light categorie badge + severity badge (Laag/Middel/Hoog)
|
||||
4. **Behandelplan** — status (Concept/Gepubliceerd), aantal doelen, laatst bijgewerkt
|
||||
5. **Afspraken** — laatste afspraak + eerstvolgende 3 afspraken (optioneel, stretch)
|
||||
|
||||
**Interacties:**
|
||||
- Klik op tegel → navigeert naar desbetreffende sectie (bv. Intake-tegel → Intakes tab)
|
||||
- **Instellingen modal:**
|
||||
- Checkboxes per tegel om zichtbaarheid in/uit te schakelen
|
||||
- Knop **Opslaan** → slaat voorkeur op (per gebruiker, lokaal)
|
||||
|
||||
---
|
||||
|
||||
### 4.3 Intakeverslag
|
||||
|
||||
**Doel:** Creëren en bewerken van intake-notities met rich text en AI-ondersteuning.
|
||||
|
||||
**Layout:**
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────┐
|
||||
│ Topbalk: Cliëntnaam | [Opslaan] [AI-acties ▼] │
|
||||
├───────────────┬─────────────────────────────────────────┤
|
||||
│ Linkernav │ Editor (hoofdpaneel) │ AI-rail │
|
||||
│ (tabs) │ TipTap rich text │ (rechts) │
|
||||
│ │ │ │
|
||||
├───────────────┴─────────────────────────┴───────────────┤
|
||||
│ Toast area (meldingen) │
|
||||
└─────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**Hoofdpaneel (Editor):**
|
||||
- **Formulier boven editor:**
|
||||
- Titel (optioneel): "Intake [datum]"
|
||||
- Tag dropdown: Intake | Evaluatie | Plan
|
||||
|
||||
- **TipTap rich text editor:**
|
||||
- Toolbar: Bold, Italic, Underline, Bullet list, Numbered list, Blockquote
|
||||
- Placeholder: "Noteer hier de intake-informatie..."
|
||||
- Auto-save indicator: "Opgeslagen om [tijd]" onder editor
|
||||
|
||||
- **Knoppen onder editor:**
|
||||
- **Opslaan** (primair, blauw) — slaat verslag op
|
||||
- **AI-acties** dropdown (secundair, grijs):
|
||||
- Samenvatten
|
||||
- Verbeter leesbaarheid (B1)
|
||||
- Extract problemen
|
||||
|
||||
**AI-rail (rechterpaneel):**
|
||||
- **Initieel:** Leeg met prompt "Selecteer een AI-actie om te beginnen"
|
||||
|
||||
- **Na AI-actie:**
|
||||
- **Header:** "AI-resultaat: [actienaam]" + loading spinner tijdens verwerking
|
||||
- **Content area:**
|
||||
- Voor **Samenvatten**: Bulletpoints van samenvatting
|
||||
- Voor **Leesbaarheid**: Herschreven tekst (diff-weergave optioneel)
|
||||
- Voor **Extract**: Voorgestelde categorie + severity + bronzinnen (highlighted in editor)
|
||||
- **Acties:**
|
||||
- **Invoegen** (primair) — voegt resultaat in editor toe
|
||||
- **Kopiëren** (secundair) — kopieert naar clipboard
|
||||
- **Annuleren** (ghost) — verwerpt resultaat
|
||||
|
||||
**States & feedback:**
|
||||
- **AI bezig:** Non-blocking spinner in AI-rail + "Genereren..." melding
|
||||
- **AI fout:** Foutmelding in rail: "Kon niet verwerken. Probeer opnieuw." + retry-knop
|
||||
- **Opslaan gelukt:** Groene toast "Verslag opgeslagen"
|
||||
- **Opslaan mislukt:** Rode toast "Kon niet opslaan. Controleer verbinding."
|
||||
|
||||
**AI Source Highlighting (voor Extract):**
|
||||
- Bronzinnen die AI gebruikt heeft worden gehighlight in de editor (lichtgele achtergrond)
|
||||
- Highlights verdwijnen bij Invoegen, Annuleren of nieuwe AI-actie
|
||||
|
||||
**Keyboard shortcuts:**
|
||||
- `Ctrl/Cmd+S`: Opslaan
|
||||
- `Ctrl/Cmd+K`: Zoeken in tekst
|
||||
- `Ctrl/Cmd+N`: Nieuw verslag
|
||||
|
||||
---
|
||||
|
||||
### 4.4 Probleemprofiel (DSM-light)
|
||||
|
||||
**Doel:** Categoriseren van problematiek volgens vereenvoudigde DSM-classificatie met severity-bepaling.
|
||||
|
||||
**Layout:**
|
||||
- **Formulier (links, 60%):**
|
||||
- **Categorie** (dropdown, verplicht):
|
||||
- Stemming / Depressieve klachten
|
||||
- Angststoornissen
|
||||
- Gedrags- en impulsstoornissen
|
||||
- Middelengebruik / Verslaving
|
||||
- Cognitieve stoornissen
|
||||
- Context / Psychosociaal
|
||||
- **Severity** (button group of slider):
|
||||
- Laag (grijs badge)
|
||||
- Middel (geel badge)
|
||||
- Hoog (rood badge)
|
||||
- **Opmerkingen** (textarea, optioneel): vrij tekstveld voor notities
|
||||
- **Bronverslag** (readonly): "Gebaseerd op intake [titel] van [datum]"
|
||||
|
||||
- **AI-suggestie paneel (rechts, 40%):**
|
||||
- **Trigger:** Knop **AI › Analyseer intake**
|
||||
- **Output:**
|
||||
- Voorgestelde categorie (highlight)
|
||||
- Voorgestelde severity (highlight)
|
||||
- Rationale (korte uitleg, 2-3 zinnen)
|
||||
- Bronzinnen (quotes uit intake)
|
||||
- **Acties:**
|
||||
- **Accepteer suggestie** — vult formulier automatisch in
|
||||
- **Negeer** — sluit suggestie paneel
|
||||
|
||||
**States:**
|
||||
- **Geen profiel:** "Nog geen probleemprofiel. Start met AI-analyse of vul handmatig in."
|
||||
- **AI bezig:** Skeleton loader in suggestie-paneel
|
||||
- **Opgeslagen:** Groene melding "Probleemprofiel opgeslagen" → activeert Behandelplan tab
|
||||
|
||||
---
|
||||
|
||||
### 4.5 Behandelplan
|
||||
|
||||
**Doel:** Genereren en bewerken van een gestructureerd behandelplan met SMART-doelen.
|
||||
|
||||
**Structuur:**
|
||||
- **Header:**
|
||||
- Versie-indicator: "Concept" (oranje badge) of "Versie X – Gepubliceerd" (groene badge)
|
||||
- Publicatiedatum (indien gepubliceerd)
|
||||
|
||||
- **Vier secties (cards/accordions):**
|
||||
|
||||
1. **Doelen**
|
||||
- Lijst van doelen (bullets, bewerkbaar)
|
||||
- Voorbeeld: "Cliënt ervaart minder angstklachten in sociale situaties binnen 3 maanden"
|
||||
- **Micro-AI-actie:** Knop **↻ Regenereer** per doel
|
||||
|
||||
2. **Interventies**
|
||||
- Lijst van interventies
|
||||
- Voorbeeld: "Cognitieve gedragstherapie (CGT), 12 sessies"
|
||||
- **Micro-AI-actie:** Knop **↻ Regenereer** per interventie
|
||||
|
||||
3. **Frequentie/Duur**
|
||||
- Tekstveld met suggestie
|
||||
- Voorbeeld: "Wekelijks, 12 weken, 50 minuten per sessie"
|
||||
|
||||
4. **Meetmomenten**
|
||||
- Lijst van evaluatiemomenten
|
||||
- Voorbeeld: "Na 4 sessies, na 8 sessies, afsluiting na 12 sessies"
|
||||
|
||||
**Initiële generatie:**
|
||||
- **Trigger:** Knop **AI › Genereer behandelplan** (alleen zichtbaar als probleemprofiel bestaat)
|
||||
- **Input:** Gebruikt intake-notities + probleemprofiel als context
|
||||
- **Output:** Vult alle vier secties met voorstellen
|
||||
- **Feedback:** "Plan gegenereerd. Bekijk en bewerk indien nodig." (blauwe info-toast)
|
||||
|
||||
**Bewerken:**
|
||||
- Alle velden/bullets zijn inline bewerkbaar (contentEditable of input fields)
|
||||
- **Auto-save:** Elke wijziging wordt automatisch opgeslagen als concept
|
||||
|
||||
**Publiceren:**
|
||||
- **Knop:** **Publiceer v[N]** (rechtsboven)
|
||||
- **Validatie:** Controleer of alle secties gevuld zijn
|
||||
- **Actie:**
|
||||
- Wijzigt status van "Concept" naar "Gepubliceerd"
|
||||
- Verhoogt versienummer
|
||||
- Timestamp van publicatie
|
||||
- Concept wordt read-only; nieuwe wijzigingen maken nieuwe versie aan
|
||||
- **Feedback:** "Behandelplan v1 gepubliceerd" (groene toast)
|
||||
|
||||
**States:**
|
||||
- **Geen plan:** "Nog geen behandelplan. Genereer met AI of start handmatig."
|
||||
- **Concept:** Oranje badge, bewerkbaar
|
||||
- **Gepubliceerd:** Groene badge, read-only met knop **Nieuwe versie**
|
||||
|
||||
---
|
||||
|
||||
### 4.6 Mini-agenda (stretch, optioneel)
|
||||
|
||||
**Doel:** Afspraken koppelen aan cliënt voor planning en follow-up.
|
||||
|
||||
**Functionaliteit:**
|
||||
- Kalenderweergave (week of maand)
|
||||
- **Nieuwe afspraak:**
|
||||
- Datum/tijd picker
|
||||
- Type afspraak (dropdown): Intake | Evaluatie | Behandeling
|
||||
- Locatie (optioneel)
|
||||
- Notities (optioneel)
|
||||
- **Weergave in dashboard:** laatste + eerstvolgende 3 afspraken
|
||||
|
||||
---
|
||||
|
||||
### 4.7 Rapportage (stretch, optioneel)
|
||||
|
||||
**Doel:** PDF export van volledige cliëntdossier voor archivering of delen.
|
||||
|
||||
**Functionaliteit:**
|
||||
- **Knop:** **Exporteer als PDF** in cliënt-menu
|
||||
- **Inhoud:**
|
||||
- Basisgegevens
|
||||
- Alle intakes (chronologisch)
|
||||
- Probleemprofiel
|
||||
- Behandelplan (gepubliceerde versie)
|
||||
- *(Optioneel)* Afspraken
|
||||
- **Output:** Downloads PDF met professionele opmaak (logo, headers, footers)
|
||||
|
||||
---
|
||||
|
||||
## 5. UI-overzicht (visuele structuur)
|
||||
|
||||
### Globale layout (alle schermen)
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────┐
|
||||
│ Topbalk: Logo | Breadcrumb | Zoeken | User menu │
|
||||
├───────────────┬──────────────────────────────────────────────┤
|
||||
│ Linkernav │ Middenpaneel (content area) │
|
||||
│ (indien actief│ → Dashboard: tegels │
|
||||
│ in dossier) │ → Intake: editor + AI-rail │
|
||||
│ │ → Profiel: formulier + suggestie │
|
||||
│ Overzicht │ → Plan: secties met doelen/interventies │
|
||||
│ Intakes │ │
|
||||
│ Profiel │ │
|
||||
│ Plan │ │
|
||||
│ (Afspraken) │ │
|
||||
├───────────────┴──────────────────────────────────────────────┤
|
||||
│ Toast area (rechtsonder): meldingen (success/error/info) │
|
||||
└──────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### Cliëntenlijst (geen linkernav)
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────┐
|
||||
│ Topbalk: Logo | Zoeken | [+ Nieuwe cliënt] │
|
||||
├──────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ Cliëntenlijst │
|
||||
│ ┌────────────────────────────────────────────────────┐ │
|
||||
│ │ ID │ Naam │ Geboortedatum │ Update │ │
|
||||
│ ├───────┼──────────────────┼───────────────┼────────┤ │
|
||||
│ │ C-001 │ Jan de Vries │ 15-03-1985 │ 2u │ │
|
||||
│ │ C-002 │ Maria Jansen │ 22-07-1990 │ 1d │ │
|
||||
│ └────────────────────────────────────────────────────┘ │
|
||||
│ │
|
||||
└──────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### Intake-editor met AI-rail
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────┐
|
||||
│ Jan de Vries | [Opslaan] [AI-acties ▼] │
|
||||
├───────────────┬─────────────────────┬────────────────────────┤
|
||||
│ Overzicht │ Editor │ AI-rail │
|
||||
│ Intakes ● │ ┌─────────────────┐ │ ┌──────────────────┐ │
|
||||
│ Profiel │ │ Titel: [.......]│ │ │ AI-resultaat: │ │
|
||||
│ Plan │ │ Tag: [Intake ▼] │ │ │ Samenvatting │ │
|
||||
│ │ └─────────────────┘ │ │ │ │
|
||||
│ │ │ │ • Punt 1 │ │
|
||||
│ │ Rich text area... │ │ • Punt 2 │ │
|
||||
│ │ │ │ │ │
|
||||
│ │ │ │ [Invoegen] │ │
|
||||
│ │ │ │ [Annuleren] │ │
|
||||
│ │ │ └──────────────────┘ │
|
||||
│ │ [Opslaan] │ │
|
||||
├───────────────┴─────────────────────┴────────────────────────┤
|
||||
│ Toast: "Verslag opgeslagen" (groen) │
|
||||
└──────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. Interacties met AI (functionele beschrijving)
|
||||
|
||||
| Locatie | AI-actie | Trigger | Input | Output | Feedback |
|
||||
|----------|-----------|----------|--------|---------|----------|
|
||||
| **Intake-editor** | Samenvatten | Klik op **AI › Samenvatten** | TipTap JSON (intake-tekst) | 5-8 bullets in NL | Preview in AI-rail → Invoegen/Annuleren |
|
||||
| **Intake-editor** | Leesbaarheid (B1) | Klik op **AI › Verbeter leesbaarheid** | TipTap JSON | Herschreven tekst (B1-niveau) | Preview in AI-rail → Invoegen/Annuleren |
|
||||
| **Intake-editor** | Extract problemen | Klik op **AI › Extract problemen** | TipTap JSON | Categorie + severity + rationale + bronzinnen | Suggestie in AI-rail + highlights in editor |
|
||||
| **Probleemprofiel** | Analyseer intake | Klik op **AI › Analyseer intake** | Intake-tekst (laatste verslag) | Voorgestelde categorie + severity + rationale | Suggestie-paneel rechts → Accepteren/Negeren |
|
||||
| **Behandelplan** | Genereer plan | Klik op **AI › Genereer behandelplan** | Intake + probleemprofiel | 4 secties (doelen, interventies, frequentie, meetmomenten) | Vult alle secties → bewerkbaar |
|
||||
| **Behandelplan** | Regenereer doel | Klik op **↻** bij specifiek doel | Context (huidige doelen + intake) | Nieuw geformuleerd doel (SMART) | Vervangt huidige doel → bewerkbaar |
|
||||
|
||||
**AI-processing states:**
|
||||
- **Bezig:** Non-blocking spinner + "Genereren..." tekst
|
||||
- **Succes:** Output verschijnt in preview/suggestie-area
|
||||
- **Fout:** Rode melding "Kon niet verwerken" + retry-knop
|
||||
- **Timeout:** "AI-actie duurde te lang. Probeer opnieuw."
|
||||
|
||||
**AI-highlights (Extract problemen):**
|
||||
- Bronzinnen krijgen lichtgele achtergrond in editor
|
||||
- Highlights verdwijnen bij: Invoegen, Annuleren, of nieuwe AI-actie
|
||||
- Implementatie: TipTap Decorations API
|
||||
|
||||
---
|
||||
|
||||
## 7. Gebruikersrollen en rechten
|
||||
|
||||
**MVP:** Vereenvoudigde autorisatie — alle authenticated users hebben volledige toegang (demo-omgeving).
|
||||
|
||||
| Rol | Toegang tot | Beperkingen | Implementatie |
|
||||
|------|--------------|-------------|---------------|
|
||||
| **Demo-user** (MVP) | Alle cliëntdossiers, alle functies | Alleen fictieve data | Supabase Auth, RLS policy: `auth.uid() IS NOT NULL` |
|
||||
|
||||
**Post-MVP (Roadmap):**
|
||||
|
||||
| Rol | Toegang tot | Beperkingen |
|
||||
|------|--------------|-------------|
|
||||
| **Behandelaar** | Eigen cliëntdossiers + gedeelde dossiers | Kan alleen eigen dossiers bewerken |
|
||||
| **Manager** | Alle dossiers (read-only) | Geen bewerkingen, alleen rapportages |
|
||||
| **Admin** | Alles | Volledige CRUD + gebruikersbeheer |
|
||||
|
||||
**Toekomstige implementatie:**
|
||||
- Multi-tenant: `org_id` kolom in alle tables
|
||||
- RLS policies: `auth.jwt() ->> 'org_id' = org_id`
|
||||
- Role-based access: `auth.jwt() ->> 'role'` checks
|
||||
|
||||
---
|
||||
|
||||
## 8. UX-specificaties (koppeling met stylesheet)
|
||||
|
||||
**Kleurgebruik (zie `/docs/ux-stylesheet.md`):**
|
||||
- **Primary actions:** `#3B82F6` (blauw) — Opslaan, Publiceren, Invoegen
|
||||
- **Secondary actions:** `#334155` (grijs) — Annuleren, Terug
|
||||
- **Success feedback:** `#16A34A` (groen) — toasts, badges
|
||||
- **Warning/Concept:** `#EAB308` (geel) — concept-status
|
||||
- **Error:** `#DC2626` (rood) — foutmeldingen
|
||||
|
||||
**Module-accenten:**
|
||||
- Afspraken: groen (`#E8F8EF` bg, `#16A34A` accent)
|
||||
- Medicatie/Herinneringen: geel (`#FEF6DC` bg, `#F59E0B` accent)
|
||||
- Lab/Resultaten: oranje (`#FFEBDC` bg, `#F97316` accent)
|
||||
|
||||
**Toegankelijkheid:**
|
||||
- Alle tekst voldoet aan WCAG AA contrast (min. 4.5:1)
|
||||
- Focus rings altijd zichtbaar (2px `#3B82F6`)
|
||||
- Keyboard navigation volledig ondersteund
|
||||
- Status niet alleen met kleur: iconen + labels combineren
|
||||
|
||||
---
|
||||
|
||||
## 9. Demo-scenario (10 minuten)
|
||||
|
||||
**Voorbereiding:** Database seeden met 2-3 fictieve cliënten (1 met partial data, 1 leeg).
|
||||
|
||||
### Flow A: Nieuwe cliënt → Intake → AI Samenvatten (4 min)
|
||||
1. **Start:** Cliëntenlijst (0:00)
|
||||
2. Klik **+ Nieuwe cliënt** → vul in: "Test Demo", "Testpersoon", "01-01-1990" → Opslaan (0:30)
|
||||
3. Navigeer naar nieuwe cliënt → klik **Intakes** tab (0:45)
|
||||
4. Klik **+ Nieuw verslag** → typ demo-intake (vooraf geprepareerde tekst plakken) (1:30)
|
||||
5. Klik **AI › Samenvatten** → toon preview in AI-rail (2:00)
|
||||
6. Klik **Invoegen** → samenvatting verschijnt in editor (2:30)
|
||||
7. Klik **Opslaan** → toast "Verslag opgeslagen" (3:00)
|
||||
|
||||
### Flow B: Probleemprofiel genereren → AI suggestie (3 min)
|
||||
8. Klik **Probleemprofiel** tab (3:15)
|
||||
9. Klik **AI › Analyseer intake** → toon suggestie (categorie, severity, rationale) (4:00)
|
||||
10. Highlights verschijnen in editor (source highlighting demo) (4:30)
|
||||
11. Klik **Accepteer suggestie** → vult formulier (4:45)
|
||||
12. Klik **Opslaan** → groene toast + Behandelplan tab wordt actief (5:00)
|
||||
|
||||
### Flow C: Behandelplan genereren → Bewerken → Publiceren (3 min)
|
||||
13. Klik **Behandelplan** tab (5:15)
|
||||
14. Klik **AI › Genereer behandelplan** → toon alle vier secties (6:00)
|
||||
15. Bewerk één doel handmatig → auto-save indicator (6:45)
|
||||
16. Klik **Publiceer v1** → status wijzigt naar "Gepubliceerd" (7:30)
|
||||
17. Navigeer terug naar **Overzicht** → toon dashboard met tegels (8:00)
|
||||
18. **(Optioneel)** Demo PDF export (8:30)
|
||||
|
||||
**Afsluiting:** Q&A + discussie AI-toegevoegde waarde (8:30-10:00)
|
||||
|
||||
---
|
||||
|
||||
## 10. Bijlagen & Referenties
|
||||
|
||||
**Gerelateerde documenten:**
|
||||
- [PRD (Product Requirements Document)](./prd-mini-ecd.md)
|
||||
- [TO (Technisch Ontwerp)](./to-mini-ecd.md)
|
||||
- [UX/UI Stylesheet](./ux-stylesheet.md)
|
||||
- [API Access Document](./api-acces-mini-ecd.md)
|
||||
|
||||
**Externe referenties:**
|
||||
- TipTap editor: https://tiptap.dev
|
||||
- Supabase documentatie: https://supabase.com/docs
|
||||
- Next.js App Router: https://nextjs.org/docs/app
|
||||
- Claude AI API: https://docs.anthropic.com/claude/reference
|
||||
|
||||
---
|
||||
|
||||
**Wijzigingslog:**
|
||||
- v1.0 (09-11-2025): Initiële versie voor MVP demo
|
||||
138
docs/specs/archive/prd-mini-ecd.md
Normal file
138
docs/specs/archive/prd-mini-ecd.md
Normal file
@@ -0,0 +1,138 @@
|
||||
# 📄 Product Requirements Document (PRD)
|
||||
|
||||
**Product:** Mini-ECD Prototype
|
||||
**Doel:** Demo tijdens AI-inspiratiesessie bij PinkRoccade GGZ
|
||||
**Versie:** 1.1 (MVP met DSM-light simulatie)
|
||||
**Datum:** aug 2025
|
||||
|
||||
---
|
||||
|
||||
## 1. Doelstelling
|
||||
|
||||
Een werkend **mini-ECD prototype** waarmee we tijdens de workshop de kernprocessen uit de GGZ kunnen demonstreren: **intake → probleemclassificatie → behandelplan**.
|
||||
Focus ligt op het **zichtbaar maken van AI-waarde** (samenvatten, structureren, plan genereren) in een herkenbare workflow.
|
||||
|
||||
---
|
||||
|
||||
## 2. Doelgroep
|
||||
|
||||
* **Product Owners & Managers** → inzicht in AI als hulpmiddel.
|
||||
* **Developers** → inspiratie voor AI-integratie.
|
||||
* **Consultants / GGZ-professionals** → herkenbare ECD-structuur.
|
||||
|
||||
---
|
||||
|
||||
## 3. Kernfunctionaliteiten (MVP)
|
||||
|
||||
1. **Cliënt inschrijven**
|
||||
|
||||
* Velden: Voornaam, Achternaam, Geboortedatum.
|
||||
* Automatische ClientID.
|
||||
* Verschijnt in Cliëntenlijst.
|
||||
|
||||
2. **Overzicht (Cliëntdashboard)**
|
||||
|
||||
* Tegels:
|
||||
|
||||
* Basisgegevens: ClientID, Naam, Geboortedatum.
|
||||
* Intake: verkorte weergave laatste intakeverslag.
|
||||
* Probleemprofiel: DSM-light categorie + severity-badge.
|
||||
* Behandelplan: doelen in bullets + status.
|
||||
* Afspraken: laatste afspraak + eerstvolgende 3 afspraken.
|
||||
* Configuratie: gebruiker kan via een instellingen-knop kiezen welke tegels zichtbaar zijn.
|
||||
|
||||
3. **Intake-verslag maken**
|
||||
|
||||
* Rich text editor.
|
||||
* Tags: Intake / Evaluatie / Plan.
|
||||
* Opslaan & koppelen aan cliënt.
|
||||
|
||||
4. **Probleemprofiel (DSM-light simulatie)**
|
||||
|
||||
* Dropdown categorieën (simulatie DSM-5 hoofdcategorieën):
|
||||
|
||||
* Stemming / Depressieve klachten
|
||||
* Angststoornissen
|
||||
* Gedrags- en impulsstoornissen
|
||||
* Middelengebruik / Verslaving
|
||||
* Cognitieve stoornissen
|
||||
* Context / Psychosociaal
|
||||
* Severity: Laag / Middel / Hoog.
|
||||
* Vrij veld: opmerkingen.
|
||||
* **AI-suggestie:** intake analyseren → voorstel categorie + severity.
|
||||
|
||||
5. **AI-ondersteuning bij verslag**
|
||||
|
||||
* Knoppen:
|
||||
|
||||
* *Samenvatten* (in bullets).
|
||||
* *Verbeter leesbaarheid* (B1-niveau).
|
||||
* *Extract problemen* (AI vult categorie/severity suggestie in).
|
||||
|
||||
6. **AI-voorstel behandelplan**
|
||||
|
||||
* Genereert secties: Doelen, Interventies, Frequentie/Duur, Meetmomenten.
|
||||
* Gebruiker kan bewerken of accepteren.
|
||||
|
||||
7. **Mini-agenda (optioneel, stretch)**
|
||||
|
||||
* Afspraak plannen gekoppeld aan cliënt.
|
||||
|
||||
8. **Rapport export (stretch)**
|
||||
|
||||
* PDF: cliëntgegevens + intake + probleemprofiel + behandelplan.
|
||||
|
||||
---
|
||||
|
||||
## 4. Demo-flows
|
||||
|
||||
1. **Nieuwe cliënt → Intake maken → AI Samenvatten.**
|
||||
2. **Probleemprofiel genereren → AI suggestie → severity kiezen.**
|
||||
3. **Behandelplan genereren → Accept → Opslaan.**
|
||||
*(Optioneel: afspraak plannen en rapport exporteren.)*
|
||||
|
||||
---
|
||||
|
||||
## 5. Niet in scope
|
||||
|
||||
* Autorisaties en rollenbeheer.
|
||||
* Externe koppelingen (Teams, TOPdesk, etc.).
|
||||
* Volledige DSM-5 implementatie (alleen simulatie).
|
||||
* Dit prototype is geen gevalideerd medisch hulpmiddel en dient enkel voor demonstratiedoeleinden.
|
||||
|
||||
---
|
||||
|
||||
## 6. Technische randvoorwaarden
|
||||
|
||||
* **Framework:** Next.js
|
||||
* **Styling:** Tailwind
|
||||
* **Database:** Supabase
|
||||
* **AI:** Claude AI
|
||||
* **Hosting:** Vercel (EU).
|
||||
|
||||
---
|
||||
|
||||
## 7. Succescriteria
|
||||
|
||||
* Demo duurt max. 10 minuten.
|
||||
* Herkenbare flow (intake → profiel → plan).
|
||||
* AI-output direct zichtbaar en bewerkbaar.
|
||||
* Minimaal 1 deelnemer kan live een cliënt toevoegen.
|
||||
* Deelnemers aan de workshop begrijpen de toegevoegde waarde van AI in het ECD-proces.
|
||||
|
||||
---
|
||||
|
||||
## 8. Risico’s
|
||||
|
||||
* **Privacy:** uitsluitend fictieve data.
|
||||
* **AI-output inconsistent:** prompts vooraf testen.
|
||||
* **Scope creep:** strak houden bij intake → plan.
|
||||
|
||||
---
|
||||
|
||||
## 9. Roadmap (post-demo)
|
||||
|
||||
* Autorisaties en auditlog.
|
||||
* Trendanalyse (stemming/voortgang).
|
||||
* Integratie met PinkRoccade modules.
|
||||
* Compliance en security uitbreiden.
|
||||
390
docs/specs/archive/to-mini-ecd.md
Normal file
390
docs/specs/archive/to-mini-ecd.md
Normal file
@@ -0,0 +1,390 @@
|
||||
# ⚙️ Technisch Ontwerp — Mini‑ECD (MVP)
|
||||
|
||||
**Datum:** aug 2025
|
||||
**Scope:** MVP voor demo tijdens AI‑inspiratiesessie (≤10 min)
|
||||
**Bronnen:** PRD (v1.1), UX/UI‑specificatie, FO (MVP)
|
||||
|
||||
---
|
||||
|
||||
## 0) TL;DR Stack & Keuzes
|
||||
|
||||
* **Framework**: **Next.js** (App Router)
|
||||
* **UI**: **Tailwind CSS** (v4; fallback v3.4 bij frictie) + **lucide-react** iconen; lichte componentlaag (shadcn/ui of eigen + headless)
|
||||
* **Editor**: **TipTap** (ProseMirror) met StarterKit + BasicNodes
|
||||
* **Auth & Data**: **Supabase** (PostgreSQL + Auth + Storage)
|
||||
* **AI**: **Claude** (Anthropic) via API
|
||||
* **Hosting**: **Vercel** (Next.js)
|
||||
* **PDF (stretch)**: server‑side HTML→PDF via **Chromium (playwright/puppeteer)** of cloud‑functie.
|
||||
* **Test**: **Vitest** (unit) + **Playwright** (e2e).
|
||||
|
||||
> ✅ Past bij MVP: minimale libs, AI‑calls server‑side, EU‑dataregio (Supabase EU), TipTap voor rijke tekst.
|
||||
|
||||
---
|
||||
|
||||
## 1) Architectuur
|
||||
|
||||
### 1.1 Overzicht
|
||||
|
||||
```
|
||||
Browser (UI)
|
||||
└─ Next.js (App Router)
|
||||
├─ Supabase (PostgreSQL + Auth + Storage)
|
||||
├─ Claude AI (Anthropic)
|
||||
└─ (Stretch) PDF service (Chromium in serverless)
|
||||
```
|
||||
|
||||
* **Server‑side AI‑calls**: keys blijven op de server; UI krijgt alleen resultaten.
|
||||
* **Dataflow (kern)**: Intake (TipTap) → AI‑samenvat → AI‑extract → Probleemprofiel → AI‑plan → Plan (concept → publiceer).
|
||||
|
||||
### 1.2 Routing & lagen
|
||||
|
||||
* **Pages** (App Router): `/clients`, `/clients/[id]` (tabs: overzicht/intakes/profiel/plan).
|
||||
* **API** (Next.js Route Handlers): `/api/clients`, `/api/intakes`, `/api/problem-profile`, `/api/treatment-plan`, `/api/ai/*`.
|
||||
|
||||
### 1.3 State
|
||||
|
||||
De state van de applicatie wordt beheerd met **React Context API** + **Zustand** (lichtgewicht state library). Dit is eenvoudig genoeg voor de MVP-scope. State wordt georganiseerd in `src/lib/stores/` of `src/contexts/`.
|
||||
|
||||
* **`clientStore.ts` (Zustand)**: Beheert de state gerelateerd aan cliëntdata.
|
||||
* `selectedClientId: string | null`: Houdt het ID van de actieve cliënt bij. Dit is de centrale spil van de applicatie-staat.
|
||||
* `clients: Client[]`: De lijst van alle cliënten voor de overzichtspagina.
|
||||
* `currentClientDossier: Dossier | null`: Reageert op wijzigingen in `selectedClientId`. Wanneer de ID verandert, haalt de store automatisch de volledige dossierinhoud (intakes, profiel, plan) op via Supabase.
|
||||
|
||||
* **`uiStore.ts` (Zustand)**: Beheert globale UI-state.
|
||||
* `toasts: ToastMessage[]`: Een array met actieve 'toast'-notificaties die globaal getoond kunnen worden.
|
||||
|
||||
* **Dataflow Patroon**:
|
||||
1. De UI update `selectedClientId` via Zustand action.
|
||||
2. De store triggert een Supabase query om dossierdata op te halen.
|
||||
3. React componenten die subscribed zijn via `useClientStore()` updaten automatisch.
|
||||
|
||||
* **Alternatief (MVP)**: Voor kleinere state kan ook React Context + `useState` volstaan zonder externe library.
|
||||
|
||||
Dit patroon zorgt voor een efficiënte, voorspelbare en reactieve dataflow door de hele applicatie.
|
||||
|
||||
---
|
||||
|
||||
## 2) Data‑model (Supabase / PostgreSQL)
|
||||
|
||||
### 2.1 Entiteiten
|
||||
|
||||
* **clients** — basisgegevens
|
||||
* **intake\_notes** — TipTap JSON + afgeleide velden
|
||||
* **problem\_profiles** — DSM‑light categorie + severity
|
||||
* **treatment\_plans** — JSONB plan (doelen/interventies/frequentie/meetmomenten), versie/status
|
||||
* **ai\_events** — prompts/completions (telemetrie, debugging)
|
||||
* *(Stretch)* **appointments**, **reports**
|
||||
|
||||
### 2.2 Relaties (PostgreSQL)
|
||||
|
||||
```
|
||||
clients (id UUID PRIMARY KEY)
|
||||
├── intake_notes (client_id → clients.id, FK)
|
||||
├── problem_profiles (client_id → clients.id, FK)
|
||||
└── treatment_plans (client_id → clients.id, FK)
|
||||
|
||||
ai_events (id UUID PRIMARY KEY, client_id + note_id als optionele FKs)
|
||||
```
|
||||
|
||||
**Row Level Security (RLS)**: Alle tables hebben RLS policies voor auth.users().
|
||||
|
||||
### 2.3 Tables (PostgreSQL schema)
|
||||
|
||||
> **NB**: Enums als TEXT met CHECK constraints; plan inhoud als JSONB voor flexibiliteit in MVP.
|
||||
|
||||
```typescript
|
||||
// PostgreSQL Tables Schema (TypeScript types)
|
||||
|
||||
// clients table
|
||||
interface Client {
|
||||
id: string; // UUID (auto-generated)
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
birth_date: string; // DATE (ISO 8601: YYYY-MM-DD)
|
||||
created_at: string; // TIMESTAMPTZ
|
||||
updated_at: string; // TIMESTAMPTZ
|
||||
}
|
||||
|
||||
// intake_notes table
|
||||
interface IntakeNote {
|
||||
id: string; // UUID
|
||||
client_id: string; // FK → clients.id
|
||||
title?: string;
|
||||
tag: 'Intake' | 'Evaluatie' | 'Plan'; // TEXT with CHECK
|
||||
content_json: object; // JSONB (ProseMirror document)
|
||||
content_text?: string; // TEXT (for full-text search)
|
||||
author?: string; // FK → auth.users.id (optioneel)
|
||||
created_at: string; // TIMESTAMPTZ
|
||||
updated_at: string; // TIMESTAMPTZ
|
||||
}
|
||||
|
||||
// problem_profiles table
|
||||
interface ProblemProfile {
|
||||
id: string; // UUID
|
||||
client_id: string; // FK → clients.id
|
||||
category: 'stemming_depressie' | 'angst' | 'gedrag_impuls' |
|
||||
'middelen_gebruik' | 'cognitief' | 'context_psychosociaal'; // TEXT with CHECK
|
||||
severity: 'laag' | 'middel' | 'hoog'; // TEXT with CHECK
|
||||
remarks?: string; // TEXT
|
||||
source_note_id?: string; // FK → intake_notes.id
|
||||
created_at: string; // TIMESTAMPTZ
|
||||
updated_at: string; // TIMESTAMPTZ
|
||||
}
|
||||
|
||||
// treatment_plans table
|
||||
interface TreatmentPlan {
|
||||
id: string; // UUID
|
||||
client_id: string; // FK → clients.id
|
||||
version: number; // INTEGER
|
||||
status: 'concept' | 'gepubliceerd'; // TEXT with CHECK
|
||||
plan: { // JSONB
|
||||
doelen: string[];
|
||||
interventies: string[];
|
||||
frequentie: string;
|
||||
meetmomenten: string[];
|
||||
};
|
||||
created_by?: string; // FK → auth.users.id
|
||||
created_at: string; // TIMESTAMPTZ
|
||||
published_at?: string; // TIMESTAMPTZ
|
||||
updated_at: string; // TIMESTAMPTZ
|
||||
}
|
||||
|
||||
// ai_events table (telemetrie)
|
||||
interface AiEvent {
|
||||
id: string; // UUID
|
||||
kind: 'summarize' | 'readability' | 'extract' | 'plan'; // TEXT with CHECK
|
||||
client_id?: string; // FK → clients.id (nullable)
|
||||
note_id?: string; // FK → intake_notes.id (nullable)
|
||||
request: object; // JSONB
|
||||
response: object; // JSONB
|
||||
duration_ms: number; // INTEGER
|
||||
created_at: string; // TIMESTAMPTZ
|
||||
}
|
||||
```
|
||||
|
||||
**SQL voorbeelden** voor table creation beschikbaar in `/supabase/migrations/`.
|
||||
**Supabase TypeScript types** kunnen automatisch gegenereerd worden via `supabase gen types typescript`.
|
||||
|
||||
### 2.4 Row Level Security (basis)
|
||||
|
||||
Voor demo kunnen RLS policies simpel zijn: **alle rows zichtbaar voor authenticated users**. In productie: per organisatie/therapeut scheiden met `org_id` kolom.
|
||||
|
||||
```sql
|
||||
-- Demo RLS policies (apply to all tables)
|
||||
-- Enable RLS
|
||||
ALTER TABLE clients ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE intake_notes ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE problem_profiles ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE treatment_plans ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE ai_events ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- Authenticated users kunnen alles lezen/schrijven (demo only!)
|
||||
CREATE POLICY "Allow all for authenticated users" ON clients
|
||||
FOR ALL USING (auth.uid() IS NOT NULL);
|
||||
|
||||
CREATE POLICY "Allow all for authenticated users" ON intake_notes
|
||||
FOR ALL USING (auth.uid() IS NOT NULL);
|
||||
|
||||
CREATE POLICY "Allow all for authenticated users" ON problem_profiles
|
||||
FOR ALL USING (auth.uid() IS NOT NULL);
|
||||
|
||||
CREATE POLICY "Allow all for authenticated users" ON treatment_plans
|
||||
FOR ALL USING (auth.uid() IS NOT NULL);
|
||||
|
||||
CREATE POLICY "Allow all for authenticated users" ON ai_events
|
||||
FOR ALL USING (auth.uid() IS NOT NULL);
|
||||
```
|
||||
|
||||
**Productie**: Voeg `org_id` toe en filter op `auth.jwt() ->> 'org_id'`.
|
||||
|
||||
---
|
||||
|
||||
## 3) API & Endpoints (Next.js Route Handlers)
|
||||
|
||||
### 3.1 CRUD
|
||||
|
||||
* `POST /api/clients` — create
|
||||
|
||||
* `GET /api/clients?query=` — list/search
|
||||
|
||||
* `GET /api/clients/:id` — detail
|
||||
|
||||
* `PATCH /api/clients/:id` — update
|
||||
|
||||
* `POST /api/intakes` — create intake
|
||||
|
||||
* `GET /api/intakes?clientId=` — list
|
||||
|
||||
* `GET /api/intakes/:id` — detail
|
||||
|
||||
* `PATCH /api/intakes/:id` — update
|
||||
|
||||
* `POST /api/problem-profile` — create/update current
|
||||
|
||||
* `GET /api/problem-profile?clientId=` — latest
|
||||
|
||||
* `POST /api/treatment-plan` — create (concept)
|
||||
|
||||
* `PATCH /api/treatment-plan/:id/publish` — publish vN
|
||||
|
||||
### 3.2 AI‑acties
|
||||
|
||||
* `POST /api/ai/summarize` — TipTap JSON → bullets
|
||||
* `POST /api/ai/readability` — TipTap JSON → B1
|
||||
* `POST /api/ai/extract` — TipTap JSON → {category, severity, rationale}
|
||||
* `POST /api/ai/generate-plan` — {noteId | profile} → plan JSON
|
||||
|
||||
**Patroon**: alle AI‑endpoints valideren input, roepen Claude API aan server‑side, loggen in `ai_events`, geven **preview** terug. UI beslist *Insert/Apply*.
|
||||
|
||||
---
|
||||
|
||||
## 4) AI‑integratie (Claude / Anthropic)
|
||||
|
||||
### 4.1 Model & API
|
||||
|
||||
* **Model**: Claude 3.5 Sonnet (of nieuwere versie) via Anthropic API.
|
||||
* **Regio**: Anthropic API is globally distributed; data blijft binnen EU waar mogelijk.
|
||||
* **SDK**: `@anthropic-ai/sdk` (officiële Node.js SDK).
|
||||
|
||||
### 4.2 Prompt‑templates (schets)
|
||||
|
||||
* **Summarize**: *“Vat het onderstaande intake‑verslag samen in 5–8 bullets. Schrijf in NL, klinisch neutraal, zonder PII.”*
|
||||
* **Readability (B1)**: *“Herschrijf leesbaar op B1‑niveau. Behoud medische betekenis, vermijd jargon waar mogelijk.”*
|
||||
* **Extract**: *"Haal uit de tekst: DSM‑light categorie (uit 6), severity (laag/middel/hoog), met korte toelichting en quote‑bronnen."*
|
||||
* **Plan**: *"Genereer behandelplan (Doelen, Interventies, Frequentie/Duur, Meetmomenten) op basis van intake/profiel. SMART‑formuleer doelen."*
|
||||
|
||||
**Parameters (startwaarden)**:
|
||||
- `model`: "claude-3-5-sonnet-20241022" (of nieuwer)
|
||||
- `temperature`: 0.3 (deterministischer)
|
||||
- `max_tokens`: passend per taak (samenvat 800–1200, plan 1600–2400)
|
||||
|
||||
**Veiligheid**: PII-verwijdering in post-processing (heuristiek); gebruik system prompt voor extra context guards.
|
||||
|
||||
---
|
||||
|
||||
## 5) Frontend implementatie
|
||||
|
||||
### 5.1 UI‑skelet
|
||||
|
||||
* **Layout**: Topbar (cliëntcontext) + LeftNav (dossier) + Main (detail) + Toast area.
|
||||
* **Componenten**: Button, Card, Input, Select, Tabs, Badge, Dialog, Drawer, Toast, Tooltip, Breadcrumb.
|
||||
|
||||
### 5.2 TipTap
|
||||
|
||||
* **Nodes**: paragraph, heading, bold/italic/underline, bullet/ordered list, blockquote, code (optioneel).
|
||||
* **Opslag**: `content_json` (ProseMirror doc).
|
||||
* **AI‑Right‑rail**: tabs: Samenvatten, B1, Extract; acties **Preview → Insert**.
|
||||
|
||||
### 5.4 Haalbaarheidsonderzoek: AI Source Highlighting
|
||||
|
||||
Een belangrijke UX-vereiste is het visueel aanduiden (highlighten) van de bronzinnen in de intaketekst die de AI heeft gebruikt voor een suggestie. Dit is technisch goed haalbaar.
|
||||
|
||||
**Aanpak:**
|
||||
|
||||
1. **Backend API Aanpassing**: Het AI-endpoint (bv. `/api/ai/extract`) moet niet alleen de suggestie retourneren, maar ook een array van de exacte bronzinnen (`sourceSentences: string[]`).
|
||||
2. **Frontend TipTap Implementatie**:
|
||||
* De frontend gebruikt de [TipTap Decorations API](https://tiptap.dev/api/decorations) om de highlighting te realiseren. Decorations passen styling toe zonder de onderliggende content te wijzigen.
|
||||
* Bij ontvangst van de `sourceSentences` doorzoekt de frontend het TipTap-document naar de posities (`from`, `to`) van deze zinnen.
|
||||
* Voor elke gevonden positie wordt een `Decoration.inline(from, to, { class: 'ai-source-highlight' })` aangemaakt.
|
||||
3. **Styling**: Een simpele CSS-klasse `.ai-source-highlight` (bv. met een lichtgele achtergrond) wordt toegevoegd aan de globale stylesheet.
|
||||
4. **Lifecycle**: De highlights worden gewist zodra de gebruiker de suggestie accepteert, negeert, of een nieuwe AI-actie initieert.
|
||||
|
||||
**Conclusie**: De aanpak is robuust en de complexiteit is laag tot gemiddeld. Het wordt meegenomen in de PoC voor de TipTap-editor.
|
||||
|
||||
### 5.3 Toetsenbord & UX
|
||||
|
||||
* `Ctrl/Cmd+S` opslaan, `Ctrl/Cmd+K` zoek, `Ctrl/Cmd+N` nieuw verslag.
|
||||
* Leeg‑staten met CTA’s; skeletons bij laden; non‑blocking spinners bij AI.
|
||||
|
||||
---
|
||||
|
||||
## 6) Security, Privacy & Compliance (MVP‑proof)
|
||||
|
||||
* **Data**: uitsluitend fictieve demo‑data; geen echte PII.
|
||||
* **Regio's**: EU‑hosting (Supabase EU: Frankfurt/London; Claude API global).
|
||||
* **Secret handling**: API keys via Vercel Envs; nooit in client bundelen.
|
||||
* **RLS Policies**: minimaal aan; authenticated users krijgen toegang (demo).
|
||||
* **Audit (lichtgewicht)**: `ai_events` + timestamps op alle tables.
|
||||
* **CORS**: beperken tot demo‑domain.
|
||||
|
||||
---
|
||||
|
||||
## 7) Deployment & Environments
|
||||
|
||||
* **Dev**: `.env.local` met Supabase keys + Claude API key
|
||||
* **Preview/Prod**: Vercel project → `VERCEL_ENV` gates; RLS policies via Supabase migrations.
|
||||
* **Supabase**: EU-regio (Frankfurt of London), schema deploy via `supabase db push` of migrations.
|
||||
|
||||
### 7.1 Environment variables (voorbeeld)
|
||||
|
||||
```bash
|
||||
# Supabase
|
||||
NEXT_PUBLIC_SUPABASE_URL=https://xyz.supabase.co
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ... # Public anon key (frontend safe)
|
||||
SUPABASE_SERVICE_ROLE_KEY=eyJ... # Service role key (server only!)
|
||||
|
||||
# Claude AI
|
||||
ANTHROPIC_API_KEY=sk-ant-... # Claude API key (server only!)
|
||||
|
||||
# App
|
||||
NEXT_PUBLIC_APP_URL=https://mini-ecd.example
|
||||
NODE_ENV=production
|
||||
```
|
||||
|
||||
**Security**:
|
||||
- `SUPABASE_SERVICE_ROLE_KEY` en `ANTHROPIC_API_KEY` alleen server-side gebruiken
|
||||
- Vercel Environment Variables voor productie
|
||||
- Gebruik `.env.local` voor lokale ontwikkeling (niet in git!)
|
||||
|
||||
---
|
||||
|
||||
## 8) Setup stappen (korte gids)
|
||||
|
||||
1. **Repo & deps**: init Next.js (App Router) + Tailwind + TipTap + Supabase client + Anthropic SDK.
|
||||
2. **Supabase**: project aanmaken (EU-regio) → Tables uit §2.3 aanmaken via migrations → RLS policies activeren.
|
||||
3. **Env**: Vercel + lokale `.env.local` vullen (Supabase keys + Claude API key).
|
||||
4. **Endpoints**: CRUD + AI‑routes implementeren als Next.js Route Handlers (server‑side).
|
||||
5. **Screens**: Clients list/detail, Intake editor + AI‑rail, Profiel form, Plan cards.
|
||||
6. **Smoke test**: Flow A/B/C end‑to‑end met mock data.
|
||||
7. **(Optioneel)** PDF export & afspraken tab.
|
||||
|
||||
---
|
||||
|
||||
## 9) Test & Kwaliteit
|
||||
|
||||
* **Unit**: parsers, validators, AI‑response mappers (Zod schemas).
|
||||
* **E2E (Playwright)**: Flow A/B/C met seeded data.
|
||||
* **Prompt tests**: vaste inputs → snapshot op kernvelden (niet volledige tekst).
|
||||
|
||||
---
|
||||
|
||||
## 10) Bekende beperkingen & risico's
|
||||
|
||||
* **TipTap** content search: extra index/afgeleide `content_text` nodig voor snelle zoek (PostgreSQL full-text search).
|
||||
* **Claude API rate limits**: monitor gebruik; overweeg caching voor veelvoorkomende prompts.
|
||||
* **Serverless PDF**: kan cold‑start of memory issues geven → overweeg queue/edge function.
|
||||
* **RLS Policies (demo)**: simplistisch; voor productie per organisatie/rol modelleren met `org_id`.
|
||||
|
||||
---
|
||||
|
||||
## 11) Wat ontbrak nog in je stack (aanvullingen)
|
||||
|
||||
* **Tailwind CSS** (UI‑basis) en **iconen (lucide-react)**.
|
||||
* **Auth**: Supabase Auth (magic link, email/password, of OAuth).
|
||||
* **Validatie**: **Zod** voor request/response schemas.
|
||||
* **Logging**: lichte audit via `ai_events` table + Next.js middleware.
|
||||
* **Testing**: Vitest/Playwright.
|
||||
* **PDF (stretch)**: keuze voor renderer (Puppeteer/Playwright).
|
||||
* **Type‑safety**: Supabase auto-generated types via `supabase gen types typescript`.
|
||||
|
||||
---
|
||||
|
||||
## 12) Roadmap na demo
|
||||
|
||||
* Rollen & rechten, multi‑tenant (org\_id) + stricte RLS policies.
|
||||
* Templates per zorgpad (verslag/plan).
|
||||
* Trendanalyse (meetmomenten) + grafieken.
|
||||
* Integraties (PinkRoccade modules), exportprofielen.
|
||||
* Real-time collaboratie via Supabase Realtime (optioneel).
|
||||
|
||||
---
|
||||
Reference in New Issue
Block a user