import 'dart:convert'; import 'package:fis_common/logger/logger.dart'; import 'package:fis_jsonrpc/rpc.dart'; import 'package:vitalapp/managers/interfaces/registration.dart'; import 'package:vitalapp/rpc.dart'; import 'package:vitalapp/store/store.dart'; class RegistrationManager implements IRegistrationManager { /// 新增登记 @override Future addRegiterInfoAsync( {required AddRegiterInfoRequest request}) async { try { request.token = Store.user.token; print(jsonEncode(request)); final getExamBookingByIDCard = await rpc.vitalHealthExamBooking.addRegiterInfoAsync( request, ); return getExamBookingByIDCard; } catch (e) { logger.e("RegistrationManager sync addRegiterInfoAsync error.", e); return null; } } /// 登记列表 @override Future?> getRegisterInfoPageAsync({ int? pageSize = 10, int? pageIndex = 1, String? keyword, DateTime? startTime, DateTime? endTime, }) async { try { GetRegiterInfoPageRequest request = GetRegiterInfoPageRequest( pageSize: pageSize!, pageIndex: pageIndex!, keyword: keyword, startTime: startTime?.toUtc(), endTime: endTime?.toUtc(), ); request.token = Store.user.token; final getExamBookingByIDCard = await rpc.vitalHealthExamBooking.getRegisterInfoPageAsync( request, ); return getExamBookingByIDCard; } catch (e) { logger.e("RegistrationManager sync getRegisterInfoPageAsync error.", e); return null; } } /// 更新登记 @override Future updateRegiterInfoAsync({ required UpdateRegiterInfoRequest request, }) async { try { request.token = Store.user.token; final getExamBookingByIDCard = await rpc.vitalHealthExamBooking.updateRegiterInfoAsync( request, ); return getExamBookingByIDCard; } catch (e) { logger.e("RegistrationManager sync addRegiterInfoAsync error.", e); return null; } } /// @override Future?> getExamListByPhysicalExamNumberAsync({ required String physicalExamNumber, }) async { try { var request = GetExamListByPhysicalExamNumberRequest(); // request.token = Store.user.token; request.physicalExamNumber = physicalExamNumber; final examList = await rpc.vitalExam.getExamListByPhysicalExamNumberAsync( request, ); return examList; } catch (e) { logger.e( "RegistrationManager sync getExamListByPhysicalExamNumberAsync error.", e); return null; } } @override Future?> getVitalReportInfoAsync( {required String physicalExamNumber}) async { try { var request = GetVitalReportInfoByPhysicalExamNumberRequest(); // request.token = Store.user.token; request.physicalExamNumber = physicalExamNumber; final examList = await rpc.report.getVitalReportInfoAsync( request, ); return examList; } catch (e) { logger.e("RegistrationManager sync getVitalReportInfoAsync error.", e); return null; } } @override Future updateResultsAndSuggestionsAsync( String code, String resultsAndSuggestions) async { var request = UpdateResultsAndSuggestionsRequest( token: Store.user.token, code: code, resultsAndSuggestions: resultsAndSuggestions, ); print(jsonEncode(request)); var result = await rpc.vitalHealthExamBooking .updateResultsAndSuggestionsAsync(request); return result; } Future getElectrocardiogramRecordAsync({ required String physicalExamNumber, }) async { try { var request = GetElectrocardiogramRecordRequest(); request.token = Store.user.token; // request.physicalExamNumber = physicalExamNumber; final electrocardiogramRecord = await rpc.vitalElectrocardiogram.getElectrocardiogramRecordAsync( request, ); return electrocardiogramRecord; } catch (e) { logger.e( "RegistrationManager sync getElectrocardiogramRecordAsync error.", e); return null; } } @override Future getElectrocardiogramRecordByPhysicalExamNumberAsync({ required String physicalExamNumber, }) async { try { var request = GetElectrocardiogramRecordByPhysicalExamNumberRequest(); request.physicalExamNumber = physicalExamNumber; final examList = await rpc.vitalElectrocardiogram .getElectrocardiogramRecordByPhysicalExamNumberAsync( request, ); return examList; } catch (e) { logger.e( "RegistrationManager sync getElectrocardiogramRecordByPhysicalExamNumberAsync error.", e); return null; } } @override Future?> getElectrocardiogramRecordPageAsync({ int? pageSize = 10, int? pageIndex = 1, String? keyword, }) async { try { var request = ElectrocardiogramRecordPageRequest( pageSize: pageSize!, pageIndex: pageIndex!, keyWord: keyword, ); request.token = Store.user.token; final electrocardiogramRecordList = await rpc.vitalElectrocardiogram.getElectrocardiogramRecordPageAsync( request, ); return electrocardiogramRecordList; } catch (e) { logger.e( "RegistrationManager sync getElectrocardiogramRecordPageAsync error.", e); return null; } } @override Future getExamLabelsByExamNoAsync({ required String physicalExamNumber, }) async { var request = GetExamLabelsByExamNoRequest( physicalExamNumber: physicalExamNumber, token: Store.user.token, ); final result = await rpc.vitalHealthExamBooking.getExamLabelsByExamNoAsync(request); return result; } }