Procházet zdrojové kódy

药监平台互认弹窗 解决,互认多单检查问题解决

zackhua před 5 měsíci
rodič
revize
0a0bc485de
4 změnil soubory, kde provedl 203 přidání a 72 odebrání
  1. 108 13
      LisPacs_MR_Bll.cs
  2. 2 2
      Properties/AssemblyInfo.cs
  3. 64 0
      SocketClient.cs
  4. 29 57
      clsPlugin.cs

+ 108 - 13
LisPacs_MR_Bll.cs

@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.Text;
 using ZLPlugin_MR.Domain.Units;
 using ZLPlugin_MR.Model;
+using static System.Windows.Forms.AxHost;
 
 namespace ZLPlugin_MR.ServerImpl
 {
@@ -27,7 +28,7 @@ namespace ZLPlugin_MR.ServerImpl
                                     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)
@@ -113,6 +114,7 @@ namespace ZLPlugin_MR.ServerImpl
                         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;
@@ -120,6 +122,7 @@ namespace ZLPlugin_MR.ServerImpl
                         codes.method = list[i].检查方法;
                         listPacs.Add(codes);
                         codeNo += type + "#";
+                        Log.Info("codeNo " + codeNo);
                         billProjectNames += list[i].医嘱内容 + "_" + list[i].标本部位 + "_" + list[i].检查方法 + "、";
                     }
                 }
@@ -150,8 +153,8 @@ namespace ZLPlugin_MR.ServerImpl
                                     d.名称 ""jzDeptName"",
                                     a.住院号 ""businessNumber"",
                                     '{2}' ""standardItemId"",
-                                    '' ""reportStartTime"",
-                                    '' ""reportEndTime"",
+                                    TO_CHAR(SYSDATE-30, 'YYYY-MM-DD HH24:MI:SS') ""reportStartTime"",
+                                    TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') ""reportEndTime"",
                                     '{3}' ""hrType"",
                                     TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') ""applyTime"",
                                     '{4}' ""hisApplyCode"",
@@ -312,8 +315,8 @@ namespace ZLPlugin_MR.ServerImpl
                                     d.名称 ""jzDeptName"",
                                     a.门诊号 ""businessNumber"",
                                     '{1}' ""standardItemId"",
-                                    '' ""reportStartTime"",
-                                    '' ""reportEndTime"",
+                                    TO_CHAR(SYSDATE-30, 'YYYY-MM-DD HH24:MI:SS') ""reportStartTime"",
+                                    TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') ""reportEndTime"",
                                     '{2}' ""hrType"",
                                     TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') ""applyTime"",
                                     '{3}' ""hisApplyCode"",
@@ -462,6 +465,81 @@ namespace ZLPlugin_MR.ServerImpl
 
         }
 
+        public static void SaveDataNew2(Results result, long lngPatientID, long lngClinicID, string no, List<Codes> listlis, List<Codes> listpacs, out List<long> lis_ids, out List<long> pacs_ids)
+        {
+
+            lis_ids = new List<long>();
+            pacs_ids = new List<long>();
+            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");
+                                string xgid = items.id;
+                                int res = InsertLis(lis[i], lngPatientID, lngClinicID, date, no, xgid);
+                                if (res > 0)
+                                {
+                                    lis_ids.Add(long.Parse(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_ids.Add(id);
+                            }
+                            break;
+                        }
+
+                    }
+                }
+            }
+        }
+
         /// <summary>
         ///  保存互认数据  原来只支持一单 
         /// </summary>
@@ -480,20 +558,37 @@ namespace ZLPlugin_MR.ServerImpl
             pacs_ids = new List<long>();
             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, xgid);
-                    if (res > 0)
+                    bool state = true;
+                    for (int j = 0; j < lis[i].ItemList.Count; j++)
                     {
-                        lis_ids.Add(long.Parse(xgid));
-                        for (int k = 0; k < lis[i].ItemList.Count; k++)
+                        if (!state)
                         {
-                            InsertLisItem(lis[i].ItemList[k], lis[i].LisCheckReportId, lngPatientID, lngClinicID, date);
+                            break;
+                        }
+                        foreach (var items in listlis)
+                        {
+                            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, xgid);
+                                if (res > 0)
+                                {
+                                    lis_ids.Add(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;
+                            }
+
                         }
                     }
                 }

+ 2 - 2
Properties/AssemblyInfo.cs

