Browse Source

多单医嘱项目合开问题解决

zzh_love 6 tháng trước cách đây
mục cha
commit
b62342dfdc
4 tập tin đã thay đổi với 236 bổ sung45 xóa
  1. 127 4
      LisPacs_MR_Bll.cs
  2. 2 2
      Properties/AssemblyInfo.cs
  3. 20 0
      Tools.cs
  4. 87 39
      clsPlugin.cs

+ 127 - 4
LisPacs_MR_Bll.cs

@@ -63,13 +63,14 @@ namespace ZLPlugin_MR.ServerImpl
         /// </summary>
         /// <param name="rsAdvice"></param>
         /// <returns></returns>
-        public static void GetTreatmentId(List<YZData> list, out string codeNo, out List<Codes> listlis, out List<Codes> listPacs)
+        public static void GetTreatmentId(List<YZData> list, out string codeNo, out List<Codes> listlis, out List<Codes> listPacs, out string billProjectNames)
         {
             //lis = "";
             //lis_id = "";
             //pacs = "";
             //pacs_id = "";
             codeNo = "";
+            billProjectNames = "";
             listlis = new List<Codes>();
             listPacs = new List<Codes>();
             for (var i = 0; i < list.Count; i++)
@@ -90,6 +91,7 @@ namespace ZLPlugin_MR.ServerImpl
                         //lis += list[i].诊疗项目ID + ",";
                         //lis_id += list[i].ID + ",";
                         codeNo += code + "#";
+                        billProjectNames += list[i].医嘱内容 + "、";
                     }
 
                 }
@@ -115,6 +117,7 @@ namespace ZLPlugin_MR.ServerImpl
                         codes.method = list[i].检查方法;
                         listPacs.Add(codes);
                         codeNo += type + "#";
+                        billProjectNames += list[i].医嘱内容 + "、";
                     }
                 }
             }
@@ -161,6 +164,28 @@ namespace ZLPlugin_MR.ServerImpl
             return rd;
         }
 
+        /// <summary>
+        /// 插入互认开单项目数据
+        /// </summary>
+        /// <param name="computerName"></param>
+        /// <param name="lngPatientID"></param>
+        /// <param name="billName"></param>
+        /// <param name="lngSendID"></param>
+        /// <param name="ip"></param>
+        /// <param name="no"></param>
+        /// <param name="yzID"></param>
+        /// <param name="type"></param>
+        /// <param name="operatorName"></param>
+        /// <returns></returns>
+        public static int InsertHuRenBillProject(string computerName, long lngPatientID, string billName, long lngSendID, string ip, string no, string yzXgID, string type, string operatorName)
+        {
+            string sql = @"Insert Into 互认开单项目(计算机名,患者id,开单项目,开单时间,发送号,计算机IP,单据号,相关id,类别,开单人) 
+                            Values('{0}','{1}','{2}',to_date('{3}','yyyy-mm-dd hh24:mi:ss'),{4},'{5}','{6}','{7}','{8}','{9}')";
+            sql = string.Format(sql, computerName, lngPatientID, billName, DateTime.Now, lngSendID, ip, no, yzXgID, type, operatorName);
+            Log.Info("InsertLis:" + sql);
+            int res = Tools.ExecuteSql(sql);
+            return res;
+        }
 
         public static string GetZYTotalPrice(string zlxmid)
         {
@@ -205,6 +230,34 @@ namespace ZLPlugin_MR.ServerImpl
             return "0";
         }
 
+        public static decimal GetTotalPriceForLisByZlxmIds(string zlxmids)
+        {
+            string sql = @"Select nvl(sum(现价),'0') 金额 from 收费价目 where  终止日期 > sysdate  and 收费细目id in (select 收费项目id from 诊疗收费关系 where 诊疗项目id in ({0}) )";
+            sql = string.Format(sql, zlxmids);
+            Log.Info("GetTotalPriceForLisByZLXM==" + sql);
+            Recordset rd = new Recordset();
+            Tools.QueryTable(sql, out rd);
+            if (!rd.EOF)
+            {
+                rd.MoveFirst();
+                decimal amount = Convert.ToDecimal(rd.Fields["金额"].Value.ToString());
+                return amount;
+            }
+            return 0;
+        }
+
+        //获取诊疗项目ids
+        public static string GetZlxmIdFromList(List<Codes> list)
+        {
+            string zlxmids = "";
+            for (var i = 0; i < list.Count; i++)
+            {
+                zlxmids += list[i].zlxmid + ",";
+            }
+            zlxmids = zlxmids.Length > 0 ? zlxmids.Substring(0, zlxmids.Length - 1) : zlxmids;
+            return zlxmids;
+        }
+
         /// <summary>
         /// 
         /// </summary>
