Files
digital-pilates/types/medication.ts
richarjiang 7c8538f5c6 feat(medications): 添加AI用药分析功能
- 集成流式AI分析接口,支持实时展示分析结果
- 添加VIP权限校验和会员弹窗引导
- 使用Markdown渲染AI分析内容
- 优化底部按钮布局,AI分析按钮占2/3宽度
- 支持请求取消和错误处理
- 自动滚动到分析结果区域
- InfoCard组件优化,图标、标签和箭头排列在同一行
2025-11-12 17:07:42 +08:00

94 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 药物管理类型定义
*/
// 药物剂型
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可选
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
}