feat(web): Copilot API 调用层
This commit is contained in:
59
apps/web/src/api/copilot.ts
Normal file
59
apps/web/src/api/copilot.ts
Normal 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 });
|
||||
}
|
||||
Reference in New Issue
Block a user