浏览代码

Merge branch 'master' of http://git.ius.plus/Project-Vital/VitalApp

finlay 11 月之前
父节点
当前提交
29af493645
共有 1 个文件被更改,包括 90 次插入30 次删除
  1. 90 30
      lib/pages/medical/widgets/exam_blood_pressure.dart

+ 90 - 30
lib/pages/medical/widgets/exam_blood_pressure.dart

@@ -1,8 +1,11 @@
+import 'dart:convert';
+
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
 import 'package:vitalapp/architecture/app_parameters.dart';
 import 'package:vitalapp/managers/device_controller_manager.dart';
 import 'package:vitalapp/managers/interfaces/organization.dart';
+import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_blood_pressure.dart';
 import 'package:vitalapp/pages/medical/widgets/device_status_position.dart';
 import 'package:vitalapp/pages/medical/widgets/exam_card.dart';
 import 'package:vitalapp/pages/medical/widgets/switch_button.dart';
@@ -265,17 +268,6 @@ class _ExamBloodPressureState extends State<ExamBloodPressure> {
     if (controller.diagnosisDataValue['NIBP'] == null) {
       return _buildLiveWidget();
     }
-    // //收缩压(高压)
-    // var hightValue =
-    //     controller.diagnosisDataValue['NIBP']?['Sbp']?.toString() ?? '';
-    // //舒张压(低压)
-    // var lowValue =
-    //     controller.diagnosisDataValue['NIBP']?['Dbp']?.toString() ?? '';
-
-    // if (hightValue.isNotEmpty || lowValue.isNotEmpty) {
-    //   return _buildResultWidget();
-    // }
-
     return _buildLiveWidget();
   }
 
@@ -315,6 +307,7 @@ class _ExamBloodPressureState extends State<ExamBloodPressure> {
       children: [
         ExamCard(
           title: '',
+          clickCard: _onClickBloodPressure,
           content: Column(
             crossAxisAlignment: CrossAxisAlignment.end,
             children: [
@@ -333,12 +326,6 @@ class _ExamBloodPressureState extends State<ExamBloodPressure> {
                   ),
                   const Expanded(child: SizedBox()),
                   _buildValue(),
-                  // InkWell(
-                  //   child: _SideBar(
-                  //     value: _buildValue(),
-                  //     unit: 'mmHg',
-                  //   ),
-                  // ),
                 ],
               ),
               Row(
@@ -353,12 +340,6 @@ class _ExamBloodPressureState extends State<ExamBloodPressure> {
                   const Expanded(child: SizedBox()),
                   if (leftHightValue.isNotEmpty || leftLowValue.isNotEmpty)
                     _buildResultWidget(leftHightValue, leftLowValue),
-                  // InkWell(
-                  //   child: _SideBar(
-                  //     value: _buildValue(),
-                  //     unit: 'mmHg',
-                  //   ),
-                  // ),
                 ],
               ),
               Row(
@@ -373,12 +354,6 @@ class _ExamBloodPressureState extends State<ExamBloodPressure> {
                   const Expanded(child: SizedBox()),
                   if (rightHightValue.isNotEmpty || rightLowValue.isNotEmpty)
                     _buildResultWidget(rightHightValue, rightLowValue),
-                  // InkWell(
-                  //   child: _SideBar(
-                  //     value: _buildValue(),
-                  //     unit: 'mmHg',
-                  //   ),
-                  // ),
                 ],
               ),
               Row(
@@ -463,7 +438,6 @@ class _ExamBloodPressureState extends State<ExamBloodPressure> {
           ),
           IconButton(
             onPressed: () {
-              // controller.diagnosisDataValue['NIBP'] = null;
               liveValue = 0;
               tryReconnect();
               setState(() {
@@ -575,4 +549,90 @@ class _ExamBloodPressureState extends State<ExamBloodPressure> {
       ],
     );
   }
+
+  Future<void> _onClickBloodPressure() async {
+    String sbp = "";
+    String dbp = "";
+    String heart = "";
+
+    if (controller.diagnosisDataValue.containsKey("NIBP")) {
+      var nibp = controller.diagnosisDataValue["NIBP"];
+      if (nibp is Map) {
+        if (pressureStatus == PressureStatus.left) {
+          if (nibp.containsKey("Sbp_Left")) {
+            sbp = nibp["Sbp_Left"];
+          }
+          if (nibp.containsKey("Dbp_Left")) {
+            dbp = nibp["Dbp_Left"];
+          }
+          if (nibp.containsKey("Pulse_Beat")) {
+            heart = nibp["Pulse_Beat"];
+          }
+        } else {
+          if (nibp.containsKey("Sbp_Right")) {
+            sbp = nibp["Sbp_Left"];
+          }
+          if (nibp.containsKey("Dbp_Right")) {
+            dbp = nibp["Dbp_Left"];
+          }
+          if (nibp.containsKey("Pulse_Beat")) {
+            heart = nibp["Pulse_Beat"];
+          }
+        }
+      }
+    }
+
+    String? result = await VDialogBloodPressure(
+      title: '血压',
+      initialValue: [
+        sbp,
+        dbp,
+      ],
+      isDisplayHeartRate: true,
+    ).show();
+    if (result != null) {
+      try {
+        String sbp = jsonDecode(result).first;
+        String dbp = jsonDecode(result)[1];
+        String heart = jsonDecode(result)[2];
+        if (sbp.isNotEmpty && dbp.isNotEmpty) {
+          if (pressureStatus == PressureStatus.left) {
+            var nibp = controller.diagnosisDataValue["NIBP"];
+            String? sdpRight = nibp?['Sbp_Right'];
+            String? dbpRight = nibp?['Dbp_Right'];
+            controller.diagnosisDataValue['NIBP'] = {
+              'Sbp_Left': sbp,
+              'Dbp_Left': dbp,
+              'Pulse_Beat': heart,
+            };
+            if (sdpRight != null && dbpRight != null) {
+              controller.diagnosisDataValue['NIBP'].addAll({
+                'Sbp_Right': sdpRight,
+                'Dbp_Right': dbpRight,
+              });
+            }
+          } else {
+            var nibp = controller.diagnosisDataValue["NIBP"];
+            String? sdpLeft = nibp?['Sbp_Left'];
+            String? dbpLeft = nibp?['Dbp_Left'];
+            controller.diagnosisDataValue['NIBP'] = {
+              'Sbp_Right': sbp,
+              'Dbp_Right': dbp,
+              'Pulse_Beat': heart,
+            };
+            if (sdpLeft != null && dbpLeft != null) {
+              controller.diagnosisDataValue['NIBP'].addAll({
+                'Sbp_Left': sdpLeft,
+                'Dbp_Left': dbpLeft,
+              });
+            }
+          }
+
+          setState(() {});
+        }
+      } catch (e) {
+        logger.e("BloodPressure _onClickBloodPressure ex:", e);
+      }
+    }
+  }
 }