123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707 |
- import 'dart:convert';
- import 'dart:io';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:flutter/foundation.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:uuid/uuid.dart';
- import 'package:vitalapp/architecture/utils/prompt_box.dart';
- import 'package:vitalapp/architecture/utils/upload.dart';
- import 'package:vitalapp/components/alert_dialog.dart';
- import 'package:vitalapp/database/db.dart';
- 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';
- import 'package:vitalapp/architecture/storage/text_storage.dart';
- import 'package:vitalapp/managers/interfaces/cachedRecord.dart';
- import 'package:vitalapp/managers/interfaces/device.dart';
- import 'package:vitalapp/managers/interfaces/diagnosis.dart';
- import 'package:vitalapp/managers/interfaces/models/device.dart';
- import 'package:vitalapp/pages/medical/models/item.dart';
- import 'package:vitalapp/pages/medical/state.dart';
- import 'package:vitalapp/store/store.dart';
- import 'package:vnote_device_plugin/events/event_type.dart';
- import 'package:fis_common/logger/logger.dart';
- import 'package:vitalapp/architecture/storage/storage.dart';
- class MedicalController extends FControllerBase {
- String appDataId = "";
- String patientCode = '';
- Map<String, dynamic> diagnosisDataValue = {};
- ExamDTO? currentExam;
- final _patientManager = Get.find<IPatientManager>();
- final _examManager = Get.find<IExamManager>();
- final state = MedicalState();
- final recordDataCacheManager = Get.find<IRecordDataCacheManager>();
- final FEventHandler<bool> onSelectExam = FEventHandler<bool>();
- // /// 体检页面回填的数据
- // final FEventHandler<Map<String, dynamic>> onGetExamData =
- // FEventHandler<Map<String, dynamic>>();
- /// 返回给体检页面的数据
- final FEventHandler<Map<String, dynamic>> setExamData =
- FEventHandler<Map<String, dynamic>>();
- static final typeConvertMap = <String, String>{
- DeviceTypes.TEMP: "Temp",
- DeviceTypes.WEIGHT: "BMI",
- DeviceTypes.SPO2: "SpO2",
- DeviceTypes.NIBP: "NIBP",
- DeviceTypes.SUGAR: "GLU",
- DeviceTypes.URINE: "Urine",
- DeviceTypes.IC_READER: "ICReader",
- DeviceTypes.HEART: "HEART",
- DeviceTypes.TWELVEHEART: "Twelveheart",
- };
- final changePatient = FEventHandler<String>();
- final _diagnosisManager = Get.find<IDiagnosisManager>();
- final _cachedRecordManager = Get.find<ICachedRecordManager>();
- final _deviceManager = Get.find<IDeviceManager>();
- final _medicalMenus = [
- MedicalItem(key: DeviceTypes.TEMP, diagnosticItem: '体温'),
- MedicalItem(key: DeviceTypes.SUGAR, diagnosticItem: '血糖'),
- MedicalItem(key: DeviceTypes.NIBP, diagnosticItem: '血压'),
- MedicalItem(key: DeviceTypes.SPO2, diagnosticItem: '血氧'),
- MedicalItem(key: DeviceTypes.WEIGHT, diagnosticItem: 'BMI'),
- MedicalItem(key: DeviceTypes.WAIST, diagnosticItem: '腰臀比'),
- MedicalItem(key: DeviceTypes.URINE, diagnosticItem: '尿常规'),
- MedicalItem(key: DeviceTypes.HEART, diagnosticItem: '心电'),
- MedicalItem(key: DeviceTypes.TWELVEHEART, diagnosticItem: '十二导心电'),
- ];
- // @override
- // void onInit() {
- // super.onInit();
- // }
- @override
- void onReady() async {
- super.onReady();
- await initData();
- await getAccessTypes();
- // onGetExamData.addListener(getExamData);
- state.currentTab = DeviceTypes.TEMP; //等数据加载完成之后在切换到体温页面
- // busy = false;
- // logger.i('MedicalController init end');
- }
- Future<void> initData() async {
- patientCode = Store.user.currentSelectPatientInfo?.code ?? '';
- 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!);
- }
- }
- Routes.parameters["diagnosisEditData"] = null;
- }
- Future<void> getAccessTypes() async {
- List<MedicalItem> medicalItemList = [];
- List<String> accessTypes = await _deviceManager.getAccessTypes();
- for (var element in _medicalMenus) {
- if (accessTypes.contains(element.key)) {
- medicalItemList.add(element);
- }
- }
- state.medicalMenuList = medicalItemList;
- }
- Future<DeviceModel?> getDevice(String type) async {
- List<DeviceModel> devices = await _deviceManager.getDeviceList();
- return devices.firstWhereOrNull((element) => element.type == type);
- }
- Future<void> initReadCached() async {
- if (patientCode.isNotEmpty) {
- logger
- .i('MedicalController initReadCached fail,patientCod e:$patientCode');
- TextStorage cachedRecord = TextStorage(
- fileName: 'JKJC',
- directory: "patient/$patientCode",
- );
- String? value = await cachedRecord.read();
- if (value == null) {
- diagnosisDataValue = {};
- Store.resident.handleSaveMedicalData(jsonEncode(diagnosisDataValue));
- return;
- }
- Store.resident.handleSaveMedicalData(value);
- if (kIsWeb) {
- diagnosisDataValue = {};
- } else {
- diagnosisDataValue = jsonDecode(value);
- }
- }
- }
- Future<bool?> saveCachedAppDataId() async {
- appDataId = const Uuid().v4().replaceAll('-', '');
- TextStorage cachedRecord = TextStorage(
- fileName: 'appDataId',
- directory: "patient/$patientCode",
- );
- // Get.back();
- return cachedRecord.save(appDataId);
- }
- Future<String?> readCachedAppDataId() async {
- TextStorage cachedRecord = TextStorage(
- fileName: 'appDataId',
- directory: "patient/$patientCode",
- );
- return cachedRecord.read();
- }
- Future<bool?> saveCachedRecord() async {
- if (patientCode.isEmpty) {
- logger.i(
- 'MedicalController saveCachedRecord fail,patientCode:$patientCode');
- return false;
- }
- Store.resident.handleSaveMedicalData(jsonEncode(diagnosisDataValue));
- TextStorage cachedRecord = TextStorage(
- fileName: 'JKJC',
- directory: "patient/$patientCode",
- );
- return cachedRecord.save(jsonEncode(diagnosisDataValue));
- }
- Future<bool?> deleteDirectory() async {
- TextStorage cachedRecord = TextStorage(
- fileName: 'JKJC',
- directory: "patient/$patientCode",
- );
- //TODO(Loki):这里是否仅删除一个JKJC的文件就行了,不需要删除整个文件夹
- return cachedRecord.delete();
- }
- Future<void> submitDiagnosis(
- Map<String, dynamic> submitDiagnosisDataValue,
- ) async {
- try {
- List<DiagnosisItem> diagnosisItems = await recordDataCacheManager
- .verifyDiagnosisDataList(submitDiagnosisDataValue);
- state.currentTab = '-1';
- await recordDataCacheManager.saveRecordData(
- appDataId,
- patientCode,
- submitDiagnosisDataValue,
- );
- if (kIsOnline) {
- busy = true;
- diagnosisItems = await recordDataCacheManager
- .convertDiagnosisDataToList(submitDiagnosisDataValue);
- bool result;
- result = await _diagnosisManager.syncPatientAndDiagnosisData(
- SyncPatientAndDiagnosisDataRequest(
- patientCode: patientCode,
- patientName: Store.user.currentSelectPatientInfo?.patientName ?? '',
- patientAddress:
- Store.user.currentSelectPatientInfo?.patientAddress ?? '',
- patientGender: Store.user.currentSelectPatientInfo?.patientGender ??
- GenderEnum.Unknown,
- permanentResidenceAddress:
- Store.user.currentSelectPatientInfo?.permanentResidenceAddress,
- phone: Store.user.currentSelectPatientInfo?.phone,
- cardNo: Store.user.currentSelectPatientInfo?.cardNo,
- nationality: Store.user.currentSelectPatientInfo?.nationality,
- birthday: Store.user.currentSelectPatientInfo?.birthday,
- crowdLabels: Store.user.currentSelectPatientInfo?.crowdLabels,
- cardType: Store.user.currentSelectPatientInfo?.cardType ??
- CardTypeEnum.Identity,
- contractedDoctor:
- Store.user.currentSelectPatientInfo?.contractedDoctor,
- appDataId: appDataId,
- diagnosisTime: DateTime.now(),
- token: Store.user.token,
- diagnosisItems: diagnosisItems,
- ),
- );
- busy = false;
- if (result) {
- //如果在线,则提交历史数据
- var submitSuccess = await _submitHistory();
- if (submitSuccess) {
- logger.i('当前数据提交成功,且历史记录:$patientCode 提交成功');
- }
- recordDataCacheManager.recordSyncStateChange(appDataId);
- PromptBox.toast('提交成功');
- await initRecordDataState();
- Get.back();
- ///提交之后,测试结果清空
- diagnosisDataValue.clear();
- } else {
- PromptBox.toast('提交失败');
- logger.i('提交失败:$patientCode');
- }
- state.currentTab = state.medicalMenuList[0].key;
- } else {
- Future.delayed(const Duration(milliseconds: 10), () {
- state.currentTab = state.medicalMenuList[0].key;
- });
- PromptBox.toast("已缓存至本地");
- logger.i('已缓存至本地:$patientCode');
- await initRecordDataState();
- ///提交之后,测试结果清空
- 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()}');
- }
- }
- Future<void> initRecordDataState() async {
- await saveCachedAppDataId();
- await deleteDirectory();
- await initReadCached();
- }
- Future<void> createDiagnosis({
- required bool isHealthCheck,
- }) async {
- busy = true;
- try {
- if (Store.user.teamName.isEmpty) {
- PromptBox.toast('未设置团队无法提交检测数据');
- return;
- }
- if (patientCode.isEmpty ||
- patientCode != Store.user.currentSelectPatientInfo?.code) {
- initData();
- }
- Map<String, dynamic> submitDiagnosisDataValue =
- Map.from(diagnosisDataValue); //确定提交值不会发生变更
- List<DiagnosisItem> diagnosisItems = await recordDataCacheManager
- .verifyDiagnosisDataList(submitDiagnosisDataValue);
- logger.i('submitDiagnosis diagnosisItems.leng:${diagnosisItems.length}');
- if (diagnosisItems.isEmpty) {
- if (patientCode.isNotEmpty && kIsOnline) {
- bool submitHistory = await _submitHistory();
- if (submitHistory) {
- PromptBox.toast('提交成功');
- return;
- }
- }
- PromptBox.toast('不能提交空数据');
- return;
- }
- if (state.medicalMenuList.length > submitDiagnosisDataValue.length) {
- logger.i(
- 'state.medicalMenuList.length:${state.medicalMenuList.length},copiedDiagnosisDataValue.length:${diagnosisDataValue.length}');
- Get.dialog(
- VAlertDialog(
- title: '提示',
- content: Container(
- margin: const EdgeInsets.only(bottom: 20),
- child: const Text(
- '当前检测项目未完成,请确定是否提交本次检测',
- style: TextStyle(fontSize: 20),
- textAlign: TextAlign.center,
- ),
- ),
- showCancel: true,
- onConfirm: () {
- Get.back();
- if (isHealthCheck) {
- try {
- setExamData.emit(
- this,
- submitDiagnosisDataValue,
- );
- } catch (e) {
- print("MedicalController setExamData ex:$e");
- logger.e("MedicalController setExamData ex:$e");
- }
- }
- submitDiagnosis(submitDiagnosisDataValue);
- },
- onCanceled: () {},
- ),
- );
- return;
- } else {
- if (isHealthCheck) {
- try {
- setExamData.emit(
- this,
- submitDiagnosisDataValue,
- );
- } catch (e) {
- print("MedicalController setExamData ex:$e");
- logger.e("MedicalController setExamData ex:$e");
- }
- }
- ///如果已完成所有检查,则直接提交
- submitDiagnosis(submitDiagnosisDataValue);
- }
- } catch (e) {
- logger.e('MedicalController createDiagnosis ex:', e);
- } finally {
- busy = false;
- }
- }
- @override
- void dispose() {
- setExamData.dispose();
- // onGetExamData.removeListener(getExamData);
- print('MedicalController dispose');
- super.dispose();
- }
- RxBool _isNormalcy = RxBool(true);
- bool get isNormalcy => _isNormalcy.value;
- set isNormalcy(bool value) => _isNormalcy.value = value;
- /// 【TODO 接口需要变更】 心电
- Future<void> createHeart(
- String physicalExamNumber,
- String? keyValue,
- String recordCode,
- ) async {
- try {
- Map<String, dynamic> input = diagnosisDataValue;
- if (diagnosisDataValue.isEmpty) {
- PromptBox.toast('不能提交空数据');
- return;
- }
- await Get.dialog(
- VAlertDialog(
- title: '提示',
- content: Container(
- margin: const EdgeInsets.only(bottom: 20),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- const Text(
- '当前心电检测结果是否正常:',
- style: TextStyle(fontSize: 20),
- textAlign: TextAlign.center,
- ),
- SizedBox(
- width: 10,
- ),
- Obx(
- () => Row(
- children: [
- Radio(
- onChanged: (v) {
- isNormalcy = v ?? false;
- },
- value: true,
- groupValue: isNormalcy,
- ),
- Text(
- "正常",
- style: TextStyle(fontSize: 20),
- ),
- Radio(
- onChanged: (v) {
- isNormalcy = v ?? false;
- },
- value: false,
- groupValue: isNormalcy,
- ),
- Text(
- "异常",
- style: TextStyle(fontSize: 20),
- ),
- ],
- ),
- )
- ],
- )),
- showCancel: false,
- onConfirm: () {
- diagnosisDataValue["TwelveHeart"]["isHeartNormalcy"] = isNormalcy;
- Get.back();
- },
- ),
- );
- for (var entry in input.entries) {
- var key = entry.key;
- var value = entry.value;
- if (value != null) {
- Store.app.setBusy("提交中");
- if (['Heart', 'TwelveHeart'].contains(key) && value is Map) {
- value = await uploadData(value);
- }
- Store.app.busy = false;
- }
- print('$key: $value');
- }
- Map<String, dynamic> output = {};
- input.forEach((key, value) {
- value.forEach((innerKey, innerValue) {
- output[innerKey] = innerValue;
- });
- });
- bool? result = false;
- if (kIsWeb && currentExam != null) {
- result = await _examManager.editExam(UpdateExamRequest(
- key: keyValue ?? "HEIECG",
- examData: jsonEncode(output),
- code: currentExam!.code));
- } else {
- result = await _examManager.createExamDatas(
- recordCode,
- jsonEncode(output),
- );
- }
- if (result == true) {
- busy = false;
- PromptBox.toast('提交成功');
- Get.back();
- }
- } catch (e) {
- busy = false;
- logger.e('MedicalController createCheckup ex:', e);
- }
- }
- bool isUploaded(String url) {
- return url.startsWith('https://') || url.startsWith('http://');
- }
- // TODO Baka 体检暂时写法 需要封装
- Future<Map> uploadData(Map data) async {
- if (data['ECG_POINT'] != null && !isUploaded(data['ECG_POINT'])) {
- if (kIsWeb) {
- Uint8List ecgPointbyte =
- await rpc.storage.writeStringToByte(data['ECG_POINT']);
- String? ecgPointUrl = await rpc.storage.uploadByte(ecgPointbyte);
- data['ECG_POINT'] = ecgPointUrl ?? '';
- } else {
- File ecgPointFile =
- await rpc.storage.writeStringToFile(data['ECG_POINT']);
- String? ecgPointUrl = await rpc.storage.uploadFile(ecgPointFile);
- data['ECG_POINT'] = ecgPointUrl ?? '';
- }
- // ... 上传点集
- }
- if (data['ECG'] != null && !isUploaded(data['ECG'])) {
- // ... 上传图片
- /// 图片地址
- final imageFile = UploadUtils.convertBase64ToXFile(data['ECG']);
- String? imageUrl = await rpc.storage.upload(imageFile!);
- data['ECG'] = imageUrl ?? '';
- }
- if (data['ECG_POINT12'] != null && !isUploaded(data['ECG_POINT12'])) {
- if (kIsWeb) {
- Uint8List ecgPointBytes =
- await rpc.storage.writeStringToByte(data['ECG_POINT12']);
- String? ecgPointUrl = await rpc.storage.uploadByte(ecgPointBytes);
- data['ECG_POINT12'] = ecgPointUrl ?? '';
- } else {
- File ecgPointFile =
- await rpc.storage.writeStringToFile(data['ECG_POINT12']);
- String? ecgPointUrl = await rpc.storage.uploadFile(ecgPointFile);
- data['ECG_POINT12'] = ecgPointUrl ?? '';
- }
- // ... 上传点集
- }
- if (data['ECG12'] != null && !isUploaded(data['ECG12'])) {
- // ... 上传图片
- if (kIsWeb) {
- var file = UploadUtils.convertBase64ToFile(data['ECG12']);
- String? url = await rpc.storage.webUpload(file!);
- data['ECG12'] = url ?? '';
- } else {
- final imageFile = UploadUtils.convertBase64ToXFile(data['ECG12']);
- String? imageUrl =
- await rpc.storage.upload(imageFile!, fileType: "jpg");
- data['ECG12'] = imageUrl ?? '';
- }
- }
- if (data['ECG12_30s'] != null && !isUploaded(data['ECG12_30s'])) {
- // ... 上传图片
- if (kIsWeb) {
- var file = UploadUtils.convertBase64ToFile(data['ECG12_30s']);
- String? url = await rpc.storage.webUpload(file!);
- data['ECG12_30s'] = url ?? '';
- } else {
- final imageFile = UploadUtils.convertBase64ToXFile(data['ECG12_30s']);
- String? imageUrl =
- await rpc.storage.upload(imageFile!, fileType: "jpg");
- data['ECG12_30s'] = imageUrl ?? '';
- }
- }
- return data;
- }
- /// 体检 检查提交
- Future<void> createCheckup(
- String? physicalExamNumber,
- String? keyValue,
- ) async {
- try {
- Map<String, dynamic> input = diagnosisDataValue;
- Map<String, dynamic> output = {};
- if (diagnosisDataValue.isEmpty) {
- PromptBox.toast('不能提交空数据');
- return;
- }
- setBusy("提交中");
- input.forEach((key, value) {
- if (value is String) {
- output[key] = value;
- } else if (value is Map) {
- value.forEach((innerKey, innerValue) {
- output[innerKey] = innerValue;
- });
- }
- });
- var result = await _examManager.createExam(CreateExamRequest(
- key: keyValue ?? "HEIBasic",
- examData: jsonEncode(output),
- physicalExamNumber: physicalExamNumber,
- ));
- if (result == true) {
- busy = false;
- PromptBox.toast('提交成功');
- Get.back();
- }
- onSelectExam.emit(this, true);
- saveCachedRecord();
- } catch (e) {
- busy = false;
- logger.e('MedicalController createCheckup ex:', e);
- }
- }
- ///提交历史记录
- Future<bool> _submitHistory() async {
- var existDatas =
- await recordDataCacheManager.getNoSubmitRecords(patientCode);
- var historyDatas = existDatas.where((element) => element.code != appDataId);
- if (historyDatas.isEmpty) {
- return false;
- }
- for (DiagnosisEntity data in historyDatas) {
- try {
- Map<String, dynamic> jsonData = jsonDecode(data.dataJson);
- var diagnosisItems =
- await recordDataCacheManager.convertDiagnosisDataToList(jsonData);
- SubmitDiagnosisRequest submitDiagnosisRequest = SubmitDiagnosisRequest(
- appDataId: data.code,
- patientCode: data.patientCode,
- diagnosisItems: diagnosisItems,
- diagnosisTime: data.updateTime ?? data.createTime,
- );
- bool submitResult;
- if (kIsOnline) {
- PatientDTO? patientInfo = await _patientManager.getDetail(
- data.patientCode,
- );
- if (patientInfo == null) {
- ///如果Server没有,则从本地读取
- var patientEntity = await db.repositories.patient
- .singleByCodeWithUserCode(
- data.patientCode, Store.user.userCode!);
- if (patientEntity != null) {
- patientInfo =
- PatientDTO.fromJson(jsonDecode(patientEntity.dataJson));
- }
- }
- submitResult = await _diagnosisManager.syncPatientAndDiagnosisData(
- SyncPatientAndDiagnosisDataRequest(
- token: Store.user.token,
- patientCode: data.patientCode,
- patientName: patientInfo?.patientName ?? '',
- patientAddress: patientInfo?.patientAddress ?? '',
- patientGender: patientInfo?.patientGender ?? GenderEnum.Unknown,
- permanentResidenceAddress: patientInfo?.permanentResidenceAddress,
- phone: patientInfo?.phone,
- cardNo: patientInfo?.cardNo,
- nationality: patientInfo?.nationality,
- birthday: patientInfo?.birthday,
- crowdLabels: patientInfo?.crowdLabels,
- cardType: patientInfo?.cardType ?? CardTypeEnum.Identity,
- contractedDoctor: patientInfo?.contractedDoctor,
- appDataId: data.code,
- diagnosisTime: data.updateTime ?? data.createTime,
- diagnosisItems: diagnosisItems,
- ),
- );
- } else {
- submitResult = await _diagnosisManager
- .submitDiagnosisAsync(submitDiagnosisRequest);
- }
- OfflineDataSyncState state;
- if (submitResult) {
- state = OfflineDataSyncState.success;
- logger.i('提交历史记录:$patientCode 成功');
- } else {
- state = OfflineDataSyncState.fail;
- logger.i('提交历史记录:$patientCode 失败');
- }
- recordDataCacheManager.recordSyncStateChange(data.code, state: state);
- } catch (e) {
- logger.e('MedicalController _submitHistory ex:', e);
- }
- }
- return true;
- }
- }
|