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.

158 lines
6.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
  1. using Dapper;
  2. using Microsoft.Extensions.Configuration;
  3. using Npgsql;
  4. using Shentun.Utilities;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data.Common;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace Shentun.Peis.PlugIns
  12. {
  13. public class LisRequestPlugInsBase : ThirdPlugInsBase
  14. {
  15. protected Guid AsbitemColumnReferenceId;
  16. protected Guid SampleTypeColumnReferenceId;
  17. public LisRequestPlugInsBase(Guid thirdInterfaceId):base(thirdInterfaceId)
  18. {
  19. var asbitemColumnReferenceIdStr = InterfaceConfig.GetSection("Interface").GetSection("AsbitemColumnReferenceId").Value;
  20. if (!string.IsNullOrWhiteSpace(asbitemColumnReferenceIdStr))
  21. {
  22. AsbitemColumnReferenceId = new Guid(asbitemColumnReferenceIdStr);
  23. }
  24. var sampleTypeColumnReferenceIdStr = InterfaceConfig.GetSection("Interface").GetSection("SampleTypeColumnReferenceId").Value;
  25. if (!string.IsNullOrWhiteSpace(sampleTypeColumnReferenceIdStr))
  26. {
  27. SampleTypeColumnReferenceId = new Guid(sampleTypeColumnReferenceIdStr);
  28. }
  29. }
  30. public LisRequestPlugInsBase(string parmValue) : base(parmValue)
  31. {
  32. var asbitemColumnReferenceIdStr = InterfaceConfig.GetSection("Interface").GetSection("AsbitemColumnReferenceId").Value;
  33. if(!string.IsNullOrWhiteSpace(asbitemColumnReferenceIdStr))
  34. {
  35. AsbitemColumnReferenceId = new Guid(asbitemColumnReferenceIdStr);
  36. }
  37. var sampleTypeColumnReferenceIdStr = InterfaceConfig.GetSection("Interface").GetSection("SampleTypeColumnReferenceId").Value;
  38. if (!string.IsNullOrWhiteSpace(sampleTypeColumnReferenceIdStr))
  39. {
  40. SampleTypeColumnReferenceId = new Guid(sampleTypeColumnReferenceIdStr);
  41. }
  42. }
  43. public virtual async Task<LisRequestPlugInsOut> SendRequestAsync(LisRequestPlugInsInput input)
  44. {
  45. var result = new LisRequestPlugInsOut();
  46. return result;
  47. }
  48. public async Task<PatientRegisterForPlugIns> GetPatientRegisterForPlugInsAsync(Guid lisRequestId)
  49. {
  50. using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
  51. {
  52. string sql;
  53. sql = @"SELECT DISTINCT patient.id as patient_id,
  54. patient_register.id as patient_register_id,
  55. patient_register.patient_register_no,
  56. patient.patient_no ,
  57. patient_register.his_patient_id,
  58. patient_register.medical_center_id,
  59. patient_register.patient_name,
  60. patient_register.sex_id,
  61. patient_register.marital_status_id,
  62. patient_register.birth_date,
  63. patient_register.age,
  64. patient.nation_id,
  65. patient.id_no,
  66. patient.email,
  67. patient.telephone,
  68. patient.mobile_telephone,
  69. patient.address
  70. from patient,patient_register,lis_request,register_check_asbitem,register_check
  71. where patient.id = patient_register.patient_id and
  72. patient_register.id = register_check.patient_register_id and
  73. register_check.id = register_check_asbitem.register_check_id and
  74. register_check_asbitem.lis_request_id = lis_request.id and
  75. lis_request.id =@LisRequestId
  76. ";
  77. var patientRegisterForPlugIns = (await conn.QueryAsync<PatientRegisterForPlugIns>(sql,
  78. new { LisRequestId = lisRequestId })).SingleOrDefault();
  79. return patientRegisterForPlugIns;
  80. }
  81. }
  82. public async Task<LisRequestForPlugIns> GetLisRequestForPlugInsAsync(Guid lisRequestId)
  83. {
  84. using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
  85. {
  86. string sql;
  87. sql = @"SELECT DISTINCT lis_request.id as lis_request_id,
  88. lis_request.lis_request_no ,
  89. lis_request.is_print ,
  90. abp_users.name ,
  91. lis_request.sampling_time,
  92. lis_request.is_sign_in,
  93. lis_request.sign_in_order,
  94. lis_request.sign_in_person,
  95. lis_request.sign_in_time,
  96. sample_type.id as sample_type_id,
  97. sample_type.display_name as sample_type_name,
  98. sample_container.display_name as sample_container_name
  99. from patient_register
  100. JOIN register_check on patient_register.id = register_check.patient_register_id
  101. JOIN register_check_asbitem on register_check.id = register_check_asbitem.register_check_id
  102. JOIN lis_request on register_check_asbitem.lis_request_id = lis_request.id
  103. left JOIN abp_users on lis_request.sampler_id = abp_users.id
  104. JOIN sample_container ON lis_request.sample_container_id = sample_container.id
  105. join sample_type on lis_request.sample_type_id = sample_type.id
  106. where lis_request.id =@LisRequestId and
  107. patient_register.complete_flag <> '3' and
  108. register_check.complete_flag <> '1'
  109. ";
  110. var lisRequestForPlugIns = (await conn.QueryAsync<LisRequestForPlugIns>(sql,
  111. new { LisRequestId = lisRequestId })).SingleOrDefault();
  112. if (lisRequestForPlugIns == null)
  113. {
  114. return null;
  115. }
  116. sql = @"
  117. SELECT register_check_asbitem.asbitem_id,
  118. asbitem.display_name as asbitem_name,
  119. register_check_asbitem.amount * register_check_asbitem.charge_price as charges
  120. from register_check
  121. JOIN register_check_asbitem on register_check.id = register_check_asbitem.register_check_id
  122. JOIN lis_request on register_check_asbitem.lis_request_id = lis_request.id
  123. JOIN asbitem on register_check_asbitem.asbitem_id = asbitem.id
  124. where
  125. lis_request.id=@LisRequestId
  126. ";
  127. lisRequestForPlugIns.Asbitems = (await conn.QueryAsync<LisRequestAsbitemForPlugIns>(sql,
  128. new { LisRequestId = lisRequestId })).ToList();
  129. return lisRequestForPlugIns;
  130. }
  131. }
  132. }
  133. public class LisRequestPlugInsInput
  134. {
  135. public Guid LisRequestId { get; set; }
  136. }
  137. public class LisRequestPlugInsOut
  138. {
  139. public string? ThirdLisRequestId { get; set; }
  140. }
  141. }