-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
297 lines (250 loc) · 8.6 KB
/
schema.prisma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum UserRole {
SUPER_ADMIN
ADMIN
DOCTOR
PATIENT
}
enum UserStatus {
ACTIVE
BLOCKED
DELETED
}
enum Gender {
MALE
FEMALE
}
enum BloodGroup {
A_POSITIVE
B_POSITIVE
O_POSITIVE
AB_POSITIVE
A_NEGATIVE
B_NEGATIVE
O_NEGATIVE
AB_NEGATIVE
}
enum MaritalStatus {
MARRIED
UNMARRIED
}
enum AppointmentStatus {
SCHEDULED
INPROGRESS
COMPLETED
CANCELED
}
enum PaymentStatus {
PAID
UNPAID
}
model User {
id String @id @default(uuid())
email String @unique
password String
role UserRole
needPasswordChange Boolean @default(false)
status UserStatus @default(ACTIVE)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
admin Admin?
doctor Doctor?
patient Patient?
@@map("users")
}
model Admin {
id String @id @default(uuid())
name String
email String @unique
profilePhoto String? @default("https://res.cloudinary.com/dwcb6qft9/image/upload/v1729165467/user/default/default_user.png")
contactNumber String
isDeleted Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [email], references: [email], onDelete: Cascade)
@@map("admins")
}
model Doctor {
id String @id @default(uuid())
name String
email String @unique
profilePhoto String? @default("https://res.cloudinary.com/dwcb6qft9/image/upload/v1729165467/user/default/default_user.png")
contactNumber String
address String? @default("")
registrationNumber String
experience Int? @default(0)
gender Gender
appointmentFee Int @default(0)
qualification String
currentWorkingPlace String? @default("")
designation String? @default("")
isDeleted Boolean @default(false)
averageRating Float @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [email], references: [email], onDelete: Cascade)
doctorSpecialties DoctorSpecialty[]
doctorSchedules DoctorSchedules[]
appointment Appointment[]
prescription Prescription[]
review Review[]
@@map("doctors")
}
model Patient {
id String @id @default(uuid())
name String
email String @unique
profilePhoto String? @default("https://res.cloudinary.com/dwcb6qft9/image/upload/v1729165467/user/default/default_user.png")
contactNumber String
address String? @default("")
isDeleted Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [email], references: [email], onDelete: Cascade)
patientHealthData PatientHealthData?
medicalReport MedicalReport[]
appointment Appointment[]
prescription Prescription[]
review Review[]
@@map("patients")
}
model Specialties {
id String @id @default(uuid())
title String
icon String @default("https://res.cloudinary.com/dwcb6qft9/image/upload/v1729165892/empty/no-image_ixbgot.jpg")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
doctorSpecialties DoctorSpecialty[]
@@map("specialties")
}
model DoctorSpecialty {
doctorId String
specialtiesId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
doctor Doctor @relation(fields: [doctorId], references: [id], onDelete: Cascade)
specialties Specialties @relation(fields: [specialtiesId], references: [id], onDelete: Cascade)
@@id([doctorId, specialtiesId])
@@map("doctor_specialties")
}
model PatientHealthData {
id String @id @default(uuid())
patientId String @unique
gender Gender
dateOfBirth String
bloodGroup BloodGroup
hasAllergies Boolean? @default(false)
hasDiabetes Boolean? @default(false)
height String
weight String
smokingStatus Boolean? @default(false)
dietaryPreferences String?
pregnancyStatus Boolean? @default(false)
mentalHealthHistory String?
immunizationStatus String?
hasPastSurgeries Boolean? @default(false)
recentAnxiety Boolean? @default(false)
recentDepression Boolean? @default(false)
maritalStatus MaritalStatus @default(UNMARRIED)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
@@map("patient_health_datas")
}
model MedicalReport {
id String @id @default(uuid())
patientId String
reportName String
reportLink String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
@@map("medical_reports")
}
model Schedule {
id String @id @default(uuid())
startDateTime DateTime
endDateTime DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
doctorSchedules DoctorSchedules[]
appointment Appointment?
@@map("schedules")
}
model DoctorSchedules {
doctorId String
scheduleId String
isBooked Boolean? @default(false)
appointmentId String? @unique
doctor Doctor @relation(fields: [doctorId], references: [id], onDelete: Cascade)
schedule Schedule @relation(fields: [scheduleId], references: [id], onDelete: Cascade)
appointment Appointment? @relation(fields: [appointmentId], references: [id], onDelete: SetNull)
@@id([doctorId, scheduleId])
@@map("doctor_schedules")
}
model Appointment {
id String @id @default(uuid())
patientId String
doctorId String
scheduleId String @unique
videoCallingId String
status AppointmentStatus @default(SCHEDULED)
paymentStatus PaymentStatus @default(UNPAID)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
doctor Doctor @relation(fields: [doctorId], references: [id], onDelete: Cascade)
schedule Schedule @relation(fields: [scheduleId], references: [id], onDelete: Cascade)
doctorSchedules DoctorSchedules?
payment Payment?
prescription Prescription?
review Review?
@@map("appointments")
}
model Payment {
id String @id @default(uuid())
appointmentId String @unique
amount Float
transactionId String @unique
status PaymentStatus @default(UNPAID)
paymentGatewayData Json?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
appointment Appointment @relation(fields: [appointmentId], references: [id], onDelete: Cascade)
@@map("payments")
}
model Prescription {
id String @id @default(uuid())
appointmentId String @unique
doctorId String
patientId String
medicines Json
tests Json
followUpDate DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
appointment Appointment @relation(fields: [appointmentId], references: [id], onDelete: Cascade)
doctor Doctor @relation(fields: [doctorId], references: [id], onDelete: Cascade)
patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
@@map("prescriptions")
}
model Review {
id String @id @default(uuid())
appointmentId String @unique
patientId String
doctorId String
rating Float
comment String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
appointment Appointment @relation(fields: [appointmentId], references: [id], onDelete: Cascade)
patient Patient @relation(fields: [patientId], references: [id], onDelete: Cascade)
doctor Doctor @relation(fields: [doctorId], references: [id], onDelete: Cascade)
@@map("reviews")
}