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:
iven
2026-04-25 00:37:59 +08:00
parent 994119ded1
commit 778ae79d84
6 changed files with 903 additions and 0 deletions

View File

@@ -0,0 +1,160 @@
import client from '../client';
import type { PaginatedResponse } from '../types';
// --- Types ---
export interface Appointment {
id: string;
patient_id: string;
doctor_id?: string;
appointment_type: string;
appointment_date: string;
start_time: string;
end_time: string;
status: string;
cancel_reason?: string;
notes?: string;
created_at: string;
updated_at: string;
version: number;
}
export interface CreateAppointmentReq {
patient_id: string;
doctor_id?: string;
appointment_type?: string;
appointment_date: string;
start_time: string;
end_time: string;
notes?: string;
}
export interface UpdateAppointmentStatusReq {
status: string;
cancel_reason?: string;
}
export interface Schedule {
id: string;
doctor_id: string;
schedule_date: string;
period_type: string;
start_time: string;
end_time: string;
max_appointments: number;
current_appointments: number;
status: string;
created_at: string;
updated_at: string;
version: number;
}
export interface CreateScheduleReq {
doctor_id: string;
schedule_date: string;
period_type?: string;
start_time: string;
end_time: string;
max_appointments: number;
}
export interface UpdateScheduleReq {
start_time?: string;
end_time?: string;
max_appointments?: number;
status?: string;
}
export interface CalendarDay {
date: string;
schedules: Schedule[];
}
// --- API ---
export const appointmentApi = {
list: async (params: {
page?: number;
page_size?: number;
status?: string;
patient_id?: string;
doctor_id?: string;
date?: string;
}) => {
const { data } = await client.get<{
success: boolean;
data: PaginatedResponse<Appointment>;
}>('/health/appointments', { params });
return data.data;
},
get: async (id: string) => {
const { data } = await client.get<{
success: boolean;
data: Appointment;
}>(`/health/appointments/${id}`);
return data.data;
},
create: async (req: CreateAppointmentReq) => {
const { data } = await client.post<{
success: boolean;
data: Appointment;
}>('/health/appointments', req);
return data.data;
},
updateStatus: async (
id: string,
req: UpdateAppointmentStatusReq & { version: number },
) => {
const { data } = await client.put<{
success: boolean;
data: Appointment;
}>(`/health/appointments/${id}/status`, req);
return data.data;
},
// Schedules
listSchedules: async (params: {
page?: number;
page_size?: number;
doctor_id?: string;
date?: string;
}) => {
const { data } = await client.get<{
success: boolean;
data: PaginatedResponse<Schedule>;
}>('/health/doctor-schedules', { params });
return data.data;
},
createSchedule: async (req: CreateScheduleReq) => {
const { data } = await client.post<{
success: boolean;
data: Schedule;
}>('/health/doctor-schedules', req);
return data.data;
},
updateSchedule: async (
id: string,
req: UpdateScheduleReq & { version: number },
) => {
const { data } = await client.put<{
success: boolean;
data: Schedule;
}>(`/health/doctor-schedules/${id}`, req);
return data.data;
},
calendar: async (params: {
start_date: string;
end_date: string;
doctor_id?: string;
}) => {
const { data } = await client.get<{
success: boolean;
data: CalendarDay[];
}>('/health/doctor-schedules/calendar', { params });
return data.data;
},
};