소스 검색

代码优化

zackhua 9 달 전
부모
커밋
11a8ed03fc

+ 2 - 2
ZLPlugin_LisPacs_MR/Domain/Infos.cs

@@ -51,8 +51,8 @@ Where U.人员id=P.ID and P.id=M.人员id and M.缺省=1 And M.部门id=D.ID and
         {
             return;
             //调整ConfigModel及SQL语句以进行实现
-            var comandText = "";
-            Config = Domain.Units.DbHelper.ExcuteSql<ConfigModel>(comandText, Con).FirstOrDefault();
+           /* var comandText = "";
+            Config = Domain.Units.DbHelper.ExcuteSql<ConfigModel>(comandText, Con).FirstOrDefault();*/
         }
     }
 }

+ 1 - 3
ZLPlugin_LisPacs_MR/IclsPlugIn.cs

@@ -1,14 +1,12 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Runtime.InteropServices;
-using System.Text;
 
 namespace ZLPlugin_LisPacs_MR
 {
 #pragma warning disable IDE1006
     [ComVisible(true)]
-    [Guid("6d6f8610-bdcc-42c1-be42-aabe21f7cac8")]
+    [Guid("6bc3022b-d05e-4e1a-b305-f06d719f6700")]
     public interface IclsPlugIn
     {
 

+ 96 - 5
ZLPlugin_LisPacs_MR/LisPacs_MR_Bll.cs

@@ -1,8 +1,6 @@
 using ADODB;
 using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using ZLPlugin_LisPacs_MR.Domain.Units;
 using ZLPlugin_LisPacs_MR.Model;
 
@@ -45,8 +43,8 @@ namespace ZLPlugin_LisPacs_MR
             total = 0;
             type = "";
             string sql = @"Select Count(1) As total,b.代码 code From 诊疗项目目录 a,ZLLPMR.字典对码表 b
-                                  Where b.名称 = a.操作类型 and 分类 ='检查' 
-                                  and a.类别 = 'D' And a.Id  = {0} --And 操作类型 In('DR','CT','MRI','X线')
+                                  Where 分类 ='检查互认项目' 
+                                  and a.类别 = 'D' And b.编码  = '{0}'
                                   group by b.代码";
             sql = string.Format(sql, zlid);
             //Log.Info("sql2:" + sql);
@@ -60,6 +58,40 @@ namespace ZLPlugin_LisPacs_MR
             }
 
         }
+
+        public static void HandleYzData(List<YZData> list,  long patientId,long limit_day ,out string message)
+        {
+            Log.Info("enter HandleYzData = "+ list.Count);
+            message = "";
+            //存在互认的医嘱
+            int existHuRemYz = 0;
+            for (var i = 0; i < list.Count; i++)
+            {
+                if (list[i].诊疗类别 == "C" && list[i].相关ID != "0.0")
+                {
+                    LisPacs_MR_Bll.GetHuRenYzData(patientId, list[i].诊疗项目ID, list[i].诊疗类别, limit_day,out  existHuRemYz);
+                    if (existHuRemYz>=1)
+                    {
+
+                        message = list[i].医嘱内容;
+                        //return message;
+                    }
+
+                }
+                else if (list[i].诊疗类别 == "D" && list[i].相关ID == "0.0")
+                {
+                    LisPacs_MR_Bll.GetHuRenYzData(patientId, list[i].诊疗项目ID, list[i].诊疗类别, limit_day, out existHuRemYz);
+                    if (existHuRemYz >= 1)
+                    {
+
+                        message = list[i].医嘱内容;
+                        //return message;
+                    }
+                }
+            }
+            Log.Info("end HandleYzData = " + message);
+            //return message;
+        }
         /// <summary>
         /// 返回诊疗项目ID
         /// </summary>
@@ -93,7 +125,7 @@ namespace ZLPlugin_LisPacs_MR
                     }
 
                 }
-                else if (list[i].诊疗类别 == "D" && list[i].相关ID == "0.0")
+                else if (list[i].诊疗类别 == "D" && list[i].相关ID != "0.0")
                 {
                     //pacs = list[i].诊疗项目ID + ",";
                     //pacs_id = list[i].ID + ",";
@@ -108,7 +140,9 @@ namespace ZLPlugin_LisPacs_MR
                         codes.id = list[i].ID;
                         codes.type = type;
                         listPacs.Add(codes);
+                        codeNo += type + "#";
                     }
+
                 }
             }
             //lis = lis.Length > 0 ? lis.Substring(0, lis.Length - 1) : lis;
