appointment.dart 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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(
  35. DeleteHealthExamBookingRequest deleteHealthExamBookingRequest) async {
  36. try {
  37. final healthExamBooking =
  38. await rpc.vitalHealthExamBooking.deleteHealthExamBookingAsync(
  39. deleteHealthExamBookingRequest,
  40. );
  41. return healthExamBooking;
  42. } catch (e) {
  43. logger.e(
  44. "AppointmentManager sync getHealthExamBookingPageAsync error.", e);
  45. return null;
  46. }
  47. }
  48. /// 查询体检详情
  49. @override
  50. Future<HealthExamBookingDTO?> getHealthExamBookingAsync({
  51. required String code,
  52. }) async {
  53. try {
  54. GetHealthExamBookingRequest healthExamBookingRequest =
  55. GetHealthExamBookingRequest();
  56. healthExamBookingRequest.token = Store.user.token;
  57. healthExamBookingRequest.code = code;
  58. final healthExamBooking =
  59. await rpc.vitalHealthExamBooking.getHealthExamBookingAsync(
  60. healthExamBookingRequest,
  61. );
  62. return healthExamBooking;
  63. } catch (e) {
  64. logger.e(
  65. "AppointmentManager sync getHealthExamBookingPageAsync error.", e);
  66. return null;
  67. }
  68. }
  69. /// 新增/修改体检信息
  70. @override
  71. Future<String?> saveHealthExamBookingAsync(
  72. SaveHealthExamBookingRequest saveHealthExamBookingRequest) async {
  73. try {
  74. saveHealthExamBookingRequest.token = Store.user.token;
  75. final healthExamBooking =
  76. await rpc.vitalHealthExamBooking.saveHealthExamBookingAsync(
  77. saveHealthExamBookingRequest,
  78. );
  79. return healthExamBooking;
  80. } catch (e) {
  81. logger.e(
  82. "AppointmentManager sync getHealthExamBookingPageAsync error.", e);
  83. return null;
  84. }
  85. }
  86. /// 根据身份证获取预约信息
  87. @override
  88. Future<HealthExamPersonDTO?> getExamBookingByIDCardAsync({
  89. String? idCardNo,
  90. }) async {
  91. try {
  92. GetExamBookingByIDCardRequest examBookingByIDCard =
  93. GetExamBookingByIDCardRequest();
  94. examBookingByIDCard.token = Store.user.token;
  95. examBookingByIDCard.iDCardNo = idCardNo;
  96. final getExamBookingByIDCard =
  97. await rpc.vitalHealthExamBooking.getExamBookingByIDCardAsync(
  98. examBookingByIDCard,
  99. );
  100. return getExamBookingByIDCard;
  101. } catch (e) {
  102. logger.e("AppointmentManager sync getExamBookingByIDCardAsync error.", e);
  103. return null;
  104. }
  105. }
  106. }