Files
triqura-ecd/docs/reports/E3.S1-organization-seed.md
colinislit a789bebe96 feat: rapportage API, speech recorder refactor, docs reorganisatie
Multiple features and improvements:

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

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

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

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

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

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 14:14:06 +01:00

5.3 KiB

E3.S1 - Organization Seed

Epic: E3 - Patients & Organizations Story: E3.S1 - Organization seed Story Points: 2 Status: 🔄 In Progress (scripts ready, database migration pending)

Doel

Default organization voor development aanmaken.

Acceptatiecriteria

  • Default organization in seed data
  • Organization heeft realistische GGZ data
  • Organization is bruikbaar voor development
  • Migratie toegepast op database (wacht op Supabase maintenance)

Implementatie

1. Migratie bestand aangemaakt

📁 Locatie: supabase/migrations/20251122_seed_default_organization.sql

De migratie maakt een default GGZ organization aan met:

  • ID: 00000000-0000-0000-0000-000000000001
  • AGB-code: AGB-DEMO-001
  • KVK-nummer: 12345678
  • Naam: Demo GGZ Instelling
  • Alias: Demo GGZ, DGGZ
  • Contact: 030-1234567, info@demo-ggz.nl
  • Adres: Demonstratiestraat 1, 3511 AB Utrecht

2. Scripts aangemaakt

TypeScript script (aanbevolen)

📁 Locatie: scripts/seed-organization.ts

Gebruik:

npx tsx scripts/seed-organization.ts

Dit script:

  • Gebruikt Supabase service role key (bypass RLS)
  • Idempotent: kan veilig opnieuw uitgevoerd worden
  • Verificatie na insert/update
  • Duidelijke output en error handling

Bash script (alternatief)

📁 Locatie: scripts/apply-organization-seed.sh

Gebruik:

chmod +x scripts/apply-organization-seed.sh
./scripts/apply-organization-seed.sh

3. Handmatige toepassing

Als de scripts niet werken, kan de migratie handmatig toegepast worden via:

Supabase Dashboard:

  1. Ga naar: https://supabase.com/dashboard/project/dqugbrpwtisgyxscpefg/sql
  2. Kopieer de SQL uit supabase/migrations/20251122_seed_default_organization.sql
  3. Plak in SQL Editor
  4. Klik "Run"

Supabase CLI:

npx supabase db push

psql (met database password):

psql 'postgresql://postgres:[PASSWORD]@db.dqugbrpwtisgyxscpefg.supabase.co:5432/postgres' \
  -f supabase/migrations/20251122_seed_default_organization.sql

Verificatie

Na het toepassen van de migratie, controleer:

SELECT * FROM organizations WHERE identifier_agb = 'AGB-DEMO-001';

Verwacht resultaat:

id                                   | 00000000-0000-0000-0000-000000000001
identifier_agb                       | AGB-DEMO-001
identifier_kvk                       | 12345678
name                                 | Demo GGZ Instelling
alias                                | {Demo GGZ,DGGZ}
type_code                            | prov
type_display                         | Healthcare Provider
telecom_phone                        | 030-1234567
telecom_email                        | info@demo-ggz.nl
telecom_website                      | https://demo-ggz.nl
address_line                         | {Demonstratiestraat 1}
address_city                         | Utrecht
address_postal_code                  | 3511 AB
address_country                      | NL
active                               | t

Afhankelijkheden

Deze organization wordt gebruikt door:

  • Practitioners - organizational affiliation
  • Encounters - organization_id foreign key (zie seed data in 20241121_seed_demo_data.sql)
  • Care Plans - care team organization

De bestaande seed data (20241121_seed_demo_data.sql) verwijst al naar deze organization via identifier_agb = 'AGB-DEMO-001', maar de organization werd nog niet aangemaakt. Deze story lost dat op.

Technische details

Database schema

De organizations tabel bestaat al in de database (zie docs/archive/migrations/20251122-current-db-scheme.sql - archived snapshot):

CREATE TABLE public.organizations (
  id uuid NOT NULL DEFAULT gen_random_uuid(),
  identifier_agb text UNIQUE,
  identifier_kvk text,
  name text NOT NULL,
  alias text[],
  type_code text DEFAULT 'prov'::text,
  type_display text DEFAULT 'Healthcare Provider'::text,
  telecom_phone text,
  telecom_email text,
  telecom_website text,
  address_line text[],
  address_city text,
  address_postal_code text,
  address_country text DEFAULT 'NL'::text,
  active boolean DEFAULT true,
  created_at timestamp with time zone DEFAULT now(),
  updated_at timestamp with time zone DEFAULT now(),
  CONSTRAINT organizations_pkey PRIMARY KEY (id)
);

Idempotentie

De migratie gebruikt ON CONFLICT (id) DO UPDATE om te zorgen dat:

  1. Bij eerste run: organization wordt aangemaakt
  2. Bij herhaalde runs: organization wordt geupdatet met nieuwe waardes
  3. Geen dubbele entries ontstaan

Volgende stappen

Na het voltooien van E3.S1:

  • E3.S2 - Patients lijst pagina (/clients met tabel, search, filters)
  • E3.S3 - Patient CRUD (Create/Update/Delete patient + validatie)

Referenties

  • Bouwplan: docs/bouwplan-mini-epd.md (regel 352-356)
  • Database schema: docs/archive/migrations/20251122-current-db-scheme.sql (archived snapshot, regel 175-194)
  • Bestaande seed data: supabase/migrations/20241121_seed_demo_data.sql (regel 13-19, 173-188)

Datum aangemaakt: 2025-11-22 Laatste update: 2025-11-22 Status: Scripts klaar, database migratie moet handmatig worden toegepast Blocker: Supabase environment variables niet geconfigureerd (NEXT_PUBLIC_SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY) Actie vereist: Voer migratie handmatig uit via Supabase Dashboard SQL Editor