From cba8c8306d04cc190b7597de06b7d4789d37bbf1 Mon Sep 17 00:00:00 2001 From: iven Date: Tue, 12 May 2026 22:16:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(web):=20Copilot=20API=20=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/api/copilot.ts | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 apps/web/src/api/copilot.ts diff --git a/apps/web/src/api/copilot.ts b/apps/web/src/api/copilot.ts new file mode 100644 index 0000000..358e99c --- /dev/null +++ b/apps/web/src/api/copilot.ts @@ -0,0 +1,59 @@ +import client from './client'; +import type { PaginatedResponse } from './types'; + +// --- Types --- + +export type InsightType = 'risk_score' | 'anomaly' | 'follow_up_hint' | 'consult_hint'; +export type InsightSource = 'rule' | 'llm' | 'hybrid'; +export type RiskLevel = 'low' | 'medium' | 'high' | 'critical'; + +export interface MatchedRule { + rule_id: string; + name: string; + score: number; + severity: string; + suggestion?: string; +} + +export interface RiskScore { + score: number; + level: RiskLevel; + matched_rules: MatchedRule[]; +} + +export interface CopilotInsight { + id: string; + patient_id: string; + insight_type: InsightType; + source: InsightSource; + severity: 'info' | 'warning' | 'critical'; + title: string; + content: Record; + rule_matches?: MatchedRule[]; + llm_supplement?: string; + created_at: string; +} + +// --- API Functions --- + +export function getPatientRisk(patientId: string) { + return client.get(`/copilot/patients/${patientId}/risk`); +} + +export function listInsights(params: { + patient_id?: string; + insight_type?: string; + severity?: string; + page?: number; + page_size?: number; +}) { + return client.get>('/copilot/insights', { params }); +} + +export function dismissInsight(id: string) { + return client.post(`/copilot/insights/${id}/dismiss`); +} + +export function listRules(params?: { page?: number; page_size?: number }) { + return client.get>>('/copilot/rules', { params }); +}