report_template_manager.dart 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import 'package:fis_common/logger/logger.dart';
  2. import 'package:fis_i18n/i18n.dart';
  3. import 'package:fis_jsonrpc/rpc.dart';
  4. import 'package:vitalapp/rpc.dart';
  5. import 'interfaces/base_manager.dart';
  6. import 'interfaces/report_template.dart';
  7. class ReportTemplateManager extends BaseManager
  8. implements IReportTemplateManager {
  9. @override
  10. Future<ReportTemplateDTO> getDefaultTemplate() async {
  11. final result = await rpc.ultrasoundReport
  12. .vitalGetDefaultReportTemplateContentAsync(
  13. GetDefaultReportTemplateContentRequest(
  14. token: token,
  15. languageCode: i18nBook.locale.toCodeString('-'),
  16. ));
  17. return result;
  18. }
  19. @override
  20. Future<PageResult<ReportTemplateDTO>> getReportTemplatePage({
  21. int pageIndex = 1,
  22. int pageSize = 100,
  23. String? keyword,
  24. }) async {
  25. try {
  26. var result = await rpc.ultrasoundReport.vitalGetReportTemplatePageAsync(
  27. FindReportTemplatePagesRequest(
  28. token: token,
  29. languageCode: i18nBook.locale.toCodeString('-'),
  30. reportTemplateName: keyword,
  31. pageIndex: pageIndex,
  32. pageSize: pageSize,
  33. ),
  34. );
  35. return result;
  36. } catch (e) {
  37. logger.e('ReportTemplateManager getReportTemplatePage ex:$e');
  38. return PageResult<ReportTemplateDTO>();
  39. }
  40. }
  41. @override
  42. Future<PageResult<ReportTemplateDTO>> getOrgReportTemplatePage({
  43. int pageIndex = 1,
  44. int pageSize = 100,
  45. String? keyword,
  46. }) async {
  47. var result = await rpc.report.getOrgReportTemplatePageAsync(
  48. FindReportTemplatePagesRequest(
  49. token: token,
  50. languageCode: i18nBook.locale.toCodeString('-'),
  51. reportTemplateName: keyword,
  52. pageIndex: pageIndex,
  53. pageSize: pageSize,
  54. ),
  55. );
  56. return result;
  57. }
  58. @override
  59. Future<ReportTemplateDTO> findReportTemplateByCode({String code = ''}) {
  60. return rpc.ultrasoundReport
  61. .vitalFindReportTemplateByCodeAsync(FindReportTemplateByCodeRequest(
  62. token: token,
  63. languageCode: i18nBook.locale.toCodeString('-'),
  64. reportTemplateCode: code,
  65. ));
  66. }
  67. }