当 AI 侧边栏打开且当前页面为患者详情时,自动调用 GET /ai/health-summary 并在侧边栏顶部显示摘要卡片: - 风险等级标签(低/中/高/严重,对应绿/橙/红/深红) - 活跃洞察数量 + 近期分析次数 - 最多 3 条摘要项(按 category + severity 着色) - 最新洞察标题(带警告图标) - 离开患者页面或关闭侧边栏时自动清除 同时: - analysis.ts 新增 getHealthSummary API + HealthSummaryResponse 类型 - 权限检查:需要 ai.analysis.list 才显示摘要卡片
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import client from '../client';
|
|
import type { PaginatedResponse } from '../types';
|
|
|
|
export interface AnalysisItem {
|
|
id: string;
|
|
patient_id: string;
|
|
patient_name?: string;
|
|
analysis_type: string;
|
|
source_ref: string;
|
|
model_used: string;
|
|
status: string;
|
|
result_content: string | null;
|
|
result_metadata: Record<string, unknown> | null;
|
|
error_message: string | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface HealthSummaryResponse {
|
|
patient_id: string;
|
|
risk_level: 'low' | 'medium' | 'high' | 'critical';
|
|
active_insights_count: number;
|
|
recent_analyses_count: number;
|
|
latest_insight_title: string | null;
|
|
latest_analysis_type: string | null;
|
|
summary_items: Array<{
|
|
category: string;
|
|
title: string;
|
|
severity: string | null;
|
|
created_at: string;
|
|
}>;
|
|
}
|
|
|
|
export const analysisApi = {
|
|
list: async (params?: { patient_id?: string; analysis_type?: string; page?: number; page_size?: number }) => {
|
|
const resp = await client.get('/ai/analysis/history', { params });
|
|
return resp.data.data as PaginatedResponse<AnalysisItem>;
|
|
},
|
|
get: async (id: string) => {
|
|
const resp = await client.get(`/ai/analysis/${id}`);
|
|
return resp.data.data as AnalysisItem;
|
|
},
|
|
getHealthSummary: async (patientId: string) => {
|
|
const resp = await client.get('/ai/health-summary', { params: { patient_id: patientId } });
|
|
return resp.data.data as HealthSummaryResponse;
|
|
},
|
|
};
|