feat(ai+db): 趋势分析 prompt 升级为结构化统计摘要
- 新增迁移 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:
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user