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.

155 lines
6.5 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
1 year ago
2 years ago
2 years ago
2 years ago
1 year 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
2 years ago
2 years ago
1 year 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
2 years 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
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
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
2 years ago
2 years ago
  1. using Dapper;
  2. using Microsoft.Data.SqlClient;
  3. using Newtonsoft.Json;
  4. using Npgsql;
  5. using NPOI.Util;
  6. using NUglify.Helpers;
  7. using Oracle.ManagedDataAccess.Client;
  8. using Shentun.Peis.ImportLisResults;
  9. using Shentun.Peis.LisRequests;
  10. using Shentun.Utilities;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Data.Common;
  14. using System.Linq;
  15. using System.Net.Http.Headers;
  16. using System.Security.Policy;
  17. using System.Text;
  18. using System.Threading.Tasks;
  19. namespace Shentun.Peis.PlugIns.ImportLisResults
  20. {
  21. public class ImportLisResultPlugInsDbBase : ImportLisResultPlugInsBase
  22. {
  23. public ImportLisResultPlugInsDbBase(Guid thirdInterfaceId) : base(thirdInterfaceId)
  24. {
  25. }
  26. public ImportLisResultPlugInsDbBase(string parmValue) : base(parmValue)
  27. {
  28. }
  29. public override async Task<ImportLisResultPlugInsOut> ImportResultByPatientRegisterIdAsync(Guid patientRegisterId)
  30. {
  31. if (ItemColumnReferenceId == null || ItemColumnReferenceId == Guid.Empty)
  32. {
  33. throw new Exception("没有设置项目编码对照");
  34. }
  35. var result = new ImportLisResultPlugInsOut();
  36. var execOrganizationUnitIdStr = InterfaceConfig.GetSection("Interface").GetSection("ExecOrganizationUnitId").Value;
  37. if (string.IsNullOrWhiteSpace(execOrganizationUnitIdStr))
  38. {
  39. throw new Exception("执行科室配置不能为空");
  40. }
  41. if (!Guid.TryParse(execOrganizationUnitIdStr, out Guid execOrganizationUnitId))
  42. {
  43. throw new Exception("执行科室配置不是有效的GUID值");
  44. }
  45. var lisRequests = await GetLisRequestForImportResultPlugInssAsync(patientRegisterId);
  46. using (DbConnection conn = CreateInterfaceDbConnect())
  47. {
  48. //设置结果,生成小结
  49. //await LoginAsync();
  50. var createImportLisResultDtos = new List<CreateImportLisResultDto>();
  51. foreach (var lisRequest in lisRequests)
  52. {
  53. //if (lisRequest.LisRequestNo == "2405090117")
  54. //{
  55. // ;
  56. //}
  57. createImportLisResultDtos.Clear();
  58. string sql;
  59. sql = InterfaceSql + " where " + InterfaceSqlKeyColumn + " = '" + lisRequest.LisRequestNo + "'";
  60. var lisResultFromInterfaces = (await conn.QueryAsync<LisResultFromImportInterface>(sql)).ToList();
  61. try
  62. {
  63. foreach (var lisResult in lisResultFromInterfaces)
  64. {
  65. if (string.IsNullOrWhiteSpace(lisResult.Result))
  66. {
  67. continue;
  68. }
  69. if (string.IsNullOrWhiteSpace(lisResult.ItemId))
  70. {
  71. throw new Exception("第三方接口数据项目编码不能为空");
  72. }
  73. if (string.IsNullOrWhiteSpace(lisResult.ItemName))
  74. {
  75. throw new Exception("第三方接口数据项目名称不能为空");
  76. }
  77. if (string.IsNullOrWhiteSpace(lisResult.CheckDoctorName))
  78. {
  79. throw new Exception("检验医生不能为空");
  80. }
  81. //if(lisResult.ItemId == "435")
  82. //{
  83. // ;
  84. //}
  85. var columnReferenceCodes = await GetColumnReferenceCodeValuesAsync(ItemColumnReferenceId, lisResult.ItemId);
  86. if (columnReferenceCodes == null || !columnReferenceCodes.Any())
  87. {
  88. //throw new Exception($"LIS系统中项目名:{lisResult.ItemName} 编码:{lisResult.ItemId}没有与体检系统对照编码");
  89. continue;
  90. }
  91. foreach (var columnReferenceCode in columnReferenceCodes)
  92. {
  93. if (string.IsNullOrWhiteSpace(columnReferenceCode.CodeValue))
  94. {
  95. continue;
  96. }
  97. if (!Guid.TryParse(columnReferenceCode.CodeValue, out var appItemId))
  98. {
  99. throw new Exception($"{lisResult.ItemName}对照的编码无效");
  100. }
  101. var createImportLisResultDto = new CreateImportLisResultDto()
  102. {
  103. LisRequestNo = lisResult.LisRequestNo,
  104. ItemId = appItemId,
  105. ItemName = lisResult.ItemName,
  106. Result = lisResult.Result,
  107. Unit = lisResult.Unit,
  108. ReferenceRangeValue = lisResult.ReferenceRangeValue,
  109. CriticalRangeValue = lisResult.CriticalRangeValue,
  110. ResultStatusId = lisResult.ResultStatusId,
  111. ReportPrompt = lisResult.ReportPrompt,
  112. CheckDoctorName = lisResult.CheckDoctorName,
  113. CheckDate = lisResult.CheckDate,
  114. ExecOrganizationUnitId = execOrganizationUnitId
  115. };
  116. createImportLisResultDtos.Add(createImportLisResultDto);
  117. }
  118. }
  119. if (!createImportLisResultDtos.Any())
  120. {
  121. continue;
  122. }
  123. var callResult = await CallAppServiceAsync<List<CreateImportLisResultDto>, object>("api/app/ImportLisResult/ImportResult", createImportLisResultDtos);
  124. }
  125. catch (Exception ex)
  126. {
  127. //throw ex;
  128. }
  129. }
  130. }
  131. return result;
  132. }
  133. }
  134. }