Переглянути джерело

新版lis报告获取开发完成

zackhua 7 місяців тому
батько
коміт
18e6f08c35

+ 6 - 0
LisPacsDataUpload/App.config

@@ -4,6 +4,7 @@
     <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342" />
   </configSections>
   <appSettings>
+	  
     <!--定时轮询时间(单位:分钟)-->
     <add key="time" value="120" />
     <!--数据上传开始时间点(值域:0-23)-->
@@ -12,6 +13,11 @@
     <add key="pacs" value="0" />
     <!--清除多久以前已上传的数据(单位:月),整数,小于1不删除-->
     <add key="upload_time" value="1" />
+
+	  <add key="UserName" value="zlhis"/>
+	  <add key="PasWord" value="aqa"/>
+	  <add key="Server" value="orcl"/>
+	  
   </appSettings>
   <connectionStrings>
     <add name="conn" connectionString="data source=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.0.1)(PORT = 1521)))(CONNECT_DATA = (SERVICE_NAME = his)));user id=ZLLPMR;password=ZLLPMR;Persist Security Info=True;Enlist=true;Pooling=true;Max Pool Size=300;Min Pool Size=0;Connection Lifetime=300;" />

+ 18 - 8
LisPacsDataUpload/Form1.cs

@@ -68,7 +68,7 @@ namespace LisPacsDataUpload
         }
         private void ShowCheckBox1()
         {
-            string sql_lis = @"select 互认,zlhr,open_multiple_upload from 互认配置表";
+            string sql_lis = @"select 互认,zlhr,open_multiple_upload,lis_source from 互认配置表";
             DataTable dt_lis = OracleHelper<object>.RunQueryDS(sql_lis);
             int total = int.Parse(dt_lis.Rows[0]["互认"].ToString());
             if (total == 1)
@@ -86,6 +86,8 @@ namespace LisPacsDataUpload
             }
             open_multiple_upload_flag = int.Parse(dt_lis.Rows[0]["open_multiple_upload"].ToString());
 
