Browse Source

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

# Conflicts:
#	lib/pages/id_card_scan/controller.dart
#	lib/pages/id_card_scan/widgets/camera_for_face.dart
loki.wu 1 year ago
parent
commit
ece366233e

+ 1 - 1
lib/database/repositories/patient.dart

@@ -26,6 +26,6 @@ class PatientRepository
   @override
   Future<bool> isNotUploadedPatient(String code) async {
     final entity = await singleByCode(code);
-    return entity?.syncState == OfflineDataSyncState.success;
+    return entity != null && entity.syncState != OfflineDataSyncState.success;
   }
 }

+ 5 - 1
lib/managers/patient.dart

@@ -83,7 +83,11 @@ class PatientManager implements IPatientManager {
         var isNotUploadedPatient =
             await db.repositories.patient.isNotUploadedPatient(element.code!);
         if (isNotUploadedPatient) {
-          patientModel.isExistLocalData = true;
+          if (kIsOnline) {
+            continue;
+          } else {
+            patientModel.isExistLocalData = true;
+          }
         } else {
           final localCount = await db.repositories.diagnosis
               .getNotUploadedCountByPatientCode(element.code!);

+ 9 - 61
lib/pages/facial_recognition/controller.dart

@@ -405,9 +405,7 @@ class FacialRecognitionController extends GetxController
               image: url,
             ),
           );
-          print(result);
           if (result.faceScanErrorType == FaceScanErrorTypeEnum.Success) {
-            PromptBox.toast('人脸识别成功,姓名:${result.patientName}}');
             finishFaceDetection(result);
           } else if (result.faceScanErrorType ==
               FaceScanErrorTypeEnum.NoCreated) {
@@ -471,35 +469,14 @@ class FacialRecognitionController extends GetxController
             image: url,
           ),
         );
-        print(result);
         if (result.success) {
-          PromptBox.toast('人脸数据存入成功');
-          await Future.delayed(const Duration(milliseconds: 800));
-
-          Get.back();
+          Get.back(result: true);
         } else {
           PromptBox.toast('人脸数据存入失败: ${result.errMessage}');
         }
       } catch (e) {
         logger.e("savePatientBaseByFaceImageAsync failed: $e", e);
       }
-
-      // if (timer.tick == 1 || kFrameImageSize == Size.zero) {
-      //   Size imageSize = await getImageSize(file);
-      //   kFrameImageSize = imageSize;
-      // }
-      // int kTime = DateTime.now().millisecondsSinceEpoch;
-      // print('⭐⭐⭐⭐⭐⭐⭐⭐ capture time: ${kTime - lastCaptureTime} ms');
-      // lastCaptureTime = kTime;
-
-      // /// 记录用时 ms
-
-      // int endTime = DateTime.now().millisecondsSinceEpoch;
-      // print('⭐⭐⭐⭐⭐⭐⭐⭐ detection time: ${endTime - lastCaptureTime} ms');
-      // update(['face_bounding_box']);
-      // if (timer.tick >= 10) {
-      //   finishFaceDetection(); // TODO 接入真实的判断条件
-      // }
     }
   }
 
