feat(health+ai): P2 咨询联动 + AI 巡检消费 — 全链路打通
业务链路打通 5/5 断点全部完成: - 咨询→随访:医生端新增"创建随访"按钮,从咨询会话直接创建随访任务 - 咨询→AI:医生端新增"AI 分析"按钮,对咨询上下文触发 AI 分析 - 告警→咨询:小程序告警详情页新增"在线咨询"快捷入口 - AI 巡检消费:erp-ai 新增 patrol_consumer,订阅 ai.patrol.requested 事件 - 前端联动:Web ConsultationDetail + 小程序 alerts 页面联动实现 后端:2 新 API + 2 handler + 1 service + AI event consumer 前端:Web 2 API + 1 页面改造 + 小程序 2 页面改造 测试:Web consultations.test.ts 9/9 通过
This commit is contained in:
@@ -305,3 +305,70 @@ where
|
||||
.await?;
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
/// 从咨询会话创建随访任务 — 自动从 session 中提取 patient_id,
|
||||
/// source_type = "consultation", source_id = session_id。
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/consultation-sessions/{id}/follow-up",
|
||||
request_body = CreateFollowUpFromConsultationReq,
|
||||
responses(
|
||||
(status = 200, description = "随访任务已创建"),
|
||||
(status = 404, description = "会话不存在"),
|
||||
),
|
||||
tag = "咨询联动",
|
||||
)]
|
||||
pub async fn create_follow_up_from_session<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
Path(id): Path<Uuid>,
|
||||
Json(req): Json<CreateFollowUpFromConsultationReq>,
|
||||
) -> Result<Json<ApiResponse<FollowUpFromConsultationResp>>, AppError>
|
||||
where
|
||||
HealthState: FromRef<S>,
|
||||
S: Clone + Send + Sync + 'static,
|
||||
{
|
||||
require_permission(&ctx, "health.follow-up.manage")?;
|
||||
let result = consultation_service::create_follow_up_from_session(
|
||||
&state,
|
||||
ctx.tenant_id,
|
||||
Some(ctx.user_id),
|
||||
id,
|
||||
req,
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
/// 从咨询会话触发 AI 分析 — 加载最近消息作为上下文,发布事件。
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/consultation-sessions/{id}/ai-analysis",
|
||||
request_body = TriggerAiAnalysisReq,
|
||||
responses(
|
||||
(status = 200, description = "AI 分析已触发"),
|
||||
(status = 404, description = "会话不存在"),
|
||||
),
|
||||
tag = "咨询联动",
|
||||
)]
|
||||
pub async fn trigger_ai_analysis_from_session<S>(
|
||||
State(state): State<HealthState>,
|
||||
Extension(ctx): Extension<TenantContext>,
|
||||
Path(id): Path<Uuid>,
|
||||
Json(req): Json<TriggerAiAnalysisReq>,
|
||||
) -> Result<Json<ApiResponse<AiAnalysisTriggeredResp>>, AppError>
|
||||
where
|
||||
HealthState: FromRef<S>,
|
||||
S: Clone + Send + Sync + 'static,
|
||||
{
|
||||
require_permission(&ctx, "health.consultation.manage")?;
|
||||
let result = consultation_service::trigger_ai_analysis_from_session(
|
||||
&state,
|
||||
ctx.tenant_id,
|
||||
Some(ctx.user_id),
|
||||
id,
|
||||
req,
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(ApiResponse::ok(result)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user