@@ -5,12 +5,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: AssemblyTitle("增加报告开始结束时间,和多单互认不匹配,增加检查乱互认修复")]
 [assembly: AssemblyDescription("ZLPlugin_MR")]
 [assembly: AssemblyConfiguration("")]
 [assembly: AssemblyCompany("")]
 [assembly: AssemblyProduct("ZLPlugin_MR")]
-[assembly: AssemblyCopyright("Copyright ©  2024")]
+[assembly: AssemblyCopyright("Copyright ©  2024 1.0.1.3")]
 [assembly: AssemblyTrademark("")]
 [assembly: AssemblyCulture("")]
 

+ 64 - 0
SocketClient.cs

@@ -3,6 +3,7 @@ using System.Net.Sockets;
 using System.Net;
 using System.Text;
 using System.Threading;
+using System.Security;
 
 namespace ZLPlugin_MR.Domain.Units
 {
@@ -78,6 +79,69 @@ namespace ZLPlugin_MR.Domain.Units
             }
 
         }
+
+        // <summary>
+        /// 循环接收消息  直到有数据
+        /// </summary>
+        public void WhileReceive(int waittingdate)
+        {
+            byte[] buffer = new byte[1024 * 100];
+            int receivedBytes = 0;
+            var begintime = DateTime.Now.Ticks;
+            TimeSpan timeSpan = new TimeSpan();
+            bool flag = true;
+            Log.Info("WhileReceive 开始接收消息》》");
+            while (flag)
+            {
+                Log.Info("flag=" + flag);
+                // 只循环 20 秒  
+                timeSpan = new TimeSpan(DateTime.Now.Ticks - begintime);
+                Log.Info("timeSpan=" + timeSpan);
+                if (timeSpan.TotalSeconds > waittingdate)
+                {
+
+                    flag = false;
+                    Log.Info("flag=" + flag);
+                }
+
+                while (flag)
+                {
+                    try
+                    {
+                        //传递一个byte数组,用于接收数据。length表示接收了多少字节的数据
+                        receivedBytes = _ClientSocket.Receive(buffer);
+                    }
+                    catch (ArgumentNullException e)
+                    {
+                        Log.Info("获取数据超时 ArgumentNullException " + e.Message);
+                        break;
+                    }
+                    catch (SocketException e)
+                    {
+                        Log.Info("获取数据超时 SocketException" + e.Message);
+                        break;
+                    }
+                    catch (ObjectDisposedException e)
+                    {
+                        Log.Info("获取数据超时 ObjectDisposedException" + e.Message);
+                        break;
+                    }
+                    catch (SecurityException e)
+                    {
+                        Log.Info("获取数据超时 SecurityException" + e.Message);
+                        break;
+                    }
+                }
+                Log.Info("receivedBytes " + receivedBytes);
+                if (receivedBytes > 0)
+                {
+                    Message = Encoding.Default.GetString(buffer, 0, receivedBytes);//只将接收到的数据进行转化
+                    Log.Info("WhileReceive 返回消息》》" + Message);
+                    break;
+                }
+            }
+        }
+
         /// <summary>
         /// 接收服务端发送过来的消息
         /// </summary>

+ 29 - 57
clsPlugin.cs

@@ -37,6 +37,7 @@
 using ADODB;
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Net;
 using System.Runtime.InteropServices;
 using System.Text;
@@ -162,42 +163,26 @@ namespace ZLPlugin_MR
                 clientSend.Send(json);
                 //Tools.Delay(10000, 0);
 
-                bool status = true; int i = 0;
-                var begintime = DateTime.Now.Ticks;
-                TimeSpan timeSpan = new TimeSpan();
                 Log.Info("初始化完成!");
-                while (status)
+                try
                 {
-                    timeSpan = new TimeSpan(DateTime.Now.Ticks - begintime);
-                    //Thread.Sleep(3000);
-                    try
-                    {
-                        clientSend.Receive();
-                    }
-                    catch (Exception e)
-                    {
-                        Log.Info("接收失败!" + e.Message);
-                    }
-                    if (timeSpan.TotalSeconds > 10 || !string.IsNullOrWhiteSpace(SocketClient.Message))
-                    {
-                        status = false;
-                    }
-                    Log.Info("timeSpan.TotalSeconds:" + timeSpan.TotalSeconds);
-                    i++;
-
+                    clientSend.WhileReceive(waittingdate);
+                }
+                catch (Exception e)
+                {
+                    Log.Info("接收失败!" + e.Message);
                 }
