appointment.dart 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import 'package:fis_common/logger/logger.dart';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:vitalapp/managers/interfaces/appointment.dart';
  4. import 'package:vitalapp/rpc.dart';
  5. import 'package:vitalapp/store/store.dart';
  6. class AppointmentManager implements IAppointmentManager {
  7. /// 分页获取健康检查预约数据
  8. @override
  9. Future<PageResult<HealthExamBookingDTO>?> getHealthExamBookingPageAsync({
  10. int? pageSize = 10,
  11. int? pageIndex = 1,
  12. String? keyword,
  13. }) async {
  14. try {
  15. GetHealthExamBookingPageRequest healthExamBookingPageRequest =
  16. GetHealthExamBookingPageRequest();
  17. healthExamBookingPageRequest.token = Store.user.token;
  18. healthExamBookingPageRequest.pageIndex = pageIndex!;
  19. healthExamBookingPageRequest.pageSize = pageSize!;
  20. healthExamBookingPageRequest.keyword = keyword;
  21. final healthExamBooking =
  22. await rpc.vitalHealthExamBooking.getHealthExamBookingPageAsync(
  23. healthExamBookingPageRequest,
  24. );
  25. return healthExamBooking;
  26. } catch (e) {
  27. logger.e(
  28. "AppointmentManager sync getHealthExamBookingPageAsync error.", e);
  29. return null;
  30. }
  31. }
  32. /// 删除体检信息
  33. @override
  34. Future<bool> deleteHealthExamBookingAsync(String code) async {
  35. try {
  36. final request = DeleteHealthExamBookingRequest(
  37. code: code,
  38. token: Store.user.token,
  39. );
  40. final healthExamBooking = await rpc.vitalHealthExamBooking
  41. .deleteHealthExamBookingAsync(request);
  42. return healthExamBooking;
  43. } catch (e) {
  44. logger.e(
  45. "AppointmentManager sync getHealthExamBookingPageAsync error.", e);
  46. return false;
  47. }
  48. }
  49. /// 查询体检详情
  50. @override
  51. Future<HealthExamBookingDTO?> getHealthExamBookingAsync({
  52. required String code,
  53. }) async {
  54. try {
  55. GetHealthExamBookingRequest healthExamBookingRequest =
  56. GetHealthExamBookingRequest();
  57. healthExamBookingRequest.token = Store.user.token;
  58. healthExamBookingRequest.code = code;
  59. final healthExamBooking =
  60. await rpc.vitalHealthExamBooking.getHealthExamBookingAsync(
  61. healthExamBookingRequest,
  62. );
  63. return healthExamBooking;
  64. } catch (e) {
  65. logger.e(
  66. "AppointmentManager sync getHealthExamBookingPageAsync error.", e);
  67. return null;
  68. }
  69. }
  70. /// 新增/修改体检信息
  71. @override
  72. Future<String?> saveHealthExamBookingAsync(
  73. SaveHealthExamBookingRequest saveHealthExamBookingRequest) async {
  74. try {
  75. saveHealthExamBookingRequest.token = Store.user.token;
  76. final healthExamBooking =
  77. await rpc.vitalHealthExamBooking.saveHealthExamBookingAsync(
  78. saveHealthExamBookingRequest,
  79. );
  80. return healthExamBooking;
  81. } catch (e) {
  82. logger.e(
  83. "AppointmentManager sync getHealthExamBookingPageAsync error.", e);
  84. return null;
  85. }
  86. }
  87. ///解除预约
  88. Future<bool> cancelHealthExam(
  89. String code,
  90. String identityCard,
  91. ) async {
  92. try {
  93. final result =
  94. await rpc.vitalHealthExamBooking.cancelHealthExamBookingAsync(
  95. CancelHealthExamBookingRequest(
  96. token: Store.user.token,
  97. code: code,
  98. identityCard: identityCard,
  99. ),
  100. );
  101. return result;
  102. } catch (e) {
  103. logger.e("AppointmentManager deleteHealthExam ex:$e");
  104. return false;
  105. }
  106. }
  107. /// 根据身份证获取预约信息
  108. @override
  109. Future<HealthExamPersonDTO?> getExamBookingByIDCardAsync({
  110. String? idCardNo,
  111. }) async {
  112. try {
  113. GetExamBookingByIDCardRequest examBookingByIDCard =
  114. GetExamBookingByIDCardRequest();
  115. examBookingByIDCard.token = Store.user.token;
  116. examBookingByIDCard.iDCardNo = idCardNo;
  117. final getExamBookingByIDCard =
  118. await rpc.vitalHealthExamBooking.getExamBookingByIDCardAsync(
  119. examBookingByIDCard,
  120. );
  121. return getExamBookingByIDCard;
  122. } catch (e) {
  123. logger.e("AppointmentManager sync getExamBookingByIDCardAsync error.", e);
  124. return null;
  125. }
  126. }
  127. }