P0-1: 危急值告警消费者 — health_data.critical_alert 事件推送给责任医护 P0-2: 危急值阈值可配置化 — 硬编码改为数据库配置(critical_value_threshold表),支持科室/年龄差异化 P0-3: daily_monitoring合并后告警验证 — update_vital_signs也触发危急值检测 P0-4: 随访逾期通知+幂等保护 — 只通知本次新标记的逾期任务,避免重复 P0-5: 知情同意记录(consent) — 新增实体/迁移/Service/Handler,PIPL合规 P0-6: 审计日志补全 — 患者更新记录前后值(过敏史/病史/状态变更) P0-7: EventBus持久化增强 — 两阶段提交(pending→published)+启动时outbox relay恢复
103 lines
3.4 KiB
Rust
103 lines
3.4 KiB
Rust
use sea_orm_migration::prelude::*;
|
|
|
|
#[derive(DeriveMigrationName)]
|
|
pub struct Migration;
|
|
|
|
#[async_trait::async_trait]
|
|
impl MigrationTrait for Migration {
|
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.create_table(
|
|
Table::create()
|
|
.table(Consent::Table)
|
|
.col(
|
|
ColumnDef::new(Consent::Id)
|
|
.uuid()
|
|
.not_null()
|
|
.primary_key(),
|
|
)
|
|
.col(ColumnDef::new(Consent::TenantId).uuid().not_null())
|
|
.col(ColumnDef::new(Consent::PatientId).uuid().not_null())
|
|
.col(ColumnDef::new(Consent::ConsentType).string_len(50).not_null())
|
|
.col(ColumnDef::new(Consent::ConsentScope).string_len(100).not_null())
|
|
.col(
|
|
ColumnDef::new(Consent::Status)
|
|
.string_len(20)
|
|
.not_null()
|
|
.default("granted"),
|
|
)
|
|
.col(ColumnDef::new(Consent::GrantedAt).timestamp_with_time_zone())
|
|
.col(ColumnDef::new(Consent::RevokedAt).timestamp_with_time_zone())
|
|
.col(ColumnDef::new(Consent::ExpiryDate).date())
|
|
.col(ColumnDef::new(Consent::ConsentMethod).string_len(30))
|
|
.col(ColumnDef::new(Consent::WitnessName).string_len(100))
|
|
.col(ColumnDef::new(Consent::Notes).text())
|
|
.col(
|
|
ColumnDef::new(Consent::CreatedAt)
|
|
.timestamp_with_time_zone()
|
|
.not_null()
|
|
.default(Expr::current_timestamp()),
|
|
)
|
|
.col(
|
|
ColumnDef::new(Consent::UpdatedAt)
|
|
.timestamp_with_time_zone()
|
|
.not_null()
|
|
.default(Expr::current_timestamp()),
|
|
)
|
|
.col(ColumnDef::new(Consent::CreatedBy).uuid())
|
|
.col(ColumnDef::new(Consent::UpdatedBy).uuid())
|
|
.col(ColumnDef::new(Consent::DeletedAt).timestamp_with_time_zone())
|
|
.col(
|
|
ColumnDef::new(Consent::Version)
|
|
.integer()
|
|
.not_null()
|
|
.default(1),
|
|
)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
|
|
manager
|
|
.create_index(
|
|
Index::create()
|
|
.name("idx_consent_tenant_patient")
|
|
.table(Consent::Table)
|
|
.col(Consent::TenantId)
|
|
.col(Consent::PatientId)
|
|
.to_owned(),
|
|
)
|
|
.await?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.drop_table(Table::drop().table(Consent::Table).to_owned())
|
|
.await
|
|
}
|
|
}
|
|
|
|
#[derive(DeriveIden)]
|
|
enum Consent {
|
|
Table,
|
|
Id,
|
|
TenantId,
|
|
PatientId,
|
|
ConsentType,
|
|
ConsentScope,
|
|
Status,
|
|
GrantedAt,
|
|
RevokedAt,
|
|
ExpiryDate,
|
|
ConsentMethod,
|
|
WitnessName,
|
|
Notes,
|
|
CreatedAt,
|
|
UpdatedAt,
|
|
CreatedBy,
|
|
UpdatedBy,
|
|
DeletedAt,
|
|
Version,
|
|
}
|