Files
digital-pilates/types/medication.ts
richarjiang 84abfa2506 feat(medication): 重构AI分析为结构化展示并支持喝水提醒个性化配置
- 将药品AI分析从Markdown流式输出重构为结构化数据展示(V2)
- 新增适合人群、不适合人群、主要成分、副作用等分类卡片展示
- 优化AI分析UI布局,采用卡片式设计提升可读性
- 新增药品跳过功能,支持用户标记本次用药为已跳过
- 修复喝水提醒逻辑,支持用户开关控制和自定义时间段配置
- 优化个人资料编辑页面键盘适配,避免输入框被遮挡
- 统一API响应码处理,兼容200和0两种成功状态码
- 更新版本号至1.0.28

BREAKING CHANGE: 药品AI分析接口从流式Markdown输出改为结构化JSON格式,旧版本分析结果将不再显示
2025-11-20 10:10:53 +08:00

108 lines
3.6 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
}
/**
* 药品 AI 分析 V2 结构化数据
*/
export interface MedicationAiAnalysisV2 {
suitableFor: string[]; // 适合人群
unsuitableFor: string[]; // 不适合人群/慎用
mainIngredients: string[]; // 主要成分
mainUsage: string; // 主要用途/功效
sideEffects: string[]; // 常见副作用
storageAdvice: string[]; // 储存建议
healthAdvice: string[]; // 健康建议/使用建议
}