Browse Source

1、新增病人详情

guanxinyi 1 year ago
parent
commit
ac5aa29766

+ 74 - 6
lib/components/dialog_table.dart

@@ -1,4 +1,8 @@
+import 'dart:convert';
+
 import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:get/get.dart';
 
 import 'alert_dialog.dart';
 
@@ -91,17 +95,24 @@ class VDialogTable extends StatelessWidget {
   List<TableRow> _buildRow(List<List<String>> tableData) {
     var tableRows = <TableRow>[];
     for (var i = 0; i < tableData.length; i++) {
-      tableRows.add(TableRow(
+      tableRows.add(
+        TableRow(
           decoration: i % 2 == 0
               ? null
               : const BoxDecoration(
                   color: Color.fromRGBO(233, 244, 255, 1),
                 ),
-          children: tableData[i]
-              .map(
-                (cellData) => _buildDataCell(cellData),
-              )
-              .toList()));
+          children: tableData[i].map(
+            (cellData) {
+              if (tableData[i][1] == '心电测量') {
+                return _buildImageDataCell(cellData);
+              }
+
+              return _buildDataCell(cellData);
+            },
+          ).toList(),
+        ),
+      );
     }
     return tableRows;
   }
@@ -133,4 +144,61 @@ class VDialogTable extends StatelessWidget {
       ),
     );
   }
+
+  TableCell _buildImageDataCell(String title) {
+    if (title.length > 50) {
+      Uint8List imageBytes = base64.decode(title);
+
+      return TableCell(
+        child: InkWell(
+          onTap: () {
+            print(imageBytes);
+            Get.dialog(
+              ImagePreviewDialog(
+                imageBytes: imageBytes,
+              ),
+            );
+          },
+          child: Container(
+            padding: const EdgeInsets.symmetric(horizontal: 14),
+            alignment: Alignment.centerLeft,
+            height: 57,
+            child: Image.memory(
+              imageBytes,
+              height: 57,
+            ),
+          ),
+        ),
+      );
+    }
+
+    return TableCell(
+      child: Container(
+        padding: const EdgeInsets.symmetric(horizontal: 14),
+        alignment: Alignment.centerLeft,
+        height: 37,
+        child: Text(
+          title,
+          style: const TextStyle(fontSize: 14),
+        ),
+      ),
+    );
+  }
+}
+
+class ImagePreviewDialog extends StatelessWidget {
+  final Uint8List imageBytes;
+
+  const ImagePreviewDialog({super.key, required this.imageBytes});
+
+  @override
+  Widget build(BuildContext context) {
+    return Dialog(
+      child: SizedBox(
+        width: 800,
+        height: 500,
+        child: Image.memory(imageBytes),
+      ),
+    );
+  }
 }

+ 15 - 36
lib/pages/home/controller.dart

