- S-1: 隐私政策描述修正("混淆加密" → "HTTPS + 微信沙箱") - A-1: getCachedPatientId 统一导出 + 9 处 Storage 直读替换 - A-2: usePageData loading 改为 useState 响应式 - A-3: health.ts refreshingToday 移入 store state - M-2: prod config 移除 console.error/warn - M-4: clearCache 后同步刷新 request.ts 内存缓存 - Q-3: doctor/appointment.ts any[] → Appointment 类型 - Q-4: daily-monitoring 常量提取到 constants.ts - 清理: 删除空目录 FamilyPicker/HealthCard + 未使用组件 DeviceCard
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { api, getCachedPatientId } from './request';
|
|
|
|
export interface MedicationReminder {
|
|
id: string;
|
|
patient_id: string;
|
|
medication_name: string;
|
|
dosage?: string;
|
|
frequency?: string;
|
|
reminder_times: string[];
|
|
start_date?: string;
|
|
end_date?: string;
|
|
is_active: boolean;
|
|
notes?: string;
|
|
version: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface CreateReminderReq {
|
|
patient_id: string;
|
|
medication_name: string;
|
|
dosage?: string;
|
|
frequency?: string;
|
|
reminder_times: string[];
|
|
start_date?: string;
|
|
end_date?: string;
|
|
is_active?: boolean;
|
|
notes?: string;
|
|
}
|
|
|
|
export interface UpdateReminderReq {
|
|
medication_name?: string;
|
|
dosage?: string;
|
|
frequency?: string;
|
|
reminder_times?: string[];
|
|
start_date?: string;
|
|
end_date?: string;
|
|
is_active?: boolean;
|
|
notes?: string;
|
|
version: number;
|
|
}
|
|
|
|
function getPatientId(): string {
|
|
return getCachedPatientId();
|
|
}
|
|
|
|
export async function listReminders() {
|
|
const patientId = getPatientId();
|
|
if (!patientId) return { data: [] as MedicationReminder[], total: 0 };
|
|
return api.get<{ data: MedicationReminder[]; total: number }>(
|
|
`/health/patients/${patientId}/medication-reminders`,
|
|
{ page: 1, page_size: 100 },
|
|
0,
|
|
);
|
|
}
|
|
|
|
export async function createReminder(req: CreateReminderReq) {
|
|
return api.post<MedicationReminder>('/health/medication-reminders', req);
|
|
}
|
|
|
|
export async function updateReminder(id: string, req: UpdateReminderReq) {
|
|
return api.put<MedicationReminder>(`/health/medication-reminders/${id}`, req);
|
|
}
|
|
|
|
export async function deleteReminder(id: string, version: number) {
|
|
return api.delete<void>(`/health/medication-reminders/${id}`, { version });
|
|
}
|