improvement: v1 standalone treatment/case creation made possible.
This commit is contained in:
@@ -90,6 +90,7 @@ model Organization {
|
||||
treatments Treatment[]
|
||||
labCaseSends LabCaseSend[]
|
||||
labCaseComments LabCaseComment[]
|
||||
partnerLabCases LabCase[] @relation("LabCasePartnerClinic")
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -106,6 +107,7 @@ model Patient {
|
||||
dateOfBirth DateTime?
|
||||
notes String?
|
||||
isActive Boolean @default(true)
|
||||
isWalkIn Boolean @default(false)
|
||||
createdByOrganizationId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -115,6 +117,7 @@ model Patient {
|
||||
appointments Appointment[]
|
||||
|
||||
@@index([lastName, firstName])
|
||||
@@index([createdByOrganizationId, isWalkIn])
|
||||
@@map("patients")
|
||||
}
|
||||
|
||||
@@ -149,6 +152,11 @@ enum LabCaseCommentSide {
|
||||
CLINIC
|
||||
}
|
||||
|
||||
enum LabCaseOrigin {
|
||||
CLINIC_DISPATCH
|
||||
LAB_INTERNAL
|
||||
}
|
||||
|
||||
model Treatment {
|
||||
id String @id @default(uuid())
|
||||
organizationId String
|
||||
@@ -168,6 +176,7 @@ model Treatment {
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([patientId, treatmentAt])
|
||||
@@index([organizationId, providerUserId, treatmentAt])
|
||||
@@map("treatments")
|
||||
}
|
||||
|
||||
@@ -196,6 +205,7 @@ model TreatmentDetailAttachment {
|
||||
id String @id @default(uuid())
|
||||
detailId String?
|
||||
appointmentId String?
|
||||
treatmentId String?
|
||||
detailClientKey String?
|
||||
fileName String
|
||||
mimeType String
|
||||
@@ -208,25 +218,35 @@ model TreatmentDetailAttachment {
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([appointmentId, detailClientKey])
|
||||
@@index([treatmentId, detailClientKey])
|
||||
@@index([detailId])
|
||||
@@map("treatment_detail_attachments")
|
||||
}
|
||||
|
||||
model LabCase {
|
||||
id String @id @default(uuid())
|
||||
treatmentId String
|
||||
id String @id @default(uuid())
|
||||
treatmentId String?
|
||||
clientKey String?
|
||||
sortOrder Int
|
||||
sortOrder Int @default(0)
|
||||
destinationOrganizationId String?
|
||||
sentAt DateTime?
|
||||
startedAt DateTime?
|
||||
dueDate DateTime?
|
||||
isImportant Boolean @default(false)
|
||||
isImportant Boolean @default(false)
|
||||
origin LabCaseOrigin @default(CLINIC_DISPATCH)
|
||||
/// Optional code from an external lab app (e.g. exocad) for print/matching.
|
||||
externalCode String?
|
||||
accessToken String? @unique
|
||||
accessToken String? @unique
|
||||
referringClinicName String?
|
||||
referringDentistName String?
|
||||
patientDisplayName String?
|
||||
patientDisplayMobile String?
|
||||
partnerClinicOrganizationId String?
|
||||
|
||||
treatment Treatment @relation(fields: [treatmentId], references: [id], onDelete: Cascade)
|
||||
treatment Treatment? @relation(fields: [treatmentId], references: [id], onDelete: Cascade)
|
||||
partnerClinic Organization? @relation("LabCasePartnerClinic", fields: [partnerClinicOrganizationId], references: [id], onDelete: SetNull)
|
||||
details LabCaseDetail[]
|
||||
lines LabCaseLine[]
|
||||
sends LabCaseSend[]
|
||||
tasks LabCaseTask[]
|
||||
toothProsthesis LabCaseToothProsthesis[]
|
||||
@@ -236,9 +256,30 @@ model LabCase {
|
||||
userReadStates LabCaseUserReadState[]
|
||||
|
||||
@@index([treatmentId, sortOrder])
|
||||
@@index([destinationOrganizationId, origin])
|
||||
@@index([partnerClinicOrganizationId])
|
||||
@@map("lab_cases")
|
||||
}
|
||||
|
||||
/// Lab-origin work lines (analog of TreatmentDetail). Clinic-sent cases do not use this table.
|
||||
model LabCaseLine {
|
||||
id String @id @default(uuid())
|
||||
labCaseId String
|
||||
clientKey String?
|
||||
sortOrder Int
|
||||
treatmentType String @default("prosthesis")
|
||||
teeth Json
|
||||
toothSelectionGroups Json?
|
||||
comment String?
|
||||
|
||||
labCase LabCase @relation(fields: [labCaseId], references: [id], onDelete: Cascade)
|
||||
toothProsthesis LabCaseToothProsthesis[]
|
||||
tasks LabCaseTask[]
|
||||
|
||||
@@index([labCaseId, sortOrder])
|
||||
@@map("lab_case_lines")
|
||||
}
|
||||
|
||||
model LabCaseAttachment {
|
||||
labCaseId String
|
||||
attachmentId String
|
||||
@@ -343,23 +384,31 @@ model ProsthesisTypeStep {
|
||||
model LabCaseToothProsthesis {
|
||||
id String @id @default(uuid())
|
||||
labCaseId String
|
||||
treatmentDetailId String
|
||||
treatmentDetailId String?
|
||||
lineId String?
|
||||
/// treatmentDetailId (clinic) or lineId (lab-origin) — required unique grouping key.
|
||||
sourceKey String
|
||||
tooth String
|
||||
prosthesisTypeCode String
|
||||
/** Links to TreatmentDetail.toothSelectionGroups[].groupId for task grouping. */
|
||||
selectionGroupId String @default("")
|
||||
treatmentType String @default("prosthesis")
|
||||
/** Links to TreatmentDetail/LabCaseLine toothSelectionGroups[].groupId for task grouping. */
|
||||
selectionGroupId String @default("")
|
||||
|
||||
labCase LabCase @relation(fields: [labCaseId], references: [id], onDelete: Cascade)
|
||||
detail TreatmentDetail @relation(fields: [treatmentDetailId], references: [id], onDelete: Cascade)
|
||||
labCase LabCase @relation(fields: [labCaseId], references: [id], onDelete: Cascade)
|
||||
detail TreatmentDetail? @relation(fields: [treatmentDetailId], references: [id], onDelete: Cascade)
|
||||
line LabCaseLine? @relation(fields: [lineId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([labCaseId, treatmentDetailId, tooth])
|
||||
@@unique([labCaseId, sourceKey, tooth])
|
||||
@@map("lab_case_tooth_prosthesis")
|
||||
}
|
||||
|
||||
model LabCaseTask {
|
||||
id String @id @default(uuid())
|
||||
labCaseId String
|
||||
treatmentDetailId String
|
||||
treatmentDetailId String?
|
||||
lineId String?
|
||||
/// treatmentDetailId (clinic) or lineId (lab-origin) — required unique grouping key.
|
||||
sourceKey String
|
||||
teeth Json
|
||||
treatmentType String
|
||||
prosthesisTypeCode String
|
||||
@@ -374,16 +423,17 @@ model LabCaseTask {
|
||||
lastStatusChangedByUserId String?
|
||||
lastStatusChangedAt DateTime?
|
||||
|
||||
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)
|
||||
labCase LabCase @relation(fields: [labCaseId], references: [id], onDelete: Cascade)
|
||||
detail TreatmentDetail? @relation(fields: [treatmentDetailId], references: [id], onDelete: Cascade)
|
||||
line LabCaseLine? @relation(fields: [lineId], references: [id], onDelete: Cascade)
|
||||
assignee User? @relation("LabCaseTaskAssignee", fields: [assigneeUserId], references: [id], onDelete: SetNull)
|
||||
lastStatusChangedBy User? @relation("LabCaseTaskLastStatusChangedBy", fields: [lastStatusChangedByUserId], references: [id], onDelete: SetNull)
|
||||
statusEvents LabCaseTaskStatusEvent[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([labCaseId, treatmentDetailId, prosthesisTypeCode, stepOrder], map: "lab_case_tasks_case_detail_prosthesis_step_key")
|
||||
@@unique([labCaseId, sourceKey, prosthesisTypeCode, stepOrder], map: "lab_case_tasks_case_source_prosthesis_step_key")
|
||||
@@index([labCaseId, status])
|
||||
@@index([assigneeUserId])
|
||||
@@map("lab_case_tasks")
|
||||
|
||||
Reference in New Issue
Block a user