Эх сурвалжийг харах

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

finlay 1 жил өмнө
parent
commit
4676732f50

+ 18 - 16
lib/pages/patient/detail/controller.dart

@@ -134,22 +134,24 @@ class PatientDetailController extends FControllerBase with HomeNavMixin {
 
   /// 读取到最近检测记录的数据
   Future<void> onReadLastRecordInfo() async {
-    var diagnosisManager = Get.find<IDiagnosisManager>();
-    List<DiagnosisAggregationRecordModel> getRecords = [];
-    var getLastRecords =
-        await diagnosisManager.getDiagnosisAggregationPageAsync(
-            Store.user.currentSelectPatientInfo!.code!, 1, 10);
-    getRecords.addAll(getLastRecords?.pageData ?? []);
-
-    var listRecords = await diagnosisManager
-        .getListByPatientCode(Store.user.currentSelectPatientInfo!.code!);
-    getRecords.addAll(listRecords ?? []);
-    if (getRecords.isNotEmpty) {
-      var lastRecordInfo = getRecords.reduce((curr, next) =>
-          (curr.diagnosisTime!).isAfter(next.diagnosisTime!) ? curr : next);
-      state.isExistLocalData = lastRecordInfo.isExistLocalData ?? false;
-      state.currentDiagnosis =
-          await diagnosisManager.getTableData(lastRecordInfo);
+    if (Store.user.currentSelectPatientInfo?.code != null) {
+      var diagnosisManager = Get.find<IDiagnosisManager>();
+      List<DiagnosisAggregationRecordModel> getRecords = [];
+      var getLastRecords =
+          await diagnosisManager.getDiagnosisAggregationPageAsync(
+              Store.user.currentSelectPatientInfo!.code!, 1, 10);
+      getRecords.addAll(getLastRecords?.pageData ?? []);
+
+      var listRecords = await diagnosisManager
+          .getListByPatientCode(Store.user.currentSelectPatientInfo!.code!);
+      getRecords.addAll(listRecords ?? []);
+      if (getRecords.isNotEmpty) {
+        var lastRecordInfo = getRecords.reduce((curr, next) =>
+            (curr.diagnosisTime!).isAfter(next.diagnosisTime!) ? curr : next);
+        state.isExistLocalData = lastRecordInfo.isExistLocalData ?? false;
+        state.currentDiagnosis =
+            await diagnosisManager.getTableData(lastRecordInfo);
+      }
     }
   }
 }