feat(health): 新增 critical_alerts + critical_alert_responses 表 + Entity
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

危急值告警数据模型:status(pending/acknowledged/resolved/escalated)、
escalation_level 分级升级、乐观锁、软删除。
This commit is contained in:
iven
2026-04-28 11:34:37 +08:00
parent 298e439fb2
commit 644efce760
5 changed files with 314 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "critical_alerts")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub tenant_id: Uuid,
pub patient_id: Uuid,
pub alert_type: String,
pub metric_name: String,
pub metric_value: String,
pub threshold_value: String,
pub severity: String,
pub status: String,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub acknowledged_by: Option<Uuid>,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub acknowledged_at: Option<DateTimeUtc>,
pub escalation_level: i32,
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub created_by: Option<Uuid>,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub updated_by: Option<Uuid>,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub deleted_at: Option<DateTimeUtc>,
pub version: i64,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::patient::Entity",
from = "Column::PatientId",
to = "super::patient::Column::Id"
)]
Patient,
}
impl Related<super::patient::Entity> for Entity {
fn to() -> RelationDef {
Relation::Patient.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -0,0 +1,42 @@
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "critical_alert_responses")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub tenant_id: Uuid,
pub alert_id: Uuid,
pub responder_id: Uuid,
pub response_type: String,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub notes: Option<String>,
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub created_by: Option<Uuid>,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub updated_by: Option<Uuid>,
#[sea_orm(skip_serializing_if = "Option::is_none")]
pub deleted_at: Option<DateTimeUtc>,
pub version: i64,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::critical_alert::Entity",
from = "Column::AlertId",
to = "super::critical_alert::Column::Id"
)]
CriticalAlert,
}
impl Related<super::critical_alert::Entity> for Entity {
fn to() -> RelationDef {
Relation::CriticalAlert.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View File

@@ -11,6 +11,8 @@ pub mod critical_value_threshold;
pub mod consent;
pub mod consultation_message;
pub mod consultation_session;
pub mod critical_alert;
pub mod critical_alert_response;
pub mod daily_monitoring;
pub mod device_readings;
pub mod diagnosis;