You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
4.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. using Dapper;
  2. using Npgsql;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data.Common;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace Shentun.Peis.PlugIns
  10. {
  11. public class ImportLisResultPlugInsBase : ThirdPlugInsBase
  12. {
  13. //protected string AppLisUser;
  14. //protected string AppLisPassword;
  15. public ImportLisResultPlugInsBase(string parmValue) : base(parmValue)
  16. {
  17. //AppLisUser = AppConfig.GetSection("App")
  18. // .GetSection("LisUser").Value;
  19. //AppLisPassword = AppConfig.GetSection("App")
  20. // .GetSection("LisPassword").Value;
  21. }
  22. public virtual async Task<ImportLisResultPlugInsOut> ImportResultAsync(ImportLisResultPlugInsInput input)
  23. {
  24. var result = new ImportLisResultPlugInsOut();
  25. return result;
  26. }
  27. public async Task<List<LisRequestForImportResultPlugIns>> GetLisRequestForImportResultPlugInssAsync(Guid patientRegisterId)
  28. {
  29. using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
  30. {
  31. string sql;
  32. sql = @"
  33. SELECT distinct lis_request.id ,
  34. lis_request.lis_request_no
  35. from patient_register
  36. JOIN register_check on patient_register.id = register_check.patient_register_id
  37. JOIN register_check_asbitem on register_check.id = register_check_asbitem.register_check_id
  38. JOIN lis_request on register_check_asbitem.lis_request_id = lis_request.id
  39. where patient_register.id = @PatientRegisterId
  40. ";
  41. var lisRequestForImportResultPlugInss = (await conn.QueryAsync<LisRequestForImportResultPlugIns>(sql,
  42. new { PatientRegisterId = patientRegisterId })).ToList();
  43. return lisRequestForImportResultPlugInss;
  44. }
  45. }
  46. public async Task<List<PatientRegisterForLisRequest>> GetRequestPatientRegisters(int days)
  47. {
  48. using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
  49. {
  50. string sql;
  51. var startDate = DateTime.Now.Date.AddDays(-days);
  52. sql = @" SELECT distinct register_check.patient_register_id
  53. from lis_request ,register_check_asbitem,register_check,patient_register
  54. WHERE lis_request.id = register_check_asbitem.lis_request_id and
  55. register_check_asbitem.register_check_id = register_check.id and
  56. register_check.patient_register_id = patient_register.id and
  57. (patient_register.complete_flag = '0' or
  58. patient_register.complete_flag = '1' or
  59. patient_register.complete_flag = '2') and
  60. lis_request.creation_time > @StartDate
  61. ORDER BY register_check.patient_register_id
  62. ";
  63. var patientRegisterForLisRequests = (await conn.QueryAsync<PatientRegisterForLisRequest>(sql,
  64. new { StartDate = startDate })).ToList();
  65. return patientRegisterForLisRequests;
  66. }
  67. }
  68. public override Task DoWork()
  69. {
  70. var loginResult = LoginAsync().Result;
  71. var queryDaysStr = InterfaceConfig.GetSection("Interface").GetSection("Scheduler").GetSection("QueryDays").Value;
  72. if (string.IsNullOrWhiteSpace(queryDaysStr))
  73. {
  74. queryDaysStr = "1";
  75. }
  76. if (!int.TryParse(queryDaysStr, out int days))
  77. {
  78. days = 1;
  79. }
  80. var patientRegisters = GetRequestPatientRegisters(days).Result;
  81. foreach (var patientRegister in patientRegisters)
  82. {
  83. try
  84. {
  85. var result = ImportResultAsync(new ImportLisResultPlugInsInput()
  86. {
  87. PatientRegisterId = patientRegister.PatientRegisterId,
  88. }).Result;
  89. }
  90. catch (Exception ex)
  91. {
  92. }
  93. }
  94. return Task.CompletedTask ;
  95. }
  96. //protected async override Task<LoginOutDto> LoginAsync()
  97. //{
  98. // var relult = await LoginAsync(AppLisUser, AppLisPassword);
  99. // return relult;
  100. //}
  101. }
  102. }