@@ -36,7 +36,6 @@ class HomeController extends FControllerBase with HomeNavMixin {
       title: "主页",
       routeName: "/dashboard",
       iconData: Icons.home_outlined,
-      // isSelected: true,
     ),
     HomeMenuItem(
       key: 'JKDA',
@@ -101,39 +100,12 @@ class HomeController extends FControllerBase with HomeNavMixin {
   void switchActiveMenu(HomeMenuItem data) async {
     if (state.currentSelectMenu != data.routeName) {
       switchNavByName(data.routeName);
-      // state.currentSelectMenu = data.routeName;
-      // await Future.delayed(const Duration(milliseconds: 100));
-      // NavGotoHelper.goto(data.routeName);
     }
-    // CommonUtil.throttle(() {
-    //   switchNavByName(data.routeName);
-    // });
-    // final index =
-    //     state.menuItems.indexWhere((e) => e.routeName == data.routeName);
-    // if (index < 0) return;
-
-    // final array = state.menuItems;
-    // array.firstWhereOrNull((e) => e.isSelected)?.isSelected = false;
-    // array[index].isSelected = true;
-    // state.menuItems = array;
-
-    // Get.offAllNamed(data.routeName, id: 1001);
   }
 
   void switchNavByName(String name) {
     state.currentSelectMenu = name;
     NavGotoHelper.goto(name);
-    // state.currentSelectMenu = name;
-    // final index = state.menuItems.indexWhere((e) => e.routeName == name);
-    // final array = state.menuItems;
-
-    // array.firstWhereOrNull((e) => e.isSelected)?.isSelected = false;
-    // array[index].isSelected = true;
-    // if (index < 0 || currentIndex == index) return;
-
-    // state.menuItems = array;
-    // currentIndex = index;
-    // Get.offNamed(name, id: 1001);
   }
 
   void initMenus() {
@@ -163,14 +135,7 @@ class HomeController extends FControllerBase with HomeNavMixin {
 
   void updateMenus() {
     if (Store.user.menuPermissionList?.isNotEmpty ?? false) {
-      List<HomeMenuItem> menuItems = [
-        HomeMenuItem(
-          key: 'JKDA',
-          title: "健康档案",
-          routeName: "/patient/detail",
-          iconWidget: _buildImgIcon('healthRecord.png'),
-        ),
-      ];
+      List<HomeMenuItem> menuItems = [];
       Store.user.menuPermissionList?.forEach((element) {
         for (var item in homeMenuItems) {
           if (item.key == element.code) {
@@ -178,6 +143,14 @@ class HomeController extends FControllerBase with HomeNavMixin {
           }
         }
       });
+      menuItems.add(
+        HomeMenuItem(
+          key: 'JKDA',
+          title: "健康档案",
+          routeName: "/patient/detail",
+          iconWidget: _buildImgIcon('healthRecord.png'),
+        ),
+      );
       state.menuItems = menuItems;
     } else {
       // state.menuItems = homeMenuItems;
@@ -189,6 +162,12 @@ class HomeController extends FControllerBase with HomeNavMixin {
         //   iconData: Icons.home_outlined,
         //   isSelected: true,
         // ),
+        HomeMenuItem(
+          key: 'JKDA',
+          title: "健康档案",
+          routeName: "/patient/detail",
+          iconWidget: _buildImgIcon('healthRecord.png'),
+        ),
         HomeMenuItem(
           key: 'JKJC',
           title: "健康检测",

+ 1 - 1
lib/pages/medical/records/controller.dart

@@ -47,7 +47,7 @@ class MedicalRecordsController extends FControllerBase {
           currentDiagnosis.add([
             (index++).toString(),
             dto?.name ?? '',
-            jsonData[key],
+            jsonData[key].toString(),
             dto?.unit ?? '',
           ]);
         }

+ 3 - 3
lib/pages/medical/widgets/body_temperature.dart

@@ -60,9 +60,9 @@ class _ExamBodyTemperatureState extends State<BodyTemperature> {
   Future<void> initTemperature() async {
     await Future.delayed(const Duration(milliseconds: 800));
     await controller.readCachedRecord();
-    setState(() {
-      _value = controller.diagnosisDataValue['Temp']?['Temperature'] ?? '';
-    });
+    _value = controller.diagnosisDataValue['Temp']?['Temperature'] ?? '';
+
+    setState(() {});
   }
 
   void loadListeners() {

+ 5 - 5
lib/pages/medical/widgets/heart_rate.dart

@@ -153,8 +153,9 @@ class _HeartRateState extends State<HeartRate> {
     // _heart = e.toString();
     _assess = e.analysis.first;
     _heart = e.heartRate.toString();
-    controller.diagnosisDataValue['Heart']?['HEART'] = e.heartRate;
-    controller.diagnosisDataValue['Heart']?['ASSESS'] = e.analysis.first;
+    controller.diagnosisDataValue['Heart']?['HEART'] = e.heartRate.toString();
+    controller.diagnosisDataValue['Heart']?['ASSESS'] =
+        dataConvertManager.heartRateConversion(int.parse(heartRate));
 
     try {
       EcgViewController ecgViewController = Get.find<EcgViewController>();
@@ -365,7 +366,8 @@ class _HeartRateState extends State<HeartRate> {
                           horizontal: 50,
                         ),
                         child: Text(
-                          dataConvertManager.heartRateConversion(heartRate),
+                          dataConvertManager
+                              .heartRateConversion(int.parse(heartRate)),
                           style: const TextStyle(
                             fontSize: 24,
                           ),
@@ -379,8 +381,6 @@ class _HeartRateState extends State<HeartRate> {
                 SizedBox(
                   height: 240,
                   child: LayoutBuilder(builder: (context, constraints) {
-                    print(constraints.maxWidth);
-                    print(constraints.maxHeight);
                     List<int> initData = [];
                     if (controller.diagnosisDataValue['Heart']?['ECG_POINT'] !=
                         null) {

+ 6 - 3
lib/pages/patient/detail/view.dart

@@ -43,10 +43,13 @@ class PatientDetailPage extends GetView<PatientDetailController> {
                     BaseInfoCard(),
                     SizedBox(height: 12),
                     Expanded(
-                      child: CrowdLabelsCard(),
+                      child: LatestRecordCard(),
                     ),
-                    SizedBox(height: 12),
-                    Expanded(child: FollowupTipsCard()),
+                    // Expanded(
+                    //   child: CrowdLabelsCard(),
+                    // ),
+                    // SizedBox(height: 12),
+                    // Expanded(child: FollowupTipsCard()),
                   ],
                 ),
               ),

+ 9 - 34
lib/pages/patient/detail/widgets/functions_panel.dart

@@ -37,49 +37,24 @@ class FunctionsPanel extends GetView<PatientDetailController> {
             onTap: controller.gotoInfo,
           ),
           // FunctionButton(
-          //   label: "健康体检",
-          //   icon: _buildImgIcon("体检.png"),
-          //   onTap: controller.gotoHealthCheck,
-          // ),
-          FunctionButton(
-            label: "体检记录",
-            icon: _buildImgIcon("体检记录.png"),
-            onTap: controller.gotoHealthCheckRecord,
-          ),
-          // FunctionButton(
-          //   label: "人群随访",
-          //   icon: _buildImgIcon("随访.png"),
-          //   onTap: controller.gotoFollowUp,
-          // ),
-          FunctionButton(
-            label: "随访记录",
-            icon: _buildImgIcon("随访报告.png"),
-            onTap: controller.gotoFollowUpRecord,
-          ),
-          // FunctionButton(
-          //   label: "医生签约",
-          //   icon: _buildImgIcon("签约.png"),
-          //   onTap: controller.gotoContract,
+          //   label: "体检记录",
+          //   icon: _buildImgIcon("体检记录.png"),
+          //   onTap: controller.gotoHealthCheckRecord,
           // ),
           // FunctionButton(
-          //   label: "健康检测",
-          //   icon: _buildImgIcon("诊疗.png"),
-          //   onTap: controller.gotoExam,
+          //   label: "随访记录",
+          //   icon: _buildImgIcon("随访报告.png"),
+          //   onTap: controller.gotoFollowUpRecord,
           // ),
           // FunctionButton(
           //   label: "双向转诊",
           //   icon: _buildImgIcon("转诊.png"),
           //   onTap: controller.gotoReferral,
           // ),
-          FunctionButton(
-            label: "签约记录",
-            icon: _buildImgIcon("签约记录.png"),
-            onTap: controller.gotoContractRecords,
-          ),
           // FunctionButton(
-          //   label: "健康检测",
-          //   icon: _buildImgIcon("诊疗.png"),
-          //   onTap: controller.gotoExam,
+          //   label: "签约记录",
+          //   icon: _buildImgIcon("签约记录.png"),
+          //   onTap: controller.gotoContractRecords,
           // ),
           FunctionButton(
             label: "健康检测记录",

+ 42 - 1
lib/pages/patient/detail/widgets/tag_cards.dart

@@ -175,7 +175,48 @@ class CrowdLabelsCard extends GetView<PatientDetailController> {
   }
 }
 
-/// 随访提醒卡片
+/// 最近检测记录
+class LatestRecordCard extends GetView<PatientDetailController> {
+  const LatestRecordCard({super.key});
+
+  @override
+  Widget build(BuildContext context) {
+    final state = controller.state;
+    final ContractUtils contractUtils = ContractUtils();
+
+    return _TitleInfoCardContainer(
+      title: "最近检测记录",
+      titleIcon: const Icon(Icons.tips_and_updates, color: Colors.white),
+      child: Padding(
+        padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8),
+        child: Column(
+          children: const [],
+        ),
+      ),
+    );
+  }
+
+  Widget _buildItem(String label, String content) {
+    return SizedBox(
+      height: 30,
+      child: Row(
+        children: [
+          Text(
+            label,
+            style: const TextStyle(color: Colors.grey, fontSize: 18),
+          ),
+          const SizedBox(width: 12),
+          Text(
+            content,
+            style: const TextStyle(color: Colors.black, fontSize: 18),
+          ),
+        ],
+      ),
+    );
+  }
+}
+
+/// 签约信息卡片
 class FollowupTipsCard extends GetView<PatientDetailController> {
   const FollowupTipsCard({super.key});
 

+ 1 - 1
lib/pages/patient/list/controller.dart

@@ -35,7 +35,7 @@ class PatientListController extends FControllerBase {
 
     await _patientDetailController.loadData();
     await medicalController.initData();
-
+    _homeController.updateMenus();
     _homeController.switchNavByName("/medical");
     //这里应该刷新病人诊断数据缓存
     // _medicalController.changePatient.emit(this, code);