/** * 药物管理类型定义 */ // 药物剂型 export type MedicationForm = | 'capsule' // 胶囊 | 'pill' // 药片 | 'injection' // 注射 | 'spray' // 喷雾 | 'drop' // 滴剂 | 'syrup' // 糖浆 | 'other'; // 其他 // 服药状态 export type MedicationStatus = | 'upcoming' // 待服用 | 'taken' // 已服用 | 'missed' // 已错过 | 'skipped'; // 已跳过 // 重复模式 export type RepeatPattern = | 'daily' // 每日 | 'weekly' // 每周 | 'custom'; // 自定义 /** * 药物基础信息 */ export interface Medication { id: string; userId: string; // 用户ID(由服务端返回) name: string; // 药物名称 photoUrl?: string | null; // 药物照片 form: MedicationForm; // 剂型 dosageValue: number; // 剂量值 dosageUnit: string; // 剂量单位 timesPerDay: number; // 每日次数 medicationTimes: string[]; // 服药时间列表 ['08:00', '20:00'] startDate: string; // 开始日期 ISO endDate?: string | null; // 结束日期 ISO(可选) expiryDate?: string | null; // 药品有效期 ISO(可选) repeatPattern: RepeatPattern; // 重复模式 note?: string; // 备注 aiAnalysis?: string; // AI 分析结果(Markdown 格式) isActive: boolean; // 是否激活 deleted: boolean; // 是否已删除(软删除标记) createdAt: string; // 创建时间 updatedAt: string; // 更新时间 } /** * 服药记录 */ export interface MedicationRecord { id: string; medicationId: string; // 关联的药物ID userId: string; // 用户ID(由服务端返回) medication?: Medication; // 关联的药物信息(可选,用于展示) scheduledTime: string; // 计划服药时间 ISO actualTime?: string | null; // 实际服药时间 ISO status: MedicationStatus; // 服药状态 note?: string; // 记录备注 deleted: boolean; // 是否已删除(软删除标记) createdAt: string; updatedAt: string; } /** * 每日服药统计 */ export interface DailyMedicationStats { date: string; // 日期 'YYYY-MM-DD' totalScheduled: number; // 计划总数 taken: number; // 已服用 missed: number; // 已错过 upcoming: number; // 待服用 completionRate: number; // 完成率 0-100 } /** * 用于展示的药物记录(组合了药物信息和服药记录) */ export interface MedicationDisplayItem { id: string; name: string; dosage: string; // 格式化的剂量字符串,如 "1 粒胶囊" scheduledTime: string; // 格式化的时间,如 "09:00" frequency: string; // 频率描述,如 "每日" status: MedicationStatus; image?: any; // 图片资源 recordId?: string; // 服药记录ID(用于更新状态) medicationId: string; // 药物ID } /** * 药品 AI 分析 V2 结构化数据 */ export interface MedicationAiAnalysisV2 { suitableFor: string[]; // 适合人群 unsuitableFor: string[]; // 不适合人群/慎用 mainIngredients: string[]; // 主要成分 mainUsage: string; // 主要用途/功效 sideEffects: string[]; // 常见副作用 storageAdvice: string[]; // 储存建议 healthAdvice: string[]; // 健康建议/使用建议 } /** * AI 识别结果结构化数据 */ export interface MedicationAiRecognitionResult { name: string; photoUrl?: string; form?: MedicationForm; dosageValue?: number; dosageUnit?: string; timesPerDay?: number; medicationTimes?: string[]; startDate?: string; endDate?: string | null; expiryDate?: string | null; note?: string; suitableFor?: string[]; unsuitableFor?: string[]; mainIngredients?: string[]; mainUsage?: string; sideEffects?: string[]; storageAdvice?: string[]; healthAdvice?: string[]; confidence?: number; } export type MedicationRecognitionStatus = | 'pending' | 'analyzing_product' | 'analyzing_suitability' | 'analyzing_ingredients' | 'analyzing_effects' | 'completed' | 'failed'; export interface MedicationRecognitionTask { taskId: string; status: MedicationRecognitionStatus; currentStep?: string; progress?: number; result?: MedicationAiRecognitionResult; errorMessage?: string; // 识别失败时的错误信息 createdAt: string; completedAt?: string; }