【后端修复】 - 删除diet/consultation agent假工具声明 - 修复DayOfWeek实体注释 - 修复Vision API content序列化 - cleanup_service级联删除修复 - 用药提醒时区偏差修复 - 统一DateTime处理(UtcNow+8) - 新增UTC DateTime JSON转换器 【前端UI重构】 - 配色体系全面更新(#8B5CF6淡紫+#F0ECFF背景) - 登录页重设计 - 首页重设计(透明顶栏、渐变背景、胶囊输入区) - 聊天卡片加白蓝边框、渐变标题 - 侧边栏重构(渐变背景、合并顶部、删除底部设置) - 确认卡片可编辑字段恢复 - 所有子页面加返回按钮 - catch异常加日志 - 删除后refresh provider缓存
685 lines
24 KiB
Dart
685 lines
24 KiB
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
import 'package:dio/dio.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:image_picker/image_picker.dart';
|
|
import 'package:file_picker/file_picker.dart';
|
|
import 'package:shadcn_ui/shadcn_ui.dart';
|
|
import '../../core/app_colors.dart';
|
|
import '../../core/app_theme.dart';
|
|
import '../../core/navigation_provider.dart';
|
|
import '../../providers/auth_provider.dart';
|
|
|
|
final reportProvider = NotifierProvider<ReportNotifier, ReportState>(ReportNotifier.new);
|
|
|
|
class ReportState {
|
|
final List<ReportItem> reports;
|
|
final String? uploadingImage;
|
|
final bool isAnalyzing;
|
|
final ReportAnalysis? currentAnalysis;
|
|
|
|
ReportState({
|
|
this.reports = const [],
|
|
this.uploadingImage,
|
|
this.isAnalyzing = false,
|
|
this.currentAnalysis,
|
|
});
|
|
|
|
ReportState copyWith({
|
|
List<ReportItem>? reports,
|
|
String? uploadingImage,
|
|
bool? isAnalyzing,
|
|
ReportAnalysis? currentAnalysis,
|
|
}) {
|
|
return ReportState(
|
|
reports: reports ?? this.reports,
|
|
uploadingImage: uploadingImage ?? this.uploadingImage,
|
|
isAnalyzing: isAnalyzing ?? this.isAnalyzing,
|
|
currentAnalysis: currentAnalysis ?? this.currentAnalysis,
|
|
);
|
|
}
|
|
}
|
|
|
|
class ReportItem {
|
|
final String id;
|
|
final String title;
|
|
final String type;
|
|
final DateTime uploadedAt;
|
|
final String? imagePath;
|
|
final bool hasAnalysis;
|
|
final String status; // PendingDoctor | DoctorReviewed
|
|
final String? severity; // Normal | Abnormal | Severe | Critical
|
|
final String? doctorComment;
|
|
final String? doctorRecommendation;
|
|
final String? doctorName;
|
|
final DateTime? reviewedAt;
|
|
|
|
ReportItem({
|
|
required this.id,
|
|
required this.title,
|
|
required this.type,
|
|
required this.uploadedAt,
|
|
this.imagePath,
|
|
this.hasAnalysis = false,
|
|
this.status = 'PendingDoctor',
|
|
this.severity,
|
|
this.doctorComment,
|
|
this.doctorRecommendation,
|
|
this.doctorName,
|
|
this.reviewedAt,
|
|
});
|
|
}
|
|
|
|
class ReportAnalysis {
|
|
final String reportId;
|
|
final String reportType;
|
|
final List<Indicator> indicators;
|
|
final String summary;
|
|
|
|
ReportAnalysis({
|
|
required this.reportId,
|
|
required this.reportType,
|
|
required this.indicators,
|
|
required this.summary,
|
|
});
|
|
}
|
|
|
|
class Indicator {
|
|
final String name;
|
|
final String value;
|
|
final String unit;
|
|
final String status;
|
|
final String? referenceRange;
|
|
|
|
Indicator({
|
|
required this.name,
|
|
required this.value,
|
|
required this.unit,
|
|
required this.status,
|
|
this.referenceRange,
|
|
});
|
|
}
|
|
|
|
class ReportNotifier extends Notifier<ReportState> {
|
|
@override
|
|
ReportState build() {
|
|
Future.microtask(() => loadReports());
|
|
return ReportState();
|
|
}
|
|
|
|
Future<void> loadReports() async {
|
|
try {
|
|
final api = ref.read(apiClientProvider);
|
|
final res = await api.get('/api/reports');
|
|
final list = (res.data['data'] as List?) ?? [];
|
|
final reports = list.map((r) {
|
|
final m = r as Map<String, dynamic>;
|
|
return ReportItem(
|
|
id: m['id']?.toString() ?? '',
|
|
title: m['category']?.toString() ?? '检查报告',
|
|
type: m['fileType']?.toString() ?? 'Image',
|
|
uploadedAt: DateTime.tryParse(m['createdAt']?.toString() ?? '') ?? DateTime.now(),
|
|
hasAnalysis: m['aiSummary'] != null,
|
|
status: m['status']?.toString() ?? 'PendingDoctor',
|
|
severity: m['severity']?.toString(),
|
|
doctorComment: m['doctorComment']?.toString(),
|
|
doctorRecommendation: m['doctorRecommendation']?.toString(),
|
|
doctorName: m['doctorName']?.toString(),
|
|
reviewedAt: DateTime.tryParse(m['reviewedAt']?.toString() ?? ''),
|
|
);
|
|
}).toList();
|
|
state = state.copyWith(reports: reports);
|
|
} catch (e) {
|
|
debugPrint('[Report] 加载报告列表失败: $e');
|
|
}
|
|
}
|
|
|
|
void fetchReportDetail(String reportId) async {
|
|
try {
|
|
final api = ref.read(apiClientProvider);
|
|
final res = await api.get('/api/reports/$reportId');
|
|
final m = (res.data['data'] as Map<String, dynamic>?) ?? {};
|
|
if (m.isEmpty) {
|
|
state = state.copyWith(currentAnalysis: _emptyAnalysis(reportId));
|
|
return;
|
|
}
|
|
final indicators = _parseIndicators(m['aiIndicators']?.toString());
|
|
final analysis = ReportAnalysis(
|
|
reportId: m['id']?.toString() ?? reportId,
|
|
reportType: m['category']?.toString() ?? '检查报告',
|
|
indicators: indicators,
|
|
summary: m['aiSummary']?.toString() ?? '',
|
|
);
|
|
state = state.copyWith(currentAnalysis: analysis);
|
|
} catch (_) {
|
|
state = state.copyWith(currentAnalysis: _emptyAnalysis(reportId));
|
|
}
|
|
}
|
|
|
|
ReportAnalysis _emptyAnalysis(String reportId) => ReportAnalysis(
|
|
reportId: reportId,
|
|
reportType: '检查报告',
|
|
indicators: [],
|
|
summary: '暂无数据,请下拉刷新重试',
|
|
);
|
|
|
|
List<Indicator> _parseIndicators(String? jsonStr) {
|
|
if (jsonStr == null || jsonStr.isEmpty) return [];
|
|
try {
|
|
final list = jsonDecode(jsonStr) as List;
|
|
return list.map((item) {
|
|
final m = item as Map<String, dynamic>;
|
|
return Indicator(
|
|
name: m['name']?.toString() ?? '',
|
|
value: m['value']?.toString() ?? '',
|
|
unit: m['unit']?.toString() ?? '',
|
|
status: m['status']?.toString() ?? 'normal',
|
|
referenceRange: m['referenceRange']?.toString(),
|
|
);
|
|
}).toList();
|
|
} catch (_) {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
void uploadImage(String path) async {
|
|
state = state.copyWith(uploadingImage: path, isAnalyzing: true);
|
|
try {
|
|
final api = ref.read(apiClientProvider);
|
|
final file = File(path);
|
|
final formData = FormData.fromMap({
|
|
'file': await MultipartFile.fromFile(file.path, filename: file.path.split('/').last),
|
|
});
|
|
// 直接上传到报告端点,后端自动触发 VLM+LLM 分析
|
|
final createRes = await api.dio.post('/api/reports', data: formData);
|
|
final data = createRes.data;
|
|
final reportId = data is Map ? (data['data']?['id']?.toString() ?? '') : '';
|
|
|
|
state = state.copyWith(isAnalyzing: false, uploadingImage: null);
|
|
loadReports();
|
|
} catch (_) {
|
|
state = state.copyWith(isAnalyzing: false, uploadingImage: null);
|
|
}
|
|
}
|
|
|
|
void uploadFile(String path) => uploadImage(path);
|
|
|
|
void viewAnalysis(String reportId) {
|
|
fetchReportDetail(reportId);
|
|
}
|
|
|
|
void clearAnalysis() {
|
|
state = state.copyWith(currentAnalysis: null);
|
|
}
|
|
}
|
|
|
|
/// 报告列表页
|
|
class ReportListPage extends ConsumerWidget {
|
|
const ReportListPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final state = ref.watch(reportProvider);
|
|
|
|
if (state.isAnalyzing) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('看报告')),
|
|
body: const Center(
|
|
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
|
CircularProgressIndicator(color: AppTheme.primaryLight),
|
|
SizedBox(height: 16),
|
|
Text('AI 正在分析报告...'),
|
|
]),
|
|
),
|
|
);
|
|
}
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
leading: IconButton(icon: const Icon(Icons.arrow_back), onPressed: () => popRoute(ref)),
|
|
title: const Text('看报告'),
|
|
centerTitle: true,
|
|
),
|
|
floatingActionButton: _buildUploadButton(context, ref),
|
|
body: RefreshIndicator(
|
|
onRefresh: () async => ref.read(reportProvider.notifier).loadReports(),
|
|
child: state.reports.isEmpty
|
|
? ListView(children: [_buildEmptyState(context)])
|
|
: ListView.builder(
|
|
padding: const EdgeInsets.all(16),
|
|
itemCount: state.reports.length,
|
|
itemBuilder: (context, index) => _buildReportCard(context, ref, state.reports[index]),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildUploadButton(BuildContext context, WidgetRef ref) {
|
|
return FloatingActionButton(
|
|
onPressed: () => _showUploadOptions(context, ref),
|
|
backgroundColor: AppTheme.primary,
|
|
child: const Icon(Icons.add),
|
|
);
|
|
}
|
|
|
|
void _showUploadOptions(BuildContext context, WidgetRef ref) {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
builder: (ctx) => SafeArea(
|
|
child: Wrap(children: [
|
|
ListTile(
|
|
leading: const Icon(Icons.camera_alt),
|
|
title: const Text('拍照上传'),
|
|
onTap: () async {
|
|
Navigator.pop(ctx);
|
|
final picker = ImagePicker();
|
|
final picked = await picker.pickImage(source: ImageSource.camera, imageQuality: 85);
|
|
if (picked != null) {
|
|
ref.read(reportProvider.notifier).uploadImage(picked.path);
|
|
}
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.photo_library),
|
|
title: const Text('从相册选择'),
|
|
onTap: () async {
|
|
Navigator.pop(ctx);
|
|
final picker = ImagePicker();
|
|
final picked = await picker.pickImage(source: ImageSource.gallery, imageQuality: 85);
|
|
if (picked != null) {
|
|
ref.read(reportProvider.notifier).uploadImage(picked.path);
|
|
}
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.file_open),
|
|
title: const Text('上传PDF文件'),
|
|
onTap: () async {
|
|
Navigator.pop(ctx);
|
|
final result = await FilePicker.platform.pickFiles(type: FileType.custom, allowedExtensions: ['pdf']);
|
|
if (result != null && result.files.isNotEmpty) {
|
|
ref.read(reportProvider.notifier).uploadFile(result.files.first.path!);
|
|
}
|
|
},
|
|
),
|
|
]),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildEmptyState(BuildContext context) {
|
|
return Center(
|
|
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
|
Container(
|
|
width: 120,
|
|
height: 120,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.primaryLight,
|
|
borderRadius: BorderRadius.circular(60),
|
|
),
|
|
child: const Icon(Icons.file_open, size: 48, color: AppTheme.primaryLight),
|
|
),
|
|
const SizedBox(height: 20),
|
|
const Text('暂无检查报告', style: TextStyle(fontSize: 21, fontWeight: FontWeight.w500)),
|
|
const SizedBox(height: 8),
|
|
const Text('点击下方按钮上传报告', style: TextStyle(fontSize: 17, color: AppColors.textHint)),
|
|
]),
|
|
);
|
|
}
|
|
|
|
Widget _buildReportCard(BuildContext context, WidgetRef ref, ReportItem report) {
|
|
return Container(
|
|
margin: const EdgeInsets.only(bottom: 12),
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.surface,
|
|
borderRadius: BorderRadius.circular(AppTheme.rLg),
|
|
boxShadow: [AppTheme.shadowCard],
|
|
),
|
|
child: ListTile(
|
|
leading: Container(
|
|
width: 48,
|
|
height: 48,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.primaryLight,
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: _getReportIcon(report.type),
|
|
),
|
|
title: Text(report.title, style: const TextStyle(fontSize: 19, fontWeight: FontWeight.w600)),
|
|
subtitle: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
Text(report.type, style: TextStyle(fontSize: 17, color: AppColors.textSecondary)),
|
|
Text(_formatDate(report.uploadedAt), style: TextStyle(fontSize: 15, color: AppColors.textHint)),
|
|
]),
|
|
trailing: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (report.status == 'DoctorReviewed')
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.successLight,
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: const Text('已审核', style: TextStyle(fontSize: 13, color: AppColors.success)),
|
|
)
|
|
else if (!report.hasAnalysis)
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.primaryLight,
|
|
borderRadius: BorderRadius.circular(AppTheme.rXs),
|
|
),
|
|
child: Text('分析中', style: TextStyle(fontSize: 13, color: AppTheme.primary)),
|
|
)
|
|
else if (report.status == 'PendingDoctor')
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.warningLight,
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: const Text('待审核', style: TextStyle(fontSize: 13, color: AppColors.warning)),
|
|
),
|
|
const SizedBox(width: 8),
|
|
report.hasAnalysis
|
|
? Icon(Icons.check_circle, size: 23, color: AppColors.success)
|
|
: Icon(Icons.arrow_forward_ios, size: 21, color: AppColors.textHint),
|
|
],
|
|
),
|
|
onTap: () => pushRoute(ref, 'reportDetail', params: {'id': report.id}),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _getReportIcon(String type) {
|
|
final icons = {
|
|
'血液检查': const Icon(Icons.bloodtype, size: 28, color: AppTheme.primaryLight),
|
|
'心电图': const Icon(Icons.monitor_heart, size: 28, color: AppTheme.primaryLight),
|
|
'超声检查': const Icon(Icons.image, size: 28, color: AppTheme.primaryLight),
|
|
'影像报告': const Icon(Icons.image, size: 28, color: AppTheme.primaryLight),
|
|
'PDF文档': const Icon(Icons.picture_as_pdf, size: 28, color: AppTheme.primaryLight),
|
|
};
|
|
return icons[type] ?? const Icon(Icons.description, size: 28, color: AppTheme.primaryLight);
|
|
}
|
|
|
|
String _formatDate(DateTime date) {
|
|
final now = DateTime.now();
|
|
final diff = now.difference(date);
|
|
if (diff.inDays == 0) return '今天';
|
|
if (diff.inDays == 1) return '昨天';
|
|
if (diff.inDays < 7) return '${diff.inDays}天前';
|
|
return '${date.month}月${date.day}日';
|
|
}
|
|
}
|
|
|
|
/// 报告详情页
|
|
class ReportDetailPage extends ConsumerStatefulWidget {
|
|
final String id;
|
|
const ReportDetailPage({super.key, required this.id});
|
|
|
|
@override
|
|
ConsumerState<ReportDetailPage> createState() => _ReportDetailPageState();
|
|
}
|
|
|
|
class _ReportDetailPageState extends ConsumerState<ReportDetailPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// 进入页面时刷新报告列表(获取最新审核状态)+ 获取详情
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
ref.read(reportProvider.notifier).loadReports();
|
|
ref.read(reportProvider.notifier).fetchReportDetail(widget.id);
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final analysis = ref.watch(reportProvider.select((s) => s.currentAnalysis));
|
|
final reports = ref.watch(reportProvider.select((s) => s.reports));
|
|
final reportItem = reports.where((r) => r.id == widget.id).firstOrNull;
|
|
|
|
if (analysis == null) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('报告详情')),
|
|
body: const Center(child: CircularProgressIndicator(color: AppTheme.primaryLight)),
|
|
);
|
|
}
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('报告解读'),
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.arrow_back),
|
|
onPressed: () {
|
|
ref.read(reportProvider.notifier).clearAnalysis();
|
|
popRoute(ref);
|
|
},
|
|
),
|
|
),
|
|
body: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
_buildReportHeader(analysis),
|
|
const SizedBox(height: 20),
|
|
if (reportItem != null && reportItem.status == 'DoctorReviewed') ...[
|
|
_buildDoctorReview(reportItem),
|
|
const SizedBox(height: 20),
|
|
],
|
|
_buildAnalysisSection(analysis),
|
|
const SizedBox(height: 20),
|
|
_buildSummarySection(analysis),
|
|
const SizedBox(height: 20),
|
|
SizedBox(
|
|
width: double.infinity, height: 48,
|
|
child: ElevatedButton(
|
|
onPressed: () => pushRoute(ref, 'aiAnalysis', params: {'id': widget.id}),
|
|
style: ElevatedButton.styleFrom(backgroundColor: AppTheme.primary, foregroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24))),
|
|
child: const Text('查看 AI 智能解读'),
|
|
),
|
|
),
|
|
const SizedBox(height: 30),
|
|
]),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildDoctorReview(ReportItem report) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.successLight,
|
|
borderRadius: BorderRadius.circular(AppTheme.rLg),
|
|
border: Border.all(color: AppColors.success.withAlpha(50)),
|
|
),
|
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
Row(children: [
|
|
const Text('✅', style: TextStyle(fontSize: 23)),
|
|
const SizedBox(width: 8),
|
|
const Text('医生审核意见', style: TextStyle(fontSize: 19, fontWeight: FontWeight.w600, color: AppColors.success)),
|
|
]),
|
|
if (report.doctorName != null) ...[
|
|
const SizedBox(height: 4),
|
|
Text('审核医生:${report.doctorName}', style: TextStyle(fontSize: 16, color: AppColors.success)),
|
|
],
|
|
if (report.reviewedAt != null) ...[
|
|
const SizedBox(height: 2),
|
|
Text('审核时间:${report.reviewedAt!.toLocal().toString().substring(0, 19)}', style: TextStyle(fontSize: 15, color: AppColors.success.withAlpha(180))),
|
|
],
|
|
if (report.severity != null) ...[
|
|
const SizedBox(height: 6),
|
|
_severityBadge(report.severity!),
|
|
],
|
|
if (report.doctorComment != null && report.doctorComment!.isNotEmpty) ...[
|
|
const SizedBox(height: 8),
|
|
Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.surface,
|
|
borderRadius: BorderRadius.circular(AppTheme.rMd),
|
|
),
|
|
child: Text('💬 ${report.doctorComment!}', style: TextStyle(fontSize: 18, color: AppColors.textPrimary, height: 1.5)),
|
|
),
|
|
],
|
|
if (report.doctorRecommendation != null && report.doctorRecommendation!.isNotEmpty) ...[
|
|
const SizedBox(height: 8),
|
|
Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.surface,
|
|
borderRadius: BorderRadius.circular(AppTheme.rMd),
|
|
),
|
|
child: Text('📝 ${report.doctorRecommendation!}', style: TextStyle(fontSize: 17, color: AppColors.textPrimary, height: 1.5)),
|
|
),
|
|
],
|
|
]),
|
|
);
|
|
}
|
|
|
|
Widget _severityBadge(String severity) {
|
|
final (label, color, bg) = switch (severity) {
|
|
'Normal' => ('🟢 正常', AppColors.success, AppColors.successLight),
|
|
'Abnormal' => ('🟡 轻度异常', AppColors.warning, AppColors.warningLight),
|
|
'Severe' => ('🟠 中度异常', AppColors.error, AppColors.errorLight),
|
|
'Critical' => ('🔴 重度异常', AppColors.error, AppColors.errorLight),
|
|
_ => (severity, AppColors.textSecondary, AppColors.border),
|
|
};
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
|
decoration: BoxDecoration(color: bg, borderRadius: BorderRadius.circular(AppTheme.rXs)),
|
|
child: Text(label, style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: color)),
|
|
);
|
|
}
|
|
|
|
Widget _buildReportHeader(ReportAnalysis analysis) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.primaryLight,
|
|
borderRadius: BorderRadius.circular(AppTheme.rLg),
|
|
),
|
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
Row(children: [
|
|
const Text('📋', style: TextStyle(fontSize: 28)),
|
|
const SizedBox(width: 12),
|
|
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
Text(analysis.reportType, style: const TextStyle(fontSize: 21, fontWeight: FontWeight.w600)),
|
|
const SizedBox(height: 4),
|
|
Text('AI 预解读结果', style: TextStyle(fontSize: 17, color: AppColors.textSecondary)),
|
|
]),
|
|
]),
|
|
]),
|
|
);
|
|
}
|
|
|
|
Widget _buildAnalysisSection(ReportAnalysis analysis) {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.surface,
|
|
borderRadius: BorderRadius.circular(AppTheme.rLg),
|
|
border: Border.all(color: AppColors.border, width: 1),
|
|
),
|
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Row(children: [
|
|
const Text('🧪', style: TextStyle(fontSize: 23)),
|
|
const SizedBox(width: 8),
|
|
const Text('指标分析', style: TextStyle(fontSize: 19, fontWeight: FontWeight.w600)),
|
|
]),
|
|
),
|
|
Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: 16),
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.warningLight,
|
|
borderRadius: BorderRadius.circular(AppTheme.rXs),
|
|
border: Border.all(color: AppColors.warning.withAlpha(80)),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(Icons.info_outline, size: 19, color: AppColors.warning),
|
|
const SizedBox(width: 6),
|
|
Text(
|
|
'AI 预解读 · 待医生确认',
|
|
style: TextStyle(fontSize: 16, color: AppColors.warning, fontWeight: FontWeight.w500),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
...analysis.indicators.map((ind) => _buildIndicatorRow(ind)),
|
|
]),
|
|
);
|
|
}
|
|
|
|
Widget _buildIndicatorRow(Indicator ind) {
|
|
Color statusColor;
|
|
IconData statusIcon;
|
|
switch (ind.status) {
|
|
case 'high':
|
|
statusColor = AppColors.error;
|
|
statusIcon = Icons.arrow_upward;
|
|
break;
|
|
case 'low':
|
|
statusColor = AppColors.warning;
|
|
statusIcon = Icons.arrow_downward;
|
|
break;
|
|
default:
|
|
statusColor = AppColors.success;
|
|
statusIcon = Icons.check_circle;
|
|
}
|
|
|
|
return Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: 16),
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: AppColors.border))),
|
|
child: Row(children: [
|
|
Expanded(
|
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
Text(ind.name, style: const TextStyle(fontSize: 17)),
|
|
if (ind.referenceRange != null)
|
|
Text('参考值: ${ind.referenceRange}', style: TextStyle(fontSize: 15, color: AppColors.textHint)),
|
|
]),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Column(children: [
|
|
Text('${ind.value} ${ind.unit}', style: TextStyle(fontSize: 19, fontWeight: FontWeight.w600, color: statusColor)),
|
|
Icon(statusIcon, size: 19, color: statusColor),
|
|
]),
|
|
]),
|
|
);
|
|
}
|
|
|
|
Widget _buildSummarySection(ReportAnalysis analysis) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.warningLight,
|
|
borderRadius: BorderRadius.circular(AppTheme.rLg),
|
|
),
|
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
Row(children: [
|
|
const Text('💡', style: TextStyle(fontSize: 23)),
|
|
const SizedBox(width: 8),
|
|
Text('综合解读', style: TextStyle(fontSize: 19, fontWeight: FontWeight.w600, color: AppColors.warning)),
|
|
]),
|
|
const SizedBox(height: 12),
|
|
Text(analysis.summary, style: TextStyle(fontSize: 17, color: AppColors.warning, height: 1.6)),
|
|
const SizedBox(height: 12),
|
|
Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: AppTheme.surface,
|
|
borderRadius: BorderRadius.circular(AppTheme.rSm),
|
|
),
|
|
child: Text('⚠️ AI 解读仅供参考,请以医生诊断为准', style: TextStyle(fontSize: 16, color: AppColors.warning)),
|
|
),
|
|
]),
|
|
);
|
|
}
|
|
} |