|
@@ -13,8 +13,10 @@ import 'package:vitalapp/database/entities/defines.dart';
|
|
|
import 'package:vitalapp/database/entities/diagnosis.dart';
|
|
|
import 'package:vitalapp/global.dart';
|
|
|
import 'package:vitalapp/managers/interfaces/exam.dart';
|
|
|
+import 'package:vitalapp/managers/interfaces/models/diagnosis_aggregation_record_model.dart';
|
|
|
import 'package:vitalapp/managers/interfaces/patient.dart';
|
|
|
import 'package:vitalapp/managers/interfaces/record_data_cache.dart';
|
|
|
+import 'package:vitalapp/routes/routes.dart';
|
|
|
import 'package:vitalapp/rpc.dart';
|
|
|
import 'package:vnote_device_plugin/consts/types.dart';
|
|
|
import 'package:vitalapp/architecture/defines.dart';
|
|
@@ -66,30 +68,57 @@ class MedicalController extends FControllerBase {
|
|
|
MedicalItem(key: DeviceTypes.HEART, diagnosticItem: '心电'),
|
|
|
MedicalItem(key: DeviceTypes.TWELVEHEART, diagnosticItem: '十二导心电'),
|
|
|
];
|
|
|
+
|
|
|
+ // @override
|
|
|
+ // void onInit() {
|
|
|
+ // super.onInit();
|
|
|
+ // }
|
|
|
+
|
|
|
@override
|
|
|
- void onInit() async {
|
|
|
- setBusy('Loading...');
|
|
|
+ void onReady() async {
|
|
|
+ super.onReady();
|
|
|
await initData();
|
|
|
await getAccessTypes();
|
|
|
state.currentTab = DeviceTypes.TEMP; //等数据加载完成之后在切换到体温页面
|
|
|
- busy = false;
|
|
|
- logger.i('MedicalController init end');
|
|
|
- super.onInit();
|
|
|
+ // busy = false;
|
|
|
+ // logger.i('MedicalController init end');
|
|
|
}
|
|
|
|
|
|
Future<void> initData() async {
|
|
|
patientCode = Store.user.currentSelectPatientInfo?.code ?? '';
|
|
|
- if (patientCode.isNotEmpty) {
|
|
|
- logger.i(
|
|
|
- 'MedicalController initData patientName:${Store.user.currentSelectPatientInfo?.patientName} patientCode:${Store.user.currentSelectPatientInfo?.code}');
|
|
|
- var cachedAppDataId = await readCachedAppDataId();
|
|
|
- if (cachedAppDataId != null) {
|
|
|
- appDataId = cachedAppDataId;
|
|
|
- } else {
|
|
|
- await saveCachedAppDataId();
|
|
|
+ if (patientCode.isEmpty) {
|
|
|
+ logger.w("MedicalController init fail, because `patientCode` not set.");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (Routes.parameters["diagnosisEditData"] != null) {
|
|
|
+ await _loadDataFromRoute();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ logger.i(
|
|
|
+ 'MedicalController initData patientName:${Store.user.currentSelectPatientInfo?.patientName} patientCode:${Store.user.currentSelectPatientInfo?.code}');
|
|
|
+ var cachedAppDataId = await readCachedAppDataId();
|
|
|
+ if (cachedAppDataId != null) {
|
|
|
+ appDataId = cachedAppDataId;
|
|
|
+ } else {
|
|
|
+ await saveCachedAppDataId();
|
|
|
+ }
|
|
|
+ await initReadCached();
|
|
|
+ }
|
|
|
+
|
|
|
+ Future<void> _loadDataFromRoute() async {
|
|
|
+ final model = Routes.parameters["diagnosisEditData"]
|
|
|
+ as DiagnosisAggregationRecordModel;
|
|
|
+ appDataId = model.appDataId!;
|
|
|
+ final dataList = model.diagnosisAggregationData ?? [];
|
|
|
+ diagnosisDataValue = {};
|
|
|
+ for (var item in dataList) {
|
|
|
+ if (item.key != null && item.diagnosisData != null) {
|
|
|
+ diagnosisDataValue[item.key!] = jsonDecode(item.diagnosisData!);
|
|
|
}
|
|
|
- await initReadCached();
|
|
|
}
|
|
|
+
|
|
|
+ Routes.parameters["diagnosisEditData"] = null;
|
|
|
}
|
|
|
|
|
|
Future<void> getAccessTypes() async {
|
|
@@ -266,12 +295,13 @@ class MedicalController extends FControllerBase {
|
|
|
///提交之后,测试结果清空
|
|
|
diagnosisDataValue.clear();
|
|
|
state.currentTab = state.medicalMenuList[0].key;
|
|
|
-
|
|
|
+ state.refreshCurrentTab();
|
|
|
Get.back();
|
|
|
}
|
|
|
} catch (err) {
|
|
|
busy = false;
|
|
|
state.currentTab = state.medicalMenuList[0].key;
|
|
|
+ state.refreshCurrentTab();
|
|
|
logger.e('submitDiagnosis error: ${err.toString()}');
|
|
|
}
|
|
|
}
|