@@ -181,6 +215,37 @@ namespace ZLPlugin_LisPacs_MR
             Tools.QueryTable(sql, out rd);
             return rd;
         }
+        /// <summary>
+        /// 判断之前是否开个互认医嘱
+        /// </summary>
+        /// <param name="patientId"></param>
+        /// <param name="zlId"></param>
+        /// <param name="zlType"></param>
+        /// <param name="limitDay"></param>
+        /// <param name="existHuRemYz"></param>
+        public static void GetHuRenYzData( long patientId ,string zlId,string zlType, long limitDay,out int existHuRemYz)
+        {
+            Log.Info("GetHuRenYzData");
+            existHuRemYz = 0;
+            try
+            {
+                string sql = @"Select count(1)  count
+                                    From 病人医嘱记录 where 病人id={0}  and  诊疗项目id = {1} and 诊疗类别 ='{2}' and 开嘱时间 > sysdate -{3} and 医嘱内容 like '%【互认】' ";
+                sql = string.Format(sql, patientId, zlId, zlType, limitDay);
+                Log.Info(sql);
+                Recordset rd = new Recordset();
+                Tools.QueryTable(sql, out rd);
+                if (!rd.EOF)
+                {
+                    rd.MoveFirst();
+                    existHuRemYz = int.Parse(rd.Fields["count"].Value.ToString());
+                }
+            }catch(Exception ex)
+            {
+                Log.Info("GetHuRenYzData Exception" + ex.Message);
+                existHuRemYz = 0;
+            }
+        }
 
         public static int InsertLis(LISItem lis, long lngPatientID, long lngClinicID, string date, string no,long yzid)
         {
@@ -338,6 +403,32 @@ namespace ZLPlugin_LisPacs_MR
             }
         }
 
+        /// <summary>
+        /// 是否互认
+        /// </summary>
+        /// <returns></returns>
+        public static void ExistHuRemYz(out long limit_day)
+        {
+            limit_day = 1;
+            try
+            {
+                string sql = @"Select limit_day From zllpmr.互认配置表";
+                Recordset rd = new Recordset();
+                Tools.QueryTable(sql, out rd);
+                if (!rd.EOF)
+                {
+                    rd.MoveFirst();
+                    limit_day = long.Parse(rd.Fields["limit_day"].Value.ToString());
+                    
+                }
+            }
+            catch (Exception ex)
+            {
+                Log.Info(ex.Message);
+                Log.Info(ex.StackTrace);
+            }
+        }
+
         /// <summary>
         /// 仅一张纸使用,查询发送的医嘱
         /// </summary>

+ 4 - 4
ZLPlugin_LisPacs_MR/Properties/AssemblyInfo.cs

@@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
 // set of attributes. Change these attribute values to modify the information
 // associated with an assembly.
 [assembly: AssemblyTitle("ZLPlugin_LisPacs_MR")]
-[assembly: AssemblyDescription("")]
+[assembly: AssemblyDescription("相同互认医嘱提示版本")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("")]
 [assembly: AssemblyProduct("ZLPlugin_LisPacs_MR")]
-[assembly: AssemblyCopyright("Copyright ©  2023")]
+[assembly: AssemblyCopyright("Copyright ©  2024")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.4.35.140")]
-[assembly: AssemblyFileVersion("1.4.35.140")]
+[assembly: AssemblyVersion("1.4.35.144")]
+[assembly: AssemblyFileVersion("1.4.35.144")]

+ 1 - 4
ZLPlugin_LisPacs_MR/Tools.cs

@@ -1,9 +1,6 @@
 using ADODB;
 using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Linq;
-using System.Text;
+
 using System.Windows.Forms;
 using ZLPlugin_LisPacs_MR.Domain.Units;
 using ZLPlugin_LisPacs_MR.Model;

+ 39 - 18
ZLPlugin_LisPacs_MR/clsPlugin.cs

@@ -74,7 +74,7 @@ namespace ZLPlugin_LisPacs_MR
                 Tools.Connection = cnOracle;
                 OracleConnect = cnOracle;
                 Domain.Infos.Con = cnOracle;
-                Domain.Infos.ReadConfig();
+                //Domain.Infos.ReadConfig();
                 Log.ClearLogAsyn().Start();
                 IsInit = true;
             }
@@ -102,6 +102,7 @@ namespace ZLPlugin_LisPacs_MR
             {
                 return true;
             }
