214 Commits

Author SHA1 Message Date
c19a0b5386 Merge pull request 'swift-cortex: technisch datamodel instroom/intake + ER-diagrammen' (#1) from swift-cortex into main
Reviewed-on: #1
2026-07-29 08:07:11 +02:00
colinislit
0db3ec2ce1 docs(datamodel): Mermaid ER-diagrammen voor alle actuele deelmodellen
Voegt docs/datamodel/diagrammen/ toe: één self-contained HTML per
deelmodel (instroom, aanmelding, behandelplan, diagnose,
intake-behandeladvies, rapportage, screening, wachtlijst), elk met een
Mermaid erDiagram, blueprint-vormgeving en sleep/scroll pan-zoom
(mermaid.js + svg-pan-zoom via CDN, geen serverside build nodig).

Per diagram alleen sleutel-/FK-attributen en de kernrelaties uit de §2/§3
entiteiten-/cardinaliteitensecties van het bijbehorende deelmodel, niet elk
veld — bedoeld als navigeerbaar overzicht naast de tabelvorm, niet als
vervanging ervan.

Scope-keuzes:
- model-intake.md en datamodel-discovery.md zijn overgeslagen: eerstgenoemde
  is volledig vervangen door model-intake-behandeladvies.md, laatstgenoemde
  is een prosedocument zonder entiteitenstructuur.
- model-aanmelding.md toont alleen de nog geldige PERSOON/CLIENT-kern;
  AANMELDING/VERWIJZING/ZORGEPISODE zijn vervangen door model-instroom.md
  en daar al gediagrammeerd.
- model-screening.md krijgt een expliciete waarschuwing in titel en
  bronregel: het losse screeningsbesluit is achterhaald door besluit B21
  (screeningsbesluit = acceptatiebesluit, nu care_acceptance_decision in
  model-instroom.md).
- model-behandelplan.md, model-rapportage.md en model-wachtlijst.md tonen
  een statusnotitie (in herziening resp. deels herzien resp. voorlopig
  onderzoeksmodel) conform hun documentstatus.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 08:01:38 +02:00
colinislit
d5b583e24a docs(datamodel): sessielog avondronde 19 juli
Legt de middag-/avondsessie van 19 juli vast die tot nu toe alleen in
commit messages en het besluitenlog terug te vinden was: afronding van de
instroom-feitenronde (vraag 3-5, entiteiten/cardinaliteiten, B21-B30,
synchronisatie begrippenlijst/model-aanmelding) en de nieuwe feitenronde
intake/behandeladvies (episode-timing, Treatment Advice, B31-B34).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 08:01:25 +02:00
colinislit
ea4c0c836f feat(db): technisch datamodel instroom/intake/behandeladvies (SQL-migraties)
Vertaalt de FCO-IM-feitenrondes en logische modellen naar 37 nieuwe
PostgreSQL-tabellen, verdeeld over vier migraties:

- create_reference_data: één generieke value_list_item-tabel (spelregel
  3.1 #1) i.p.v. ~30 losse waardelijst-tabellen, met alle startwaarden uit
  model-aanmelding.md/model-instroom.md/model-intake-behandeladvies.md.
- create_person_client_domain: person, address, contact_detail, client,
  client_relation, referrer, practice_organization,
  client_general_practitioner, insurance, consent, client_portal_account
  (model-aanmelding.md §2.1-2.9, 2.14, 2.16). BSN als bsn_hash (SHA-256),
  conform de platform-privacyregel — geen raw BSN, geen reversibele
  encryptie.
- create_referral_domain: 20 entiteiten uit model-instroom.md (referral_
  request t/m episode_team_involvement), inclusief de vervangt-constraints
  als partial unique index (voorkomt vertakking) en de XOR-check op
  clinical_care_episode tussen acceptatiebesluit en Wvggz-mandaat.
- create_intake_treatment_advice_domain: 5 entiteiten uit
  model-intake-behandeladvies.md.

Scope: dit zijn nieuwe, additieve tabellen naast de bestaande prototype-
tabellen (patients, screenings, intakes, patients.is_john_doe,
intakes.kindcheck_data) — die tabellen zijn bewust niet aangeraakt.
Wiring van de live app op dit schema, en migratie van prototype-data, is
een aparte, nog te nemen beslissing. Migraties zijn nog niet toegepast op
een database.

decision_authority_id (care_acceptance_decision) is tijdelijk nullable
zonder FK — het doeltabel volgt uit de bevoegdheidsronde (B16). Perifere
waardelijst-kolommen zijn TEXT met een verwijzing naar de bedoelde lijst in
een comment, geen harde FK naar value_list_item — applicatievalidatie (Zod)
dekt die laag; business-kritieke uitkomsten (decision_outcome,
treatment_advice_outcome, mandate_type) hebben wel een CHECK-constraint.
2026-07-20 08:57:12 +02:00
colinislit
7ad50f4e33 docs(datamodel): feitenronde intake en behandeladvies afgerond
Voegt feitenmodel-intake-behandeladvies.md en model-intake-behandeladvies.md
toe: FCO-IM-feitenronde en entiteiten-/cardinaliteitenafleiding voor
Clinical Intake Assessment, Intake Contact, Child Safety Check en Treatment
Advice. Corrigeert de episode-timing (intake start ná het acceptatiebesluit,
niet bij een niet meer bestaande aanmelding-uitkomst "intake").

Sluit feitenmodel-instroom.md §7 vraag 2 af (behandeladvies-uitkomsten,
sinds sessielog 19 juli geparkeerd): behandeladvies wordt een eigen
Treatment Advice-object met vervangt-mechanisme, naar het patroon van Care
Acceptance Decision — geen apart voorafgaand advies. Op basis van volledige
LKS 4.0-teksttoetsing (niet alleen samenvattingen): doorverwijzing/
terugverwijzing zijn een volgtijdelijk paar, extra_diagnostiek is
praktijkgefundeerd niet LKS-genormeerd, en MDT-bespreking is voor settings
3-8 een dwingende norm (minimale hook: intake_mdt_review).

Legt B31-B34 vast in het besluitenlog, synchroniseert begrippenlijst §4
(Clinical Intake Assessment, Intake Contact, Child Safety Check, Treatment
Advice) en markeert het oudere model-intake.md niet-destructief als
vervangen, consistent met hoe model-aanmelding.md eerder is behandeld.
2026-07-19 18:24:34 +02:00
colinislit
890704a0f4 docs(datamodel): synchroniseer begrippenlijst en model-aanmelding met instroom
begrippenlijst-kernmodel.md §3: vervangt de voorlopige werktermen (Inbound
Care Signal, Access Assessment Case, Presenting Care Need, Screening
Recommendation) door de bevestigde instroom-begrippen uit model-instroom.md
(Referral Request/Submission/Case, Professional/Municipal Referral, Legal
Mandate, Case Information Request/Withdrawal, Crisis Encounter Note, Case
Urgency Assessment). §10 bijgewerkt: opgeloste terminologievragen gemarkeerd,
Wvggz/Wmo-Jeugdwet-aannames als nieuw juridisch te bevestigen punt.

model-aanmelding.md: AANMELDING/VERWIJZING/VERWIJSDOCUMENT/TOEWIJZING/
ZORGEPISODE (§2.10-§2.13, §2.15) niet-destructief gemarkeerd als vervallen
met verwijzing naar de vervangende entiteit in model-instroom.md — tekst
blijft als historisch werkdocument staan, consistent met het
niet-destructieve patroon dat elders in het datamodel wordt toegepast.
PERSOON/CLIENT/CLIENTRELATIE/VERWIJZER/PRAKTIJK_INSTELLING/CLIENT_HUISARTS/
VERZEKERING/TOESTEMMING/CLIENTPORTAAL_ACCOUNT (§2.1-§2.9, §2.14, §2.16)
blijven ongewijzigd en behouden hun sectienummers, waar model-instroom.md
extern naar verwijst. §7 (open besluitpunten) per punt van een status
voorzien, inclusief waar de uiteindelijke beslissing afweek van het advies.

Corrigeert ook twee foutieve paden in model-instroom.md (§4 waardelijsten
verwezen naar de verkeerde sectie in model-aanmelding.md).
2026-07-19 18:08:43 +02:00
colinislit
b663851233 docs(datamodel): besluitenlog uitgebreid met B21-B30 (instroom-feitenronde)
Legt de uitkomst van de instroom-feitenronde en het entiteitenmodel formeel
vast als besluiten B21-B30: screening=acceptatie, losse besluit-/vervolgroute-
/onderbouwingsfeiten, expliciete vervangt-relatie bij herziening,
cliënt-intrekking zonder bevoegdheidseis, tijdlijn i.p.v. statusmachine,
zorgverzoek zonder bekende persoon, Wmo/Jeugdwet en Wvggz als eigen
instroomroutes, crisisdocumentatie vóór identificatie, herhaalbare
urgentiebeoordeling, en een minimale hook voor teambetrokkenheid vooruitlopend
op een aparte zorgteam-ronde.

Werkt §10 (vervolg en nog open) bij: markeert afgeronde punten, voegt de
juridische verificatie- en behandeladvies-onderzoekspunten toe, en noteert
dat model-aanmelding.md's AANMELDING/VERWIJZING/ZORGEPISODE-deel is vervangen
door model-instroom.md (synchronisatie volgt als eerstvolgende stap).
2026-07-19 17:59:30 +02:00
colinislit
f68d63145a docs(datamodel): instroom entiteiten/cardinaliteiten + vier reviewrondes
Voegt model-instroom.md toe: de eerste entiteiten-/cardinaliteitenafleiding
uit feitenmodel-instroom.md (20 entiteiten, Engelstalig conform B20,
vervangt-patroon voor herzieningen, tijdlijn i.p.v. statusmachine voor
Referral Case).

Vier reviewrondes verwerkt:
- technische en GGZ-domeinreview (vertakkende vervangt-keten gefixed,
  timestamp-precisie, ontbrekende ZPM-velden hersteld);
- tweede ronde met datamodel-, GGZ-domein- en UX-expert-agents (lege
  screening-entiteit vervallen, naamgeving, cardinaliteitsfout, read-model-eis);
- GGZ-wetgeving-onderzoek (Wvggz, Wmo/Jeugdwet, 275-dagentoets,
  365-dagenregel, crisisdocumentatie) vertaald naar nieuwe entiteiten
  (municipal_care_assignment, legal_mandate, crisis_encounter_note);
- domeinreview eigenaarschap/urgentie met Colin: herhaalbare
  urgentiebeoordeling (case_urgency_assessment) en een bewust minimale hook
  voor teambetrokkenheid (episode_team_involvement) — het volledige
  zorgteam-model blijft een aparte, nog te plannen ronde.

feitenmodel-instroom.md: "verzoek zonder bekende persoon" (crisisaanmelding)
beantwoord — geen placeholder-persoon, koppeling als eigen gedateerd feit.
2026-07-19 17:46:57 +02:00
colinislit
dc15bf60d6 docs(datamodel): instroom domeinreview afronden (vraag 3, 4, 5)
Beantwoordt de resterende open vragen uit feitenmodel-instroom.md §7:
aanvullende_informatie_nodig wordt een gebeurtenisfeit i.p.v. besluituitkomst
of statusfase, heroverweging na afwijzing krijgt een expliciete
"vervangt"-relatie tussen acceptatiebesluiten, en intrekking vóór start
intake krijgt twee routes (cliënt-intrekking zonder bevoegdheidseis,
institutionele correctie met dezelfde bevoegdheid als het origineel) waarbij
de al ontstane zorgepisode altijd wordt afgesloten, nooit verwijderd.
Referral Case krijgt daarmee een tijdlijn-gebaseerde stand i.p.v. een vaste
lineaire statusmachine. Alleen vraag 2 (behandeladvies-uitkomsten) blijft
open als apart onderzoek.
2026-07-19 11:37:26 +02:00
colinislit
2a1278936b docs(datamodel): FCO-IM feitenronde instroom, besluitenlog + herstructurering
Voegt de discovery- en besluitvormingsronde van 18-19 juli toe (besluitenlog,
begrippenlijst, feitenmodel-instroom met scenariotoetsen, terminologie- en
leveranciersonderzoek) en synchroniseert feitenmodel-instroom.md met de
screening=acceptatie-beslissing (§5). Herstructureert docs/datamodel/ naar
submappen per documentsoort (besluiten/sessielogs/feitenmodellen/deelmodellen/
onderzoek/entiteitenkaarten) zodat toekomstige besluitenlogs en feitenrondes
per deelgebied een vaste plek krijgen.
2026-07-19 11:07:21 +02:00
colinislit
37beef14be docs(datamodel): discovery uitgebreid t/m behandelplan + sessielog 17 juli
- datamodel-discovery.md: scopeverbreding ronde 1 (wachtlijst, diagnose,
  behandelplan), besluiten zorgepisode als eigen entiteit, DSM-5-TR
  primair met ICD-10-mapping, wachtlijstplaatsing op twee momenten
  (Treeknormen), behandelplan-kern; bevindingen prototype-verkenning
- entiteitenkaart-instroom.html: samenhang-diagram (aanmelding als
  besluitproces vs zorgepisode als periode van zorg), diagram 3 met
  wachtlijst/diagnose/behandelplan, nieuwe waardelijsten
- sessielog 17 juli: 13 besluiten, bevindingen en open vragen

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 21:51:05 +02:00
colinislit
ca4c409733 docs(datamodel): discovery instroomflow — feitzinnen, besluiten en entiteitenkaart
- datamodel-discovery.md: FCO-IM-werkwijze, spelregels, feitzinnen §5.1
  afgerond met besluiten 17 juli (persoon/cliënt-splitsing, verwijzer +
  praktijk als eigen entiteiten, AGB per verwijzertype, flexibele
  statussen, verwijsbrief als nudge, cliëntportaal-account, BSN optioneel
  op persoon)
- entiteitenkaart-instroom.html: ER-diagram + waardelijsten instroomflow,
  gepubliceerd als artifact ter review

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 20:53:14 +02:00
colinislit
6419398060 docs: discussiestuk samenspel TIP-ECD, sessielog 14 juli en releasenote-screenshots
- docs/intent/samenspel-tip-ecd.html: laag-of-platform discussiestuk voor
  de werksessie over de TIP-koppeling (twee modellen, drie routes,
  API-mapping, beslisvragen)
- docs/sessions/2026-07-14-sessielog.md: besluiten, reviewbevindingen en
  uitgevoerde opschoning van vandaag

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 15:32:15 +02:00
colinislit
b00bfa5032 chore(strip): verwijder ongebruikte dependencies en marketing-restanten
- next-mdx-remote en gray-matter uit package.json (0 imports)
- components/ui/hero-section-2.tsx en timeline.tsx (nergens geimporteerd)
- lokale .DS_Store-bestanden opgeruimd (stonden al in .gitignore)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:51:47 +02:00
colinislit
caeba77bf8 chore(strip): verwijder /epd/clients redirect-laag
Alle verwijzingen (middleware, login, auth-callback, set-password,
Cortex context-bar) wijzen nu rechtstreeks naar /epd/patients; de
backwards-compat redirects zijn daarmee overbodig.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:50:52 +02:00
colinislit
38dd7c1f8a chore(strip): verwijder placeholder-pagina's dashboard en reports
Beide waren lege placeholders ('Epic 1 - Placeholder', 'Not designed yet').
Sidebar-items eruit; login-tests gebruiken /epd/agenda als voorbeeld van
een beveiligde route.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:49:40 +02:00
colinislit
96848ecc81 chore(strip): verwijder behandelplan-module
AI-generatie negeerde de geregistreerde diagnose en ernst — elk plan was
generiek (reviewbevinding). Module komt terug bij de rebuild, gekoppeld
aan het nieuwe datamodel.

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

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

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

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:44:09 +02:00
colinislit
5e910c3053 chore(strip): verwijder dubbele diagnosemodule op patientniveau
De intake-variant (intakes/[intakeId]/diagnosis) is de meest complete en
blijft. Sidebar-items Diagnose en Behandelplan (level 2) verwijderd —
behandelplan-module zelf volgt in de volgende commit.

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

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

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 22:21:20 +02:00
colinislit
c0a4fa24f2 docs: architectuurdocs, styleguides en release notes intake/behandelplan
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 23:16:28 +02:00
colinislit
9195eb9fed test: Cypress en Playwright e2e-suites voor login, agenda, cortex en verpleegrapportage
Configs voor beide runners, login via session caching, AI-chat
mocks (SSE) voor deterministische Cortex-tests. Supabase local
config toegevoegd. Auth-state en reports zijn gitignored.

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

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

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 23:14:55 +02:00
colinislit
d08db12765 fix(build): resolve type errors blocking production build
- agenda-create-form: capture prefilled patient name in const so the
  async closure sees a narrowed string type
- tsconfig: exclude tests/ from next build typecheck (Cypress/Playwright
  files have their own type context)

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

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-09 22:37:46 +02:00
colinislit
6c6dae5eb7 feat(cortex): enhance intake workflow with new navigation and status features
- Introduced new navigation handler for intake_navigeer intent, allowing users to navigate to specific patient intake pages.
- Added intake status display to show completion percentage and section checklist.
- Updated action-parser schema to include new intake intents and improved routing for better user experience.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 12:26:33 +01:00
colinislit
af88ac9446 docs: add architecture and intake intent documentation
- Add architecture overview, implementation plan, and intent overview
- Add intake intent process specs (gap analyse, bouwplan, testplan)
- Add swift architecture specs and visualization prompts
- Remove obsolete aispeedrun-manifesto template

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 19:26:14 +01:00
colinislit
91b61d215b feat(cortex): add intake suggestions to chat UI
Add intake-related suggestions to both chat interfaces:

1. Cortex Command Center (lib/cortex/suggestions.ts):
   - New "Intake" category with status, risico, diagnose examples
   - Triggers intake_status, risico_query, diagnose_query, intake_navigeer

2. Docs Chat Widget (components/docs-chat/chat-suggestions.tsx):
   - Updated CLIENT_SUGGESTION_CATEGORIES with intake options
   - Categories: Intake Status, Risicotaxatie, Diagnoses, Navigatie

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:14:53 +01:00
colinislit
601ad8c3f0 fix(cortex): integrate intake intents into full chat + artifact flow
Fixes 4 bugs preventing intake blocks from working:

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

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:07:10 +01:00
colinislit
a41a500fe3 feat(cortex): add intake_navigeer navigation handler (E5.S2)
- Add intake intents to action-parser schema and routing
- Add navigation handler in command-center for intake_navigeer intent
- Navigate to patient intakes page with toast feedback
- Update bouwplan: E5 now complete (6/7 epics done)

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

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

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 23:21:18 +01:00
colinislit
05836c5c6a feat(cortex): implement activePatient fallback in various components
- Updated DagnotatieBlock to use activePatient for prefill if no patientId is provided.
- Enhanced PatientDashboardBlock to fallback to activePatient for patientId and name.
- Adjusted usePatientSelection to handle pending actions and re-route after patient selection.
- Refined chat components to manage nudge messages and integrate them into the chat flow.
- Improved UI elements for better patient selection experience.

This update enhances user experience by ensuring that the active patient context is utilized across multiple components, streamlining workflows and reducing manual input.
2026-01-03 22:18:30 +01:00
colinislit
7040241f7d docs(cortex): herstructureer documentatie in 6 aparte secties
Vervangt de enkele "Cortex Command Center" pagina door 6 gerichte documenten:
- Overzicht: introductie, basis gebruik, context bar
- Intent Systeem: Reflex Arc, Orchestrator, intent types
- Blocks: Dagnotitie, Zoeken, Overdracht, Patient Dashboard
- @Mention Systeem: mentions, sidebar, context-aware selectie
- Keyboard Shortcuts: alle sneltoetsen per context
- Proactieve Suggesties: Nudge systeem en protocollen

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 21:40:56 +01:00
colinislit
6cc813aa58 chore: remove dead code command-input.tsx (376 lines)
Component was exported but never imported/used anywhere.
v3.0 architecture uses chat-input.tsx instead.

Voice features (useCortexVoice hook) remain available for future use.

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

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

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:30:58 +01:00
colinislit
54e54d6d7e fix(cortex): add @mention detection to ChatInput (not just CommandInput)
The @mention dropdown was only in command-input.tsx but users type in
chat-input.tsx (the v3.0 chat textarea). Added @mention support there:

- @mention state and detection logic
- PatientMentionDropdown rendering
- handleMentionSelect with activePatient setting
- Escape key closes dropdown before clearing input

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:27:48 +01:00
colinislit
2cce338aa8 docs: update bouwplan v1.4 - Epic 2 status en totalen
- Epic 2 stories: 5→3 (YAGNI versimpeling)
- Story Points: 23→19 SP
- Voortgang: 14/19 SP (74%)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:23:22 +01:00
colinislit
73894ac879 feat(cortex): Epic 2 - @Mention Systeem (E2.S1-S3)
Inline patient selectie via @naam in de chat input.

YAGNI Versimpeling: 8→4 SP, 5→3 stories
- Geen selectedMentions array (activePatient is al beschikbaar)
- Geen API payload wijziging nodig
- Geen meerdere mentions tracking

E2.S1 - @-detectie:
- Detecteer laatste @ in input
- Track query en startIndex
- Actief als geen space na @ en minimaal 1 char

E2.S2 - PatientMentionDropdown:
- Hergebruik usePatientSearch (debounce 150ms, limit 5)
- Hergebruik PatientListItem (size="sm")
- Positioned above input (bottom-full)
- Escape sluit dropdown

E2.S3 - Selectie flow:
- Vervang @query met @naam in input
- Zet activePatient via usePatientSelection
- Sluit dropdown automatisch

Bouwplan v1.4: Epic 2 compleet (14/19 SP - 74%)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 12:11:14 +01:00
colinislit
9b0352de44 feat(cortex): Epic 1 - Patient Sidebar (E1.S1-S4)
Collapsible overlay sidebar voor snelle patient selectie met search en recent patients.

E1.S1 - Store uitbreiding:
- recentPatients: Patient[] (max 5, nieuwste eerst, geen duplicaten)
- patientSidebarOpen: boolean
- addRecentPatient, togglePatientSidebar, setPatientSidebarOpen actions

E1.S2 - PatientSidebar component:
- Overlay sidebar (w-80, z-50) met backdrop
- Search input met debounce (200ms)
- Recent patients sectie
- Hergebruik usePatientSearch, usePatientSelection hooks
- Hergebruik PatientListItem component

E1.S3 - Toggle button + shortcut:
- Users icon button in ContextBar
- Cmd/Ctrl+P keyboard shortcut
- Escape sluit sidebar (prioriteit boven artifacts)

E1.S4 - Click-to-select flow:
- Selectie zet activePatient
- Voegt toe aan recentPatients
- Sluit sidebar automatisch

Bouwplan v1.3: Epic 1 compleet (10/23 SP - 43%)

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

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

Aangepast in beide search endpoints:
- /api/patients/search
- /api/cortex/patients/search
2026-01-03 11:47:12 +01:00
colinislit
4b45853868 chore(docs): remove duplicate swift docs (moved to docs/archive/swift)
Remove 39 swift documentation files that were duplicated.
Original files are preserved in docs/archive/swift/.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 11:41:26 +01:00
colinislit
983807d833 refactor(cortex): Epic 0 - Extract patient search hooks & components (E0.S1-S4)
DRY refactor: Extract reusable patient search logic from ZoekenBlock.

New files:
- lib/cortex/hooks/use-patient-search.ts (116 lines)
  Debounced patient search with abort controller
- lib/cortex/hooks/use-patient-selection.ts (98 lines)
  FHIR fetch + store update flow
- lib/fhir/patient-mapper.ts (109 lines)
  FHIR Patient to DB Patient mapping + utilities
- components/cortex/shared/patient-list-item.tsx (114 lines)
  Reusable patient list item with loading states

Refactored:
- ZoekenBlock: 349 -> 127 lines (-64%)

Documentation:
- docs/intent/patient-search/ux-analyse-patient-selectie.md
- docs/intent/patient-search/bouwplan-patient-selectie-v1.md

CLAUDE.md updated with Cortex architecture documentation.

Epic 0 complete: 4/4 stories (4 SP)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 11:40:23 +01:00
colinislit
7b9de4ada2 feat(ui): mobile responsiveness audit + type fixes
Mobile Responsiveness:
- Viewport meta tags toegevoegd in layout.tsx
- EPD header: patient details verborgen op mobiel, zoekbalk responsive
- Agenda: auto-switch naar dagview op mobiel, mini-kalender verborgen
- Agenda toolbar: verticale stacking, Week/Werkweek knoppen verborgen
- Patiëntenlijst: compact icoon-only button op mobiel
- Verpleegrapportage: verticale flow i.p.v. twee-koloms layout
- Cortex: artifact overlay met slide-in animatie op mobiel
- Cortex: "Terug" knop toegevoegd aan artifact panels
- Toast feedback bij succesvolle afspraak creatie

Code Quality Fixes (KISS/DRY):
- Resize listener vervangen door bestaande useMediaQuery hook
- Dubbele flex class opgeschoond in epd-header.tsx
- userScalable: false verwijderd (accessibility)

Type Fixes:
- actions.ts: status literal type met 'as const'
- agenda-block.tsx: dateRange start/end optioneel
- chat-empty-state.tsx: framer-motion ease type
- cortex-store.ts: ChatEntities.dateRange consistent met Zod schema

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 10:28:04 +01:00
colinislit
52e07aaf80 fix(cortex): update date handling in API and UI components
- Adjusted date handling in the agenda API to ensure optional parameters for start, end, and label are correctly processed.
- Enhanced chat input and action parser to support optional date labels for relative dates.
- Updated agenda components to handle date ranges and loading states more effectively.
- Improved error handling and loading indicators in the agenda block for better user experience.

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

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

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

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-02 08:49:20 +01:00
colinislit
6add89dc51 feat(cortex): Epic 5 - Integration & Polish complete (MVP DONE)
Epic 5 completes the Cortex V2 MVP with end-to-end integration:

E5.S1 - Feature Flag Guards
- ActionChainCard wrapped with CORTEX_MULTI_INTENT flag
- ClarificationCard wrapped with CORTEX_V2_ENABLED flag
- NudgeToast wrapped with CORTEX_NUDGE flag
- V1 UI remains functional when flags disabled

E5.S2 - Chain Execution Flow
- handleConfirmAction routes actions to artifacts via routeIntentToArtifact()
- Nudge evaluation triggered after successful action completion
- Sequential chain execution with auto-advance useEffect
- Chain auto-completes when all actions done

E5.S3 - Integration Tests (21 tests)
- Scenario 1: Simple input → Reflex handles (4 tests)
- Scenario 2: Multi-intent → Orchestrator handles (4 tests)
- Scenario 3: Context-dependent → Pronoun resolution (4 tests)
- Scenario 4: Wondzorg → Nudge suggestion (4 tests)
- Scenario 5: Graceful fallback (3 tests)
- Scenario 6: Chain building (2 tests)

E5.S4 - Demo Script
- 5-minute demo flow with exact phrases
- 5 scenes: Reflex speed, Multi-intent, Pronoun, Nudge, Clarification
- Backup scenarios documented
- Test phrases reference included

Files changed:
- components/cortex/chat/chat-panel.tsx (feature flags + execution)
- components/cortex/command-center/command-center.tsx (NudgeToast flag)
- lib/cortex/__tests__/cortex-v2.test.ts (NEW - 21 integration tests)
- docs/intent/demo-script-cortex-v2.md (NEW - demo documentation)
- docs/intent/bouwplan-cortex-v2.md (v1.5 - MVP complete)

MVP Status: 26/26 stories, 48/48 SP - 100% COMPLETE

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 13:16:20 +01:00
colinislit
4b759c9b3d feat(cortex): Epic 4 - Nudge MVP (Layer 3) complete
Proactive suggestions after successful actions - proof of concept.

E4.S1 - Protocol Rules (lib/cortex/nudge.ts)
- ProtocolRule and ProtocolCondition types
- Condition operators: equals, contains, matches, exists
- 2 hardcoded rules: wondzorg-controle, medicatie-controle

E4.S2 - evaluateNudge Function
- evaluateNudge(input) returns NudgeSuggestion[]
- checkCondition() helper for rule matching
- Priority sorting (high → medium → low)

E4.S3 - NudgeToast Component
- Countdown progress bar with auto-dismiss (5 min)
- Priority-based styling (low/medium/high)
- Accept and dismiss buttons
- Framer Motion animations

E4.S4 - Integration
- NudgeToast rendered in CommandCenter (fixed position)
- Trigger added in DagnotatieBlock after successful save
- Accept opens corresponding artifact with prefilled data

Demo flow:
1. Create dagnotitie with "wond" in content
2. Save → NudgeToast appears
3. Click "Ja, inplannen" → Appointment artifact opens

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 12:42:49 +01:00
colinislit
42d64761ec feat(cortex): Epic 3 - UI Components complete
Epic 3 delivers the visual layer for multi-intent flows and clarification:

E3.S1 - ActionChainCard (3 SP)
- Container for multi-intent chain display
- Header with AI/Local source badge and action count
- Original user input context
- Stacked ActionItems with Framer Motion animations
- Collapsible AI reasoning section
- Status-dependent styling (pending/executing/completed/partial/failed)

E3.S2 - ActionItem (2 SP)
- 6 status icons (pending, confirming, executing, success, failed, skipped)
- Dutch intent labels via shared intent-labels.ts
- Confidence badge with color coding (green ≥90%, amber ≥70%, red <70%)
- Entity summary formatting
- Confirmation buttons for confirming status
- Retry button for failed + recoverable actions

E3.S3 - ClarificationCard (2 SP)
- Amber-themed styling for question context
- Header with HelpCircle icon
- Original user input display
- Responsive options grid (2 cols desktop, 1 col mobile)
- Dismiss button and cancel link
- Framer Motion entry/exit animations

E3.S4 - ProcessingIndicator (1 SP)
- 3 variants: spinner, skeleton, pulse
- 3 sizes: sm, md, lg
- Configurable message
- InlineSpinner export for buttons

Integration in ChatPanel (v4.0):
- V2 store hooks for activeChain, pendingClarification
- Event handlers for confirm/skip/retry/dismiss
- Conditional rendering with AnimatePresence

New files:
- lib/cortex/intent-labels.ts
- components/cortex/chat/action-chain-card.tsx
- components/cortex/chat/action-item.tsx
- components/cortex/chat/clarification-card.tsx
- components/cortex/chat/processing-indicator.tsx

Modified:
- components/cortex/chat/chat-panel.tsx (v3.0 → v4.0)
- docs/intent/bouwplan-cortex-v2.md (v1.2 → v1.3)

Progress: 35/48 SP (73%) - E0, E1, E2, E3 complete

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

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

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

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 11:28:14 +01:00
colinislit
7df92dd2fb feat(blog): enhance blog functionality and SEO
- Added a new '/blog' route to middleware for improved navigation.
- Updated sitemap to dynamically include blog posts and series URLs.
- Enhanced blog page metadata with Open Graph and Twitter card information.
- Implemented structured data for blog posts and series to improve SEO.
- Removed outdated blog post "Week 1: De Kickoff" from content.
- Introduced optional OG image field in blog frontmatter for better sharing visuals.
2026-01-01 10:56:34 +01:00