feat(ai+db): 趋势分析 prompt 升级为结构化统计摘要
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

- 新增迁移 000093:更新 health_trend_analysis prompt,使用统计字段
  替代原始数据点遍历,引导 AI 专注 slope/R²/异常点分析
- erp-ai handler: stream_trends 改用 get_trend_analysis_data()
  替代 get_vital_signs(),传递预计算趋势特征
- sanitizer: 新增 sanitize_trend_analysis() 方法
This commit is contained in:
iven
2026-04-28 19:57:51 +08:00
parent 1c9e7ccf1d
commit cf844a561f
4 changed files with 107 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
use erp_core::health_provider::{
HealthReportDto, LabReportDto, PatientSummaryDto, VitalSignDto,
HealthReportDto, LabReportDto, PatientSummaryDto, TrendAnalysisDto, VitalSignDto,
};
use serde_json::Value;
@@ -43,6 +43,13 @@ impl SanitizationService {
Ok(sanitized)
}
pub fn sanitize_trend_analysis(&self, data: &TrendAnalysisDto) -> AiResult<Value> {
let sanitized = serde_json::to_value(data)
.map_err(|e| AiError::SanitizationError(format!("序列化失败: {e}")))?;
self.verify_no_pii(&sanitized)?;
Ok(sanitized)
}
/// 二次验证: 确保没有意外泄漏的 PII
fn verify_no_pii(&self, value: &Value) -> AiResult<()> {
let pii_keys = [