feat: share patients across all users
Removed per-user patient filtering so all staff accounts see the same patient pool. Previously each user only saw patients they created. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@ model User {
|
||||
npiProviders NpiProvider[]
|
||||
claims Claim[]
|
||||
insuranceCredentials InsuranceCredential[]
|
||||
shoppingVendors ShoppingVendor[]
|
||||
updatedPayments Payment[] @relation("PaymentUpdatedBy")
|
||||
backups DatabaseBackup[]
|
||||
backupDestinations BackupDestination[]
|
||||
@@ -42,6 +43,8 @@ model User {
|
||||
officeHours OfficeHours?
|
||||
officeContact OfficeContact?
|
||||
procedureTimeslot ProcedureTimeslot?
|
||||
insuranceContacts InsuranceContact[]
|
||||
patientConversations PatientConversation[]
|
||||
}
|
||||
|
||||
model Patient {
|
||||
@@ -61,6 +64,7 @@ model Patient {
|
||||
policyHolder String?
|
||||
allergies String?
|
||||
medicalConditions String?
|
||||
preferredLanguage String? @default("English")
|
||||
status PatientStatus @default(UNKNOWN)
|
||||
userId Int
|
||||
createdAt DateTime @default(now())
|
||||
@@ -73,6 +77,7 @@ model Patient {
|
||||
payment Payment[]
|
||||
communications Communication[]
|
||||
documents PatientDocument[]
|
||||
conversation PatientConversation?
|
||||
|
||||
@@index([insuranceId])
|
||||
@@index([createdAt])
|
||||
@@ -98,6 +103,7 @@ model Appointment {
|
||||
notes String?
|
||||
procedureCodeNotes String?
|
||||
status String @default("scheduled") // "scheduled", "completed", "cancelled", "no-show"
|
||||
movedByAi Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
eligibilityStatus PatientStatus @default(UNKNOWN)
|
||||
@@ -147,6 +153,8 @@ model NpiProvider {
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
claims Claim[]
|
||||
payments Payment[]
|
||||
commissionBatches CommissionBatch[]
|
||||
appointmentProcedures AppointmentProcedure[]
|
||||
|
||||
@@unique([userId, npiNumber])
|
||||
@@ -190,7 +198,7 @@ model AppointmentProcedure {
|
||||
model Claim {
|
||||
id Int @id @default(autoincrement())
|
||||
patientId Int
|
||||
appointmentId Int
|
||||
appointmentId Int?
|
||||
userId Int
|
||||
staffId Int
|
||||
patientName String
|
||||
@@ -205,10 +213,11 @@ model Claim {
|
||||
updatedAt DateTime @updatedAt
|
||||
status ClaimStatus @default(PENDING)
|
||||
claimNumber String?
|
||||
preAuthNumber String?
|
||||
npiProviderId Int?
|
||||
|
||||
patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
|
||||
appointment Appointment @relation(fields: [appointmentId], references: [id], onDelete: Cascade)
|
||||
appointment Appointment? @relation(fields: [appointmentId], references: [id], onDelete: Cascade)
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
staff Staff? @relation("ClaimStaff", fields: [staffId], references: [id])
|
||||
npiProvider NpiProvider? @relation(fields: [npiProviderId], references: [id])
|
||||
@@ -224,6 +233,7 @@ enum ClaimStatus {
|
||||
CANCELLED
|
||||
REVIEW
|
||||
VOID
|
||||
PREAUTH
|
||||
}
|
||||
|
||||
enum MissingTeethStatus {
|
||||
@@ -242,6 +252,9 @@ model ServiceLine {
|
||||
arch String?
|
||||
toothNumber String?
|
||||
toothSurface String?
|
||||
icn String?
|
||||
paidCode String?
|
||||
allowedAmount Decimal? @db.Decimal(10, 2)
|
||||
totalBilled Decimal @db.Decimal(10, 2)
|
||||
totalPaid Decimal @default(0.00) @db.Decimal(10, 2)
|
||||
totalAdjusted Decimal @default(0.00) @db.Decimal(10, 2)
|
||||
@@ -287,6 +300,19 @@ model InsuranceCredential {
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
model ShoppingVendor {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int
|
||||
vendorName String
|
||||
websiteUrl String
|
||||
loginUsername String
|
||||
loginPassword String
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
model PdfGroup {
|
||||
id Int @id @default(autoincrement())
|
||||
title String
|
||||
@@ -325,10 +351,14 @@ model Payment {
|
||||
patientId Int
|
||||
userId Int
|
||||
updatedById Int?
|
||||
npiProviderId Int?
|
||||
totalBilled Decimal @db.Decimal(10, 2)
|
||||
totalPaid Decimal @default(0.00) @db.Decimal(10, 2)
|
||||
totalAdjusted Decimal @default(0.00) @db.Decimal(10, 2)
|
||||
totalDue Decimal @db.Decimal(10, 2)
|
||||
mhPaidAmount Decimal? @db.Decimal(10, 2)
|
||||
copayment Decimal @default(0.00) @db.Decimal(10, 2)
|
||||
adjustment Decimal @default(0.00) @db.Decimal(10, 2)
|
||||
status PaymentStatus @default(PENDING)
|
||||
notes String?
|
||||
icn String?
|
||||
@@ -338,8 +368,10 @@ model Payment {
|
||||
claim Claim? @relation(fields: [claimId], references: [id], onDelete: Cascade)
|
||||
patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
|
||||
updatedBy User? @relation("PaymentUpdatedBy", fields: [updatedById], references: [id])
|
||||
npiProvider NpiProvider? @relation(fields: [npiProviderId], references: [id])
|
||||
serviceLineTransactions ServiceLineTransaction[]
|
||||
serviceLines ServiceLine[]
|
||||
commissionBatchItems CommissionBatchItem[]
|
||||
|
||||
@@index([claimId])
|
||||
@@index([patientId])
|
||||
@@ -564,9 +596,11 @@ model TwilioSettings {
|
||||
}
|
||||
|
||||
model AiSettings {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int @unique
|
||||
apiKey String
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int @unique
|
||||
apiKey String
|
||||
afterHoursEnabled Boolean @default(true)
|
||||
openPhoneReply Boolean @default(false)
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@ -586,17 +620,34 @@ model OfficeHours {
|
||||
model OfficeContact {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int @unique
|
||||
officeName String?
|
||||
receptionistName String?
|
||||
dentistName String?
|
||||
phoneNumber String?
|
||||
email String?
|
||||
fax String?
|
||||
streetAddress String?
|
||||
city String?
|
||||
state String?
|
||||
zipCode String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("office_contact")
|
||||
}
|
||||
|
||||
model InsuranceContact {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int
|
||||
name String
|
||||
phoneNumber String?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("insurance_contact")
|
||||
}
|
||||
|
||||
model ProcedureTimeslot {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int @unique
|
||||
@@ -606,3 +657,45 @@ model ProcedureTimeslot {
|
||||
|
||||
@@map("procedure_timeslot")
|
||||
}
|
||||
|
||||
model PatientConversation {
|
||||
id Int @id @default(autoincrement())
|
||||
patientId Int @unique
|
||||
userId Int
|
||||
stage String @default("initial")
|
||||
aiHandoff Boolean @default(true)
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("patient_conversation")
|
||||
}
|
||||
|
||||
// Commission tracking
|
||||
model CommissionBatch {
|
||||
id Int @id @default(autoincrement())
|
||||
npiProviderId Int
|
||||
totalCollection Decimal @db.Decimal(14, 2)
|
||||
commissionAmount Decimal @db.Decimal(14, 2)
|
||||
notes String?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
npiProvider NpiProvider @relation(fields: [npiProviderId], references: [id])
|
||||
items CommissionBatchItem[]
|
||||
|
||||
@@index([npiProviderId])
|
||||
}
|
||||
|
||||
model CommissionBatchItem {
|
||||
id Int @id @default(autoincrement())
|
||||
commissionBatchId Int
|
||||
paymentId Int
|
||||
collectionAmount Decimal @db.Decimal(14, 2)
|
||||
|
||||
commissionBatch CommissionBatch @relation(fields: [commissionBatchId], references: [id], onDelete: Cascade)
|
||||
payment Payment @relation(fields: [paymentId], references: [id])
|
||||
|
||||
@@unique([commissionBatchId, paymentId])
|
||||
@@index([paymentId])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user