Browse Source

合单互认解决,循环医嘱在前 控制循序次数,多单互认检查 代码优化

zackhua 5 months ago
parent
commit
9be052bc69

+ 126 - 227
LisPacsDataUpload/Form1.cs

@@ -6,7 +6,6 @@ using LisPacsDataUpload.Models;
 using LisPacsDataUpload.services;
 using Newtonsoft.Json;
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.Data;
 using System.Drawing;
@@ -281,14 +280,14 @@ namespace LisPacsDataUpload
                 th.Name = name;
                 th.Start(name);
                 System.Threading.Thread.Sleep(5000);
-                string name2 = "LIS2" + Tools.GuidTo16String();
+                string name2 = "LIS1" + Tools.GuidTo16String();
                 Thread th2 = new Thread(new ParameterizedThreadStart(LisUpload));
                 th2.IsBackground = true;
                 th2.Name = name2;
                 th2.Start(name2);
 
                 System.Threading.Thread.Sleep(5000);
-                string namecompletUpload = "LIS2" + Tools.GuidTo16String();
+                string namecompletUpload = "LisCompletUpload" + Tools.GuidTo16String();
                 Thread thredcompletUpload = new Thread(new ParameterizedThreadStart(LisCompletUpload));
                 thredcompletUpload.IsBackground = true;
                 thredcompletUpload.Name = namecompletUpload;
