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.

115 lines
4.3 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
  1. using Dapper;
  2. using Npgsql;
  3. using Shentun.Peis.ThirdInterfaces;
  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
  11. {
  12. public class ImportPacsResultPlugInsBase : ThirdPlugInsBase
  13. {
  14. public ImportPacsResultPlugInsBase(Guid thirdInterfaceId) : base(thirdInterfaceId)
  15. {
  16. }
  17. public ImportPacsResultPlugInsBase(string parmValue) : base(parmValue)
  18. {
  19. }
  20. public virtual async Task<ImportPacsResultPlugInsOut> ImportResultByPatientRegisterIdAsync(Guid patientRegisterId)
  21. {
  22. var result = new ImportPacsResultPlugInsOut();
  23. return result;
  24. }
  25. public async Task<List<PacsRequestForImportResultPlugIns>> GetPacsRequestForImportResultPlugInssAsync(Guid patientRegisterId)
  26. {
  27. using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
  28. {
  29. string sql;
  30. sql = @"
  31. SELECT distinct patient_register.patient_register_no,
  32. patient_register.patient_name,
  33. register_check.id ,
  34. register_check.check_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 asbitem on register_check_asbitem.asbitem_id = asbitem.id
  39. JOIN item_type on asbitem.item_type_id = item_type.id
  40. where patient_register.id = @PatientRegisterId and
  41. item_type.is_check_request = 'Y' and
  42. (patient_register.complete_flag = '0' or
  43. patient_register.complete_flag = '1' or
  44. patient_register.complete_flag = '2') and
  45. register_check.check_request_no <> ''
  46. ";
  47. var pacsRequestForResultImportPlugInss = (await conn.QueryAsync<PacsRequestForImportResultPlugIns>(sql,
  48. new { PatientRegisterId = patientRegisterId })).ToList();
  49. return pacsRequestForResultImportPlugInss;
  50. }
  51. }
  52. public async Task<List<PatientRegisterForLisRequest>> GetRequestPatientRegisters(int days)
  53. {
  54. using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
  55. {
  56. string sql;
  57. var startDate = DateTime.Now.Date.AddDays(-days);
  58. sql = @" SELECT distinct register_check.patient_register_id
  59. from patient_register
  60. JOIN register_check on patient_register.id = register_check.patient_register_id
  61. JOIN register_check_asbitem on register_check.id = register_check_asbitem.register_check_id
  62. JOIN asbitem on register_check_asbitem.asbitem_id = asbitem.id
  63. JOIN item_type on asbitem.item_type_id = item_type.id
  64. where
  65. item_type.is_check_request = 'Y' and
  66. (
  67. patient_register.complete_flag = '1' or
  68. patient_register.complete_flag = '2') and
  69. patient_register.medical_center_id =@MedicalCenterId and
  70. patient_register.medical_start_date >@StartDate and
  71. register_check.creation_time >@StartDate
  72. ORDER BY register_check.patient_register_id
  73. ";
  74. var patientRegisterForLisRequests = (await conn.QueryAsync<PatientRegisterForLisRequest>(sql,
  75. new { MedicalCenterId = _thirdInterfaceDto.MedicalCenterId, StartDate = startDate })).ToList();
  76. return patientRegisterForLisRequests;
  77. }
  78. }
  79. public override Task DoWork()
  80. {
  81. //var loginResult = LoginAsync().Result;
  82. var queryDaysStr = InterfaceConfig.GetSection("Interface").GetSection("Scheduler").GetSection("QueryDays").Value;
  83. if (string.IsNullOrWhiteSpace(queryDaysStr))
  84. {
  85. queryDaysStr = "1";
  86. }
  87. if (!int.TryParse(queryDaysStr, out int days))
  88. {
  89. days = 1;
  90. }
  91. var patientRegisters = GetRequestPatientRegisters(days).Result;
  92. foreach (var patientRegister in patientRegisters)
  93. {
  94. try
  95. {
  96. var result = ImportResultByPatientRegisterIdAsync(patientRegister.PatientRegisterId).Result;
  97. }
  98. catch (Exception ex)
  99. {
  100. }
  101. }
  102. return Task.CompletedTask;
  103. }
  104. }
  105. }