feat(web): Copilot API 调用层

This commit is contained in:
iven
2026-05-12 22:16:28 +08:00
parent ba0a4f4d2e
commit cba8c8306d

View File

@@ -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<string, unknown>;
rule_matches?: MatchedRule[];
llm_supplement?: string;
created_at: string;
}
// --- API Functions ---
export function getPatientRisk(patientId: string) {
return client.get<RiskScore>(`/copilot/patients/${patientId}/risk`);
}
export function listInsights(params: {
patient_id?: string;
insight_type?: string;
severity?: string;
page?: number;
page_size?: number;
}) {
return client.get<PaginatedResponse<CopilotInsight>>('/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<PaginatedResponse<Record<string, unknown>>>('/copilot/rules', { params });
}