feat(web): 健康模块 API 服务层 6 文件 47 端点
- patients.ts: 患者CRUD/标签/家庭/医护关联 14端点 - healthData.ts: 体征/化验/健康档案CRUD + 趋势 18端点 - appointments.ts: 预约CRUD + 排班管理 + 日历 8端点 - followUp.ts: 随访任务/记录CRUD 7端点 - consultations.ts: 咨询会话/消息CRUD + 导出 6端点 - doctors.ts: 医护CRUD 5端点
This commit is contained in:
107
apps/web/src/api/health/consultations.ts
Normal file
107
apps/web/src/api/health/consultations.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
import client from '../client';
|
||||
import type { PaginatedResponse } from '../types';
|
||||
|
||||
// --- Types ---
|
||||
export interface Session {
|
||||
id: string;
|
||||
patient_id: string;
|
||||
doctor_id?: string;
|
||||
consultation_type: string;
|
||||
status: string;
|
||||
last_message_at?: string;
|
||||
unread_count_patient: number;
|
||||
unread_count_doctor: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface CreateSessionReq {
|
||||
patient_id: string;
|
||||
doctor_id?: string;
|
||||
consultation_type?: string;
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
id: string;
|
||||
session_id: string;
|
||||
sender_id: string;
|
||||
sender_role: string;
|
||||
content_type: string;
|
||||
content: string;
|
||||
is_read: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface CreateMessageReq {
|
||||
session_id: string;
|
||||
sender_id: string;
|
||||
sender_role: string;
|
||||
content_type?: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
// --- API ---
|
||||
export const consultationApi = {
|
||||
listSessions: async (params: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
status?: string;
|
||||
patient_id?: string;
|
||||
doctor_id?: string;
|
||||
}) => {
|
||||
const { data } = await client.get<{
|
||||
success: boolean;
|
||||
data: PaginatedResponse<Session>;
|
||||
}>('/health/consultation-sessions', { params });
|
||||
return data.data;
|
||||
},
|
||||
|
||||
createSession: async (req: CreateSessionReq) => {
|
||||
const { data } = await client.post<{
|
||||
success: boolean;
|
||||
data: Session;
|
||||
}>('/health/consultation-sessions', req);
|
||||
return data.data;
|
||||
},
|
||||
|
||||
closeSession: async (
|
||||
id: string,
|
||||
req: { version: number },
|
||||
) => {
|
||||
const { data } = await client.put<{
|
||||
success: boolean;
|
||||
data: Session;
|
||||
}>(`/health/consultation-sessions/${id}/close`, req);
|
||||
return data.data;
|
||||
},
|
||||
|
||||
listMessages: async (
|
||||
sessionId: string,
|
||||
params: { page?: number; page_size?: number },
|
||||
) => {
|
||||
const { data } = await client.get<{
|
||||
success: boolean;
|
||||
data: PaginatedResponse<Message>;
|
||||
}>(`/health/consultation-sessions/${sessionId}/messages`, { params });
|
||||
return data.data;
|
||||
},
|
||||
|
||||
createMessage: async (req: CreateMessageReq) => {
|
||||
const { data } = await client.post<{
|
||||
success: boolean;
|
||||
data: Message;
|
||||
}>('/health/consultation-messages', req);
|
||||
return data.data;
|
||||
},
|
||||
|
||||
exportSessions: async (params: {
|
||||
status?: string;
|
||||
patient_id?: string;
|
||||
doctor_id?: string;
|
||||
}) => {
|
||||
const { data } = await client.get<{
|
||||
success: boolean;
|
||||
data: Session[];
|
||||
}>('/health/consultation-sessions/export', { params });
|
||||
return data.data;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user