mirror of
https://github.com/temetro/temetro.git
synced 2026-07-26 11:58:14 +00:00
dec04ec506
Add the appointments table, validation, service and CRUD routes (/api/appointments, RBAC-gated) and the matching frontend data module. The appointments page now loads and persists real data; KPIs are computed from it and the schedule/calendar anchor to the real current date. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
19 lines
1.0 KiB
SQL
19 lines
1.0 KiB
SQL
CREATE TABLE "appointments" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"organization_id" text NOT NULL,
|
|
"patient_file_number" text DEFAULT '' NOT NULL,
|
|
"patient_name" text NOT NULL,
|
|
"patient_initials" text NOT NULL,
|
|
"date" text NOT NULL,
|
|
"time" text NOT NULL,
|
|
"type" text NOT NULL,
|
|
"provider" text NOT NULL,
|
|
"status" text NOT NULL,
|
|
"created_by" text,
|
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
ALTER TABLE "appointments" ADD CONSTRAINT "appointments_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
ALTER TABLE "appointments" ADD CONSTRAINT "appointments_created_by_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
CREATE INDEX "appointments_org_date_idx" ON "appointments" USING btree ("organization_id","date"); |