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.

117 lines
4.3 KiB

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