feat: add Lab RX feature with template management and auto-seed defaults

- New lab_rx_template table with sortOrder and Prisma migrations
- Backend CRUD + reorder routes at /api/lab-rx/templates
- Auto-seeds 3 Highland Dental Studio defaults on first use per user
- LabRxModal: template picker, inline rename, up/down reorder, full
  template form with sections (Template Name / Lab Info / Case Details)
- RX popup: Tooth Number, Shade, Due Date, Doctor (from NPI providers),
  Instructions pre-filled with "Please make / Thank you!", print output
- lab-rx-templates.ts config file for future git-managed additions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-02 23:20:44 -04:00
co-authored by Claude Sonnet 4.6
parent ac4d8c4c74
commit abb2a0ac96
908 changed files with 4858 additions and 14271 deletions
@@ -0,0 +1,24 @@
-- CreateTable
CREATE TABLE "lab_rx_template" (
"id" SERIAL NOT NULL,
"userId" INTEGER NOT NULL,
"name" TEXT NOT NULL,
"labName" TEXT,
"labPhone" TEXT,
"labFax" TEXT,
"labAddress" TEXT,
"labAccount" TEXT,
"caseType" TEXT,
"material" TEXT,
"instructions" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "lab_rx_template_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "lab_rx_template_userId_idx" ON "lab_rx_template"("userId");
-- AddForeignKey
ALTER TABLE "lab_rx_template" ADD CONSTRAINT "lab_rx_template_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "lab_rx_template" ADD COLUMN "sortOrder" INTEGER NOT NULL DEFAULT 0;
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "lab_rx_template" ADD COLUMN "doctorName" TEXT;
+23
View File
@@ -50,6 +50,7 @@ model User {
procedureTimeslot ProcedureTimeslot?
insuranceContacts InsuranceContact[]
patientConversations PatientConversation[]
labRxTemplates LabRxTemplate[]
}
model Patient {
@@ -695,6 +696,28 @@ model PatientConversation {
@@map("patient_conversation")
}
model LabRxTemplate {
id Int @id @default(autoincrement())
userId Int
name String
labName String?
labPhone String?
labFax String?
labAddress String?
labAccount String?
caseType String?
material String?
instructions String?
sortOrder Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
@@map("lab_rx_template")
}
// Commission tracking
model CommissionBatch {
id Int @id @default(autoincrement())