Bläddra i källkod

互认专业版 lis 已解决 代码开发完成

zzh_love 7 månader sedan
förälder
incheckning
4bcbe0d72d

+ 45 - 0
Common/Tools.cs

@@ -214,6 +214,51 @@ namespace Common
             return srcString;
         }
 
+
+        public static string WSDataToZlsoftInterface(string url, string data)
+        {
+            string srcString = string.Empty;
+            try
+            {
+                Encoding myEncoding = Encoding.GetEncoding("UTF-8");
+                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; //将提交的字符串数据转换成字节数组 //注意提交的编码,这里默认的是Default:系统当前编码
+                byte[] postData = myEncoding.GetBytes(data); //设置提交的相关参数
+                HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
+                request.Method = "POST";
+                request.KeepAlive = false;
+                request.ProtocolVersion = HttpVersion.Version10;
+                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
+                //request.ContentType = "text/xml;charset=utf-8";
+                request.ContentType = "application/json;charset=utf-8";
+
+                request.ContentLength = postData.Length;
+
+                using (System.IO.Stream writer = request.GetRequestStream())
+                {
+                    writer.Write(postData, 0, postData.Length);
+                }
+
+                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
+                using (System.IO.Stream sr = response.GetResponseStream())
+                {
+                    using (StreamReader reader = new StreamReader(sr, myEncoding))
+                    {
+                        srcString = reader.ReadToEnd();
+                    }
+                }
+                //result = JSON.JsonToObject<Result>(Tools.FormatStr(srcString), Encoding.UTF8);
+            }
+            catch (Exception ex)
+            {
+                LogHelper.Info("请求入参:" + data);
+                LogHelper.Info("请求出参:" + srcString);
+                LogHelper.Error(ex);
+            }
+            //Log.Info("入参:" + data, true);
+            //Log.Info("出参:" + srcString, true);
+            return srcString;
+        }
+
         public static string GuidTo16String()
         {
             return DateTime.Now.ToString("yyyyMMddHHmmssff");

+ 72 - 16
LisPacsDataUpload/Form1.cs

@@ -404,19 +404,31 @@ namespace LisPacsDataUpload
                         int uploaded = 0;
                         for (int i = 0; i < dt.Rows.Count; i++)
                         {
-                            //获取标本号 和报表编号
-                           string reportNumber =  dt.Rows[i]["reportNumber"].ToString(); //报告编号
-                           string bbid =  dt.Rows[i]["bbid"].ToString();   // 标本id
                             //生成pdf
-                            
-                            
-                            string GeneratePdfUrl =  PdfUtils.GeneratePdf(lisSource, reportNumber, bbid);
-                            if (!GeneratePdfUrl.Contains(".pdf") )
+                            string GeneratePdfUrl = "未生成pdf成功";
+                            if (zlhr == zlhrConstant_true)
                             {
-                                LogHelper.Info("生成pdf失败,原因是 = " + GeneratePdfUrl);
-                                continue ; 
+                                string requestId = dt.Rows[i]["requestId"].ToString(); // 临生免报告id
+                                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);
+
+                            }
+                            else
+                            {
+                                //获取标本号 和报表编号
+                                string reportNumber = dt.Rows[i]["reportNumber"].ToString(); //报告编号
+                                string bbid = dt.Rows[i]["bbid"].ToString();   // 标本id
+                                GeneratePdfUrl = PdfUtils.GeneratePdf(lisSource, reportNumber, bbid);
+                                if (!GeneratePdfUrl.Contains(".pdf"))
+                                {
+                                    LogHelper.Info("生成pdf失败,原因是 = " + GeneratePdfUrl);
+                                    continue;
+                                }
+                                LogHelper.Info("生成pdf成功,地址为 = " + GeneratePdfUrl);
                             }
-                            LogHelper.Info("生成pdf成功,地址为 = " + GeneratePdfUrl);
                             /*string orgName = dt.Rows[i]["orgName"].ToString();
                             string name = dt.Rows[i]["patientName"].ToString();
                             string sex = dt.Rows[i]["sex"].ToString();
@@ -485,9 +497,17 @@ namespace LisPacsDataUpload
                             }
 
                             //最新调整  需要获取 原始pdf 文件  存在场景  有三方lis、中联lis 、 以及专业版临生免 的报告 三种  
-                            
+                            string attachmentFile = "";
+                            if (zlhr == zlhrConstant_true)
+                            {
+                                attachmentFile = GeneratePdfUrl;
+                            }
+                            else
+                            {
+                                attachmentFile = Tools.FileToBase64Str(GeneratePdfUrl);
+                            }
                             //上传文件
-                            string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检验报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + Tools.FileToBase64Str(GeneratePdfUrl) + "\"}";
+                            string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检验报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + attachmentFile + "\"}";
                             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";
@@ -1006,7 +1026,35 @@ namespace LisPacsDataUpload
                         int uploaded = 0;
                         for (int i = 0; i < dt.Rows.Count; i++)
                         {
-                            string orgName = dt.Rows[i]["orgName"].ToString();
+
+                            //获取标本号 和报表编号
+                            string reportNumber = dt.Rows[i]["reportNumber"].ToString(); //报告编号
+                            string bbid = dt.Rows[i]["bbid"].ToString();   // 标本id
+                                                                           //生成pdf
+                            string GeneratePdfUrl = "未生成pdf成功";
+                            if (zlhr == zlhrConstant_true)
+                            {
+                                string requestId = dt.Rows[i]["requestId"].ToString(); // 临生免报告id
+                                string sql_zlhr = @"select dr.id  from specimen_rec sr, diagnosticreport_rec dr where sr.id = dr.specmids::int
+                                    dr.status  in ('3003', '3004') and and sr.id = " + requestId;
+                                DataTable dt_lis = OracleHelper<object>.RunQueryDS(sql_zlhr);
+                                string reportId = dt_lis.Rows[0]["id"].ToString();
+
+                                GeneratePdfUrl = PdfUtils.GeneratePdf(lisSource, reportId, reportId);
+
+                            }
+                            else
+                            {
+                                GeneratePdfUrl = PdfUtils.GeneratePdf(lisSource, reportNumber, bbid);
+                                if (!GeneratePdfUrl.Contains(".pdf"))
+                                {
+                                    LogHelper.Info("生成pdf失败,原因是 = " + GeneratePdfUrl);
+                                    continue;
+                                }
+                                LogHelper.Info("生成pdf成功,地址为 = " + GeneratePdfUrl);
+                            }
+                            
+                            /*string orgName = dt.Rows[i]["orgName"].ToString();
                             string name = dt.Rows[i]["patientName"].ToString();
                             string sex = dt.Rows[i]["sex"].ToString();
                             string ch = dt.Rows[i]["bedNo"].ToString();
@@ -1066,15 +1114,23 @@ namespace LisPacsDataUpload
                                 this.SetText(ShowLog);
                                 LogHelper.Info(ShowLog);
                                 continue;
-                            }
+                            }*/
                             //是否授权
                             if (!isAuthorization())
                             {
                                 continue;
                             }
-
+                            string attachmentFile = "";
+                            if (zlhr==zlhrConstant_true)
+                            {
+                                attachmentFile = GeneratePdfUrl;
+                            }
+                            else
+                            {
+                                attachmentFile=Tools.FileToBase64Str(GeneratePdfUrl);
+                            }
                             //上传文件
-                            string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检验报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + Tools.FileToBase64Str(res) + "\"}";
+                            string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检验报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + attachmentFile + "\"}";
                             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";

+ 17 - 2
LisPacsDataUpload/business/PdfUtils.cs

@@ -70,14 +70,29 @@ namespace LisPacsDataUpload.business
                 {
                     return path;
                 }
-                
-
             }
             else if (lisVersion == 2)
             {
                 //专业版临生免
+                string sql_zlhr = @"select standard_url from 互认配置表";
+                DataTable dt_lis = OracleHelper<object>.RunQueryDS(sql_zlhr);
+                string standard_url = dt_lis.Rows[0]["standard_url"].ToString();
+
+                string jsonTemplate = "{\"input\":{\"req_info\":{\"rpt_id\":\"{rpt_id}\",\"rpt_type\":\"0\"},\"head\":{\"bizno\":\"S4021\",\"sysno\":\"zlhr\",\"tarno\":\"ZLHIS\",\"time\":\"{time}\",\"action_no\":\"{action_no}\"}}}";
+                // 使用字符串插值替换占位符
+                string data = jsonTemplate
+                    .Replace("{rpt_id}", bbid)
+                    .Replace("{time}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
+                    .Replace("{action_no}", Guid.NewGuid().ToString());
+               string responseString = Tools.WSDataToZlsoftInterface(standard_url, data);
 
+                ZlsoftOutVO zlsoftOutVO =  JsonConvert.DeserializeObject<ZlsoftOutVO>(responseString);
 
+                if (!"A".Equals(zlsoftOutVO.input.ack_info.exe_status))
+                {
+                    return zlsoftOutVO.input.ack_info.err_msg;
+                }
+                return zlsoftOutVO.input.file_info.rpt_content;
             }
             else
             {

+ 36 - 0
LisPacsDataUpload/business/ZlsoftOutVO.cs

@@ -0,0 +1,36 @@
+
+namespace LisPacsDataUpload.business
+{
+    public class ZlsoftOutVO
+    {
+        public Input input { get; set; }
+       
+
+
+    }
+
+    public class Input
+    {
+        public FileInfo file_info { get; set; }
+        public AckInfo ack_info { get; set; }
+      
+
+
+    }
+
+    public class FileInfo
+    {
+        public string rpt_id { get; set; }  //报告id
+        public string rpt_content { get; set; }  //base64 加密的pdf文件
+
+
+    }
+
+    public class AckInfo
+    {
+        public string exe_status { get; set; }  //A 成功
+        public string err_msg { get; set; }  //
+
+
+    }
+}