fix(ai): AI 分析预校验 + prompt 非对话化
- 四个 SSE 端点增加数据完整性校验:items/sections 为空时返回 400 - 迁移 000123 更新全部 prompt system_prompt:明确非对话、输出结构化结果 - 前端用户看到的是分析结论,不再收到"请补充数据"的对话式回复
This commit is contained in:
@@ -42,6 +42,13 @@ where
|
||||
.health_provider
|
||||
.get_lab_report(ctx.tenant_id, report_id)
|
||||
.await?;
|
||||
|
||||
if lab_dto.items.is_empty() {
|
||||
return Err(erp_core::error::AppError::Validation(
|
||||
"化验报告缺少检查项目数据,无法进行 AI 分析。请先录入完整的化验指标。".into(),
|
||||
));
|
||||
}
|
||||
|
||||
let sanitized_data = state.analysis.sanitizer.sanitize_lab_report(&lab_dto)?;
|
||||
|
||||
let prompt = state
|
||||
@@ -112,6 +119,13 @@ where
|
||||
.health_provider
|
||||
.get_trend_analysis_data(ctx.tenant_id, patient_id, &metrics, &range)
|
||||
.await?;
|
||||
|
||||
if trend_data.metrics.is_empty() {
|
||||
return Err(erp_core::error::AppError::Validation(
|
||||
"患者在选定时间段内无体征监测数据,无法进行趋势分析。".into(),
|
||||
));
|
||||
}
|
||||
|
||||
let sanitized_data = state.analysis.sanitizer.sanitize_trend_analysis(&trend_data)?;
|
||||
|
||||
let prompt = state
|
||||
@@ -223,6 +237,13 @@ where
|
||||
.health_provider
|
||||
.get_full_report(ctx.tenant_id, report_id)
|
||||
.await?;
|
||||
|
||||
if report_dto.sections.is_empty() {
|
||||
return Err(erp_core::error::AppError::Validation(
|
||||
"健康报告缺少内容数据,无法生成摘要。请先完善报告内容。".into(),
|
||||
));
|
||||
}
|
||||
|
||||
let sanitized_data = state
|
||||
.analysis
|
||||
.sanitizer
|
||||
|
||||
Reference in New Issue
Block a user