GandClaude Opus 5 aef5071908 feat(bookings): a doctor who can close intake, and an assistant that can join a patient's own thread (#56)
Two real gaps, both already half-built.

DOCTOR CHOICE ALREADY EXISTED — CareTeamCard on the profile page, and
/api/care-team already let a patient pick without an admin round trip. What
was missing was the other half of that sentence: the doctor's own say. A
clinician could not signal "I am full right now", so the only way to protect
a calendar from new patients was for Manuel to manually turn people away.

profiles.acceptingPatients is self-service — a clinician sets their own,
nobody sets it for them, and there is no admin override route. Enforcement is
ONE function, canPatientChooseClinician(), called at both places a patient
actually chooses a doctor: adding them to the care team, and booking a first
slot with them. Two different doors, one rule, so "not accepting" means the
same thing at both.

The rule is deliberately narrow: closing intake protects a calendar from NEW
patients, and must never look like a doctor dropping someone mid-treatment.
An existing relationship — care-team membership, or ANY prior booking, even
one still pending — always continues. A dual-role clinician can always choose
themselves. A closed clinician is never hidden from the roster; hiding a
person reads as the clinic disowning them, and an existing patient must still
be able to find their own doctor in the list. Staff booking on a patient's
behalf may override — the clinic picking up the phone is the exception being
made, not a patient finding a workaround.

Surfaced everywhere the roster already renders: a "Not accepting new
patients" badge in warn tone (never danger — this is a normal practice state,
not a fault) in the care-team picker and the booking picker, the Choose
button disabled with the server's own reason as its tooltip, and the Confirm
button on a closed doctor's slot honestly relabelled rather than left to fail
after the fact.

THE AI ASSISTANT ALREADY EXISTED, on one side. #53 wired threadkit's model
seam into thread conversations — consent-gated, participant-visibility-scoped,
prompted to defer every clinical question — and put an "Ask assistant" button
on the ADMIN thread view. The API route was already generic (requireSession,
any participant may call it); only the patient's own thread page never grew
the button. "They all can brainstorm solutions together" needed the same
control on both sides of the same thread, not a new capability.

Mirrors the admin handler exactly: on demand only, posts into the shared
thread so the clinician sees precisely what the patient saw, and turns the
451 legal-gate response into an actionable note ("turn on AI in your privacy
settings") rather than a dead button.

Also: two definitions of "the clinician roster" existed (care-team.ts and
scheduling-data.ts) for different reasons — one needs email for availability
rules and orders by account age, the other doesn't. Not merged; both note the
duplication and the rule that would trigger unifying them (a third caller).
The checkbox-toggle CSS pattern DID have two definitions with no reason
(portal-only, needed on admin too) — moved to shared.module.css, both sides
compose from it now.

+19 tests. 1264 passing; build green. Migration 0011 is additive-only, one
boolean column.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 22:34:31 +00:00

VitaReBa

Clinical patient management platform for VitaReBa GmbH — a metabolic psychiatry and systemic longevity clinic in Zürich. The platform has two parts:

  1. Public marketing site — multilingual (de/en/fr/it), with the Inflection Edge self-assessment overlay as the primary CTA.
  2. Patient portal + admin panel — authenticated and database-backed: patients at /dashboard, the clinician at /admin.

Stack

  • Next.js 16 (App Router, standalone output) · TypeScript (strict)
  • Tailwind v4 (tokens in app/globals.css, no tailwind.config.*)
  • PostgreSQL (self-hosted) via Drizzle ORM (pg driver)
  • NextAuth 5 (auth) · Resend (transactional email)
  • next-intl (i18n)

Hosting

Self-hosted on the Hetzner box ("bitbaum") behind Caddy, served at https://vitareba.ch. There is no managed platform — deployment is pull, pnpm build (standalone output), and a systemd service restart. Uploaded documents are stored on local disk and served by Caddy under /uploads/*. Scheduled /api/cron/* jobs run from systemd timers / cron on the box (schedules defined in CLAUDE.md → Cron Jobs).

Getting started

pnpm install
cp env.local.example .env.local   # fill in DATABASE_URL, auth + Resend secrets
pnpm db:push                      # apply the Drizzle schema to your Postgres
pnpm dev                          # http://localhost:3000

Scripts

pnpm dev          # dev server
pnpm build        # production build (standalone)
pnpm start        # serve the production build
pnpm lint         # eslint
pnpm typecheck    # tsc --noEmit
pnpm test         # vitest run
pnpm db:push      # push schema changes to Postgres
pnpm db:generate  # generate migration files
pnpm db:studio    # Drizzle Studio

See CLAUDE.md for architecture, conventions, and the full design-system rules.

Languages
TypeScript 89.1%
CSS 10.2%
JavaScript 0.7%