217 lines
6.7 KiB
Text
217 lines
6.7 KiB
Text
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
// ─── Utilisateurs Admin/Soignant ──────────────────────────────────────────────
|
|
model Staff {
|
|
id String @id @default(uuid())
|
|
email String @unique
|
|
password String
|
|
name String
|
|
role StaffRole @default(NURSE)
|
|
service String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
messages Message[]
|
|
handledRequests PatientRequest[] @relation("handledBy")
|
|
}
|
|
|
|
enum StaffRole {
|
|
ADMIN
|
|
NURSE
|
|
DOCTOR
|
|
TECH
|
|
}
|
|
|
|
// ─── Chambres ─────────────────────────────────────────────────────────────────
|
|
model Room {
|
|
id String @id @default(uuid())
|
|
number String @unique
|
|
service String
|
|
floor Int @default(1)
|
|
bedCount Int @default(1)
|
|
tvOnline Boolean @default(false)
|
|
currentChannel Int?
|
|
createdAt DateTime @default(now())
|
|
|
|
sessions PatientSession[]
|
|
requests PatientRequest[]
|
|
messages Message[]
|
|
domotics DomoticState?
|
|
}
|
|
|
|
// ─── Sessions Patient (QR Pairing) ────────────────────────────────────────────
|
|
model PatientSession {
|
|
id String @id @default(uuid())
|
|
roomId String
|
|
room Room @relation(fields: [roomId], references: [id])
|
|
token String @unique
|
|
pairingCode String @unique
|
|
paired Boolean @default(false)
|
|
pairedAt DateTime?
|
|
expiresAt DateTime
|
|
createdAt DateTime @default(now())
|
|
wipedAt DateTime?
|
|
|
|
messages Message[]
|
|
requests PatientRequest[]
|
|
}
|
|
|
|
// ─── Demandes Patient ─────────────────────────────────────────────────────────
|
|
model PatientRequest {
|
|
id String @id @default(uuid())
|
|
roomId String
|
|
room Room @relation(fields: [roomId], references: [id])
|
|
sessionId String
|
|
session PatientSession @relation(fields: [sessionId], references: [id])
|
|
type RequestType
|
|
message String?
|
|
priority Priority @default(NORMAL)
|
|
status RequestStatus @default(PENDING)
|
|
handledById String?
|
|
handledBy Staff? @relation("handledBy", fields: [handledById], references: [id])
|
|
handledAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
enum RequestType {
|
|
WATER
|
|
PAIN
|
|
TOILET
|
|
MEAL
|
|
BLANKET
|
|
HELP
|
|
OTHER
|
|
}
|
|
|
|
enum Priority {
|
|
LOW
|
|
NORMAL
|
|
HIGH
|
|
URGENT
|
|
}
|
|
|
|
enum RequestStatus {
|
|
PENDING
|
|
ACKNOWLEDGED
|
|
IN_PROGRESS
|
|
COMPLETED
|
|
CANCELLED
|
|
}
|
|
|
|
// ─── Messages Chat ────────────────────────────────────────────────────────────
|
|
model Message {
|
|
id String @id @default(uuid())
|
|
roomId String
|
|
room Room @relation(fields: [roomId], references: [id])
|
|
sessionId String?
|
|
session PatientSession? @relation(fields: [sessionId], references: [id])
|
|
staffId String?
|
|
staff Staff? @relation(fields: [staffId], references: [id])
|
|
sender SenderType
|
|
content String
|
|
read Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
enum SenderType {
|
|
PATIENT
|
|
STAFF
|
|
}
|
|
|
|
// ─── État Domotique Chambre ───────────────────────────────────────────────────
|
|
model DomoticState {
|
|
id String @id @default(uuid())
|
|
roomId String @unique
|
|
room Room @relation(fields: [roomId], references: [id])
|
|
mainLight Boolean @default(true)
|
|
nightLight Boolean @default(false)
|
|
blinds Int @default(100) // 0=fermé, 100=ouvert
|
|
temperature Float @default(22.0)
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
// ─── Chaînes TV ───────────────────────────────────────────────────────────────
|
|
model Channel {
|
|
id String @id @default(uuid())
|
|
number Int @unique
|
|
name String
|
|
streamUrl String
|
|
logoUrl String?
|
|
category String @default("general")
|
|
active Boolean @default(true)
|
|
sortOrder Int @default(0)
|
|
}
|
|
|
|
// ─── Push Subscriptions ───────────────────────────────────────────────────────
|
|
model PushSubscription {
|
|
id String @id @default(uuid())
|
|
staffId String?
|
|
endpoint String @unique
|
|
p256dh String
|
|
auth String
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
// ─── Satisfaction Patient ─────────────────────────────────────────────────────
|
|
model Satisfaction {
|
|
id String @id @default(uuid())
|
|
roomId String
|
|
sessionId String?
|
|
rating Int // 1-5 étoiles
|
|
comfort Int? // 1-5
|
|
food Int? // 1-5
|
|
staff Int? // 1-5
|
|
cleanliness Int? // 1-5
|
|
comment String?
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
// ─── Repas ────────────────────────────────────────────────────────────────────
|
|
model Meal {
|
|
id String @id @default(uuid())
|
|
date DateTime
|
|
type MealType
|
|
name String
|
|
description String?
|
|
allergens String?
|
|
vegetarian Boolean @default(false)
|
|
available Boolean @default(true)
|
|
sortOrder Int @default(0)
|
|
}
|
|
|
|
enum MealType {
|
|
BREAKFAST
|
|
LUNCH
|
|
DINNER
|
|
SNACK
|
|
}
|
|
|
|
model MealChoice {
|
|
id String @id @default(uuid())
|
|
roomId String
|
|
sessionId String?
|
|
mealId String
|
|
mealType MealType
|
|
date DateTime
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([roomId, mealType, date])
|
|
}
|
|
|
|
// ─── Radio / Musique ──────────────────────────────────────────────────────────
|
|
model RadioStation {
|
|
id String @id @default(uuid())
|
|
name String
|
|
streamUrl String
|
|
genre String @default("general")
|
|
logoUrl String?
|
|
active Boolean @default(true)
|
|
sortOrder Int @default(0)
|
|
}
|