@@ -214,7 +267,7 @@ namespace ZLPlugin_MR.ServerImpl
         /// <param name="method"> 方法</param>
         /// <param name="patientResource"> 病人来源   门诊  1  还是住院  2   0 所有</param>
         /// <returns></returns>
-        public static string GetTotalPriceForPacsByZLXM(string zlxmid, string zlksid, string part, string method, int patientResource)
+        public static decimal GetTotalPriceForPacsByZLXM(string zlxmid, string zlksid, string part, string method, int patientResource)
         {
             string sql = @"select nvl(sum(a.现价* b.收费数量),'0') 金额 from 收费价目 a,(
                     select * from 诊疗收费关系  where 诊疗项目id = {0} and ( 适用科室id  is null or  适用科室id = {1} )and 检查部位 = '{2}' and 检查方法 = '{3}'  and 病人来源 <> {4}
@@ -228,9 +281,10 @@ namespace ZLPlugin_MR.ServerImpl
             if (!rd.EOF)
             {
                 rd.MoveFirst();
-                return rd.Fields["金额"].Value.ToString();
+                decimal amount = Convert.ToDecimal(rd.Fields["金额"].Value.ToString());
+                return amount;
             }
-            return "0";
+            return 0;
         }
 
         /// <summary>
@@ -403,6 +457,74 @@ namespace ZLPlugin_MR.ServerImpl
 
 
         }
+
+        /// <summary>
+        ///  保存互认数据  原来只支持一单 
+        /// </summary>
+        /// <param name="result"></param>
+        /// <param name="lngPatientID"></param>
+        /// <param name="lngClinicID"></param>
+        /// <param name="no"></param>
+        /// <param name="listlis"></param>
+        /// <param name="listpacs"></param>
+        /// <param name="lis_id"></param>
+        /// <param name="pacs_id"></param>
+        public static void SaveDataNew(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)
+            {
+                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)
+                    {
+                        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);
+                        }
+                    }
+                }
+            }
+            if (pacs != null)
+            {
+                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)
+                        {
+
+                            id = long.Parse(items.id);
+                            break;
+                        }
+                    }
+                    int res = InsertPacs(pacs[i], lngPatientID, lngClinicID, no, id);
+                    if (res > 0)
+                    {
+                        if (pacs_id == -1)
+                        {
+                            pacs_id = id;
+                        }
+                    }
+                }
+
+            }
+        }
+
+
         /// <summary>
         /// 是否互认
         /// </summary>
@@ -548,6 +670,7 @@ namespace ZLPlugin_MR.ServerImpl
             }
             return list;
         }
+
         /// <summary>
         /// 作废医嘱
         /// </summary>

+ 2 - 2
Properties/AssemblyInfo.cs

@@ -5,7 +5,7 @@ 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("")]
@@ -33,4 +33,4 @@ using System.Runtime.InteropServices;
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
 [assembly: AssemblyVersion("1.4.35.140")]
-[assembly: AssemblyFileVersion("1.0.1.1")]
+[assembly: AssemblyFileVersion("1.0.1.2")]

+ 20 - 0
Tools.cs

@@ -1,5 +1,7 @@
 using ADODB;
 using System;
+using System.Net;
+using System.Net.Sockets;
 using System.Windows.Forms;
 using ZLPlugin_MR.Model;
 
