feat: 二级页面色彩刷新 + 用药/通知/设备重构 + 后端健康档案/通知管线增强 + 大量测试

## 后端
- 健康档案: 新增手术状态字段 + EF 迁移; HealthArchiveService 新增查询方法
- 健康记录: HealthRecordService 新增批量/统计方法; 契约扩展
- 用药: 新增 MedicationScheduleStatus 枚举; MedicationService 排班逻辑调整
- 通知: EfUserNotificationPipeline 重构; 新增 EfReminderCatchUpService; 通知管线支持更多场景
- 用户: UserService 账号删除逻辑; 新增 local_account_file_cleanup; EfUserRepository 扩展
- AI: medication_agent_handler 微调; prompt_manager 优化; AiConversationService 上下文处理
- Endpoint: doctor/medication/exercise/health/notification/user 等多接口调整
- BackgroundService: health_record_reminder_service 重构, 提醒补漏逻辑
- 测试: 新增 account_deletion/doctor_endpoint/medication_schedule/medication_update/prompt_manager 测试

## 前端
- UI 系统: app_theme 大幅重构; app_colors/app_design_tokens/app_module_visuals 调整; 二级页面色彩刷新
- 主页: home_page 背景渐变 + 消息列表提取 _HomeMessages + 通知检查逻辑; chat_messages_view 全面重构
- 用药: medication_list/edit/checkin 三页重构, 新增 medication_ui_logic 抽取
- 通知: notification_prefs_page 重构, 新增 notification_prefs_logic; notification_center 优化
- 设备: device_management 重构, 新增 device_sync_ui_logic; device_scan 优化
- 趋势图: trend_page 大幅重构
- 登录: login_page 重构
- 个人资料: 新增 profile_edit_page; profile_page 优化
- 运动: 新增 exercise/ 目录 + care_plan_ui_logic
- 其他: remaining_pages/report_pages/health_drawer/admin/doctor 等多页面调整
- 组件: common_widgets/app_empty_state/app_error_state/app_future_view/app_toast/ai_content 优化
- Provider: chat_provider/consultation_provider/data_providers/auth_provider 调整
- AndroidManifest: 移除多余权限
- 测试: 新增 ai_content/care_plan/home_message/login_flow/medication_checkin/medication_ui/notification_prefs/profile_device/secondary_page/swipe_delete 等大量测试

## 文档
- 新增 ui-design-system.md 设计系统文档
- 新增 secondary-page-color-refresh 计划 + specs 目录
This commit is contained in:
MingNian
2026-07-15 23:22:52 +08:00
parent e654c1e0cc
commit fade61ac21
138 changed files with 12636 additions and 5013 deletions

View File