@@ -667,21 +644,12 @@ class FacialRecognitionController extends GetxController
 
   /// 完成人脸识别
   void finishFaceDetection(PatientBaseDTO patient) {
-    print(patient.toJson());
-
-    final result = PatientDTO(
-      code: patient.cardNo,
-      cardNo: patient.cardNo,
-      patientName: patient.patientName,
-      nationality: patient.nationality,
-      patientGender: patient.patientGender,
-      birthday: patient.birthday,
-      patientAddress: patient.patientAddress,
+    Get.back<FaceRecognitionResult>(
+      result: FaceRecognitionResult(
+        success: true,
+        patientInfo: patient,
+      ),
     );
-    Store.user.currentSelectPatientInfo = result;
-    Get.find<PatientListController>().gotoDetail(result.code!);
-
-    // TODO 识别成功后的切换逻辑
   }
 
   /// WIP
@@ -826,32 +794,12 @@ class FacialRecognitionController extends GetxController
 class FaceRecognitionResult {
   bool success;
 
-  /// 身份证号
-  String cardNo;
-
-  /// 姓名
-  String name;
-
-  /// 性别
-  GenderEnum gender;
-
-  /// 民族
-  String nation;
-
-  /// 出生日期
-  DateTime birthday;
-
-  /// 地址
-  String address;
+  /// 身份信息
+  PatientBaseDTO patientInfo;
 
   FaceRecognitionResult({
     required this.success,
-    required this.cardNo,
-    required this.name,
-    required this.gender,
-    required this.nation,
-    required this.birthday,
-    required this.address,
+    required this.patientInfo,
   });
 }
 

+ 93 - 118
lib/pages/id_card_scan/controller.dart

@@ -358,101 +358,96 @@ class IdCardScanController extends GetxController with WidgetsBindingObserver {
           if (result.isSuccess) {
             PromptBox.toast('身份证识别成功');
             idCardInfo.localCardImagePath = file.path;
-            idCardInfo.idCardName = result.patientName ?? "";
-            idCardInfo.idCardGender =
-                result.patientGender == GenderEnum.Male ? "男" : "女";
-            idCardInfo.idCardNation = result.nationality ?? "";
-            idCardInfo.idCardBirthDate =
-                DataTimeUtils.formatDateString(result.birthday!);
-            idCardInfo.idCardAddress = result.patientAddress ?? "";
-            idCardInfo.idCardNumber = result.cardNo ?? "";
-            state.isShowIdCardInfoSwitch = true;
-            state.isIdCardInfoShow = true;
-            state.isInFaceInput = true;
-            await _createPatient(result);
-            openBackCamera();
-          } else {
-            PromptBox.toast('身份证识别失败: ${result.errorMessage}');
-          }
-        } catch (e) {
-          logger.e("getPatientBaseByImageAsync failed: $e", e);
-        }
-      }
-      state.isIdCardScanning = false;
-    });
-  }
-
-  /// 发生人脸录入事件
-  void onCaptureFaceButtonPressed() async {
-    state.isRunningFaceInput = true;
-    if (kCameraController == null) {
-      state.isRunningFaceInput = false;
-      return;
-    }
-    try {
-      final XFile? file = await takePicture();
-      if (file != null) {
-        faceDetector = FaceDetector(options: FaceDetectorOptions());
-        // faceDetector =
-        //     FaceDetector(options: FaceDetectorOptions(enableContours: true));
-        int faceNum = 1; // max 分辨率下检测用时大约 100ms
-        // int faceNum =
-        //     await doDetection(faceDetector, file.path); // max 分辨率下检测用时大约 100ms
-
-        if (faceNum == 0) {
-          PromptBox.toast('请将面部保持在识别框内');
-          return;
-        } else if (faceNum > 1) {
-          PromptBox.toast('请保持只有一张面部在识别范围内');
-          return;
-        }
-
-        /// TODO 上传图像到云然后传给后端
-        final url = await rpc.storage.upload(
-          file,
-          fileType: 'png',
-        );
-        print('⭐⭐⭐⭐⭐⭐⭐⭐ url: $url');
-        try {
-          SavePersonDTO result =
-              await rpc.patient.savePatientBaseByFaceImageAsync(
-            SavePatientBaseByFaceImageRequest(
-              cardNo: idCardInfo.idCardNumber,
-              token: Store.user.token,
-              image: url,
-            ),
-          );
-          print(result);
-          if (result.success) {
-            PromptBox.toast('人脸数据存入成功');
             final idCardScanResult = IdCardScanResult(
               success: true,
-              cardNo: idCardInfo.idCardNumber,
-              name: idCardInfo.idCardName,
-              nation: idCardInfo.idCardNation,
-              gender: idCardInfo.idCardGender == '男'
-                  ? GenderEnum.Male
-                  : GenderEnum.Female,
-              birthday: DateTime.parse(idCardInfo.idCardBirthDate),
-              address: idCardInfo.idCardAddress,
+              patientBaseDTO: result,
             );
 
             Get.back<IdCardScanResult>(
               result: idCardScanResult,
             );
           } else {
-            PromptBox.toast('人脸数据存入失败');
+            PromptBox.toast('身份证识别失败: ${result.errorMessage}');
           }
         } catch (e) {
-          logger.e("savePatientBaseByFaceImageAsync failed: $e", e);
+          logger.e("getPatientBaseByImageAsync failed: $e", e);
         }
       }
-    } catch (e) {
-      logger.e("doDetection failed: $e", e);
-    }
-    state.isRunningFaceInput = false;
+      state.isIdCardScanning = false;
+    });
   }
 