@@ -7,6 +9,24 @@ namespace ZLPlugin_MR.Domain.Units
 {
     public class Tools
     {
+
+        public static string GetHostIp()
+        {
+            string hostName = Dns.GetHostName();
+            IPHostEntry ipHostInfo = Dns.GetHostEntry(hostName);
+            IPAddress[] ipAddresses = ipHostInfo.AddressList;
+
+            foreach (IPAddress ip in ipAddresses)
+            {
+                if (ip.AddressFamily == AddressFamily.InterNetwork)
+                {
+                    Console.WriteLine("本机 IP 地址:" + ip);
+                    return ip.ToString();
+                }
+            }
+            return hostName;
+        }
+
         public static string FormatStr(string str)
         {
             return str.Replace("\n", "").Replace("\t", "").Replace("\r", "");

+ 87 - 39
clsPlugin.cs

@@ -37,9 +37,11 @@
 using ADODB;
 using System;
 using System.Collections.Generic;
+using System.Net;
 using System.Runtime.InteropServices;
 using System.Text;
 using System.Windows.Forms;
+using ZLPlugin_MR.Domain;
 using ZLPlugin_MR.Domain.Units;
 using ZLPlugin_MR.Model;
 using ZLPlugin_MR.ServerImpl;
@@ -85,7 +87,6 @@ namespace ZLPlugin_MR
             //'      lngSendID=发送号(病人医嘱发送.id)
             Log.Info("AdviceSend   lngModual == " + lngModual );
             Log.Info("AdviceSend   lngSys == " + lngSys);
-            
             //住院的时候发送 不需要  20241015
             if (lngModual == 1254)
             {
@@ -93,7 +94,6 @@ namespace ZLPlugin_MR
             }
             //--------------  20241015
             Log.Info("AdviceSend  enter=="+ lngSendID);
-            
             try
             {
                 Log.Info("AdviceSend  enter==");
@@ -107,14 +107,13 @@ namespace ZLPlugin_MR
                 }
                 List<YZData> ss_list = LisPacs_MR_Bll.GetYZList(lngSendID);
                 string code = "";
+                string billProjectNames = "";  //开单项目名称
                 List<Codes> listlis;
                 List<Codes> listpacs;
-                LisPacs_MR_Bll.GetTreatmentId(ss_list, out code, out listlis, out listpacs);
-
-                string xgid = "";
-                string yzid = "";
-                string zlxmid = "";
-                string totalPrice = "0";
+                LisPacs_MR_Bll.GetTreatmentId(ss_list, out code, out listlis, out listpacs,out billProjectNames);
+                Log.Info("code==" + code);
+                Log.Info("billProjectNames==" + billProjectNames);
+                decimal totalPrice = 0;
                 int hrType = 0;
                 if (listlis.Count == 0 && listpacs.Count == 0)
                 {
@@ -124,20 +123,34 @@ namespace ZLPlugin_MR
                 else if (listlis.Count > 0 && listpacs.Count == 0)//只有检验
                 {
                     hrType = 1;
-                    yzid = listlis[0].yzid;
-                    xgid = listlis[0].id;
-                    zlxmid = listlis[0].zlxmid;
                 }
                 else if (listpacs.Count > 0 && listlis.Count == 0)//只有检查
                 {
                     hrType = 2;
-                    yzid = listpacs[0].yzid;
-                    xgid = listpacs[0].id;
-                    zlxmid = listpacs[0].zlxmid;
                 }
-
-                totalPrice= LisPacs_MR_Bll.GetMZTotalPrice(lngPatientID, yzid);
-                Recordset rd = LisPacs_MR_Bll.GetMZPostJson(lngClinicID, code, hrType, totalPrice, xgid);
+                if (hrType == 1)
+                {
+                    totalPrice = LisPacs_MR_Bll.GetTotalPriceForLisByZlxmIds(LisPacs_MR_Bll.GetZlxmIdFromList(listlis));// 获取总金额
+                     //totalPrice = LisPacs_MR_Bll.GetTotalPriceForLisByZLXM(zlxmid);
+                }
+                else if (hrType == 2)
+                {
+                    for (var ii = 0; ii < listpacs.Count; ii++)
+                    {
+                        totalPrice += LisPacs_MR_Bll.GetTotalPriceForPacsByZLXM(listpacs[ii].zlxmid, listpacs[ii].zxksid, listpacs[ii].part, listpacs[ii].method, 2);
+                    }
+                    // totalPrice = LisPacs_MR_Bll.GetTotalPriceForPacsByZLXM(zlxmid, listpacs[0].zxksid, listpacs[0].part, listpacs[0].method, 2);
+                }
+                else
+                {
+                    //获取合单之后 同时有检查和检验  的开单项目唯一id  以及金额
+                    totalPrice = LisPacs_MR_Bll.GetTotalPriceForLisByZlxmIds(LisPacs_MR_Bll.GetZlxmIdFromList(listlis));// 获取总金额
+                    for (var ii = 0; ii < listpacs.Count; ii++)
+                    {
+                        totalPrice += LisPacs_MR_Bll.GetTotalPriceForPacsByZLXM(listpacs[ii].zlxmid, listpacs[ii].zxksid, listpacs[ii].part, listpacs[ii].method, 2);
+                    }
+                }
+                Recordset rd = LisPacs_MR_Bll.GetMZPostJson(lngClinicID, code, hrType, totalPrice.ToString(), code);
                 string json = Tools.RecordsetToJson(rd);
                 Log.Info(json);
                 SocketClient clientSend = new SocketClient("127.0.0.1", 6061);
@@ -181,6 +194,9 @@ namespace ZLPlugin_MR
                         clientSend.Receive();
                        // 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(), code, hrType.ToString(), Infos.UserInfo.用户名);
+                        Log.Info("开单状态=" + ii);
                         clientSend.Close();
                         return true;
                     }
@@ -192,6 +208,9 @@ namespace ZLPlugin_MR
                     }
                     else
                     {
+                        MessageBox.Show(rex.ResultText.ToString(), "中联软件", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
+                        int ii = LisPacs_MR_Bll.InsertHuRenBillProject(Dns.GetHostName(), lngPatientID, billProjectNames, 999, Tools.GetHostIp(), Infos.UserInfo.ID.ToString(), code, hrType.ToString(), Infos.UserInfo.用户名);
+                        Log.Info("开单状态=" + ii);
                         clientSend.Close();
                         return true;//此病人不存在互认信息
                     }
@@ -250,16 +269,14 @@ namespace ZLPlugin_MR
                 }
                 List<YZData> ss_list = JSON.JsonToObject<List<YZData>>(Tools.FormatStr(str), Encoding.UTF8);
                 string code = "";
+                string billProjectNames = "";  //开单项目名称
                 List<Codes> listlis;
                 List<Codes> listpacs;
-                LisPacs_MR_Bll.GetTreatmentId(ss_list, out code, out listlis, out listpacs);
+                LisPacs_MR_Bll.GetTreatmentId(ss_list, out code, out listlis, out listpacs, out billProjectNames);
                 Log.Info("code==" + code);
+                Log.Info("billProjectNames==" + billProjectNames);
                 Recordset rd = new Recordset();
-
-                string xgid = "";
-                string yzid = "";
-                string zlxmid = "";
-                string totalPrice = "0";
+                decimal totalPrice = 0;
                 int hrType = 0;
                 if (listlis.Count == 0 && listpacs.Count == 0)
                 {
@@ -269,37 +286,64 @@ namespace ZLPlugin_MR
                 else if (listlis.Count > 0 && listpacs.Count == 0)//只有检验
                 {
                     hrType = 1;
-                    yzid = listlis[0].yzid;
-                    xgid = listlis[0].id;
-                    zlxmid = listlis[0].zlxmid;
                 }
                 else if (listpacs.Count > 0 && listlis.Count == 0)//只有检查
                 {
                     hrType = 2;
-                    yzid = listpacs[0].yzid;
-                    xgid = listpacs[0].id;
-                    zlxmid = listpacs[0].zlxmid;
                 }
 
                 if (lngModual == 1253)//住院
                 {
                     if (hrType == 1)
                     {
-                        totalPrice = LisPacs_MR_Bll.GetTotalPriceForLisByZLXM(zlxmid);
+                        totalPrice = LisPacs_MR_Bll.GetTotalPriceForLisByZlxmIds(LisPacs_MR_Bll.GetZlxmIdFromList(listlis));// 获取总金额
+                        //totalPrice = LisPacs_MR_Bll.GetTotalPriceForLisByZLXM(zlxmid);
+                    }
+                    else if (hrType == 2)
+                    {
+                        for (var ii = 0; ii < listpacs.Count; ii++)
+                        {
+                            totalPrice += LisPacs_MR_Bll.GetTotalPriceForPacsByZLXM(listpacs[ii].zlxmid, listpacs[ii].zxksid, listpacs[ii].part, listpacs[ii].method, 1);
+                        }
                     }
                     else
                     {
-
-                        totalPrice = LisPacs_MR_Bll.GetTotalPriceForPacsByZLXM(zlxmid, listpacs[0].zxksid, listpacs[0].part, listpacs[0].method, 1);
+                        //获取合单之后 同时有检查和检验  的开单项目唯一id  以及金额
+                        totalPrice = LisPacs_MR_Bll.GetTotalPriceForLisByZlxmIds(LisPacs_MR_Bll.GetZlxmIdFromList(listlis));// 获取总金额
+                        for (var ii = 0; ii < listpacs.Count; ii++)
+                        {
+                            totalPrice += LisPacs_MR_Bll.GetTotalPriceForPacsByZLXM(listpacs[ii].zlxmid, listpacs[ii].zxksid, listpacs[ii].part, listpacs[ii].method, 1);
+                        }
                     }
                     //totalPrice = LisPacs_MR_Bll.GetZYTotalPrice(zlxmid);
-                    rd = LisPacs_MR_Bll.GetZYPostJson(lngPatientID, lngClinicID, code, hrType, totalPrice, xgid);
+                    rd = LisPacs_MR_Bll.GetZYPostJson(lngPatientID, lngClinicID, code, hrType, totalPrice.ToString(), code);
                 }
                 else
                 {
-                     totalPrice = LisPacs_MR_Bll.GetMZTotalPrice(lngPatientID, yzid);
-                    
-                    rd = LisPacs_MR_Bll.GetMZPostJson(lngClinicID, code, hrType, totalPrice,xgid);
+                    //totalPrice = LisPacs_MR_Bll.GetMZTotalPrice(lngPatientID, yzid);
+                    if (hrType == 1)
+                    {
+                        totalPrice = LisPacs_MR_Bll.GetTotalPriceForLisByZlxmIds(LisPacs_MR_Bll.GetZlxmIdFromList(listlis));// 获取总金额
+                        //totalPrice = LisPacs_MR_Bll.GetTotalPriceForLisByZLXM(zlxmid);
+                    }
+                    else if (hrType == 2)
+                    {
+                        for (var ii = 0; ii < listpacs.Count; ii++)
+                        {
+                            totalPrice += LisPacs_MR_Bll.GetTotalPriceForPacsByZLXM(listpacs[ii].zlxmid, listpacs[ii].zxksid, listpacs[ii].part, listpacs[ii].method, 2);
+                        }
+                        // totalPrice = LisPacs_MR_Bll.GetTotalPriceForPacsByZLXM(zlxmid, listpacs[0].zxksid, listpacs[0].part, listpacs[0].method, 2);
+                    }
+                    else
+                    {
+                        //获取合单之后 同时有检查和检验  的开单项目唯一id  以及金额
+                        totalPrice = LisPacs_MR_Bll.GetTotalPriceForLisByZlxmIds(LisPacs_MR_Bll.GetZlxmIdFromList(listlis));// 获取总金额
+                        for (var ii = 0; ii < listpacs.Count; ii++)
+                        {
+                            totalPrice += LisPacs_MR_Bll.GetTotalPriceForPacsByZLXM(listpacs[ii].zlxmid, listpacs[ii].zxksid, listpacs[ii].part, listpacs[ii].method, 1);
+                        }
+                    }
+                    rd = LisPacs_MR_Bll.GetMZPostJson(lngClinicID, code, hrType, totalPrice.ToString(),code);
                 }
                 SocketClient socketClient = new SocketClient("127.0.0.1", 6061);
                 //Results result = new Results();
@@ -333,7 +377,6 @@ namespace ZLPlugin_MR
 
                 }
                 Log.Info("22222" + SocketClient.Message);
-
                 if (!string.IsNullOrWhiteSpace(SocketClient.Message))
                 {
                     Log.Info(SocketClient.Message);
@@ -345,6 +388,9 @@ namespace ZLPlugin_MR
                         socketClient.Receive();
                         //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(), code, hrType.ToString(), Infos.UserInfo.用户名);
+                        Log.Info("开单状态=" + ii);
                         socketClient.Close();
                         return true;
                     }
@@ -356,10 +402,12 @@ namespace ZLPlugin_MR
                     }
                     else
                     {
+                        MessageBox.Show(rex.ResultText.ToString(), "中联软件", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
+                        int ii = LisPacs_MR_Bll.InsertHuRenBillProject(Dns.GetHostName(), lngPatientID, billProjectNames, 999, Tools.GetHostIp(), Infos.UserInfo.ID.ToString(), code, hrType.ToString(), Infos.UserInfo.用户名);
+                        Log.Info("开单状态=" + ii);
                         socketClient.Close();
                         return true;//此病人不存在互认信息
                     }
-
                 }
                 socketClient.Close();
             }
@@ -405,7 +453,7 @@ namespace ZLPlugin_MR
             long lisId;
             long pacsId;
             Log.Info("Domain.Infos.UserInfo.编号 = " + Domain.Infos.UserInfo.编号);
-            LisPacs_MR_Bll.SaveData(result, lngPatientID, lngClinicID, Domain.Infos.UserInfo.编号, listlis, listpacs, out lisId, out pacsId);
+            LisPacs_MR_Bll.SaveDataNew(result, lngPatientID, lngClinicID, Domain.Infos.UserInfo.编号, listlis, listpacs, out lisId, out pacsId);
             Log.Info("state:"+ state + "  lisId"+ lisId);
             if (state < 1)
             {