diff --git a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportLisResults/AiDiKang/GetReportItemListByCustomerBarocdeCGOut.cs b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportLisResults/AiDiKang/GetReportItemListByCustomerBarocdeCGOut.cs new file mode 100644 index 00000000..b50866bf --- /dev/null +++ b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportLisResults/AiDiKang/GetReportItemListByCustomerBarocdeCGOut.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Shentun.Peis.PlugIns.Extensions.ImportLisResults.AiDiKang +{ + + // 根节点对应的类 + [XmlRoot("NewDataSet")] + public class GetReportItemListByCustomerBarocdeCGOut + { + [XmlElement("item")] + public List Items { get; set; } + } + + // 每个item对应的类 + public class GetReportItemListByCustomerBarocdeCGItem + { + public string AdiconBarcode { get; set; } + public string PatientName { get; set; } + public string Sex { get; set; } + public string Age { get; set; } + public string AgeType { get; set; } + public string Department { get; set; } + public string BedNo { get; set; } + public string CollectionDate { get; set; } + public string ReceivedDate { get; set; } + public string LisDate { get; set; } + public string ReportDate { get; set; } + public string CustomerBarcode { get; set; } + public string Doctor { get; set; } + public string Technician { get; set; } + public string Checkedby { get; set; } + public string Remark { get; set; } + public string Instrument { get; set; } + public string SerialNumber { get; set; } + public string SampleType { get; set; } + public string ClinicalDiagnosis { get; set; } + public string ItemCode { get; set; } + public string ItemName_CN { get; set; } + public string ItemName_EN { get; set; } + public string Result { get; set; } + public string ResultHint { get; set; } + public string ResultHintJT { get; set; } + public string ResultReference { get; set; } + public string ResultUnit { get; set; } + public string TestMethod { get; set; } + public string TestMethod_EN { get; set; } + public string SampleChar { get; set; } + public string Result_Pathology { get; set; } + public string PatientNumber { get; set; } + public string PatientPhone { get; set; } + public string BirthDate { get; set; } + public string jyjs { get; set; } + public string Str1 { get; set; } + public string Str2 { get; set; } + public string Str3 { get; set; } + public string Str4 { get; set; } + public string Str5 { get; set; } + public string CustomRequestitemid { get; set; } + public string Customitemid { get; set; } + public string CriticalValueFlag { get; set; } + public string ItemPositiveFlag { get; set; } + public string CustomerPositiveFlag { get; set; } + public string Xmbh { get; set; } + public string Ybzt { get; set; } + public string Pdf { get; set; } + public string Sfzy { get; set; } + public string Bglxs { get; set; } + public string Zhmc { get; set; } + public string checkedbyid { get; set; } + public string technicianid { get; set; } + public string approverid { get; set; } + public string approver { get; set; } + public string meiNianClassify { get; set; } + public string sfzid { get; set; } + public string mutualRecognition { get; set; } + public string reportSumUp { get; set; } + public string Result_EN { get; set; } + public string ResultReference_EN { get; set; } + public string hasResultRechecked { get; set; } + } +} diff --git a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportLisResults/AiDiKang/ImportLisResultPlugInsAiDiKang.cs b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportLisResults/AiDiKang/ImportLisResultPlugInsAiDiKang.cs index c81b8ddc..f32aebab 100644 --- a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportLisResults/AiDiKang/ImportLisResultPlugInsAiDiKang.cs +++ b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ImportLisResults/AiDiKang/ImportLisResultPlugInsAiDiKang.cs @@ -89,13 +89,13 @@ namespace Shentun.Peis.PlugIns.Extensions.ImportLisResults.AiDiKang List itemCommonTableOuts = new List(); - List asbitemCommonTableOuts = new List(); + //List asbitemCommonTableOuts = new List(); string sql_item = $"select data_code as dian_code,display_name as item_id from common_table " + $" where common_table_type_id='{InterfaceConfig.GetSection("Interface").GetSection("ItemCommonTableTypeId").Value}' "; - string sql_asbitem = $"select data_code as dian_code,display_name as item_id from common_table " + - $" where common_table_type_id='{InterfaceConfig.GetSection("Interface").GetSection("AsbitemCommonTableTypeId").Value}' "; + //string sql_asbitem = $"select data_code as dian_code,display_name as item_id from common_table " + + // $" where common_table_type_id='{InterfaceConfig.GetSection("Interface").GetSection("AsbitemCommonTableTypeId").Value}' "; var result = new ImportLisResultPlugInsOut(); @@ -103,7 +103,7 @@ namespace Shentun.Peis.PlugIns.Extensions.ImportLisResults.AiDiKang using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) { itemCommonTableOuts = (await conn.QueryAsync(sql_item)).ToList(); - asbitemCommonTableOuts = (await conn.QueryAsync(sql_asbitem)).ToList(); + //asbitemCommonTableOuts = (await conn.QueryAsync(sql_asbitem)).ToList(); try @@ -132,136 +132,59 @@ namespace Shentun.Peis.PlugIns.Extensions.ImportLisResults.AiDiKang if (isCheck == "True") { //检查完 - - var sdsd = await client.GetJSONReportItemListByCustomerBarocdeAsync(barCode, aiDiKangKeyValue); - - var sdsd2 = await client.GetReportItemListByCustomerBarocdeAsync(aiDiKangKeyValue, barCode, "常规报告"); + var result_cg = await client.GetReportItemListByCustomerBarocdeAsync(aiDiKangKeyValue, barCode, "常规报告"); + var resultObj_cg = XmlHelper.DeserializeXml(result_cg); + + foreach (var li in lisResultFromInterfaces) + { + var dian_code = itemCommonTableOuts.FirstOrDefault(f => f.ItemId == li.ItemId); + if (dian_code != null) + { + if (resultObj_cg.Items != null && resultObj_cg.Items.Any()) + { + var dianResult = resultObj_cg.Items.FirstOrDefault(f => f.ItemCode == dian_code.DianCode); + if (dianResult != null) + { + DateTime collectionDate = DateTime.Now; + + if (DateTime.TryParse(dianResult.CollectionDate, out var itemCollectionDate)) + { + // 使用 collectionDate + collectionDate = itemCollectionDate; + } + + var createImportLisResultDto = new CreateImportLisResultDto() + { + LisRequestNo = li.LisRequestNo, + ItemId = Guid.Parse(li.ItemId), + ItemName = li.ItemName, + Result = dianResult.Result, + // Unit = lisResult.Unit, + // ReferenceRangeValue = lisResult.ReferenceRangeValue, + // CriticalRangeValue = lisResult.CriticalRangeValue, + // ResultStatusId = lisResult.ResultStatusId, + // ReportPrompt = lisResult.ReportPrompt, + CheckDoctorName = defaultCheckDoctorName, + //CheckDate = dianResult.ApproveDate, + CheckDate = collectionDate, + ExecOrganizationUnitId = Guid.Parse(execOrganizationUnitIdStr) + }; + createImportLisResultDtos.Add(createImportLisResultDto); + } + } + + + } + } + + + if (createImportLisResultDtos.Any()) + { + var callResult = await CallAppServiceAsync, object>("api/app/ImportLisResult/ImportResult", createImportLisResultDtos); + } } - ////病理结果 - //var result_bl = await client.GetDetailByHospCodeAsync(_clientID, _clientGUID, barCode, 1); - //var resultObj_bl = XmlHelper.DeserializeXmlAddRoot(result_bl.Body.GetDetailByHospCodeResult); - - //if (resultObj_bl.ResultsDataSet != null && resultObj_bl.ResultsDataSet.Tables.Count > 0 && string.IsNullOrWhiteSpace(barCodeDian)) - //{ - // barCodeDian = resultObj_bl.ResultsDataSet.Tables.FirstOrDefault().Barcode; - //} - //foreach (var li in lisResultFromInterfaces) - //{ - // var dian_code = itemCommonTableOuts.FirstOrDefault(f => f.ItemId == li.ItemId); - // if (dian_code != null) - // { - // if (resultObj_cg.ResultsDataSet != null) - // { - // var dianResult = resultObj_cg.ResultsDataSet.Tables.FirstOrDefault(f => f.S == dian_code.DianCode); - // if (dianResult != null) - // { - // var createImportLisResultDto = new CreateImportLisResultDto() - // { - // LisRequestNo = li.LisRequestNo, - // ItemId = Guid.Parse(li.ItemId), - // ItemName = li.ItemName, - // Result = dianResult.FinalResult, - // // Unit = lisResult.Unit, - // // ReferenceRangeValue = lisResult.ReferenceRangeValue, - // // CriticalRangeValue = lisResult.CriticalRangeValue, - // // ResultStatusId = lisResult.ResultStatusId, - // // ReportPrompt = lisResult.ReportPrompt, - // CheckDoctorName = defaultCheckDoctorName, - // //CheckDate = dianResult.ApproveDate, - // CheckDate = dianResult.CollectDate, - // ExecOrganizationUnitId = Guid.Parse(execOrganizationUnitIdStr) - // }; - // createImportLisResultDtos.Add(createImportLisResultDto); - // } - // } - - // if (resultObj_bl.ResultsDataSet != null) - // { - // var dianResult = resultObj_bl.ResultsDataSet.Tables.FirstOrDefault(f => f.TestCode == dian_code.DianCode); - // if (dianResult != null) - // { - // var createImportLisResultDto = new CreateImportLisResultDto() - // { - // LisRequestNo = li.LisRequestNo, - // ItemId = Guid.Parse(li.ItemId), - // ItemName = li.ItemName, - // Result = dianResult.Repidea, - // // Unit = lisResult.Unit, - // // ReferenceRangeValue = lisResult.ReferenceRangeValue, - // // CriticalRangeValue = lisResult.CriticalRangeValue, - // // ResultStatusId = lisResult.ResultStatusId, - // // ReportPrompt = lisResult.ReportPrompt, - // CheckDoctorName = defaultCheckDoctorName, - // // CheckDate = dianResult.ReportDate, - // CheckDate = dianResult.CollectDate, - // ExecOrganizationUnitId = Guid.Parse(execOrganizationUnitIdStr) - // }; - // createImportLisResultDtos.Add(createImportLisResultDto); - // } - // } - // } - //} - - //if (createImportLisResultDtos.Any()) - //{ - // var callResult = await CallAppServiceAsync, object>("api/app/ImportLisResult/ImportResult", createImportLisResultDtos); - //} - - ////导入图片 - //using (var clientReport = CreateReportClient(lisReportAddress)) - //{ - // var result_report = await clientReport.GetReportInfoAsync(_clientID, _clientGUID, barCodeDian, "0"); - // var resultObj_report = XmlHelper.DeserializeXmlAddRoot(result_report.Body.GetReportInfoResult); - // if (resultObj_report.Msg.Code == "1" && resultObj_report.ResultsDataSetReport != null && resultObj_report.ResultsDataSetReport.Tables.Any()) - // { - - // var ImportReportInputs = new List(); - - // foreach (var itemReport in resultObj_report.ResultsDataSetReport.Tables) - // { - // var base64str = ToBase64(itemReport.PicReportUrl); - // var asbitemIds = asbitemCommonTableOuts.Where(m => m.DianCode == itemReport.TestCode).ToList(); - // if (asbitemIds.Any()) - // { - // string sql_register_check_id = "select distinct b.id as register_check_id from patient_register as a " + - // " left join register_check as b on a.id=b.patient_register_id " + - // " left join register_check_asbitem as c on b.id=c.register_check_id " + - // $" where a.id='{patientRegisterId}' and c.asbitem_id=ANY(@asbitemIds) "; - // var registerCheckIds = (await conn.QueryAsync(sql_register_check_id, new - // { - // asbitemIds = asbitemIds.Select(s => Guid.Parse(s.ItemId)).ToArray() - // })).ToList(); - // foreach (var registerCheckId in registerCheckIds) - // { - // List pictureBaseStrs = new List(); - // pictureBaseStrs.Add(new UploadRegisterCheckPictureManyPictureBaseStrsDto - // { - // PictureBaseStr = base64str, - // FileName = itemReport.TestCode, - // IsPrint = 'Y' - // }); - - // ImportReportInputs.Add(new UploadRegisterCheckPictureManyDto - // { - // PictureBaseStrs = pictureBaseStrs, - // PictureFileType = '0', - // RegisterCheckId = registerCheckId.RegisterCheckId - // }); - // } - - - // } - - // } - - // foreach (var importReportInput in ImportReportInputs) - // { - // var callResult = await CallAppServiceAsync("api/app/registercheckpicture/uploadregistercheckpicturemany", importReportInput); - // } - - // } - //} + } catch (Exception ex) @@ -281,7 +204,27 @@ namespace Shentun.Peis.PlugIns.Extensions.ImportLisResults.AiDiKang private AdiconWebServiceSoapClient CreateClient(string url) { - return new AdiconWebServiceSoapClient(new BasicHttpBinding(), + // 创建自定义绑定,设置更大的消息大小限制 + var binding = new BasicHttpBinding(); + + // 设置最大接收消息大小(根据需要调整,建议先设为 10MB) + binding.MaxReceivedMessageSize = 10485760; // 10MB = 10 * 1024 * 1024 + binding.MaxBufferSize = 10485760; // 必须与 MaxReceivedMessageSize 保持一致 + + // 设置 ReaderQuotas 以支持大字符串和大数组 + binding.ReaderQuotas.MaxDepth = 2147483647; + binding.ReaderQuotas.MaxStringContentLength = 10485760; + binding.ReaderQuotas.MaxArrayLength = 10485760; + binding.ReaderQuotas.MaxBytesPerRead = 10485760; + binding.ReaderQuotas.MaxNameTableCharCount = 10485760; + + // 可选:增加超时时间(因为大数据传输需要更长时间) + binding.SendTimeout = TimeSpan.FromMinutes(5); + binding.ReceiveTimeout = TimeSpan.FromMinutes(5); + binding.OpenTimeout = TimeSpan.FromMinutes(5); + binding.CloseTimeout = TimeSpan.FromMinutes(1); + + return new AdiconWebServiceSoapClient(binding, new EndpointAddress(url)); } diff --git a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/XmlHelper.cs b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/XmlHelper.cs index 2ba7d918..c36d84f2 100644 --- a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/XmlHelper.cs +++ b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/XmlHelper.cs @@ -76,5 +76,7 @@ namespace Shentun.Peis.PlugIns.Extensions return xml; } } + + } }