| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- generator client {
- provider = "prisma-client-js"
- }
- datasource db {
- provider = "postgresql"
- url = env("DATABASE_URL")
- }
- model User {
- id String @id @default(cuid())
- name String
- lastname String
- username String @unique
- email String? @unique
- password String?
- identificacion String? @unique
- isExternalAuth Boolean @default(false)
- role Role @default(PATIENT)
- profileImage String?
- phone String?
- dateOfBirth DateTime?
- gender Gender?
- address String?
- emergencyContact String?
- medicalHistory String?
- allergies String?
- currentMedications String?
- isActive Boolean @default(true)
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
- deletedAt DateTime?
-
- // Relaciones
- records Record[]
- assignedPatients PatientAssignment[] @relation("DoctorPatients")
- assignedDoctor PatientAssignment[] @relation("PatientDoctor")
- patientAppointments Appointment[] @relation("PatientAppointments")
- doctorAppointments Appointment[] @relation("DoctorAppointments")
- dailyLogs DailyLog[]
- }
- model PatientAssignment {
- id String @id @default(cuid())
- doctorId String
- patientId String
- assignedAt DateTime @default(now())
- notes String?
- isActive Boolean @default(true)
-
- doctor User @relation("DoctorPatients", fields: [doctorId], references: [id], onDelete: Cascade)
- patient User @relation("PatientDoctor", fields: [patientId], references: [id], onDelete: Cascade)
-
- @@unique([doctorId, patientId])
- }
- model Record {
- id String @id @default(cuid())
- userId String
- content String
- messages Json?
- chatType ChatType @default(MEDICAL)
- createdAt DateTime @default(now())
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
- appointment Appointment?
- }
- model Appointment {
- id String @id @default(cuid())
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
-
- // Relaciones
- pacienteId String
- paciente User @relation("PatientAppointments", fields: [pacienteId], references: [id], onDelete: Cascade)
- medicoId String?
- medico User? @relation("DoctorAppointments", fields: [medicoId], references: [id], onDelete: SetNull)
- recordId String? @unique
- record Record? @relation(fields: [recordId], references: [id], onDelete: SetNull)
-
- // Info de la cita
- fechaSolicitada DateTime?
- estado AppointmentStatus @default(PENDIENTE)
- motivoConsulta String
- motivoRechazo String?
- notas String?
-
- // Notas de consulta (durante videollamada)
- notasConsulta String?
- notasGuardadas Boolean @default(false)
- notasGuardadasAt DateTime?
-
- // Jitsi
- roomName String? @unique
-
- @@index([pacienteId])
- @@index([medicoId])
- @@index([estado])
- @@index([fechaSolicitada])
- }
- model DailyLog {
- id String @id @default(cuid())
- userId String
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
- date DateTime @db.Date
-
- // Métricas (1-5)
- mood Int?
- energy Int?
- sleepHours Float?
- sleepQuality Int?
-
- // Notas personales
- notes String? @db.Text
-
- // Metadata
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
-
- @@unique([userId, date])
- @@index([userId])
- @@index([date])
- }
- enum Role {
- ADMIN
- DOCTOR
- PATIENT
- }
- enum AppointmentStatus {
- PENDIENTE
- APROBADA
- RECHAZADA
- COMPLETADA
- CANCELADA
- }
- enum Gender {
- MALE
- FEMALE
- OTHER
- PREFER_NOT_TO_SAY
- }
- enum ChatType {
- MEDICAL
- PSYCHOLOGICAL
- }
|