-                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)//有互认
                     {
+                        
+                        clientSend.WhileReceive(waittingdate);
                         MessageBox.Show("回传数据至his!");
-                        clientSend.Receive();
-                       // SocketClient.Message = null;
+                        // SocketClient.Message = null;
                         SaveData(waittingdate, lngPatientID, lngClinicID, listlis, listpacs, 1);
                         //保存开单项目
                         int ii = LisPacs_MR_Bll.InsertHuRenBillProject(Dns.GetHostName(), lngPatientID, billProjectNames, 999, Tools.GetHostIp(), Infos.UserInfo.ID.ToString(), hisApplyId, hrType.ToString(), Infos.UserInfo.姓名,patientSource);
@@ -275,6 +260,14 @@ namespace ZLPlugin_MR
                 }
 
                 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;
+                }
+
                 string hisApplyId = Tools.Generate16CharGUID();
                 Log.Info("hisApplyId==" + hisApplyId);
                 string patientSource = ""; //病人来源
@@ -364,47 +357,27 @@ namespace ZLPlugin_MR
                 string json = Tools.RecordsetToJson(rd);
                 Log.Info(json);
                 socketClient.Send(json);
-                //Tools.Delay(10000, 0);
-
-                bool status = true; int i = 0;
-                var begintime = DateTime.Now.Ticks;
-                TimeSpan timeSpan = new TimeSpan();
-                Log.Info("初始化完成!");
-                while (status)
+                Log.Info("waittingdate=" + waittingdate);
+                try
                 {
-                    timeSpan = new TimeSpan(DateTime.Now.Ticks - begintime);
-                    //Thread.Sleep(3000);
-                    try
-                    {
-                        socketClient.Receive();
-                    }
-                    catch (Exception e)
-                    {
-                        Log.Info("接收失败!" + e.Message);
-                    }
-                    if (timeSpan.TotalSeconds > 10 || !string.IsNullOrWhiteSpace(SocketClient.Message))
-                    {
-                        status = false;
-                    }
-                    Log.Info("timeSpan.TotalSeconds:" + timeSpan.TotalSeconds);
-                    i++;
-
+                    socketClient.WhileReceive(waittingdate);
+                }
+                catch (Exception e)
+                {
+                    Log.Info("接收失败!" + e.Message);
+                    return false;
                 }
-                Log.Info("22222" + SocketClient.Message);
-                Log.Info("退出循环!");
                 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)//有互认
                     {
-                        MessageBox.Show("回传数据至his!");
-                        socketClient.Receive();
                         
-                        //SocketClient.Message = null;
+                        socketClient.WhileReceive(waittingdate);
+                        MessageBox.Show("回传数据至his!");
                         SaveData(waittingdate, lngPatientID, lngClinicID, listlis, listpacs, -1);
                         //保存开单项目
                         int ii = LisPacs_MR_Bll.InsertHuRenBillProject(Dns.GetHostName(), lngPatientID, billProjectNames, 999, Tools.GetHostIp(), Infos.UserInfo.ID.ToString(), hisApplyId, hrType.ToString(), Infos.UserInfo.姓名, patientSource);
@@ -453,7 +426,6 @@ namespace ZLPlugin_MR
             }
             try
             {
-                Log.Info("互认的信息》》" + SocketClient.Message);
                 result = JSON.JsonToObject<Results>(Tools.FormatStr(SocketClient.Message), Encoding.UTF8);
             }
             catch (Exception ex)//插件关闭时,返回格式不一样
@@ -472,7 +444,7 @@ namespace ZLPlugin_MR
             List<long> lisIds = new List<long>();
             List<long> pacsIds = new List<long>();
             Log.Info("Domain.Infos.UserInfo.编号 = " + Domain.Infos.UserInfo.编号);
-            LisPacs_MR_Bll.SaveDataNew(result, lngPatientID, lngClinicID, Domain.Infos.UserInfo.编号, listlis, listpacs, out lisIds, out pacsIds);
+            LisPacs_MR_Bll.SaveDataNew2(result, lngPatientID, lngClinicID, Infos.UserInfo.编号, listlis, listpacs, out lisIds, out pacsIds);
             Log.Info("state:"+ state + "  lisId"+ lisIds.Count);
             if (state < 1)
             {