@@ -1,12 +1,18 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../core/api_client.dart';
import '../../core/app_colors.dart';
import '../../core/app_design_tokens.dart';
import '../../core/app_theme.dart';
import '../../core/navigation_provider.dart';
import '../../providers/data_providers.dart';
import '../../widgets/app_error_state.dart';
import '../../widgets/app_toast.dart';
import '../../widgets/common_widgets.dart';
import '../care_plan_ui_logic.dart';
import 'medication_ui_logic.dart';
class MedicationEditPage extends ConsumerStatefulWidget {
final String? id;
@@ -18,117 +24,163 @@ class MedicationEditPage extends ConsumerStatefulWidget {
}
class _MedicationEditPageState extends ConsumerState<MedicationEditPage> {
final _nameCtrl = TextEditingController();
final _dosageCtrl = TextEditingController();
final _notesCtrl = TextEditingController();
int _timesPerDay = 2;
final _nameController = TextEditingController();
final _dosageController = TextEditingController();
final _notesController = TextEditingController();
List<TimeOfDay> _times = [
const TimeOfDay(hour: 8, minute: 0),
const TimeOfDay(hour: 18, minute: 0),
];
DateTime _start = DateTime.now();
DateTime? _end;
DateTime _startDate = DateTime.now();
DateTime? _endDate;
bool _saving = false;
bool _loading = false;
String? _loadError;
bool get _editing => widget.id?.isNotEmpty == true;
@override
void initState() {
super.initState();
if (widget.id != null) _load();
if (_editing) _load();
}
@override
void dispose() {
_nameCtrl.dispose();
_dosageCtrl.dispose();
_notesCtrl.dispose();
_nameController.dispose();
_dosageController.dispose();
_notesController.dispose();
super.dispose();
}
Future<void> _load() async {
final srv = ref.read(medicationServiceProvider);
final list = await srv.getList();
final m = list.cast<Map<String, dynamic>?>().firstWhere(
(x) => x?['id']?.toString() == widget.id,
orElse: () => null,
);
if (m == null || !mounted) return;
_nameCtrl.text = m['name']?.toString() ?? '';
_dosageCtrl.text = m['dosage']?.toString() ?? '';
_notesCtrl.text = m['notes']?.toString() ?? '';
final tod =
(m['timeOfDay'] as List?)?.map((t) {
final parts = t.toString().split(':');
return TimeOfDay(
hour: int.tryParse(parts[0]) ?? 8,
minute: int.tryParse(parts.length > 1 ? parts[1] : '0') ?? 0,
);
}).toList() ??
[
const TimeOfDay(hour: 8, minute: 0),
const TimeOfDay(hour: 18, minute: 0),
];
_timesPerDay = tod.length;
_times = tod;
if (m['startDate'] != null) {
_start = DateTime.tryParse(m['startDate'].toString()) ?? DateTime.now();
setState(() {
_loading = true;
_loadError = null;
});
try {
final medications = await ref.read(medicationServiceProvider).getList();
final medication = medications.cast<Map<String, dynamic>?>().firstWhere(
(item) => item?['id']?.toString() == widget.id,
orElse: () => null,
);
if (medication == null) throw const ApiException('该用药记录不存在');
_nameController.text = medication['name']?.toString() ?? '';
_dosageController.text = medication['dosage']?.toString() ?? '';
_notesController.text = medication['notes']?.toString() ?? '';
final loadedTimes =
(medication['timeOfDay'] as List?)
?.map((value) => _parseTime(value))
.whereType<TimeOfDay>()
.toList() ??
[];
if (loadedTimes.isNotEmpty) _times = loadedTimes;
_startDate =
DateTime.tryParse(medication['startDate']?.toString() ?? '') ??
DateTime.now();
_endDate = DateTime.tryParse(medication['endDate']?.toString() ?? '');
} catch (error) {
_loadError = error is ApiException ? error.message : '用药信息加载失败';
} finally {
if (mounted) setState(() => _loading = false);
}
if (m['endDate'] != null) _end = DateTime.tryParse(m['endDate'].toString());
setState(() {});
}
Future<void> _save() async {
final name = _nameCtrl.text.trim();
if (name.isEmpty) {
AppToast.show(context, '请输入药品名称', type: AppToastType.warning);
final timeValues = _times.map(_timeValue).toList();
final validation = validateMedicationForm(
name: _nameController.text,
dosage: _dosageController.text,
times: timeValues,
startDate: _startDate,
endDate: _endDate,
);
if (validation != null) {
AppToast.show(context, validation, type: AppToastType.warning);
return;
}
setState(() => _loading = true);
final data = {
'name': name,
'dosage': _dosageCtrl.text.trim(),
'frequency': 'Daily',
'notes': _notesCtrl.text.trim(),
'timeOfDay': _times
.map(
(t) =>
'${t.hour.toString().padLeft(2, '0')}:${t.minute.toString().padLeft(2, '0')}',
)
.toList(),
'startDate':
'${_start.year}-${_start.month.toString().padLeft(2, '0')}-${_start.day.toString().padLeft(2, '0')}',
if (_end != null)
'endDate':
'${_end!.year}-${_end!.month.toString().padLeft(2, '0')}-${_end!.day.toString().padLeft(2, '0')}',
setState(() => _saving = true);
final payload = <String, dynamic>{
'name': _nameController.text.trim(),
'dosage': _dosageController.text.trim(),
'frequency': _frequencyForTimes(_times.length),
'notes': _notesController.text.trim(),
'timeOfDay': timeValues,
'startDate': _dateValue(_startDate),
'endDate': _endDate == null ? null : _dateValue(_endDate!),
'source': 'Manual',
};
final srv = ref.read(medicationServiceProvider);
try {
if (widget.id != null) {
await srv.update(widget.id!, data);
final service = ref.read(medicationServiceProvider);
if (_editing) {
await service.update(widget.id!, payload);
} else {
await srv.create(data);
await service.create(payload);
}
ref.invalidate(medicationListProvider);
ref.invalidate(medicationReminderProvider);
if (mounted) popRoute(ref);
} catch (_) {
if (mounted) {
AppToast.show(context, '保存失败', type: AppToastType.error);
AppToast.show(
context,
_editing ? '用药已更新' : '用药已添加',
type: AppToastType.success,
);
popRoute(ref);
}
} catch (error) {
if (mounted) {
AppToast.show(
context,
error is ApiException ? error.message : '保存失败,请稍后重试',
type: AppToastType.error,
);
}
} finally {
if (mounted) setState(() => _saving = false);
}
if (mounted) setState(() => _loading = false);
}
void _updateTimes(int n) {
setState(() {
_timesPerDay = n;
while (_times.length < n) {
_times.add(const TimeOfDay(hour: 12, minute: 0));
Future<void> _deleteMedication() async {
if (!_editing || _saving) return;
final confirmed = await showDialog<bool>(
context: context,
builder: (dialogContext) => AlertDialog(
title: const Text('删除用药'),
content: Text('确定删除“${_nameController.text.trim()}”吗?相关服药记录也将一并删除。'),
actions: [
TextButton(
onPressed: () => Navigator.pop(dialogContext, false),
child: const Text('取消'),
),
TextButton(
onPressed: () => Navigator.pop(dialogContext, true),
style: TextButton.styleFrom(foregroundColor: AppColors.errorText),
child: const Text('删除'),
),
],
),
);
if (confirmed != true || !mounted) return;
setState(() => _saving = true);
try {
await ref.read(medicationServiceProvider).deleteMedication(widget.id!);
ref.invalidate(medicationListProvider);
ref.invalidate(medicationReminderProvider);
if (mounted) {
AppToast.show(context, '用药已删除', type: AppToastType.success);
popRoute(ref);
}
while (_times.length > n) {
_times.removeLast();
} catch (error) {
if (mounted) {
AppToast.show(
context,
error is ApiException ? error.message : '删除失败,请稍后重试',
type: AppToastType.error,
);
}
});
} finally {
if (mounted) setState(() => _saving = false);
}
}
@override
@@ -139,282 +191,371 @@ class _MedicationEditPageState extends ConsumerState<MedicationEditPage> {
icon: const Icon(Icons.arrow_back),
onPressed: () => popRoute(ref),
),
title: Text(widget.id != null ? '编辑用药' : '添加用药'),
title: Text(_editing ? '编辑用药' : '添加用药'),
),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
Row(
children: [
Expanded(
flex: 3,
child: _field('药品名称', _nameCtrl, hint: '如:阿司匹林'),
),
const SizedBox(width: 12),
Expanded(
flex: 2,
child: _field('剂量', _dosageCtrl, hint: '100mg'),
),
],
),
const SizedBox(height: 16),
_label('每日服药次数'),
const SizedBox(height: 8),
GestureDetector(
onTap: () async {
final n = await showAppCountPicker(
context,
initialValue: _timesPerDay,
min: 1,
max: 4,
label: '',
);
if (n != null) _updateTimes(n);
},
child: _PickerBox(
child: Text('$_timesPerDay 次/天', style: AppTextStyles.formValue),
),
),
const SizedBox(height: 16),
_label('服药时间'),
const SizedBox(height: 8),
Wrap(
spacing: 8,
runSpacing: 8,
children: List.generate(
_timesPerDay,
(i) => GestureDetector(
onTap: () async {
final t = await showAppTimePicker(
context,
initialTime: _times[i],
);
if (t != null) setState(() => _times[i] = t);
},
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 10,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: AppRadius.mdBorder,
border: Border.all(color: AppColors.border, width: 1),
),
child: Text(
'${_times[i].hour.toString().padLeft(2, '0')}:${_times[i].minute.toString().padLeft(2, '0')}',
style: AppTextStyles.formValue,
),
bottomNavigationBar: _loading || _loadError != null
? null
: SafeArea(
top: false,
child: Container(
color: Colors.white,
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
child: AppGradientOutlineButton(
label: _editing ? '保存修改' : '添加用药',
onPressed: _saving ? null : _save,
loading: _saving,
),
),
),
),
const SizedBox(height: 16),
Row(
children: [
Expanded(
child: _dateField(
'开始日期',
_start,
(d) => setState(() => _start = d),
body: _loading
? const Center(child: CircularProgressIndicator())
: _loadError != null
? AppErrorState(title: _loadError!, onRetry: _load)
: ListView(
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
padding: const EdgeInsets.fromLTRB(16, 12, 16, 28),
children: [
_FormSection(
title: '药品信息',
children: [
_TextFieldRow(
label: '药品名称',
controller: _nameController,
hint: '请输入药品名称',
),
const _SectionDivider(),
_TextFieldRow(
label: '剂量',
controller: _dosageController,
hint: '例如 100 mg',
),
],
),
),
const SizedBox(width: 12),
Expanded(
child: _dateFieldOpt(
'结束日期(可选)',
_end,
(d) => setState(() => _end = d),
),
),
],
),
const SizedBox(height: 16),
_field('备注', _notesCtrl, hint: '如:饭后服用、睡前'),
const SizedBox(height: 32),
_GradientOutlineButton(
onPressed: _loading ? null : _save,
label: _loading ? '保存中...' : '保存',
),
const SizedBox(height: 20),
],
),
);
}
Widget _label(String text) => Text(text, style: AppTextStyles.formLabel);
Widget _field(String label, TextEditingController ctrl, {String? hint}) =>
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_label(label),
const SizedBox(height: 6),
TextField(
controller: ctrl,
decoration: InputDecoration(
hintText: hint,
filled: true,
fillColor: AppTheme.surface,
border: _inputBorder(AppColors.border),
enabledBorder: _inputBorder(AppColors.border),
focusedBorder: _inputBorder(AppColors.primary),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 12,
),
),
style: AppTextStyles.formValue,
),
],
);
Widget _dateField(String label, DateTime val, ValueChanged<DateTime> cb) =>
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_label(label),
const SizedBox(height: 6),
GestureDetector(
onTap: () async {
final d = await showAppDatePicker(
context,
initialDate: val,
firstDate: DateTime(2024),
lastDate: DateTime(2030),
);
if (d != null) cb(d);
},
child: _PickerBox(
child: Text(_displayDate(val), style: AppTextStyles.formValue),
),
),
],
);
Widget _dateFieldOpt(
String label,
DateTime? val,
ValueChanged<DateTime?> cb,
) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_label(label),
const SizedBox(height: 6),
GestureDetector(
onTap: () async {
final d = await showAppDatePicker(
context,
initialDate: val ?? DateTime.now(),
firstDate: DateTime(2024),
lastDate: DateTime(2030),
);
if (d != null) cb(d);
},
child: _PickerBox(
child: Row(
children: [
Expanded(
child: Text(
val != null ? _displayDate(val) : '不设置',
style: AppTextStyles.formValue.copyWith(
color: val != null ? null : AppTheme.textHint,
),
),
),
if (val != null)
GestureDetector(
onTap: () => cb(null),
child: const Icon(
Icons.close,
size: 19,
color: AppColors.textHint,
),
),
],
),
),
),
],
);
OutlineInputBorder _inputBorder(Color color) => OutlineInputBorder(
borderRadius: AppRadius.mdBorder,
borderSide: BorderSide(color: color),
);
}
class _PickerBox extends StatelessWidget {
final Widget child;
const _PickerBox({required this.child});
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: AppTheme.surface,
borderRadius: AppRadius.mdBorder,
border: Border.all(color: AppColors.border),
),
child: child,
);
}
}
class _GradientOutlineButton extends StatelessWidget {
final VoidCallback? onPressed;
final String label;
const _GradientOutlineButton({required this.onPressed, required this.label});
@override
Widget build(BuildContext context) {
final enabled = onPressed != null;
return Container(
width: double.infinity,
decoration: BoxDecoration(
gradient: enabled ? AppColors.actionOutlineGradient : null,
color: enabled ? null : AppColors.border,
borderRadius: AppRadius.lgBorder,
),
padding: const EdgeInsets.all(1.4),
child: Material(
color: Colors.white,
borderRadius: AppRadius.lgBorder,
child: InkWell(
onTap: onPressed,
borderRadius: AppRadius.lgBorder,
child: SizedBox(
height: 46,
child: Center(
child: enabled
? ShaderMask(
shaderCallback: (bounds) =>
AppColors.actionOutlineGradient.createShader(bounds),
child: Text(
label,
style: AppTextStyles.button.copyWith(
color: Colors.white,
),
),
)
: Text(
label,
style: AppTextStyles.button.copyWith(
color: AppColors.textHint,
const SizedBox(height: 16),
_FormSection(
title: '服用安排',
children: [
_PickerRow(
label: '每日次数',
value: '${_times.length}',
onTap: _pickCount,
),
const _SectionDivider(),
Padding(
padding: const EdgeInsets.fromLTRB(16, 11, 12, 11),
child: Row(
children: [
const Text('服药时间', style: AppTextStyles.formLabel),
const SizedBox(width: 12),
Expanded(
child: Wrap(
alignment: WrapAlignment.end,
spacing: 8,
runSpacing: 8,
children: List.generate(
_times.length,
(index) => _TimeButton(
value: _timeValue(_times[index]),
onTap: () => _pickTime(index),
),
),
),
),
],
),
),
],
),
const SizedBox(height: 16),
_FormSection(
title: '用药周期',
children: [
_PickerRow(
label: '开始日期',
value: _displayDate(_startDate),
onTap: _pickStartDate,
),
const _SectionDivider(),
_PickerRow(
label: '结束日期',
value: _endDate == null ? '长期' : _displayDate(_endDate!),
onTap: _pickEndDate,
onClear: _endDate == null
? null
: () => setState(() => _endDate = null),
),
],
),
const SizedBox(height: 16),
_FormSection(
title: '备注',
children: [
Padding(
padding: const EdgeInsets.all(16),
child: TextField(
controller: _notesController,
minLines: 3,
maxLines: 5,
maxLength: 200,
decoration: const InputDecoration(
hintText: '可填写饭前、饭后或其他用药要求(选填)',
border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
filled: false,
contentPadding: EdgeInsets.zero,
),
),
),
],
),
if (_editing) ...[
const SizedBox(height: 16),
Material(
color: Colors.white,
borderRadius: AppRadius.lgBorder,
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: _saving ? null : _deleteMedication,
child: const SizedBox(
height: 54,
child: Center(
child: Text(
'删除用药',
style: TextStyle(
color: AppColors.errorText,
fontSize: 15,
fontWeight: FontWeight.w700,
),
),
),
),
),
),
],
],
),
);
}
Future<void> _pickCount() async {
final count = await showAppCountPicker(
context,
initialValue: _times.length,
min: 1,
max: 4,
label: '',
);
if (count == null || !mounted) return;
setState(() {
while (_times.length < count) {
final hour = (8 + _times.length * 5).clamp(0, 23);
_times.add(TimeOfDay(hour: hour, minute: 0));
}
while (_times.length > count) {
_times.removeLast();
}
});
}
Future<void> _pickTime(int index) async {
final value = await showAppTimePicker(context, initialTime: _times[index]);
if (value != null && mounted) setState(() => _times[index] = value);
}
Future<void> _pickStartDate() async {
final value = await showAppDatePicker(
context,
initialDate: _startDate,
firstDate: DateTime(2020),
lastDate: DateTime(2035),
);
if (value != null && mounted) setState(() => _startDate = value);
}
Future<void> _pickEndDate() async {
final value = await showAppDatePicker(
context,
initialDate: _endDate ?? _startDate,
firstDate: DateTime(2020),
lastDate: DateTime(2035),
);
if (value != null && mounted) setState(() => _endDate = value);
}
}
class _FormSection extends StatelessWidget {
final String title;
final List<Widget> children;
const _FormSection({required this.title, required this.children});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(left: 2, bottom: 8),
child: Text(
title,
style: AppTextStyles.sectionTitle.copyWith(fontSize: 16),
),
),
Container(
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: AppRadius.lgBorder,
),
child: Column(children: children),
),
],
);
}
}
class _TextFieldRow extends StatelessWidget {
final String label;
final TextEditingController controller;
final String hint;
const _TextFieldRow({
required this.label,
required this.controller,
required this.hint,
});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: Row(
children: [
SizedBox(
width: 82,
child: Text(label, style: AppTextStyles.formLabel),
),
Expanded(
child: TextField(
controller: controller,
textAlign: TextAlign.right,
decoration: InputDecoration(
hintText: hint,
border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
filled: false,
contentPadding: const EdgeInsets.symmetric(vertical: 14),
),
style: AppTextStyles.formValue,
),
),
],
),
);
}
}
class _PickerRow extends StatelessWidget {
final String label;
final String value;
final VoidCallback onTap;
final VoidCallback? onClear;
const _PickerRow({
required this.label,
required this.value,
required this.onTap,
this.onClear,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 15, 10, 15),
child: Row(
children: [
Expanded(child: Text(label, style: AppTextStyles.formLabel)),
Text(value, style: AppTextStyles.formValue),
if (onClear != null)
IconButton(
tooltip: '清除结束日期',
visualDensity: VisualDensity.compact,
onPressed: onClear,
icon: const Icon(Icons.close, size: 18),
)
else
const Padding(
padding: EdgeInsets.only(left: 6),
child: Icon(
LucideIcons.chevronRight,
color: AppColors.textHint,
size: 20,
),
),
],
),
),
);
}
}
String _displayDate(DateTime date) {
return '${date.year}/${date.month.toString().padLeft(2, '0')}/${date.day.toString().padLeft(2, '0')}';
class _TimeButton extends StatelessWidget {
final String value;
final VoidCallback onTap;
const _TimeButton({required this.value, required this.onTap});
@override
Widget build(BuildContext context) {
return OutlinedButton.icon(
onPressed: onTap,
icon: const Icon(LucideIcons.clock, size: 18),
label: Text(value),
style: OutlinedButton.styleFrom(
foregroundColor: AppColors.primary,
side: BorderSide(color: AppColors.primary.withValues(alpha: 0.38)),
shape: RoundedRectangleBorder(borderRadius: AppRadius.smBorder),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 11),
),
);
}
}
class _SectionDivider extends StatelessWidget {
const _SectionDivider();
@override
Widget build(BuildContext context) {
return const Padding(
padding: EdgeInsets.only(left: 16),
child: Divider(height: 1, thickness: 0.7, color: AppColors.divider),
);
}
}
TimeOfDay? _parseTime(Object value) {
final parts = value.toString().split(':');
if (parts.length < 2) return null;
final hour = int.tryParse(parts[0]);
final minute = int.tryParse(parts[1]);
if (hour == null || minute == null) return null;
return TimeOfDay(hour: hour, minute: minute);
}
String _timeValue(TimeOfDay value) =>
'${value.hour.toString().padLeft(2, '0')}:${value.minute.toString().padLeft(2, '0')}';
String _dateValue(DateTime value) =>
'${value.year}-${value.month.toString().padLeft(2, '0')}-${value.day.toString().padLeft(2, '0')}';
String _displayDate(DateTime value) => formatMedicationFormDate(value);
String _frequencyForTimes(int count) => switch (count) {
2 => 'TwiceDaily',
3 => 'ThreeTimesDaily',
_ => 'Daily',
};