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:
@@ -73,4 +73,26 @@ describe('consultationApi', () => {
|
||||
|
||||
expect(mockPost).toHaveBeenCalledWith('/health/consultation-messages', req)
|
||||
})
|
||||
|
||||
it('createFollowUpFromSession 应调用 POST /health/consultation-sessions/:id/follow-up', async () => {
|
||||
mockPost.mockResolvedValue(fakeRes)
|
||||
const req = { follow_up_type: 'phone', planned_date: '2026-06-01' }
|
||||
await consultationApi.createFollowUpFromSession('sess-001', req)
|
||||
|
||||
expect(mockPost).toHaveBeenCalledWith('/health/consultation-sessions/sess-001/follow-up', req)
|
||||
})
|
||||
|
||||
it('triggerAiAnalysisFromSession 应调用 POST /health/consultation-sessions/:id/ai-analysis', async () => {
|
||||
mockPost.mockResolvedValue(fakeRes)
|
||||
await consultationApi.triggerAiAnalysisFromSession('sess-001')
|
||||
|
||||
expect(mockPost).toHaveBeenCalledWith('/health/consultation-sessions/sess-001/ai-analysis', {})
|
||||
})
|
||||
|
||||
it('triggerAiAnalysisFromSession 传入 analysis_type 时应携带参数', async () => {
|
||||
mockPost.mockResolvedValue(fakeRes)
|
||||
await consultationApi.triggerAiAnalysisFromSession('sess-001', { analysis_type: 'trend' })
|
||||
|
||||
expect(mockPost).toHaveBeenCalledWith('/health/consultation-sessions/sess-001/ai-analysis', { analysis_type: 'trend' })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -41,6 +41,30 @@ export interface CreateMessageReq {
|
||||
content: string;
|
||||
}
|
||||
|
||||
// --- 咨询联动请求类型 ---
|
||||
export interface CreateFollowUpFromConsultationReq {
|
||||
follow_up_type: string;
|
||||
planned_date: string;
|
||||
assigned_to?: string;
|
||||
content_template?: string;
|
||||
}
|
||||
|
||||
export interface FollowUpFromConsultationResp {
|
||||
task_id: string;
|
||||
session_id: string;
|
||||
patient_id: string;
|
||||
}
|
||||
|
||||
export interface TriggerAiAnalysisReq {
|
||||
analysis_type?: string;
|
||||
}
|
||||
|
||||
export interface AiAnalysisTriggeredResp {
|
||||
session_id: string;
|
||||
patient_id: string;
|
||||
analysis_type: string;
|
||||
}
|
||||
|
||||
// --- API ---
|
||||
export const consultationApi = {
|
||||
listSessions: async (params: {
|
||||
@@ -134,4 +158,28 @@ export const consultationApi = {
|
||||
}>('/health/consultation-sessions/export', { params });
|
||||
return data.data;
|
||||
},
|
||||
|
||||
/** 从咨询会话创建随访任务 */
|
||||
createFollowUpFromSession: async (
|
||||
sessionId: string,
|
||||
req: CreateFollowUpFromConsultationReq,
|
||||
) => {
|
||||
const { data } = await client.post<{
|
||||
success: boolean;
|
||||
data: FollowUpFromConsultationResp;
|
||||
}>(`/health/consultation-sessions/${sessionId}/follow-up`, req);
|
||||
return data.data;
|
||||
},
|
||||
|
||||
/** 从咨询会话触发 AI 分析 */
|
||||
triggerAiAnalysisFromSession: async (
|
||||
sessionId: string,
|
||||
req?: TriggerAiAnalysisReq,
|
||||
) => {
|
||||
const { data } = await client.post<{
|
||||
success: boolean;
|
||||
data: AiAnalysisTriggeredResp;
|
||||
}>(`/health/consultation-sessions/${sessionId}/ai-analysis`, req ?? {});
|
||||
return data.data;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user