registration.dart 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import 'dart:convert';
  2. import 'package:fis_common/logger/logger.dart';
  3. import 'package:fis_jsonrpc/rpc.dart';
  4. import 'package:vitalapp/managers/interfaces/registration.dart';
  5. import 'package:vitalapp/rpc.dart';
  6. import 'package:vitalapp/store/store.dart';
  7. class RegistrationManager implements IRegistrationManager {
  8. /// 新增登记
  9. @override
  10. Future<String?> addRegiterInfoAsync(
  11. {required AddRegiterInfoRequest request}) async {
  12. try {
  13. request.token = Store.user.token;
  14. print(jsonEncode(request));
  15. final getExamBookingByIDCard =
  16. await rpc.vitalHealthExamBooking.addRegiterInfoAsync(
  17. request,
  18. );
  19. return getExamBookingByIDCard;
  20. } catch (e) {
  21. logger.e("RegistrationManager sync addRegiterInfoAsync error.", e);
  22. return null;
  23. }
  24. }
  25. /// 登记列表
  26. @override
  27. Future<PageResult<RegisterInfoDTO>?> getRegisterInfoPageAsync({
  28. int? pageSize = 10,
  29. int? pageIndex = 1,
  30. String? keyword,
  31. DateTime? startTime,
  32. DateTime? endTime,
  33. }) async {
  34. try {
  35. GetRegiterInfoPageRequest request = GetRegiterInfoPageRequest(
  36. pageSize: pageSize!,
  37. pageIndex: pageIndex!,
  38. keyword: keyword,
  39. startTime: startTime?.toUtc(),
  40. endTime: endTime?.toUtc(),
  41. );
  42. request.token = Store.user.token;
  43. final getExamBookingByIDCard =
  44. await rpc.vitalHealthExamBooking.getRegisterInfoPageAsync(
  45. request,
  46. );
  47. return getExamBookingByIDCard;
  48. } catch (e) {
  49. logger.e("RegistrationManager sync getRegisterInfoPageAsync error.", e);
  50. return null;
  51. }
  52. }
  53. /// 更新登记
  54. @override
  55. Future<bool?> updateRegiterInfoAsync({
  56. required UpdateRegiterInfoRequest request,
  57. }) async {
  58. try {
  59. // request.token = Store.user.token;
  60. final getExamBookingByIDCard =
  61. await rpc.vitalHealthExamBooking.updateRegiterInfoAsync(
  62. request,
  63. );
  64. return getExamBookingByIDCard;
  65. } catch (e) {
  66. logger.e("RegistrationManager sync addRegiterInfoAsync error.", e);
  67. return null;
  68. }
  69. }
  70. ///
  71. @override
  72. Future<List<ExamDTO>?> getExamListByPhysicalExamNumberAsync({
  73. required String physicalExamNumber,
  74. }) async {
  75. try {
  76. var request = GetExamListByPhysicalExamNumberRequest();
  77. // request.token = Store.user.token;
  78. request.physicalExamNumber = physicalExamNumber;
  79. final examList = await rpc.vitalExam.getExamListByPhysicalExamNumberAsync(
  80. request,
  81. );
  82. return examList;
  83. } catch (e) {
  84. logger.e(
  85. "RegistrationManager sync getExamListByPhysicalExamNumberAsync error.",
  86. e);
  87. return null;
  88. }
  89. }
  90. @override
  91. Future<List<ReportDTO2>?> getVitalReportInfoAsync(
  92. {required String physicalExamNumber}) async {
  93. try {
  94. var request = GetVitalReportInfoByPhysicalExamNumberRequest();
  95. // request.token = Store.user.token;
  96. request.physicalExamNumber = physicalExamNumber;
  97. final examList = await rpc.report.getVitalReportInfoAsync(
  98. request,
  99. );
  100. return examList;
  101. } catch (e) {
  102. logger.e("RegistrationManager sync getVitalReportInfoAsync error.", e);
  103. return null;
  104. }
  105. }
  106. @override
  107. Future<bool> updateResultsAndSuggestionsAsync(
  108. String code, String resultsAndSuggestions) async {
  109. var request = UpdateResultsAndSuggestionsRequest(
  110. token: Store.user.token,
  111. code: code,
  112. resultsAndSuggestions: resultsAndSuggestions,
  113. );
  114. print(jsonEncode(request));
  115. var result = await rpc.vitalHealthExamBooking
  116. .updateResultsAndSuggestionsAsync(request);
  117. return result;
  118. }
  119. Future<ElectrocardiogramRecord?> getElectrocardiogramRecordAsync({
  120. required String physicalExamNumber,
  121. }) async {
  122. try {
  123. var request = GetElectrocardiogramRecordRequest();
  124. request.token = Store.user.token;
  125. // request.physicalExamNumber = physicalExamNumber;
  126. final electrocardiogramRecord =
  127. await rpc.vitalElectrocardiogram.getElectrocardiogramRecordAsync(
  128. request,
  129. );
  130. return electrocardiogramRecord;
  131. } catch (e) {
  132. logger.e(
  133. "RegistrationManager sync getElectrocardiogramRecordAsync error.", e);
  134. return null;
  135. }
  136. }
  137. @override
  138. Future<ElectrocardiogramRecord?>
  139. getElectrocardiogramRecordByPhysicalExamNumberAsync({
  140. required String physicalExamNumber,
  141. }) async {
  142. try {
  143. var request = GetElectrocardiogramRecordByPhysicalExamNumberRequest();
  144. request.physicalExamNumber = physicalExamNumber;
  145. final examList = await rpc.vitalElectrocardiogram
  146. .getElectrocardiogramRecordByPhysicalExamNumberAsync(
  147. request,
  148. );
  149. return examList;
  150. } catch (e) {
  151. logger.e(
  152. "RegistrationManager sync getElectrocardiogramRecordByPhysicalExamNumberAsync error.",
  153. e);
  154. return null;
  155. }
  156. }
  157. @override
  158. Future<PageCollection<ElectrocardiogramRecord>?>
  159. getElectrocardiogramRecordPageAsync({
  160. int? pageSize = 10,
  161. int? pageIndex = 1,
  162. String? keyword,
  163. }) async {
  164. try {
  165. var request = ElectrocardiogramRecordPageRequest(
  166. pageSize: pageSize!,
  167. pageIndex: pageIndex!,
  168. keyWord: keyword,
  169. );
  170. request.token = Store.user.token;
  171. final electrocardiogramRecordList =
  172. await rpc.vitalElectrocardiogram.getElectrocardiogramRecordPageAsync(
  173. request,
  174. );
  175. return electrocardiogramRecordList;
  176. } catch (e) {
  177. logger.e(
  178. "RegistrationManager sync getElectrocardiogramRecordPageAsync error.",
  179. e);
  180. return null;
  181. }
  182. }
  183. }