feature: Tasks tab added for lab organizations. tasks now can be assigned and their status can be updated by the assignee.

This commit is contained in:
2026-06-28 22:56:56 +03:30
parent feb0b26ad0
commit 2a48946a51
29 changed files with 851 additions and 43 deletions

View File

@@ -0,0 +1,22 @@
-- Add task priority, timestamps, and Tasks tab permissions
ALTER TABLE "lab_case_tasks" ADD COLUMN "priority" INTEGER NOT NULL DEFAULT 3;
ALTER TABLE "lab_case_tasks" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE "lab_case_tasks" ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
CREATE INDEX "lab_case_tasks_assigneeUserId_priority_createdAt_idx"
ON "lab_case_tasks"("assigneeUserId", "priority", "createdAt");
INSERT INTO "features" ("id", "name", "description", "organizationTypeId")
VALUES (gen_random_uuid(), 'Tasks', 'Lab task inbox', NULL)
ON CONFLICT ("name") DO NOTHING;
INSERT INTO "permissions" ("id", "name", "description", "featureId")
SELECT gen_random_uuid(), v.name, NULL, f.id
FROM (VALUES
('TAB_TASKS_READ'),
('TAB_TASKS_EDIT')
) AS v(name)
CROSS JOIN "features" f
WHERE f.name = 'Tasks'
ON CONFLICT ("name") DO NOTHING;

View File

@@ -0,0 +1,6 @@
-- Track when a task was assigned (for sorting and display)
ALTER TABLE "lab_case_tasks" ADD COLUMN "assignedAt" TIMESTAMP(3);
CREATE INDEX "lab_case_tasks_assignedAt_labCaseId_priority_idx"
ON "lab_case_tasks"("assignedAt" DESC, "labCaseId" ASC, "priority" DESC);

View File

@@ -253,14 +253,21 @@ model LabCaseTask {
stepOrder Int
stepLabel String
assigneeUserId String?
assignedAt DateTime?
priority Int @default(3)
status LabTaskStatus @default(PENDING)
labCase LabCase @relation(fields: [labCaseId], references: [id], onDelete: Cascade)
detail TreatmentDetail @relation(fields: [treatmentDetailId], references: [id], onDelete: Cascade)
assignee User? @relation("LabCaseTaskAssignee", fields: [assigneeUserId], references: [id], onDelete: SetNull)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([labCaseId, tooth, treatmentType, stepOrder])
@@index([labCaseId, status])
@@index([assigneeUserId, priority, createdAt])
@@index([assignedAt, labCaseId, priority])
@@map("lab_case_tasks")
}

View File

@@ -94,6 +94,10 @@ async function main() {
name: 'Cases',
permissions: ['TAB_CASES_READ', 'TAB_CASES_EDIT'],
},
{
name: 'Tasks',
permissions: ['TAB_TASKS_READ', 'TAB_TASKS_EDIT'],
},
{
name: 'Billing',
permissions: ['TAB_BILLING_READ', 'TAB_BILLING_EDIT'],