@@ -298,7 +297,7 @@ namespace LisPacsDataUpload
                 if (1 == open_multiple_upload_flag)
                 {
                     System.Threading.Thread.Sleep(5000);
-                    string name3 = "LIS3" + Tools.GuidTo16String();
+                    string name3 = "LIS2" + Tools.GuidTo16String();
                     Thread th3 = new Thread(new ParameterizedThreadStart(LisUpload2));
                     th3.IsBackground = true;
                     th3.Name = name3;
@@ -425,7 +424,7 @@ namespace LisPacsDataUpload
                     if (zlhr == zlhrConstant_true)
                     {
                         lis_sql = @"Select t.* from lis_upload t  Where t.attachmentId Is Null
-                                                       Order By to_date(t.AUDITTIME,'yyyy-mm-dd hh24:mi:ss') limit 100";
+                                                       Order By t.AUDITTIME desc limit 100";
                         dt = OracleHelper<object>.PgQueryDS(lis_sql);
                     }
                     else
@@ -446,19 +445,21 @@ namespace LisPacsDataUpload
                         int uploaded = 0;
                         for (int i = 0; i < dt.Rows.Count; i++)
                         {
+                            string requestId = dt.Rows[i]["requestId"].ToString();
+                            
                             //生成pdf
                             string generatePdfUrl = "未生成pdf成功";
                             if (zlhr == zlhrConstant_true)
                             {
-                                string requestId = dt.Rows[i]["requestId"].ToString(); // 临生免报告id
+                                // 临生免报告id  requestId
                                 string sql_zlhr = @"select dr.id as id  from specimen_rec sr, diagnosticreport_rec dr where sr.id = dr.specmids::int
                                   and  dr.status  in ('3003', '3004') and  sr.id = " + requestId;
                                 DataTable dt_lis = OracleHelper<object>.PgQueryDS(sql_zlhr);
-                                string reportId = dt_lis.Rows[0]["id"].ToString();
-                                generatePdfUrl = PdfUtils.GeneratePdf(lisSource, reportId, reportId,null);
+                                string id = dt_lis.Rows[0]["id"].ToString();
+                                generatePdfUrl = PdfUtils.GeneratePdf(lisSource, id, id, null);
                             }
                             else if(lisSource==3){
-                                string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
+                                 // 申请id requestId
                                 generatePdfUrl = PdfUtils.GeneratePdf(lisSource, requestId, requestId,null);
                                 if (!generatePdfUrl.Contains(".pdf"))
                                 {
@@ -470,9 +471,8 @@ namespace LisPacsDataUpload
                             }
                             else if (lisSource == 10)
                             {
-                                string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
+                                 // 申请id requestId
                                 string pdfUrl = dt.Rows[i]["pdfUrl"].ToString(); // 三方pdf地址 需要下载
-
                                 generatePdfUrl = PdfUtils.GeneratePdf(lisSource, pdfUrl, requestId,null);
                                 if (string.IsNullOrEmpty(generatePdfUrl))
                                 {
@@ -484,9 +484,10 @@ namespace LisPacsDataUpload
                             }
                             else
                             {
-                                string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
+                                // 申请id requestId
                                 //获取标本号 和报表编号
-                                string reportNumber = dt.Rows[i]["reportNumber"].ToString(); //报告编号
+                                //报告编号  reportNumber
+                                string reportNumber = dt.Rows[i]["reportNumber"].ToString();
                                 string bbid = dt.Rows[i]["bbid"].ToString();   // 标本id
                                 generatePdfUrl = PdfUtils.GeneratePdf(lisSource, reportNumber, bbid, requestId);
                                 if (!generatePdfUrl.Contains(".pdf"))
@@ -514,6 +515,7 @@ namespace LisPacsDataUpload
                             }
                             else
                             {
+                                LogHelper.Info("generatePdfUrl=" + generatePdfUrl);
                                 attachmentFile = Tools.FileToBase64Str(generatePdfUrl);
                             }
                             //LogHelper.Info("上传的文件类容==" + attachmentFile);
@@ -532,7 +534,6 @@ namespace LisPacsDataUpload
                             {
 
                                 //写入后台表机构记录上传错误的数据
-
                                 string errSql = @"Insert Into 互认报告上传异常记录(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,REQUEST_DATA,IV,UPLOADED,UPLOADE_TIME) Values('{0}','{1}',2,'{2}',{3},{4},0,to_date('{5}','yyyy/mm/dd hh24:mi:ss'))";
                                 errSql = string.Format(errSql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString(), null, file_json, file_vi, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                                 int err_count = 0;
@@ -584,7 +585,8 @@ namespace LisPacsDataUpload
                             }
                             pdfcountAll += 1;
 
-
+                            string businessNumber = dt.Rows[i]["businessNumber"].ToString();
+                            string reportId = dt.Rows[i]["reportId"].ToString();
                             //上传lis数据
                             string item_sql = @"select  a.orgCode,
                                                         a.orgName,
@@ -647,7 +649,7 @@ namespace LisPacsDataUpload
                                                         a.reportorName,
                                                         a.sampleNotes,
                                                         a.checkPrice,
-                                                        a.attachmentId,
+                                                        b.attachmentId,
                                                         a.patientId ,
                                                         a.healthNo ,
                                                         a.medicareNo ,
@@ -667,7 +669,7 @@ namespace LisPacsDataUpload
                                                            and b.type = 2
                                                            and a.BUSINESSNUMBER = '{0}'
                                                            and a.REPORTID = '{1}'";
-                            item_sql = string.Format(item_sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString());
+                            item_sql = string.Format(item_sql, businessNumber, reportId);
                             List<LIS> list = new List<LIS>();
                             if (zlhr == zlhrConstant_true)
                             {
@@ -730,11 +732,9 @@ namespace LisPacsDataUpload
                             }
                             catch (Exception e)
                             {
-
                                 //写入后台表机构记录上传错误的数据
-
                                 string errSql = @"Insert Into 互认报告上传异常记录(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,REQUEST_DATA,IV,UPLOADED,UPLOADE_TIME) Values('{0}','{1}',2,'{2}',{3},{4},0,to_date('{5}','yyyy/mm/dd hh24:mi:ss'))";
-                                errSql = string.Format(errSql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString(), resfile.mainBody.attachmentId, json_pacs, vi_pacs, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
+                                errSql = string.Format(errSql, businessNumber, reportId, resfile.mainBody.attachmentId, json_pacs, vi_pacs, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                                 int err_count = 0;
                                 if (zlhr == zlhrConstant_true)
                                 {
@@ -748,15 +748,13 @@ namespace LisPacsDataUpload
                                 LogHelper.Info("写入后台表机构记录上传错误的数据" + err_count);
                                 LogHelper.Info( e.Message);
                                 continue;
-
                             }
-
                             string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
                             ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
-                            LogHelper.Info("上传检验报告的接口状态==" + JsonConvert.SerializeObject(respacs));
+                            LogHelper.Info(reportId+":lis1上传检验报告的接口状态==" + JsonConvert.SerializeObject(respacs));
                             if (respacs.statusCode != "1")
                             {
-                                ShowLog = respacs.message + ",[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs;
+                                ShowLog = respacs.message + ",[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:reportId=" + reportId;
                                 this.SetText(ShowLog);
                                 LogHelper.Info(ShowLog);
                                 LogHelper.Info("[LIS]出错入参:" + json_pacs_log);
@@ -805,85 +803,7 @@ namespace LisPacsDataUpload
                     this.SetText(ShowLog);
                     this.SetText("补传失败lis数据开始");
                     int count_pc = 0;
-                    string pc_sql = @"select  a.orgCode,
-                                                    a.orgName,
-                                                    a.orgThrdCode,
-                                                    a.reportId,
-                                                    a.reportName,
-                                                    a.requestId,
-                                                    a.barcode,
-                                                    a.sampleNo,
-                                                    a.businessNumber,
-                                                    a.patientType,
-                                                    a.patientName,
-                                                    a.patientSex,
-                                                    a.patientBirthday,
-                                                    a.patientAge,
-                                                    a.ageUnit,
-                                                    a.patientIdCard,
-                                                    a.inpatientAreaName,
-                                                    a.roomNo,
-                                                    a.bedNo,
-                                                    a.phoneNo,
-                                                    a.address,
-                                                    a.reportType,
-                                                    a.reportTypeName,
-                                                    a.sampCode,
-                                                    a.sampName,
-                                                    a.diagnosisCode,
-                                                    a.diagnosisName,
-                                                    a.resultType,
-                                                    a.applyTime,
-                                                    a.applyerCode,
-                                                    a.applyerName,
-                                                    a.applyDeptCode,
-                                                    a.applyDeptName,
-                                                    a.collectTime,
-                                                    a.collectCode,
-                                                    a.collectName,
-                                                    a.transportCode,
-                                                    a.transportName,
-                                                    a.transportDeptCode,
-                                                    a.transportDeptName,
-                                                    a.transportOrgCode,
-                                                    a.transportOrgName,
-                                                    a.acceptTime,
-                                                    a.acceptorCode,
-                                                    a.acceptorName,
-                                                    a.receiveTime,
-                                                    a.receiverCode,
-                                                    a.receiverName,
-                                                    a.checkTime,
-                                                    a.checkerCode,
-                                                    a.checkerName,
-                                                    a.checkDeptCode,
-                                                    a.checkDeptName,
-                                                    a.auditTime,
-                                                    a.auditorCode,
-                                                    a.auditorName,
-                                                    a.reportTime,
-                                                    a.reportorCode,
-                                                    a.reportorName,
-                                                    a.sampleNotes,
-                                                    a.checkPrice,
-                                                    a.attachmentId,
-                                                    a.patientId ,
-                                                    a.healthNo ,
-                                                    a.medicareNo ,
-                                                    a.socialNo ,
-                                                    a.inpatientAreaCode ,
-                                                    a.sampleName ,
-                                                    a.execHospitalCode ,
-                                                    a.execHospitalName,
-                                                    a.sameHospital,
-                                                    a.projectCode,
-                                                    a.projectName
-                                                    from lis_upload a ,已上传PDF b 
-                                                       where b.businessnumber = a.BUSINESSNUMBER 
-                                                       and b.reportid = a.REPORTID 
-                                                       and b.attachmentid is not null
-                                                       and b.uploaded = 0
-                                                       and b.type = 2 ";
+                    string pc_sql = @"select * from lis_complet_upload ";
                     LogHelper.Info("补传lis数据执行sql:" + pc_sql);
                     List<LIS> list_pc = new List<LIS>();
                     if (zlhr == zlhrConstant_true)
@@ -970,14 +890,12 @@ namespace LisPacsDataUpload
                             LogHelper.Info("写入后台表机构记录上传错误的数据" + err_count);
                             LogHelper.Info(e.Message);
                             continue;
-
                         }
-
                         string res_aes_pacs_pc = Tools.AESDecrypt(res_pacs_pc, Tools.pwd, vi_pacs_pc);
                         ResPacs respacs_pc = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs_pc), Encoding.UTF8);
                         if (respacs_pc.statusCode != "1")
                         {
-                            ShowLog = respacs_pc.message + ",补传[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs_pc;
+                            ShowLog = respacs_pc.message + ",补传[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:reportId=" + list_pc[i].REPORTID;
                             this.SetText(ShowLog);
                             LogHelper.Info(ShowLog);
                             LogHelper.Info("[LIS]出错入参:" + json_pacs_log_pc);
@@ -1048,85 +966,7 @@ namespace LisPacsDataUpload
                     this.SetText(ShowLog);
                     this.SetText("补传失败lis数据开始");
                     int count_pc = 0;
-                    string pc_sql = @"select  a.orgCode,
-                                                    a.orgName,
-                                                    a.orgThrdCode,
-                                                    a.reportId,
-                                                    a.reportName,
-                                                    a.requestId,
-                                                    a.barcode,
-                                                    a.sampleNo,
-                                                    a.businessNumber,
-                                                    a.patientType,
-                                                    a.patientName,
-                                                    a.patientSex,
-                                                    a.patientBirthday,
-                                                    a.patientAge,
-                                                    a.ageUnit,
-                                                    a.patientIdCard,
-                                                    a.inpatientAreaName,
-                                                    a.roomNo,
-                                                    a.bedNo,
-                                                    a.phoneNo,
-                                                    a.address,
-                                                    a.reportType,
-                                                    a.reportTypeName,
-                                                    a.sampCode,
-                                                    a.sampName,
-                                                    a.diagnosisCode,
-                                                    a.diagnosisName,
-                                                    a.resultType,
-                                                    a.applyTime,
-                                                    a.applyerCode,
-                                                    a.applyerName,
-                                                    a.applyDeptCode,
-                                                    a.applyDeptName,
-                                                    a.collectTime,
-                                                    a.collectCode,
-                                                    a.collectName,
-                                                    a.transportCode,
-                                                    a.transportName,
-                                                    a.transportDeptCode,
-                                                    a.transportDeptName,
-                                                    a.transportOrgCode,
-                                                    a.transportOrgName,
-                                                    a.acceptTime,
-                                                    a.acceptorCode,
-                                                    a.acceptorName,
-                                                    a.receiveTime,
-                                                    a.receiverCode,
-                                                    a.receiverName,
-                                                    a.checkTime,
-                                                    a.checkerCode,
-                                                    a.checkerName,
-                                                    a.checkDeptCode,
-                                                    a.checkDeptName,
-                                                    a.auditTime,
-                                                    a.auditorCode,
-                                                    a.auditorName,
-                                                    a.reportTime,
-                                                    a.reportorCode,
-                                                    a.reportorName,
-                                                    a.sampleNotes,
-                                                    a.checkPrice,
-                                                    a.attachmentId,
-                                                    a.patientId ,
-                                                    a.healthNo ,
-                                                    a.medicareNo ,
-                                                    a.socialNo ,
-                                                    a.inpatientAreaCode ,
-                                                    a.sampleName ,
-                                                    a.execHospitalCode ,
-                                                    a.execHospitalName,
-                                                    a.sameHospital,
-                                                    a.projectCode,
-                                                    a.projectName
-                                                    from lis_upload a ,已上传PDF b 
-                                                       where b.businessnumber = a.BUSINESSNUMBER 
-                                                       and b.reportid = a.REPORTID 
-                                                       and b.attachmentid is not null
-                                                       and b.uploaded = 0
-                                                       and b.type = 2 ";
+                    string pc_sql = @"select * from lis_complet_upload  ";
                     LogHelper.Info("补传lis数据执行sql:" + pc_sql);
                     List<LIS> list_pc = new List<LIS>();
                     if (zlhr == zlhrConstant_true)
@@ -1215,7 +1055,7 @@ namespace LisPacsDataUpload
                         ResPacs respacs_pc = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs_pc), Encoding.UTF8);
                         if (respacs_pc.statusCode != "1")
                         {
-                            ShowLog = respacs_pc.message + ",补传[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs_pc;
+                            ShowLog = respacs_pc.message + ",补传[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:REPORTID=" + list_pc[i].REPORTID;
                             this.SetText(ShowLog);
                             LogHelper.Info(ShowLog);
                             LogHelper.Info("[LIS]出错入参:" + json_pacs_log_pc);
@@ -1267,9 +1107,6 @@ namespace LisPacsDataUpload
             {
                 LogHelper.Error(ex);
             }
-
-
-
         }
 
         private void HandleLisItemDataForWebLis(List<LISITEMS> items)
@@ -1368,21 +1205,24 @@ namespace LisPacsDataUpload
                         int uploaded = 0;
                         for (int i = 0; i < dt.Rows.Count; i++)
                         {
+                            string businessNumber = dt.Rows[i]["businessNumber"].ToString();
+                            string reportId = dt.Rows[i]["reportId"].ToString();
 
+                            string requestId = dt.Rows[i]["requestId"].ToString();
                             //生成pdf
                             string generatePdfUrl = "未生成pdf成功";
                             if (zlhr == zlhrConstant_true)
                             {
-                                string requestId = dt.Rows[i]["requestId"].ToString(); // 临生免报告id
+                                // 临生免报告id requestId
                                 string sql_zlhr = @"select dr.id as id  from specimen_rec sr, diagnosticreport_rec dr where sr.id = dr.specmids::int
                                   and  dr.status  in ('3003', '3004') and  sr.id = " + requestId;
                                 DataTable dt_lis = OracleHelper<object>.PgQueryDS(sql_zlhr);
-                                string reportId = dt_lis.Rows[0]["id"].ToString();
-                                generatePdfUrl = PdfUtils.GeneratePdf(lisSource, reportId, reportId,null);
+                                string id = dt_lis.Rows[0]["id"].ToString();
+                                generatePdfUrl = PdfUtils.GeneratePdf(lisSource, id, id, null);
                             }
                             else if (lisSource == 3)
                             {
-                                string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
+                                 // 申请id requestId
                                 generatePdfUrl = PdfUtils.GeneratePdf(lisSource, requestId, requestId, null);
                                 if (!generatePdfUrl.Contains(".pdf"))
                                 {
@@ -1394,9 +1234,8 @@ namespace LisPacsDataUpload
                             }
                             else if (lisSource == 10)
                             {
-                                string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
+                                // 申请id requestId 
                                 string pdfUrl = dt.Rows[i]["pdfUrl"].ToString(); // 三方pdf地址 需要下载
-
                                 generatePdfUrl = PdfUtils.GeneratePdf(lisSource, pdfUrl, requestId, null);
                                 if (string.IsNullOrEmpty(generatePdfUrl))
                                 {
@@ -1408,7 +1247,7 @@ namespace LisPacsDataUpload
                             }
                             else
                             {
-                                string requestId = dt.Rows[i]["requestId"].ToString(); // 申请id
+                                // 申请id requestId
                                 //获取标本号 和报表编号
                                 string reportNumber = dt.Rows[i]["reportNumber"].ToString(); //报告编号
                                 string bbid = dt.Rows[i]["bbid"].ToString();   // 标本id
@@ -1422,7 +1261,6 @@ namespace LisPacsDataUpload
                                 }
                                 LogHelper.Info("生成pdf成功,地址为 = " + generatePdfUrl);
                             }
-                           
                             //是否授权
                             if (!isAuthorization())
                             {
@@ -1454,7 +1292,7 @@ namespace LisPacsDataUpload
                                 LogHelper.Info("写入后台表机构记录上传错误的数据");
                                 //写入后台表机构记录上传错误的数据
                                 string errSql = @"Insert Into 互认报告上传异常记录(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,REQUEST_DATA,IV,UPLOADED,UPLOADE_TIME) Values('{0}','{1}',2,'{2}',{3},{4},0,to_date('{5}','yyyy/mm/dd hh24:mi:ss'))";
-                                errSql = string.Format(errSql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString(), null, file_json, file_vi, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
+                                errSql = string.Format(errSql, businessNumber, reportId, null, file_json, file_vi, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                                 int err_count = 0;
                                 if (zlhr == zlhrConstant_true)
                                 {
@@ -1474,15 +1312,15 @@ namespace LisPacsDataUpload
                             ResFile resfile = Tools.JsonToObject<ResFile>(Tools.FormatStr(file_res_aes), Encoding.UTF8);
                             if (resfile.statusCode != "1")
                             {
-                                LogHelper.Info(resfile.message + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。thread2 ");
+                                LogHelper.Info(resfile.message + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。thread2 reportId="+ reportId);
                                 LogHelper.Info("入参:" + file_json);
                                 LogHelper.Info("出参:" + file_res_aes);
-                                ShowLog = "入参:" + file_json + ",出参:" + file_res_aes + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。";
+                                ShowLog = "入参:" + file_json + ",出参:" + file_res_aes + ",[LIS]PDF文件上传失败!跳过本条数据上传下一条。" + reportId;
                                 this.SetText(ShowLog);
                                 continue;
                             }
                             string sql = @"Insert Into 已上传PDF(BUSINESSNUMBER,REPORTID,TYPE,ATTACHMENTID,UPLOADED,UPLOADE_TIME) Values('{0}','{1}',2,'{2}',0,to_date('{3}','yyyy/mm/dd hh24:mi:ss'))";
-                            sql = string.Format(sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString(), resfile.mainBody.attachmentId, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
+                            sql = string.Format(sql, businessNumber, reportId, resfile.mainBody.attachmentId, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                             int file_count = 0;
                             if (zlhr==zlhrConstant_true)
                             {
@@ -1502,7 +1340,6 @@ namespace LisPacsDataUpload
                             }
                             pdfcountAll += 1;
 
-
                             //上传lis数据
                             string item_sql = @"select  a.orgCode,
                                                         a.orgName,
@@ -1565,7 +1402,7 @@ namespace LisPacsDataUpload
                                                         a.reportorName,
                                                         a.sampleNotes,
                                                         a.checkPrice,
-                                                        a.attachmentId,
+                                                        b.attachmentId,
                                                         a.patientId ,
                                                         a.healthNo ,
                                                         a.medicareNo ,
@@ -1585,7 +1422,7 @@ namespace LisPacsDataUpload
                                                            and b.type = 2
                                                            and a.BUSINESSNUMBER = '{0}'
                                                            and a.REPORTID = '{1}'";
-                            item_sql = string.Format(item_sql, dt.Rows[i]["businessNumber"].ToString(), dt.Rows[i]["reportId"].ToString());
+                            item_sql = string.Format(item_sql, businessNumber, reportId);
                             List<LIS> list = new List<LIS>();
                             if (zlhr==zlhrConstant_true)
                             {
@@ -1671,9 +1508,10 @@ namespace LisPacsDataUpload
                             }
                             string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
                             ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
+                            LogHelper.Info(reportId + ":lis2上传检验报告的接口状态==" + JsonConvert.SerializeObject(respacs));
                             if (respacs.statusCode != "1")
                             {
-                                ShowLog = respacs.message + ",thread2 ,[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:" + vi_pacs;
+                                ShowLog = respacs.message + ",thread2 ,[LIS]数据上传异常!跳过本条数据上传下一条,偏移量为:REPORTID=" + list[0].REPORTID;
                                 this.SetText(ShowLog);
                                 LogHelper.Info(ShowLog);
                                 LogHelper.Info("thread2  [LIS]出错入参:" + json_pacs_log);
@@ -1707,7 +1545,6 @@ namespace LisPacsDataUpload
                                 }
 
                             }
-
                         }
 
                         ShowLog = Thread_name + "thread2  本次已生成、上传[LIS]PDF文件总条数为[" + pdfcountAll + "]条,上传[LIS]总条数为[" + uploaded + "]条。";
@@ -1816,7 +1653,17 @@ namespace LisPacsDataUpload
                             string file_vi = Tools.GuidTo16String();
                             file_json = Tools.AESEncrypt(file_json, Tools.pwd, file_vi);
                             string file_url = "http://40.26.204.3:8084/phimp-napi/attachMent/upload";
-                            string file_res = Tools.WSCenterData(file_url, file_json, file_vi, Tools.accessToken, 1);
+                            //string file_res = Tools.WSCenterData(file_url, file_json, file_vi, Tools.accessToken, 1);
+                            string file_res=string.Empty;
+                            try
+                            {
+                                file_res = Tools.WSCenterData(file_url, file_json, file_vi, Tools.accessToken, 1);
+                            }
+                            catch (Exception e)
+                            {
+                                LogHelper.Error(e, "pacs 报告生成上传失败");
+                                continue;
+                            }
                             string file_res_aes = Tools.AESDecrypt(file_res, Tools.pwd, file_vi);
                             ResFile resfile = Tools.JsonToObject<ResFile>(Tools.FormatStr(file_res_aes), Encoding.UTF8);
                             if (resfile.statusCode != "1")
@@ -1898,7 +1745,7 @@ namespace LisPacsDataUpload
                                               a.machineType ,
                                               a.machineCode ,
                                               a.machineName ,
-                                              a.attachmentId  ,
+                                              b.attachmentId  ,
                                               a.studyInstanceUid  ,
                                               a.dicomImgFtpUrl  ,
                                               a.orgCode ,
@@ -1948,7 +1795,17 @@ namespace LisPacsDataUpload
                             string json_pacs_log = json_pacs;
                             string vi_pacs = Tools.GuidTo16String();
                             json_pacs = Tools.AESEncrypt(json_pacs, Tools.pwd, vi_pacs);
-                            string res_pacs = Tools.WSCenterData(url_pacs, json_pacs, vi_pacs, Tools.accessToken, 1);
+                            //string res_pacs = Tools.WSCenterData(url_pacs, json_pacs, vi_pacs, Tools.accessToken, 1);
+                            string res_pacs = string.Empty;
+                            try
+                            {
+                                res_pacs = Tools.WSCenterData(url_pacs, json_pacs, vi_pacs, Tools.accessToken, 1);
+                            }
+                            catch (Exception e)
+                            {
+                                LogHelper.Error(e, "pacs 报告上传失败");
+                                continue;
+                            }
                             string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
                             //LogHelper.Info("[PACS]上传出参:" + res_aes_pacs);
                             ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
@@ -2047,7 +1904,7 @@ namespace LisPacsDataUpload
                                               a.machineType ,
                                               a.machineCode ,
                                               a.machineName ,
-                                              a.attachmentId  ,
+                                              b.attachmentId  ,
                                               a.studyInstanceUid  ,
                                               a.dicomImgFtpUrl  ,
                                               a.orgCode ,
@@ -2095,7 +1952,17 @@ namespace LisPacsDataUpload
                         string json_pacs_log = json_pacs;
                         string vi_pacs = Tools.GuidTo16String();
                         json_pacs = Tools.AESEncrypt(json_pacs, Tools.pwd, vi_pacs);
-                        string res_pacs = Tools.WSCenterData(url_pacs, json_pacs, vi_pacs, Tools.accessToken, 1);
+                        //string res_pacs = Tools.WSCenterData(url_pacs, json_pacs, vi_pacs, Tools.accessToken, 1);
+                        string res_pacs = string.Empty;
+                        try
+                        {
+                            res_pacs = Tools.WSCenterData(url_pacs, json_pacs, vi_pacs, Tools.accessToken, 1);
+                        }
+                        catch (Exception e)
+                        {
+                            LogHelper.Error(e, "pacs 报告补传失败");
+                            continue;
+                        }
                         string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
                         //LogHelper.Info("[PACS]上传出参:" + res_aes_pacs);
                         ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
@@ -2292,7 +2159,17 @@ namespace LisPacsDataUpload
                             string json_pacs_log = json_pacs;
                             string vi_pacs = Tools.GuidTo16String();
                             json_pacs = Tools.AESEncrypt(json_pacs, Tools.pwd, vi_pacs);
-                            string res_pacs = Tools.WSCenterData(pacs_upload_url, json_pacs, vi_pacs, Tools.accessToken, 1);
+                            //string res_pacs = Tools.WSCenterData(pacs_upload_url, json_pacs, vi_pacs, Tools.accessToken, 1);
+                            string res_pacs = string.Empty;
+                            try
+                            {
+                                res_pacs = Tools.WSCenterData(pacs_upload_url, json_pacs, vi_pacs, Tools.accessToken, 1);
+                            }
+                            catch (Exception e)
+                            {
+                                LogHelper.Error(e, "pacs 报告上传失败");
+                                continue;
+                            }
                             string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
                             //LogHelper.Info("[PACS]上传出参:" + res_aes_pacs);
                             ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
@@ -2376,7 +2253,17 @@ namespace LisPacsDataUpload
                         string json_pacs_log = json_pacs;
                         string vi_pacs = Tools.GuidTo16String();
                         json_pacs = Tools.AESEncrypt(json_pacs, Tools.pwd, vi_pacs);
-                        string res_pacs = Tools.WSCenterData(pacs_upload_url, json_pacs, vi_pacs, Tools.accessToken, 1);
+                        //string res_pacs = Tools.WSCenterData(pacs_upload_url, json_pacs, vi_pacs, Tools.accessToken, 1);
+                        string res_pacs = string.Empty;
+                        try
+                        {
+                            res_pacs = Tools.WSCenterData(pacs_upload_url, json_pacs, vi_pacs, Tools.accessToken, 1);
+                        }
+                        catch (Exception e)
+                        {
+                            LogHelper.Error(e, "pacs 报告上传失败");
+                            continue;
+                        }
                         string res_aes_pacs = Tools.AESDecrypt(res_pacs, Tools.pwd, vi_pacs);
                         //LogHelper.Info("[PACS]上传出参:" + res_aes_pacs);
                         ResPacs respacs = Tools.JsonToObject<ResPacs>(Tools.FormatStr(res_aes_pacs), Encoding.UTF8);
@@ -2538,24 +2425,36 @@ namespace LisPacsDataUpload
         private bool isAuthorization()
         {
             bool result = true;
-            if (string.IsNullOrWhiteSpace(Tools.accessToken) || Tools.DateTimes == null || Tools.DateTimes <= DateTime.Now)
+            string res_aes = string.Empty;
+            try
             {
-                //获取授权
-                string vi = Tools.GuidTo16String();
-                string url = "http://40.26.204.3:8084/phimp-napi/token";
-                string res = Tools.WSCenterData(url, "", vi);
-                string res_aes = Tools.AESDecrypt(res, Tools.pwd, vi);
-                Authorization ahz = Tools.JsonToObject<Authorization>(Tools.FormatStr(res_aes), Encoding.UTF8);
-                if (ahz.statusCode != "1")
+                if (string.IsNullOrWhiteSpace(Tools.accessToken) || Tools.DateTimes == null || Tools.DateTimes <= DateTime.Now)
                 {
-                    ShowLog = ahz.message + ",获取Token授权失败!等待下一次轮询。";
-                    this.SetText(ShowLog);
-                    LogHelper.Info(ShowLog);
-                    result = false;
+                    //获取授权
+                    string vi = Tools.GuidTo16String();
+                    string url = "http://40.26.204.3:8084/phimp-napi/token";
+                    string res = Tools.WSCenterData(url, "", vi);
+                    res_aes = Tools.AESDecrypt(res, Tools.pwd, vi);
+                    Authorization ahz = Tools.JsonToObject<Authorization>(Tools.FormatStr(res_aes), Encoding.UTF8);
+                    if (ahz.statusCode != "1")
+                    {
+                        ShowLog = ahz.message + ",获取Token授权失败!等待下一次轮询。";
+                        this.SetText(ShowLog);
+                        LogHelper.Info(ShowLog);
+                        result = false;
+                    }
+                    Tools.accessToken = ahz.mainBody.accessToken;
+                    Tools.DateTimes = DateTime.Now.AddSeconds(int.Parse(ahz.mainBody.expirationTime));
                 }
-                Tools.accessToken = ahz.mainBody.accessToken;
-                Tools.DateTimes = DateTime.Now.AddSeconds(int.Parse(ahz.mainBody.expirationTime));
             }
+            catch (Exception e)
+            {
+                result = false;
+                LogHelper.Info("isAuthorization Exception=" + result);
+                LogHelper.Info(res_aes+"获取token异常" + e.Message);
+                return result;
+            }
+            LogHelper.Info("isAuthorization="+ result);
             return result;
         }
         private void Form1_FormClosing(object sender, FormClosingEventArgs e)

+ 2 - 0
LisPacsDataUpload/LisPacsDataUpload.csproj

@@ -85,6 +85,7 @@
     <Compile Include="Models\LISITEMS.cs" />
     <Compile Include="Models\LISOBJ.cs" />
     <Compile Include="Models\PACS.cs" />
+    <Compile Include="Models\PacsItems.cs" />
     <Compile Include="Models\Report\Paramater.cs" />
     <Compile Include="Models\ResFile.cs" />
     <Compile Include="Models\ResPacs.cs" />
@@ -97,6 +98,7 @@
     </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="services\PacsUploadServiceImpl.cs" />
     <Compile Include="SqlServerHelper.cs" />
     <EmbeddedResource Include="Form1.resx">
       <DependentUpon>Form1.cs</DependentUpon>

+ 1 - 0
LisPacsDataUpload/Models/PacsItems.cs

@@ -7,6 +7,7 @@ namespace LisPacsDataUpload.Models
         public string POSITIONCODE { get; set; }//检查部位编码
         public string POSITIONNAME { get; set; }//检查部位名称
         public string TESTPRICE { get; set; }//检查明细费用(元)传数值,保留小数点后四位,如:233.5600
+        public string REGIONHR { get; set; }//是否互认   1 互认 
 
 
     }

+ 121 - 30
ZLPlugin_LisPacs_MR/LisPacs_MR_Bll.cs

@@ -3,6 +3,7 @@ using System;
 using System.Collections.Generic;
 using ZLPlugin_LisPacs_MR.Domain.Units;
 using ZLPlugin_LisPacs_MR.Model;
+using static System.Windows.Forms.AxHost;
 
 namespace ZLPlugin_LisPacs_MR
 {
@@ -26,7 +27,7 @@ namespace ZLPlugin_LisPacs_MR
                                     and x.类别 = 'C'
                                     And x.Id = {0}";
             sql = string.Format(sql, zlid);
-            //Log.Info("sql1:" + sql);
+            Log.Info("sql1:" + sql);
             Recordset rd = new Recordset();
             Tools.QueryTable(sql, out rd);
             if (!rd.EOF)
@@ -115,10 +116,8 @@ namespace ZLPlugin_LisPacs_MR
                         Codes codes = new Codes();
                         codes.id = list[i].相关ID;  //原先是 取id 不行 
                         codes.code = code;
-                      
                         codes.yzid = list[i].ID;
                         codes.zlxmid = list[i].诊疗项目ID;
-
                         codes.yzContent = list[i].医嘱内容;
                         codes.doctorName = list[i].开嘱医生;
                         listlis.Add(codes);
@@ -143,12 +142,12 @@ namespace ZLPlugin_LisPacs_MR
                         Codes codes = new Codes();
                         codes.id = list[i].相关ID;
                         codes.type = type;
+                        codes.code = type;
                         codes.yzid = list[i].ID;
                         codes.zlxmid = list[i].诊疗项目ID;
                         codes.zxksid = list[i].执行科室ID;
                         codes.part = list[i].标本部位;
                         codes.method = list[i].检查方法;
-
                         codes.yzContent = list[i].医嘱内容 + "_" + list[i].标本部位 + "_" + list[i].检查方法;
                         codes.doctorName = list[i].开嘱医生;
                         listPacs.Add(codes);
@@ -172,14 +171,14 @@ namespace ZLPlugin_LisPacs_MR
         /// <param name="ZYID"></param>
         /// <param name="standardItemId"></param>
         /// <returns></returns>
-        public static Recordset GetZYPostJson(long lngPatientID, long ZYID, string no,int type,string totalPrice, string xgid)
+        public static Recordset GetZYPostJson(long lngPatientID, long ZYID, string no,int type,string totalPrice, string xgid,string userName,string userCode)
         {
             string sql = @"select * from (Select distinct  a.姓名 ""PatientName"",
                                     b.身份证号 ""PatientIdCard"",
                                     e.机构编码 ""jzOrgCode"",
                                     e.机构名称 ""jzOrgName"",
-                                    c.编号 ""jzDoctorCode"",
-                                    c.姓名 ""jzDoctorName"",
+                                    '{7}' ""jzDoctorCode"",
+                                    '{6}' ""jzDoctorName"",
                                     d.编码 ""jzDeptCode"",
                                     d.名称 ""jzDeptName"",
                                     a.住院号 ""businessNumber"",
@@ -191,12 +190,11 @@ namespace ZLPlugin_LisPacs_MR
                                     '{4}' ""hisApplyCode"",
                                     '2' ""patientType"",
                                      '{5}'   ""totalAmount""
-                                    From 病案主页 a,病人信息 b, 人员表 c,部门表 d,ZLLPMR.互认配置表 e
+                                    From 病案主页 a,病人信息 b,部门表 d,ZLLPMR.互认配置表 e
                                     Where b.病人id = a.病人id
-                                    And c.姓名 = a.住院医师
-                                    And d.Id = a.入院科室id
+                                    And d.Id = a.当前病区id
                                     And a.病人id = {0} And a.主页id = {1} ) ";
-            sql = string.Format(sql, lngPatientID, ZYID, no,type, xgid, totalPrice);
+            sql = string.Format(sql, lngPatientID, ZYID, no,type, xgid, totalPrice, userName,userCode);
             Log.Info("GetZYPostJson==" + sql);
             Recordset rd = new Recordset();
             Tools.QueryTable(sql, out rd);
@@ -209,14 +207,14 @@ namespace ZLPlugin_LisPacs_MR
         /// <param name="ZYID"></param>
         /// <param name="standardItemId"></param>
         /// <returns></returns>
-        public static Recordset GetMZPostJson(long ZYID, string no,int type, string totalAmount, string xgId)
+        public static Recordset GetMZPostJson(long ZYID, string no,int type, string totalAmount, string xgId, string userName, string userCode)
         {
             string sql = @"Select distinct a.姓名 ""PatientName"",
                                     b.身份证号 ""PatientIdCard"",
                                     e.机构编码 ""jzOrgCode"",
                                     e.机构名称 ""jzOrgName"",
-                                    c.编号 ""jzDoctorCode"",
-                                    c.姓名 ""jzDoctorName"",
+                                    '{6}' ""jzDoctorCode"",
+                                    '{5}' ""jzDoctorName"",
                                     d.编码 ""jzDeptCode"",
                                     d.名称 ""jzDeptName"",
                                     a.门诊号 ""businessNumber"",
@@ -233,7 +231,7 @@ namespace ZLPlugin_LisPacs_MR
                                     And c.姓名 = a.执行人
                                     And d.Id = a.执行部门id
                                     And a.id = {0}";
-            sql = string.Format(sql, ZYID, no,type, xgId, totalAmount);
+            sql = string.Format(sql, ZYID, no,type, xgId, totalAmount, userName, userCode);
             Log.Info("GetMZPostJson==" + sql);
             Recordset rd = new Recordset();
             Tools.QueryTable(sql, out rd);
@@ -550,23 +548,41 @@ namespace ZLPlugin_LisPacs_MR
             pacs_id = -1;
             var lis = result.ResultText[0].LIS;
             var pacs = result.ResultText[0].PACS;
+            
             if (lis != null)
             {
                 for (int i = 0; i < lis.Count; i++)
                 {
-                    //insert 互认_lis
-                    string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-                    string xgid = listlis[i].id; 
-                    int res = InsertLis(lis[i], lngPatientID, lngClinicID, date, no, long.Parse(xgid));
-                    if (res > 0)
+                    bool state = true;
+                    for (int j = 0; j < lis[i].ItemList.Count; j++)
                     {
-                        if (lis_id == -1)
+                        if (!state)
                         {
-                            lis_id = long.Parse(xgid);
+                            break;
                         }
-                        for (int k = 0; k < lis[i].ItemList.Count; k++)
+                        foreach (var items in listlis)
                         {
-                            InsertLisItem(lis[i].ItemList[k], lis[i].LisCheckReportId, lngPatientID, lngClinicID, date);
+                            
+                            if (items.code.Contains(lis[i].ItemList[j].StandardItemId))
+                            {
+                                //insert 互认_lis
+                                string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                                string xgid = items.id;
+                                int res = InsertLis(lis[i], lngPatientID, lngClinicID, date, no, long.Parse(xgid));
+                                if (res > 0)
+                                {
+                                    if (lis_id == -1)
+                                    {
+                                        lis_id = long.Parse(xgid);
+                                    }
+                                    for (int k = 0; k < lis[i].ItemList.Count; k++)
+                                    {
+                                        InsertLisItem(lis[i].ItemList[k], lis[i].LisCheckReportId, lngPatientID, lngClinicID, date);
+                                    }
+                                }
+                                state = false;
+                            }
+                            
                         }
                     }
                 }
@@ -576,7 +592,6 @@ namespace ZLPlugin_LisPacs_MR
                 long id = long.Parse(listpacs[0].id);
                 for (int i = 0; i < pacs.Count; i++)
                 {
-
                     foreach (var items in listpacs)
                     {
                         if (pacs[i].reportTypeCode == items.type)
@@ -599,11 +614,87 @@ namespace ZLPlugin_LisPacs_MR
             }
         }
 
-        /// <summary>
-        /// 是否互认
-        /// </summary>
-        /// <returns></returns>
-        public static void IsAgree(out int res,out int date,out int yzzState)
+
+
+        public static void SaveDataNew2(Results result, long lngPatientID, long lngClinicID, string no, List<Codes> listlis, List<Codes> listpacs, out long lis_id, out long pacs_id)
+        {
+            lis_id = -1;
+            pacs_id = -1;
+            var lis = result.ResultText[0].LIS;
+            var pacs = result.ResultText[0].PACS;
+
+            if (lis != null)
+            {
+                Log.Info("lis.Count=" + lis.Count);
+                foreach (var items in listlis)
+                {
+                    Log.Info("items.id=" + items.id);
+                    bool state = true;
+                    for (int i = 0; i < lis.Count; i++)
+                    {
+                        Log.Info("state=" + state);
+                        if (!state)
+                        {
+                            break;
+                        }
+                        bool flag = true;
+                        for (int j = 0; j < lis[i].ItemList.Count; j++)
+                        {
+                            Log.Info("flag=" + flag);
+                            //这里判断指标不能循环多次
+                            if (!flag)
+                            {
+                                break;
+                            }
+                            if (items.code.Contains(lis[i].ItemList[j].StandardItemId))
+                            {
+                                string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                                long xgid = long.Parse(items.id);
+                                int res = InsertLis(lis[i], lngPatientID, lngClinicID, date, no, xgid);
+                                if (res > 0)
+                                {
+                                    lis_id= xgid;
+                                    for (int k = 0; k < lis[i].ItemList.Count; k++)
+                                    {
+                                        InsertLisItem(lis[i].ItemList[k], lis[i].LisCheckReportId, lngPatientID, lngClinicID, date);
+                                    }
+                                }
+                                flag = false;
+                                state = false;
+                            }
+                        }
+
+                    }
+                }
+            }
+            if (pacs != null)
+            {
+                Log.Info("pacs.Count=" + pacs.Count);
+                foreach (var items in listpacs)
+                {
+                    for (int i = 0; i < pacs.Count; i++)
+                    {
+                        long id = long.Parse(items.id);
+                        if (pacs[i].StandardItemId.Contains(items.code))
+                        {
+                            int res = InsertPacs(pacs[i], lngPatientID, lngClinicID, no, id);
+                            if (res > 0)
+                            {
+                                pacs_id=id;
+                            }
+                            break;
+                        }
+
+                    }
+                }
+            }
+
+        }
+            /// <summary>
+            /// 是否互认
+            /// </summary>
+            /// <returns></returns>
+            public static void IsAgree(out int res,out int date,out int yzzState)
         {
             res = 1;
             date = 20000;

+ 3 - 3
ZLPlugin_LisPacs_MR/Properties/AssemblyInfo.cs

@@ -4,12 +4,12 @@ using System.Runtime.InteropServices;
 // General Information about an assembly is controlled through the following 
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
-[assembly: AssemblyTitle("时间格式解决,回传提示解决")]
-[assembly: AssemblyDescription("")]
+[assembly: AssemblyTitle("当前病区id,开单提当前操作人,针对合单互认")]
+[assembly: AssemblyDescription("开多少个医嘱 就互认多少,针对合单互认")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("zlsoft")]
 [assembly: AssemblyProduct("ZLPlugin_LisPacs_MR")]
-[assembly: AssemblyCopyright("Copyright ©  2024-1.0.1.8")]
+[assembly: AssemblyCopyright("Copyright ©  2024-1.0.2.2")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 

+ 1 - 1
ZLPlugin_LisPacs_MR/SocketClient.cs

@@ -50,7 +50,7 @@ namespace ZLPlugin_LisPacs_MR
         public SocketClient(string ip,int Port)
         {
             _ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
-            _ClientSocket.ReceiveTimeout = 60000;
+            _ClientSocket.ReceiveTimeout = 2000;
             this.ipAddress = ip;
             this.Port = Port;
             Start();

+ 16 - 10
ZLPlugin_LisPacs_MR/clsPlugin.cs

@@ -3,7 +3,11 @@
 // 作    者:YTH-PC
 // 创建时间:2022/8/19 10:14:06
 // 描    述:
+//
 // 版    本:
+//1.0.1.9  检验互认混乱解决
+//1.0.2.0  当前病区解决
+//1.0.2.1  住院门诊  开单发送数据 信息提当前操作人的信息 
 //-----------------------------------------------------------------------------
 // 历史更新纪录
 //-----------------------------------------------------------------------------
@@ -44,6 +48,7 @@ using ZLPlugin_LisPacs_MR.Model;
 using System.Windows.Forms;
 using System.Net;
 using ZLPlugin_LisPacs_MR.Domain;
+using System.Linq;
 
 namespace ZLPlugin_LisPacs_MR
 {
@@ -157,7 +162,7 @@ namespace ZLPlugin_LisPacs_MR
                 string yzid = listlis[0].yzid;
                 string xgid = listlis[0].id;
                 decimal totalPrice = LisPacs_MR_Bll.GetTotalPriceForLisByZLXM(yzid);
-                Recordset rd = LisPacs_MR_Bll.GetMZPostJson(lngClinicID, code, hrType, totalPrice.ToString(), code);
+                Recordset rd = LisPacs_MR_Bll.GetMZPostJson(lngClinicID, code, hrType, totalPrice.ToString(), code,Infos.UserInfo.姓名,Infos.UserInfo.ID.ToString());
                 string json = Tools.RecordsetToJson(rd);
                 clientSend.Send(json);
                 Log.Info("初始化完成!");
@@ -226,7 +231,13 @@ namespace ZLPlugin_LisPacs_MR
                 return true;
             }
             List<YZData> ss_list = JSON.JsonToObject<List<YZData>>(Tools.FormatStr(str), Encoding.UTF8);
-
+            //这里需要过滤 保存修改的数据
+            ss_list= ss_list.Where(data => !'2'.Equals(data.EDITSTATE)).ToList();
+            if (ss_list.Count<=0)
+            {
+                Log.Info("过滤修改后没有数据:");
+                return true;
+            }
             SocketClient socketClient = new SocketClient("127.0.0.1", 6061);
             try
             {
@@ -302,7 +313,7 @@ namespace ZLPlugin_LisPacs_MR
                         }
                     }
                     patientSource = "2";
-                    rd = LisPacs_MR_Bll.GetZYPostJson(lngPatientID, lngClinicID, code, hrType, totalPrice.ToString(), hisApplyId);
+                    rd = LisPacs_MR_Bll.GetZYPostJson(lngPatientID, lngClinicID, code, hrType, totalPrice.ToString(), hisApplyId, Infos.UserInfo.姓名, Infos.UserInfo.ID.ToString());
                 }
                 else
                 {
@@ -329,7 +340,7 @@ namespace ZLPlugin_LisPacs_MR
                         }
                     }
                     patientSource = "1";
-                    rd = LisPacs_MR_Bll.GetMZPostJson(lngClinicID, code, hrType, totalPrice.ToString(), hisApplyId);
+                    rd = LisPacs_MR_Bll.GetMZPostJson(lngClinicID, code, hrType, totalPrice.ToString(), hisApplyId, Infos.UserInfo.姓名, Infos.UserInfo.ID.ToString());
                 }
                 //SocketClient client = new SocketClient("127.0.0.1", 6061);
                 //Results result = new Results();
@@ -346,13 +357,10 @@ namespace ZLPlugin_LisPacs_MR
                     Log.Info("接收失败!"+ e.Message);
                     return false;
                 }
-                    
-                
                 Log.Info("listlis count!" + listlis.Count);
                 Log.Info("listpacs count!" + listpacs.Count);
                 if (!string.IsNullOrWhiteSpace(SocketClient.Message))
                 {
-                    Log.Info( SocketClient.Message);
                     ResultsEx rex = new ResultsEx();
                     rex = JSON.JsonToObject<ResultsEx>(Tools.FormatStr(SocketClient.Message), Encoding.UTF8);
                     if (rex.ResultCode == 2)//有互认
@@ -402,14 +410,12 @@ namespace ZLPlugin_LisPacs_MR
         {
             Results result = new Results();
             Tools.Delay(waittingdate);
-            Log.Info("SaveData的信息" + SocketClient.Message);
             if (string.IsNullOrWhiteSpace(SocketClient.Message))
             {
                 return true;
             }
             try
             {
-                Log.Info("互认的信息>>" + SocketClient.Message);
                 result = JSON.JsonToObject<Results>(Tools.FormatStr(SocketClient.Message), Encoding.UTF8);
             }
             catch (Exception ex)//插件关闭时,返回格式不一样
@@ -426,7 +432,7 @@ namespace ZLPlugin_LisPacs_MR
             long lisId;
             long pacsId;
             Log.Info("开始保存数据!");
-            LisPacs_MR_Bll.SaveDataNew(result, lngPatientID, lngClinicID, Domain.Infos.UserInfo.编号, listlis, listpacs,out lisId,out pacsId);
+            LisPacs_MR_Bll.SaveDataNew2(result, lngPatientID, lngClinicID, Domain.Infos.UserInfo.编号, listlis, listpacs,out lisId,out pacsId);
             if (state < 1)
             {
                 return true;