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 listAlerts(params?: { severity?: string; page?: number; page_size?: number }) { return listInsights({ insight_type: 'anomaly', ...params }); } export function listRules(params?: { page?: number; page_size?: number }) { return client.get>>('/copilot/rules', { params }); }