+  /// 发生人脸录入事件
+  // void onCaptureFaceButtonPressed() async {
+  //   state.isRunningFaceInput = true;
+  //   if (kCameraController == null) {
+  //     state.isRunningFaceInput = false;
+  //     return;
+  //   }
+  //   try {
+  //     final XFile? file = await takePicture();
+  //     if (file != null) {
+  //       faceDetector = FaceDetector(options: FaceDetectorOptions());
+  //       // faceDetector =
+  //       //     FaceDetector(options: FaceDetectorOptions(enableContours: true));
+  //       int faceNum = 1; // max 分辨率下检测用时大约 100ms
+  //       // int faceNum =
+  //       //     await doDetection(faceDetector, file.path); // max 分辨率下检测用时大约 100ms
+
+  //       if (faceNum == 0) {
+  //         PromptBox.toast('请将面部保持在识别框内');
+  //         return;
+  //       } else if (faceNum > 1) {
+  //         PromptBox.toast('请保持只有一张面部在识别范围内');
+  //         return;
+  //       }
+
+  //       /// TODO 上传图像到云然后传给后端
+  //       final url = await rpc.storage.upload(
+  //         file,
+  //         fileType: 'png',
+  //       );
+  //       print('⭐⭐⭐⭐⭐⭐⭐⭐ url: $url');
+  //       try {
+  //         SavePersonDTO result =
+  //             await rpc.patient.savePatientBaseByFaceImageAsync(
+  //           SavePatientBaseByFaceImageRequest(
+  //             cardNo: idCardInfo.idCardNumber,
+  //             token: Store.user.token,
+  //             image: url,
+  //           ),
+  //         );
+  //         print(result);
+  //         if (result.success) {
+  //           PromptBox.toast('人脸数据存入成功');
+  //           final idCardScanResult = IdCardScanResult(
+  //             success: true,
+  //             cardNo: idCardInfo.idCardNumber,
+  //             name: idCardInfo.idCardName,
+  //             nation: idCardInfo.idCardNation,
+  //             gender: idCardInfo.idCardGender == '男'
+  //                 ? GenderEnum.Male
+  //                 : GenderEnum.Female,
+  //             birthday: DateTime.parse(idCardInfo.idCardBirthDate),
+  //             address: idCardInfo.idCardAddress,
+  //           );
+
+  //           Get.back<IdCardScanResult>(
+  //             result: idCardScanResult,
+  //           );
+  //         } else {
+  //           PromptBox.toast('人脸数据存入失败');
+  //         }
+  //       } catch (e) {
+  //         logger.e("savePatientBaseByFaceImageAsync failed: $e", e);
+  //       }
+  //     }
+  //   } catch (e) {
+  //     logger.e("doDetection failed: $e", e);
+  //   }
+  //   state.isRunningFaceInput = false;
+  // }
+
   /// 发生结束录制视频事件
   void onStopButtonPressed() {
     stopVideoRecording().then((XFile? file) {
@@ -617,20 +612,20 @@ class IdCardScanController extends GetxController with WidgetsBindingObserver {
 
   /// 完成人脸识别
   void finishFaceDetection() {
-    final result = IdCardScanResult(
-      success: true,
-      cardNo: idCardInfo.idCardNumber,
-      name: idCardInfo.idCardName,
-      nation: idCardInfo.idCardNation,
-      gender:
-          idCardInfo.idCardGender == '男' ? GenderEnum.Male : GenderEnum.Female,
-      birthday: DateTime.now(),
-      address: idCardInfo.idCardAddress,
-    );
-
-    Get.back<IdCardScanResult>(
-      result: result,
-    );
+    // final result = IdCardScanResult(
+    //   success: true,
+    //   cardNo: idCardInfo.idCardNumber,
+    //   name: idCardInfo.idCardName,
+    //   nation: idCardInfo.idCardNation,
+    //   gender:
+    //       idCardInfo.idCardGender == '男' ? GenderEnum.Male : GenderEnum.Female,
+    //   birthday: DateTime.now(),
+    //   address: idCardInfo.idCardAddress,
+    // );
+
+    // Get.back<IdCardScanResult>(
+    //   result: result,
+    // );
   }
 
   /// WIP
@@ -790,31 +785,11 @@ class IdCardScanController extends GetxController with WidgetsBindingObserver {
 class IdCardScanResult {
   bool success;
 
-  /// 身份证号
-  String cardNo;
-
-  /// 姓名
-  String name;
-
-  /// 性别
-  GenderEnum gender;
-
-  /// 民族
-  String nation;
-
-  /// 出生日期
-  DateTime birthday;
-
-  /// 地址
-  String address;
+  /// 身份证信息
+  PatientBaseDTO patientBaseDTO;
 
   IdCardScanResult({
     required this.success,
-    required this.cardNo,
-    required this.name,
-    required this.gender,
-    required this.nation,
-    required this.birthday,
-    required this.address,
+    required this.patientBaseDTO,
   });
 }

+ 4 - 4
lib/pages/id_card_scan/view.dart

@@ -63,10 +63,10 @@ class IdCardScanPage extends GetView<IdCardScanController> {
                           alignment: Alignment.centerLeft,
                           child: _idCardInfoSwitch(),
                         ),
-                        if (controller.state.isInFaceInput)
-                          const CameraForFace()
-                        else
-                          const CameraForIdCard(),
+                        // if (controller.state.isInFaceInput)
+                        //   const CameraForFace()
+                        // else
+                        const CameraForIdCard(),
                       ],
                     ),
                   ),

+ 96 - 146
lib/pages/id_card_scan/widgets/camera_for_face.dart

@@ -1,149 +1,99 @@
-import 'package:flutter/material.dart';
-import 'package:get/get.dart';
-import '../index.dart';
+// import 'package:flutter/material.dart';
+// import 'package:get/get.dart';
+// import '../index.dart';
 
-class CameraForFace extends GetView<IdCardScanController> {
-  const CameraForFace({Key? key}) : super(key: key);
+// class CameraForFace extends GetView<IdCardScanController> {
+//   const CameraForFace({Key? key}) : super(key: key);
 
-  @override
-  Widget build(BuildContext context) {
-    return Stack(
-      children: <Widget>[
-        // Align(
-        //   alignment: Alignment.center,
-        //   child: OverflowBox(
-        //     maxHeight: 2000,
-        //     maxWidth: 2000,
-        //     child: Container(
-        //       decoration: BoxDecoration(
-        //         border: Border.all(
-        //           color: const Color.fromARGB(80, 0, 0, 0),
-        //           width: 500,
-        //           strokeAlign: BorderSide.strokeAlignOutside,
-        //         ),
-        //         borderRadius: BorderRadius.circular(50),
-        //       ),
-        //       margin: const EdgeInsets.only(bottom: 110),
-        //       child: const SizedBox(
-        //         width: 465,
-        //         height: 430,
-        //       ),
-        //     ),
-        //   ),
-        // ),
-        Align(
-          alignment: Alignment.center,
-          child: Container(
-            margin: const EdgeInsets.only(top: 80),
-            child: const Image(
-              image: AssetImage('assets/images/face_rec.png'),
-              width: 800,
-            ),
-          ),
-        ),
-        Align(
-          alignment: Alignment.centerRight,
-          child: Container(
-            child: _captureButton(),
-          ),
-        ),
-        Align(
-          alignment: Alignment.bottomCenter,
-          child: Container(
-            padding: const EdgeInsets.only(bottom: 40),
-            child: const Text(
-              '请将面部保持在识别框内,并确保面部清晰可见,然后按下拍摄键',
-              style: TextStyle(color: Colors.white, fontSize: 22),
-            ),
-          ),
-        ),
-        Align(
-          alignment: Alignment.bottomRight,
-          child: Container(
-            child: _switchCameraLens(),
-          ),
-        ),
-      ],
-    );
-  }
+//   @override
+//   Widget build(BuildContext context) {
+//     return Stack(
+//       children: <Widget>[
+//         // Align(
+//         //   alignment: Alignment.center,
+//         //   child: OverflowBox(
+//         //     maxHeight: 2000,
+//         //     maxWidth: 2000,
+//         //     child: Container(
+//         //       decoration: BoxDecoration(
+//         //         border: Border.all(
+//         //           color: const Color.fromARGB(80, 0, 0, 0),
+//         //           width: 500,
+//         //           strokeAlign: BorderSide.strokeAlignOutside,
+//         //         ),
+//         //         borderRadius: BorderRadius.circular(50),
+//         //       ),
+//         //       margin: const EdgeInsets.only(bottom: 110),
+//         //       child: const SizedBox(
+//         //         width: 465,
+//         //         height: 430,
+//         //       ),
+//         //     ),
+//         //   ),
+//         // ),
+//         Align(
+//           alignment: Alignment.center,
+//           child: Container(
+//             margin: const EdgeInsets.only(top: 80),
+//             child: const Image(
+//               image: AssetImage('assets/images/face_rec.png'),
+//               width: 800,
+//             ),
+//           ),
+//         ),
+//         Align(
+//           alignment: Alignment.centerRight,
+//           child: Container(
+//             child: _captureButton(),
+//           ),
+//         ),
+//         Align(
+//           alignment: Alignment.bottomCenter,
+//           child: Container(
+//             padding: const EdgeInsets.only(bottom: 40),
+//             child: const Text(
+//               '请将面部保持在识别框内,并确保面部清晰可见,然后按下拍摄键',
+//               style: TextStyle(color: Colors.white, fontSize: 22),
+//             ),
+//           ),
+//         ),
+//       ],
+//     );
+//   }
 
-  ///切换摄像头按钮
-  Widget _switchCameraLens() {
-    return Obx(() {
-      if (controller.state.isRunningFaceInput) {
-        return Container();
-      }
-      return GestureDetector(
-        onTap: () {
-          controller.state.isUsingFrontCamera =
-              !controller.state.isUsingFrontCamera;
-          if (controller.state.isUsingFrontCamera) {
-            controller.openFrontCamera();
-          } else {
-            controller.openBackCamera();
-          }
-        },
-        child: Container(
-          padding: const EdgeInsets.all(10.0),
-          // padding: const EdgeInsets.all(10),
-          decoration: BoxDecoration(
-            color: Colors.black.withOpacity(0.2),
-            borderRadius: BorderRadius.circular(10),
-          ),
-          margin: const EdgeInsets.symmetric(horizontal: 40.0, vertical: 20.0),
-          child: Column(
-            mainAxisSize: MainAxisSize.min,
-            children: [
-              const Icon(
-                Icons.camera_rear,
-                size: 30,
-                color: Colors.white,
-              ),
-              const SizedBox(height: 10),
-              Text(
-                controller.state.isUsingFrontCamera ? "切换为后置" : "切换为前置",
-                style: const TextStyle(color: Colors.white),
-              )
-            ],
-          ),
-        ),
-      );
-    });
-  }
-
-  /// 拍照按钮
-  Widget _captureButton() {
-    return Obx(() {
-      if (controller.state.isRunningFaceInput) {
-        return Container(
-          margin: const EdgeInsets.only(right: 60),
-          width: 100,
-          height: 100,
-          decoration: BoxDecoration(
-            color: Colors.white,
-            borderRadius: BorderRadius.circular(50),
-          ),
-          child: const Center(
-            child: CircularProgressIndicator(
-              color: Colors.blue,
-            ),
-          ),
-        );
-      }
-      return Container(
-        margin: const EdgeInsets.only(right: 60),
-        width: 100,
-        height: 100,
-        decoration: BoxDecoration(
-          color: Colors.white,
-          borderRadius: BorderRadius.circular(50),
-        ),
-        child: IconButton(
-          icon: const Icon(Icons.sensor_occupied, size: 50),
-          color: Colors.blue,
-          onPressed: controller.onCaptureFaceButtonPressed,
-        ),
-      );
-    });
-  }
-}
+//   /// 拍照按钮
+//   Widget _captureButton() {
+//     return Obx(() {
+//       if (controller.state.isRunningFaceInput) {
+//         return Container(
+//           margin: const EdgeInsets.only(right: 60),
+//           width: 100,
+//           height: 100,
+//           decoration: BoxDecoration(
+//             color: Colors.white,
+//             borderRadius: BorderRadius.circular(50),
+//           ),
+//           child: const Center(
+//             child: CircularProgressIndicator(
+//               color: Colors.blue,
+//             ),
+//           ),
+//         );
+//       }
+//       return Container(
+//         margin: const EdgeInsets.only(right: 60),
+//         width: 100,
+//         height: 100,
+//         decoration: BoxDecoration(
+//           color: Colors.white,
+//           borderRadius: BorderRadius.circular(50),
+//         ),
+//         child: IconButton(
+//           icon: const Icon(Icons.sensor_occupied, size: 50),
+//           color: Colors.blue,
+//           onPressed: controller.onCaptureFaceButtonPressed,
+//         ),
+//       );
+//     });
+//   }
+// }

+ 3 - 3
lib/pages/medical/records/view.dart

@@ -192,7 +192,7 @@ class _MedicalRecordCard extends GetView<MedicalRecordsController> {
                         ),
                         RecordCommonItem(
                           itemName: '诊断时间',
-                          itemValue: DateFormat("yyyy-MM-dd")
+                          itemValue: DateFormat("yyyy-MM-dd HH:mm:ss")
                               .format(dto.diagnosisTime!.toLocal()),
                           fontSize: 18,
                         ),
@@ -236,8 +236,8 @@ class _MedicalRecordCard extends GetView<MedicalRecordsController> {
               title: '数据展示',
               columnNames: const ['序号', '检测项目', '检测结果', '单位'],
               tableData: result,
-              diagnosisTime:
-                  DateFormat("yyyy-MM-dd").format(dto.diagnosisTime!.toLocal()),
+              diagnosisTime: DateFormat("yyyy-MM-dd HH:mm:ss")
+                  .format(dto.diagnosisTime!.toLocal()),
             ).show();
           },
           child: body,

+ 28 - 23
lib/pages/patient/create/controller.dart

@@ -87,8 +87,7 @@ class CreatePatientController extends FControllerBase with HomeNavMixin {
     }
 
     /// 拥有人脸权限并且不是身份证扫码建档
-    if (Store.user.hasFeature(FeatureKeys.FaceRecognition) &&
-        !state.isIdCardScanClicked) {
+    if (Store.user.hasFeature(FeatureKeys.FaceRecognition)) {
       await Get.dialog(VAlertDialog(
         title: '提示',
         content: Container(
@@ -102,7 +101,6 @@ class CreatePatientController extends FControllerBase with HomeNavMixin {
         showCancel: true,
         onConfirm: () async {
           await onFaceEntryClicked();
-          Get.back();
         },
       ));
     }
@@ -119,7 +117,6 @@ class CreatePatientController extends FControllerBase with HomeNavMixin {
           state.reset(); // 重置状态
           busy = false;
           PromptBox.toast("保存成功");
-          state.isIdCardScanClicked = false;
           _patientListController.reloadList();
         },
       );
@@ -181,15 +178,16 @@ class CreatePatientController extends FControllerBase with HomeNavMixin {
       () => const IdCardScanPage(),
     );
     if (result != null && result.success) {
-      PromptBox.toast("录入成功");
-      state.cardNo = result.cardNo; // 回填身份证号
-      state.name = result.name; // 回填姓名
-      state.gender = result.gender; // 回填性别
-      state.nation = result.nation; // 回填民族
-      state.birthday = result.birthday; // 回填出生日期
-      state.censusRegister = result.address; // 回填户籍地址
+      PromptBox.toast("身份证信息识别成功");
+      PatientBaseDTO patientInfo = result.patientBaseDTO;
+      state.cardNo = patientInfo.cardNo ?? ""; // 回填身份证号
+      state.name = patientInfo.patientName ?? ""; // 回填姓名
+      state.gender = patientInfo.patientGender; // 回填性别
+      state.nation = patientInfo.nationality ?? ""; // 回填民族
+      state.birthday = patientInfo.birthday; // 回填出生日期
+      state.censusRegister = patientInfo.patientAddress ?? ""; // 回填户籍地址
       if (state.isSyncAddresses) {
-        state.address = result.address; // 回填现住地址
+        state.address = patientInfo.patientAddress ?? ""; // 回填现住地址
       }
     } else {
       print("识别取消");
@@ -206,16 +204,20 @@ class CreatePatientController extends FControllerBase with HomeNavMixin {
       ),
     );
     if (result != null && result.success) {
-      PromptBox.toast("录入成功");
-      state.cardNo = result.cardNo; // 回填身份证号
-      state.name = result.name; // 回填姓名
-      state.gender = result.gender; // 回填性别
-      state.nation = result.nation; // 回填民族
-      state.birthday = result.birthday; // 回填出生日期
-      state.censusRegister = result.address; // 回填户籍地址
-      if (state.isSyncAddresses) {
-        state.address = result.address; // 回填现住地址
-      }
+      final patient = result.patientInfo;
+      PromptBox.toast('人脸识别成功,姓名:${patient.patientName}');
+      // PromptBox.toast("录入成功");
+      final patientDTO = PatientDTO(
+        code: patient.cardNo,
+        cardNo: patient.cardNo,
+        patientName: patient.patientName,
+        nationality: patient.nationality,
+        patientGender: patient.patientGender,
+        birthday: patient.birthday,
+        patientAddress: patient.patientAddress,
+      );
+      Store.user.currentSelectPatientInfo = patientDTO;
+      Get.find<PatientListController>().gotoDetail(patientDTO.code!);
     } else {
       print("识别取消");
     }
@@ -234,12 +236,15 @@ class CreatePatientController extends FControllerBase with HomeNavMixin {
       patientGender: state.gender,
       code: state.cardNo,
     );
-    await Get.to<FaceRecognitionResult>(
+    bool? result = await Get.to<bool>(
       () => FacialRecognitionPage(
         mode: FacialRecognitionMode.faceInput,
         patientInfo: patientInfo,
       ),
     );
+    if (result != null && result) {
+      PromptBox.toast('人脸数据存入成功');
+    }
   }
 
   /// 处理 “同户籍地址” 勾选变更事件

+ 0 - 5
lib/pages/patient/create/state.dart

@@ -45,7 +45,6 @@ class CreatePatientState {
     phoneNo = "";
     crowdLabelCodes = [];
     isSyncAddresses = true;
-    isIdCardScanClicked = false;
   }
 
   /// 机构名称
@@ -155,8 +154,4 @@ class CreatePatientState {
   /// 是否开启地址同步
   bool get isSyncAddresses => _isSyncAddresses.value;
   set isSyncAddresses(bool val) => _isSyncAddresses.updateValue(val);
-
-  /// 是否身份证扫码建档
-  bool get isIdCardScanClicked => _isIdCardScanClicked.value;
-  set isIdCardScanClicked(bool val) => _isIdCardScanClicked.updateValue(val);
 }

+ 0 - 1
lib/pages/patient/create/widgets/quick_create.dart

@@ -66,7 +66,6 @@ class QuickCreatePatientPage extends GetView<CreatePatientController> {
       title: "身份识别建档",
       icon: Icon(Icons.perm_contact_cal_rounded, color: Colors.grey.shade700),
       onTap: () {
-        controller.state.isIdCardScanClicked = true;
         controller.onIdCardScanClicked();
       },
     );

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

@@ -24,8 +24,6 @@ class PatientListController extends FControllerBase {
 
   /// 前进到检测页面
   Future<void> gotoDetail(String code) async {
-    Get.back();
-
     if (!Get.isRegistered<MedicalController>()) {
       Get.lazyPut(() => MedicalController());
     }
@@ -73,7 +71,7 @@ class PatientListController extends FControllerBase {
       final request = PatientPageRequest(
         keyword: state.searchString,
         startTime: state.startTime.value,
-        endTime: state.endTime.value,
+        endTime: state.endTime.value?.add(const Duration(days: 1)),
         crowdLabels: crowdLabelsController.state.selectedCodes,
       );
       var offlineList = await _patientManager.getPagedOfflineList(request);

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

@@ -19,5 +19,5 @@ class PatientListState with PagedStateMixin<PatientModelDTO> {
   late Rx<DateTime?> startTime =
       DateTime(_now.year - 1, _now.month, _now.day).obs; // >= 1年前00:00:00
   late Rx<DateTime?> endTime =
-      DateTime(_now.year, _now.month, _now.day + 1).obs; // < 第二天00:00:00
+      DateTime(_now.year, _now.month, _now.day).obs; // < 第二天00:00:00
 }

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

@@ -119,7 +119,7 @@ class PatientListPage extends GetView<PatientListController> {
         var endTime = state.endTime.value;
         if (startTime != null &&
             endTime != null &&
-            endTime.difference(startTime).inSeconds <= 0) {
+            endTime.difference(startTime).inSeconds < 0) {
           PromptBox.toast('起始时间不能晚于结束时间');
           return;
         }