import 'package:fis_common/logger/logger.dart'; import 'package:fis_jsonrpc/rpc.dart'; import 'package:vitalapp/managers/interfaces/appointment.dart'; import 'package:vitalapp/rpc.dart'; import 'package:vitalapp/store/store.dart'; class AppointmentManager implements IAppointmentManager { /// 分页获取健康检查预约数据 @override Future?> getHealthExamBookingPageAsync({ int? pageSize = 10, int? pageIndex = 1, String? keyword, }) async { try { GetHealthExamBookingPageRequest healthExamBookingPageRequest = GetHealthExamBookingPageRequest(); healthExamBookingPageRequest.token = Store.user.token; healthExamBookingPageRequest.pageIndex = pageIndex!; healthExamBookingPageRequest.pageSize = pageSize!; healthExamBookingPageRequest.keyword = keyword; final healthExamBooking = await rpc.vitalHealthExamBooking.getHealthExamBookingPageAsync( healthExamBookingPageRequest, ); return healthExamBooking; } catch (e) { logger.e( "AppointmentManager sync getHealthExamBookingPageAsync error.", e); return null; } } /// 删除体检信息 @override Future deleteHealthExamBookingAsync(String code) async { try { final request = DeleteHealthExamBookingRequest( code: code, token: Store.user.token, ); final healthExamBooking = await rpc.vitalHealthExamBooking .deleteHealthExamBookingAsync(request); return healthExamBooking; } catch (e) { logger.e( "AppointmentManager sync getHealthExamBookingPageAsync error.", e); return false; } } /// 查询体检详情 @override Future getHealthExamBookingAsync({ required String code, }) async { try { GetHealthExamBookingRequest healthExamBookingRequest = GetHealthExamBookingRequest(); healthExamBookingRequest.token = Store.user.token; healthExamBookingRequest.code = code; final healthExamBooking = await rpc.vitalHealthExamBooking.getHealthExamBookingAsync( healthExamBookingRequest, ); return healthExamBooking; } catch (e) { logger.e( "AppointmentManager sync getHealthExamBookingPageAsync error.", e); return null; } } /// 新增/修改体检信息 @override Future saveHealthExamBookingAsync( SaveHealthExamBookingRequest saveHealthExamBookingRequest) async { try { saveHealthExamBookingRequest.token = Store.user.token; final healthExamBooking = await rpc.vitalHealthExamBooking.saveHealthExamBookingAsync( saveHealthExamBookingRequest, ); return healthExamBooking; } catch (e) { logger.e( "AppointmentManager sync getHealthExamBookingPageAsync error.", e); return null; } } ///解除预约 Future cancelHealthExam( String code, String identityCard, ) async { try { final result = await rpc.vitalHealthExamBooking.cancelHealthExamBookingAsync( CancelHealthExamBookingRequest( token: Store.user.token, code: code, identityCard: identityCard, ), ); return result; } catch (e) { logger.e("AppointmentManager deleteHealthExam ex:$e"); return false; } } /// 根据身份证获取预约信息 @override Future getExamBookingByIDCardAsync({ String? idCardNo, }) async { try { GetExamBookingByIDCardRequest examBookingByIDCard = GetExamBookingByIDCardRequest(); examBookingByIDCard.token = Store.user.token; examBookingByIDCard.iDCardNo = idCardNo; final getExamBookingByIDCard = await rpc.vitalHealthExamBooking.getExamBookingByIDCardAsync( examBookingByIDCard, ); return getExamBookingByIDCard; } catch (e) { logger.e("AppointmentManager sync getExamBookingByIDCardAsync error.", e); return null; } } }