mirror of
https://github.com/temetro/temetro.git
synced 2026-08-20 23:22:18 +00:00
2f36875d37
New staff_profile table (org + user, unique) holding a clinician's clinical specialty. GET /api/staff and /api/staff/providers now include specialty; new PATCH /api/staff/:userId (member:update) upserts it. Migration 0023. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { pgTable, text, timestamp, uniqueIndex } from "drizzle-orm/pg-core";
|
|
|
|
import { organization, user } from "./auth.js";
|
|
|
|
// Per-member, per-clinic profile extras that Better Auth's member row doesn't
|
|
// hold. Currently just a doctor's clinical specialty (e.g. "Orthopedist",
|
|
// "Dentist") which the admin sets in Care Team and surfaces on the patient
|
|
// sheet for the patient's primary provider. Unique on (org, user) so each
|
|
// member has at most one profile per clinic.
|
|
export const staffProfile = pgTable(
|
|
"staff_profile",
|
|
{
|
|
organizationId: text("organization_id")
|
|
.notNull()
|
|
.references(() => organization.id, { onDelete: "cascade" }),
|
|
userId: text("user_id")
|
|
.notNull()
|
|
.references(() => user.id, { onDelete: "cascade" }),
|
|
specialty: text("specialty"),
|
|
updatedAt: timestamp("updated_at")
|
|
.defaultNow()
|
|
.$onUpdate(() => new Date())
|
|
.notNull(),
|
|
},
|
|
(table) => [
|
|
uniqueIndex("staff_profile_org_user_idx").on(
|
|
table.organizationId,
|
|
table.userId,
|
|
),
|
|
],
|
|
);
|