Initial commit from Create Next App
This commit is contained in:
74
docs/api-acces-mini-ecd.md
Normal file
74
docs/api-acces-mini-ecd.md
Normal file
@@ -0,0 +1,74 @@
|
||||
## API‑toegang Mini‑ECD
|
||||
|
||||
Laatste update: 2025‑11‑09 • Versie: 0.2 (MVP)
|
||||
|
||||
### Overzicht
|
||||
De Mini‑ECD API biedt server‑side endpoints in Next.js voor AI‑functionaliteit (Claude / Anthropic). In de MVP is één endpoint beschikbaar.
|
||||
|
||||
### Base URL
|
||||
- Ontwikkel (lokaal): `http://localhost:3000`
|
||||
- Productie: n.t.b. (Vercel)
|
||||
|
||||
### Authenticatie
|
||||
- **MVP**: geen externe client‑auth; endpoints dienen alleen in trusted context gebruikt te worden (server‑side calls of demo‑omgeving).
|
||||
- Claude AI authenticatie verloopt server‑side via Anthropic API key.
|
||||
|
||||
### Headers
|
||||
- `Content-Type: application/json`
|
||||
|
||||
### Endpoints
|
||||
|
||||
#### POST `/api/ai/summarize`
|
||||
- **Doel**: vat NL intake‑tekst samen in puntsgewijze bullets (max 6), neutraal en feitelijk.
|
||||
- **Request body**
|
||||
```json
|
||||
{
|
||||
"text": "string (1..20000)",
|
||||
"language": "string (optioneel, default: nl)"
|
||||
}
|
||||
```
|
||||
- **Voorbeeld (PowerShell)**
|
||||
```powershell
|
||||
Invoke-RestMethod -Uri http://localhost:3000/api/ai/summarize -Method POST -Body (@{ text = "Korte intake tekst" } | ConvertTo-Json) -ContentType "application/json"
|
||||
```
|
||||
- **Voorbeeld (curl)**
|
||||
```bash
|
||||
curl -X POST http://localhost:3000/api/ai/summarize \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"text":"Korte intake tekst"}'
|
||||
```
|
||||
- **Response (200)**
|
||||
```json
|
||||
{
|
||||
"summary": "- Bullet 1\n- Bullet 2\n..."
|
||||
}
|
||||
```
|
||||
- **Fouten**
|
||||
- 400: ongeldige body (validatie faalt)
|
||||
- 500: Claude AI fout of configuratie ontbreekt
|
||||
|
||||
### Omgevingsvariabelen
|
||||
- **Claude AI**
|
||||
- `ANTHROPIC_API_KEY` (bv. `sk-ant-...`) — vereist voor alle AI-endpoints
|
||||
- **Optioneel**
|
||||
- `ANTHROPIC_MODEL` (default `claude-3-5-sonnet-20241022`)
|
||||
|
||||
Voorbeeld in `.env.local` (lokaal): zie `/.env.example`.
|
||||
|
||||
### Implementatiedetails
|
||||
- Server helper: `src/lib/server/claude.ts` initialiseert Claude client met API key.
|
||||
- Endpoint: `src/app/api/ai/summarize/route.ts` (Next.js Route Handler met Zod‑validatie, Claude API call).
|
||||
|
||||
### Beveiliging (MVP)
|
||||
- Houd `ANTHROPIC_API_KEY` uit de client; uitsluitend server‑side gebruiken.
|
||||
- Gebruik Vercel Environment Variables in productie.
|
||||
|
||||
### Roadmap (volgende endpoints)
|
||||
- `POST /api/ai/readability` – herschrijf naar B1‑niveau.
|
||||
- `POST /api/ai/extract` – extracteer categorie/severity uit intake.
|
||||
- `POST /api/ai/generate-plan` – genereer behandelplan (Doelen, Interventies, etc.).
|
||||
|
||||
### Changelog
|
||||
- 0.2 (2025‑11‑09): Migratie naar Next.js + Claude AI (Anthropic); update van base URL naar :3000.
|
||||
- 0.1 (2025‑09‑02): Eerste versie met `summarize` endpoint en env‑richtlijnen.
|
||||
|
||||
138
docs/prd-mini-ecd.md
Normal file
138
docs/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/to-mini-ecd.md
Normal file
390
docs/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).
|
||||
|
||||
---
|
||||
194
docs/ux-stylesheet.md
Normal file
194
docs/ux-stylesheet.md
Normal file
@@ -0,0 +1,194 @@
|
||||
# 🎨 Kleur Stylesheet – Mini‑ECD (v2, UX‑geoptimaliseerd)
|
||||
|
||||
> Doel: consistente, toegankelijke kleuren met **lage cognitieve belasting**. Accentpalet teruggebracht tot **3 modules** (Afspraken, Medicatie/Herinneringen, Lab/Resultaten). Inclusief duidelijke states en contrastrichtlijnen.
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Basiskleuren
|
||||
|
||||
* **App‑achtergrond**: `#F8FAFC`
|
||||
* **Oppervlak (kaarten/modals)**: `#FFFFFF`
|
||||
* **Sub‑oppervlak** (sekundair paneel/right‑rail): `#F1F5F9`
|
||||
* **Tekst primair**: `#0F172A`
|
||||
* **Tekst secundair**: `#475569`
|
||||
* **Borders/Dividers**: `#E2E8F0`
|
||||
|
||||
**WCAG tip:** tekst op witte of zachte pastelfondsen ≥ `#0F172A` / `#1E293B` voor AA‑contrast.
|
||||
|
||||
---
|
||||
|
||||
## 🔹 Merk & Primaire UI
|
||||
|
||||
* **Primary / Brand**: `#3B82F6`
|
||||
|
||||
* Hover: `#2563EB`
|
||||
* Active: `#1D4ED8`
|
||||
* Subtle bg (chips, empty‑states): `#EFF6FF`
|
||||
* On‑Primary text/icon: `#FFFFFF`
|
||||
|
||||
* **Neutral CTA (secundair/terug)**: `#334155`
|
||||
|
||||
* Hover: `#1F2937`
|
||||
* On‑Neutral: `#FFFFFF`
|
||||
|
||||
---
|
||||
|
||||
## 📊 Module‑accenten (gereduceerd)
|
||||
|
||||
Gebruik **max. drie** accentfamilies. Pastel voor kaarten + een verzadigd accent voor iconen/teksten.
|
||||
|
||||
1. **Afspraken**
|
||||
|
||||
* Card bg: `#E8F8EF`
|
||||
* Accent (icon/label): `#16A34A`
|
||||
* Border: `#CDECDC`
|
||||
|
||||
2. **Medicatie / Herinneringen**
|
||||
|
||||
* Card bg: `#FEF6DC`
|
||||
* Accent: `#F59E0B`
|
||||
* Border: `#F6E7B6`
|
||||
|
||||
3. **Lab / Resultaten**
|
||||
|
||||
* Card bg: `#FFEBDC`
|
||||
* Accent: `#F97316`
|
||||
* Border: `#FFD2B8`
|
||||
|
||||
> **Toegankelijkheid:** tekst op pastelkaarten in **donkergrijs `#0F172A`**. Accentkleur enkel voor iconen/badges/kleine headings.
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Status & Feedback
|
||||
|
||||
* **Success**: `#16A34A`
|
||||
* **Warning**: `#EAB308`
|
||||
* **Error**: `#DC2626`
|
||||
* **Info**: `#3B82F6`
|
||||
|
||||
**Subtle backgrounds**
|
||||
|
||||
* Success subtle: `#ECFDF5`
|
||||
* Warning subtle: `#FEFCE8`
|
||||
* Error subtle: `#FEF2F2`
|
||||
* Info subtle: `#EFF6FF`
|
||||
|
||||
**Toasts/alerts**
|
||||
|
||||
* Tekst: `#0F172A`
|
||||
* Icon: statuskleur
|
||||
* Border: statuskleur op 30% (bijv. mix met wit)
|
||||
|
||||
---
|
||||
|
||||
## 🏷️ Badges & Labels (Severity DSM‑light)
|
||||
|
||||
* **Laag**: bg `#E5E7EB`, text `#374151`
|
||||
* **Middel**: bg `#FEF3C7`, text `#92400E`
|
||||
* **Hoog**: bg `#FEE2E2`, text `#991B1B`
|
||||
|
||||
---
|
||||
|
||||
## ✍️ Formulieren & Invoervelden
|
||||
|
||||
* **Input bg**: `#FFFFFF`
|
||||
* **Input text**: `#0F172A`
|
||||
* **Placeholder**: `#94A3B8`
|
||||
* **Border default**: `#CBD5E1`
|
||||
* **Border hover**: `#94A3B8`
|
||||
* **Focus**: 2px ring `#3B82F6` + 1px inset border `#2563EB`
|
||||
* **Disabled**: bg `#F1F5F9`, text `#94A3B8`, border `#E2E8F0`
|
||||
* **Invalid**: border `#DC2626`, help‑text `#B91C1C`
|
||||
|
||||
**Select/Dropdown**
|
||||
|
||||
* Menu bg: `#FFFFFF`
|
||||
* Hover option: `#F1F5F9`
|
||||
* Active/selected: left bar `#3B82F6`
|
||||
|
||||
---
|
||||
|
||||
## 🧩 Component‑states (Buttons/Links/Cards)
|
||||
|
||||
**Primary button**
|
||||
|
||||
* Default: bg `#3B82F6`, text `#FFFFFF`
|
||||
* Hover: bg `#2563EB`
|
||||
* Active: bg `#1D4ED8`
|
||||
* Disabled: bg `#BFDBFE`, text `#FFFFFF` @ 70%
|
||||
|
||||
**Secondary button**
|
||||
|
||||
* Default: bg `#334155`, text `#FFFFFF`
|
||||
* Hover: bg `#1F2937`
|
||||
* Disabled: bg `#CBD5E1`, text `#FFFFFF` @ 60%
|
||||
|
||||
**Ghost button**
|
||||
|
||||
* Text: `#334155`; hover bg: `#F1F5F9`
|
||||
|
||||
**Links**
|
||||
|
||||
* Default: `#2563EB`
|
||||
* Hover/Focus: underline + `#1D4ED8`
|
||||
* Visited: `#4F46E5`
|
||||
|
||||
**Cards**
|
||||
|
||||
* Default: bg `#FFFFFF`, border `#E2E8F0`, shadow sm
|
||||
* Hoverable variant: shadow md + translateY(‑1px)
|
||||
|
||||
---
|
||||
|
||||
## 🗺️ Navigatie
|
||||
|
||||
* **Sidebar item**
|
||||
|
||||
* Default text: `#334155`
|
||||
* Active: text `#0F172A`, bg `#E2E8F0`, left accent bar `#3B82F6`
|
||||
* Disabled: text `#94A3B8`
|
||||
|
||||
* **Topbar**
|
||||
|
||||
* Bg: `#FFFFFF`, border‑bottom: `#E2E8F0`
|
||||
|
||||
---
|
||||
|
||||
## 🌫️ Elevation & Focus
|
||||
|
||||
* **Shadows**
|
||||
|
||||
* sm: `0 1px 2px rgba(15,23,42,0.06)`
|
||||
* md: `0 2px 6px rgba(15,23,42,0.08)`
|
||||
* lg: `0 8px 20px rgba(15,23,42,0.10)`
|
||||
|
||||
* **Focus ring (universeel)**: 2px `#3B82F6` buiten het element + 1px contrast‑border.
|
||||
|
||||
---
|
||||
|
||||
## ♿ Toegankelijkheidsrichtlijnen
|
||||
|
||||
* Minimale contrastverhouding **AA**:
|
||||
|
||||
* Body‑tekst op wit ≥ 4.5:1 (gebruik `#0F172A`/`#1E293B`)
|
||||
* Tekst op gekleurde knoppen altijd **wit** (`#FFFFFF`) en check contrast.
|
||||
* Gebruik niet alleen kleur: combineer status met **icoon**, **label** of **shape**.
|
||||
* Focus is altijd zichtbaar (geen `outline: none`).
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Semantische tokens (aliasing)
|
||||
|
||||
Gebruik semantische namen in code i.p.v. ruwe HEX‑waarden:
|
||||
|
||||
* `--color-bg`, `--color-surface`, `--color-text`, `--color-border`
|
||||
* `--color-brand`, `--color-brand-hover`, `--color-info`, `--color-success`, `--color-warning`, `--color-error`
|
||||
* `--color-module-appointments`, `--color-module-meds`, `--color-module-labs`
|
||||
|
||||
---
|
||||
|
||||
## 📌 Notities
|
||||
|
||||
* Accentpalet bewust klein gehouden → minder visuele ruis, sneller scannen.
|
||||
* Kaarten tonen **accent** alleen in icoon/badge of kleine titel; content blijft donker op licht voor leesbaarheid.
|
||||
* Voor donker thema kunnen bovenstaande waarden gespiegeld worden met lichtere teksten en donkerder oppervlakken.
|
||||
Reference in New Issue
Block a user