+            
             SocketClient clientSend = new SocketClient("127.0.0.1", 6061);
             try
             {
@@ -178,14 +179,37 @@ namespace ZLPlugin_LisPacs_MR
             //'               字段 EditState  '1 - 新增,2-修改
             //'      int场合=0-医生站调用,1-护士站调用,2-医技站调用(PACS/LIS)
             Log.Info("AdviceSave  lngModual=="+ lngModual);
+            rsAdvice.Filter = "";
             #region 仅印江人民医院使用,仅支持住院,因为一张纸发送医嘱后也会触发此方法
-            if (lngModual == 1252)
-             {
-                 return true;
-             }
+            /* if (lngModual == 1252)
+              {
+                  return true;
+              }*/
             #endregion
-            rsAdvice.Filter = "";
-            SocketClient client = new SocketClient("127.0.0.1", 6061);
+            string str = Tools.GetAdviceSaveData(rsAdvice);
+            Log.Info("保存前医嘱:" + str);
+            if (str == "")
+            {
+                return true;
+            }
+            List<YZData> ss_list = JSON.JsonToObject<List<YZData>>(Tools.FormatStr(str), Encoding.UTF8);
+            
+            /*Log.Info("111");
+            //循环取出 诊疗项目id   并过滤已经互认的医嘱
+            // 查询医嘱天数  默认一天
+            long limit_day = 1;
+            LisPacs_MR_Bll.ExistHuRemYz(out limit_day);
+            Log.Info("limit_day==" + limit_day);
+            //判断一下 是否已经互认过
+            string message = "";
+            LisPacs_MR_Bll.HandleYzData(ss_list, lngPatientID, limit_day ,out message);
+            Log.Info("message=="+ message);
+            if (!string.IsNullOrWhiteSpace(message))
+            {
+                MessageBox.Show("已经存在互认医嘱为:"+message, "中联软件", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
+                return false;
+            }*/
+            
             try
             {
                 int res = 1;
@@ -195,13 +219,6 @@ namespace ZLPlugin_LisPacs_MR
                 {
                     return true;
                 }
-                string str = Tools.GetAdviceSaveData(rsAdvice);
-                Log.Info("保存前医嘱:" + str);
-                if (str == "")
-                {
-                    return true;
-                }
-                List<YZData> ss_list = JSON.JsonToObject<List<YZData>>(Tools.FormatStr(str), Encoding.UTF8);
                 string code = "";
                 List<Codes> listlis;
                 List<Codes> listpacs;
@@ -229,13 +246,15 @@ namespace ZLPlugin_LisPacs_MR
                 {
                     rd = LisPacs_MR_Bll.GetMZPostJson(lngClinicID, code, hrType);
                 }
+                SocketClient client = new SocketClient("127.0.0.1", 6061);
                 //Results result = new Results();
                 string json = Tools.RecordsetToJson(rd);
                 client.Send(json);
-                Tools.Delay(10000, 0);
+                Tools.Delay(20000, 0);
+                Log.Info("22222"+SocketClient.Message);
                 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)//有互认
@@ -261,10 +280,10 @@ namespace ZLPlugin_LisPacs_MR
                 Log.Info(ex.Message);
                 Log.Info(ex.StackTrace);
             }
-            if (client != null)
+            /*if (client != null)
             {
                 client.Close();
-            }
+            }*/
             return true;
         }
         private bool SaveData(int waittingdate, long lngPatientID, long lngClinicID, List<Codes> listlis, List<Codes> listpacs,int state)
@@ -449,6 +468,7 @@ namespace ZLPlugin_LisPacs_MR
             //'                开始执行时间,执行终止时间(住院调用才有,没填时为cdate(0)), 病人科室id, 开嘱科室id, 开嘱医生, 开嘱时间, 挂号单, 前提id, 摘要
             //'                ,除此之外,门诊调用时,还包含医嘱对应的诊断的疾病ID
             //'      int场合=0-医生站调用,1-护士站调用,2-医技站调用(PACS/LIS)
+            Log.Info("AdviceEditAfter  ");
             return true;
         }
 
@@ -461,6 +481,7 @@ namespace ZLPlugin_LisPacs_MR
             //'      rsAdvice=当前病人本次新开或修改的所有医嘱记录,字段同AdviceEnter接口的该参数,除此之外,门诊调用时,还包含医嘱对应的诊断的疾病ID
             //'               字段 EditState  '1 - 新增,2-修改
             //'      int场合=0-医生站调用,1-护士站调用,2-医技站调用(PACS/LIS)
+            Log.Info("AdviceEnter  ");
             return true;
         }