+            lisSource= int.Parse(dt_lis.Rows[0]["lis_source"].ToString());
+
         }
         private void ShowCheckBox2()
         {
@@ -403,10 +405,19 @@ namespace LisPacsDataUpload
                         for (int i = 0; i < dt.Rows.Count; i++)
                         {
                             //获取标本号 和报表编号
-                            dt.Rows[i]["bbid"].ToString();
-                            PdfUtils.getPdfParamByLisVersion(lisSource, 111);
-
-                            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 =  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();
@@ -417,7 +428,6 @@ namespace LisPacsDataUpload
                             string type;
                             string title = dt.Rows[i]["reportName"].ToString();
                             string patientType = dt.Rows[i]["patientType"].ToString();
-
                             if (patientType == "1")
                             {
                                 type = "门诊";
@@ -467,7 +477,7 @@ namespace LisPacsDataUpload
                                 this.SetText(ShowLog);
                                 LogHelper.Info(ShowLog);
                                 continue;
-                            }
+                            }*/
                             //是否授权
                             if (!isAuthorization())
                             {
@@ -477,7 +487,7 @@ namespace LisPacsDataUpload
                             //最新调整  需要获取 原始pdf 文件  存在场景  有三方lis、中联lis 、 以及专业版临生免 的报告 三种  
                             
                             //上传文件
-                            string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检验报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + Tools.FileToBase64Str(res) + "\"}";
+                            string file_json = "{\"attachmentType\":\".pdf\",\"attachmentName\":\"检验报告\",\"businessType\":\"A001\",\"attachmentFile\":\"" + Tools.FileToBase64Str(GeneratePdfUrl) + "\"}";
                             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";

+ 1 - 1
LisPacsDataUpload/Models/Report/Paramater.cs

@@ -12,7 +12,7 @@ namespace LisPacsDataUpload.Models.Report
         /// </summary>
         public int InvokeType { get; set; } = 4;
         public string PdfPath { get; set; } = "pdf=" + AppDomain.CurrentDomain.BaseDirectory + "PDF\\PrintReport";
-        public int ReturnType { get; set; } = 0;
+        //public int ReturnType { get; set; } = 0;
         public List<SubParameter> Params { get; set; } = new List<SubParameter>();
 
     }

+ 110 - 14
LisPacsDataUpload/business/PdfUtils.cs

@@ -1,9 +1,15 @@
 using Common;
+using LisPacsDataUpload.Models;
 using LisPacsDataUpload.Models.Report;
+using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
 using System.Diagnostics;
+using System.IO;
 using System.Linq;
+using System.Reflection;
 using System.Text;
 
 namespace LisPacsDataUpload.business
@@ -14,17 +20,27 @@ namespace LisPacsDataUpload.business
     public class PdfUtils
     {
         /// <summary>
-        /// 根据lis版本获取请求生成pdf报告的参数   0中联老版lis 1 中联新版lis  2  专业版临生免  3 三方lis
+        /// 根据lis版本获取请求生成pdf报告的参数   0中联老版lis 1 中联新版lis  2  专业版临生免  10 标准服务老版lis 11标准服务新版lis  3 三方lis  
         /// </summary>
         /// <returns></returns>
-        public static string getPdfParamByLisVersion(int lisVersion,long yzid)
+        public static string getPdfParamByLisVersion(int lisVersion, string reportNumber,string bbid)
         {
+
+            string dicLis = AppDomain.CurrentDomain.BaseDirectory + "Lis\\";
+
+            if (!Directory.Exists(dicLis))
+            {
+                Directory.CreateDirectory(dicLis);
+            }
+            string path = dicLis + "LIS" + bbid+ ".pdf";
             Paramater paramter = new Paramater
             {
                 ZlSysCode = 2500,
-                PdfPath = $"pdf={AppDomain.CurrentDomain.BaseDirectory}PDF\\Report\\LIS{yzid}.pdf"
+                RePortCode = reportNumber,
+                PdfPath = $"pdf={path}",
+                InvokeType = 4
             };
-            
+            paramter.Params.Add(new SubParameter { Param = $"标本id={bbid}" });
             if (lisVersion==0)
             {
                 //老版lis
@@ -38,9 +54,23 @@ namespace LisPacsDataUpload.business
             else if (lisVersion == 1)
             {
                 // 新版lis
-               /* Select distinct 'ZLLISBILL00' || Decode(b.病人来源, 2, c.住院单据, 3, c.体检单据, 4, c.院外单据, c.门诊单据) || '-2' 报表编号, a.Id 标本id
-From 检验报告记录 A, 检验申请组合 B, 检验仪器记录 C
-Where  a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
+                /* Select distinct 'ZLLISBILL00' || Decode(b.病人来源, 2, c.住院单据, 3, c.体检单据, 4, c.院外单据, c.门诊单据) || '-2' 报表编号, a.Id 标本id
+ From 检验报告记录 A, 检验申请组合 B, 检验仪器记录 C
+ Where  a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
+                string strJson= JsonConvert.SerializeObject(paramter);
+                LogHelper.Info("strJson=="+ strJson);
+                if (!Init())
+                {
+                    LogHelper.Info("Init初始化异常");
+                    return "Init初始化异常";
+                }
+
+                //生成pdf成功
+                if (OutPdf(strJson))
+                {
+                    return path;
+                }
+                
 
             }
             else if (lisVersion == 2)
@@ -53,17 +83,24 @@ Where  a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
             {
                 // 三方lis
             }
+            return "失败";
+        }
 
-            return null;
+        public static string GeneratePdf(int lisVersion, string reportNumber, string bbid)
+        {
+            return getPdfParamByLisVersion(lisVersion, reportNumber, bbid);
         }
 
-        public bool GeneratePdf()
+
+        //调用exe
+        public static bool CallingProgram(string strJson)
         {
+
             // 定义要启动的外部程序的路径
-            string exePath = @"C:\Path\To\Your\Program.exe";
+            string exePath = @"C:\APPSOFT\ReportPrint\zlgyReport.exe";
 
             // 定义要传递给外部程序的参数
-            string arguments = "strJson value1";
+            string arguments = "strJson " + strJson;
 
             // 创建一个新的 ProcessStartInfo 对象
             ProcessStartInfo startInfo = new ProcessStartInfo
@@ -73,7 +110,7 @@ Where  a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
                 RedirectStandardOutput = false, // 是否重定向标准输出(根据需要设置)
                 RedirectStandardError = false, // 是否重定向标准错误(根据需要设置)
                 UseShellExecute = true, // 是否使用操作系统的 shell 启动进程(通常设置为 true)
-                CreateNoWindow = true // 是否创建窗口(如果不需要显示窗口,可以设置为 true)
+                CreateNoWindow = false // 是否创建窗口(如果不需要显示窗口,可以设置为 true)
             };
             try
             {
@@ -85,8 +122,11 @@ Where  a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
                     process.WaitForExit();
                     LogHelper.Info("成功生成lis报告");
                     // 如果需要读取输出或错误,可以在这里处理
-                    // string output = process.StandardOutput.ReadToEnd();
-                    // string error = process.StandardError.ReadToEnd();
+                     string output = process.StandardOutput.ReadToEnd();
+                     string error = process.StandardError.ReadToEnd();
+
+                    LogHelper.Info("output==" + output);
+                    LogHelper.Info("error==" + error);
                 }
             }
             catch (Exception ex)
@@ -97,6 +137,62 @@ Where  a.Id = b.标本id And a.仪器id = c.Id And b.医嘱id = :id*/
             return true;
         }
 
+        static object Instance = null;
+        public static bool Init()
+        {
+            if (Instance != null )
+            {
+                return true;
+            }
+            
+            var para = JsonConvert.SerializeObject(new UserLogin
+            {
+                UserName = ConfigurationManager.AppSettings["UserName"],
+                PassWord = ConfigurationManager.AppSettings["PasWord"],
+                Server = ConfigurationManager.AppSettings["Server"]
+            });
+            LogHelper.Info("初始化入参" + para);
+            string strReval = string.Empty;
+            try
+            {
+                Process.GetProcessesByName("zlgyReport").ToList().ForEach(x => x.Kill());
+            }
+            catch (Exception ex) {
+                LogHelper.Info("进程结束异常" + ex.Message); }
+            var type = Type.GetTypeFromProgID("zlgyReport.clsGyReport");
+            Instance = Activator.CreateInstance(type);
+            ParameterModifier modifier = new ParameterModifier(2);
+            modifier[1] = true;
+            var result = type.InvokeMember("Init", BindingFlags.Default | BindingFlags.InvokeMethod, null, Instance, new object[] { para, strReval },
+                    new ParameterModifier[] { modifier },
+                    null,
+                    new string[] { "strJson", "strResult" });
+            LogHelper.Info("出参:" + strReval);
+            LogHelper.Info("返回:" + result.ToString());
+            return (bool)result;
+        }
+
+        public static bool OutPdf(string para)
+        {
+            var type = Type.GetTypeFromProgID("zlgyReport.clsGyReport");
+            ParameterModifier modifier = new ParameterModifier(2);
+            modifier[1] = true;
+            string strReval = string.Empty;
+            var result = type.InvokeMember("ReportOpen", BindingFlags.Default | BindingFlags.InvokeMethod, null, Instance, new object[] { para, strReval },
+                    new ParameterModifier[] { modifier },
+                    null,
+                    new string[] { "strJson", "strResult" });
+            LogHelper.Info("出参:" + strReval);
+            LogHelper.Info("返回:" + result.ToString());
+            return (bool)result;
+        }
+
+        public class UserLogin
+        {
+            public string UserName { get; set; }
+            public string PassWord { get; set; }
+            public string Server { get; set; }
+        }
 
     }
 }