From dda0aa0aa2af66c3a5075bc846e0579d913cbadb Mon Sep 17 00:00:00 2001 From: lxd <1004405501@qq.com> Date: Fri, 25 Apr 2025 11:11:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B2=E5=BE=B7=E5=8D=AB=E7=94=9F=E9=99=A2?= =?UTF-8?q?=205390=20=208460=20=20=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.config | 4 +- deviceAnalysis.cs | 211 ++++++++++++++++++++++++++++++++++++++++--- mainForm.Designer.cs | 2 +- mainForm.cs | 4 +- 4 files changed, 206 insertions(+), 15 deletions(-) diff --git a/app.config b/app.config index 46b9f70..d8ffb6d 100644 --- a/app.config +++ b/app.config @@ -86,6 +86,8 @@ - + + + diff --git a/deviceAnalysis.cs b/deviceAnalysis.cs index a31bac2..79fdee2 100644 --- a/deviceAnalysis.cs +++ b/deviceAnalysis.cs @@ -2662,7 +2662,14 @@ namespace FlyDockTool erm.sampleNo = sampleNo1; erm.testDate = testDate1; erm.chanelNo = "WBC";//项目代号 - erm.itemValue = resulteArray[i + 4].Replace("WBC", "").Replace("CELL/uL", "").Trim().Split(' ')[0].Trim(); //项目结果 + if (resulteArray[i + 4].Contains("*")) + { + erm.itemValue = resulteArray[i + 4].Replace("*WBC", "").Replace("CELL/uL", "").Trim().Split(' ')[0].Trim(); //项目结果; + } + else + { + erm.itemValue = resulteArray[i + 4].Replace("WBC", "").Replace("CELL/uL", "").Trim().Split(' ')[0].Trim(); //项目结果; + } erm.itemUnit = ""; ermList.Add(erm); examResultMode erm1 = new examResultMode(); @@ -2671,7 +2678,15 @@ namespace FlyDockTool erm1.sampleNo = sampleNo1; erm1.testDate = testDate1; erm1.chanelNo = "KET";//项目代号 - erm1.itemValue = resulteArray[i + 5].Replace("KET", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim(); + if (resulteArray[i + 5].Contains("*")) + { + erm1.itemValue = resulteArray[i + 5].Replace("*KET", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim(); + } + else + { + erm1.itemValue = resulteArray[i + 5].Replace("KET", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim(); + } + erm1.itemUnit = ""; ermList.Add(erm1); @@ -2681,7 +2696,15 @@ namespace FlyDockTool erm2.sampleNo = sampleNo1; erm2.testDate = testDate1; erm2.chanelNo = "NIT";//项目代号 - erm2.itemValue = resulteArray[i + 6].Replace("NIT", "").Replace("Neg", "").Trim().Split(' ')[0].Trim(); + if (resulteArray[i + 6].Contains("*")) + { + erm2.itemValue = resulteArray[i + 6].Replace("*NIT", "").Replace("Neg", "").Trim().Split(' ')[0].Trim(); + } + else + { + erm2.itemValue = resulteArray[i + 6].Replace("NIT", "").Replace("Neg", "").Trim().Split(' ')[0].Trim(); + } + erm2.itemUnit = ""; ermList.Add(erm2); @@ -2691,7 +2714,15 @@ namespace FlyDockTool erm3.sampleNo = sampleNo1; erm3.testDate = testDate1; erm3.chanelNo = "URO";//项目代号 - erm3.itemValue = resulteArray[i + 7].Replace("URO", "").Replace("umol/L", "").Trim().Split(' ')[0].Trim(); + if (resulteArray[i + 7].Contains("*")) + { + erm3.itemValue = resulteArray[i + 7].Replace("*URO", "").Replace("umol/L", "").Trim().Split(' ')[0].Trim(); + } + else + { + erm3.itemValue = resulteArray[i + 7].Replace("URO", "").Replace("umol/L", "").Trim().Split(' ')[0].Trim(); + } + erm3.itemUnit = ""; ermList.Add(erm3); @@ -2701,7 +2732,14 @@ namespace FlyDockTool erm4.sampleNo = sampleNo1; erm4.testDate = testDate1; erm4.chanelNo = "BIL";//项目代号 - erm4.itemValue = resulteArray[i + 8].Replace("BIL", "").Replace("umol/L", "").Trim().Split(' ')[0].Trim(); + if (resulteArray[i + 8].Contains("*")) + { + erm4.itemValue = resulteArray[i + 8].Replace("*BIL", "").Replace("umol/L", "").Trim().Split(' ')[0].Trim(); + } + else + { + erm4.itemValue = resulteArray[i + 8].Replace("BIL", "").Replace("umol/L", "").Trim().Split(' ')[0].Trim(); + } erm4.itemUnit = ""; ermList.Add(erm4); @@ -2712,7 +2750,15 @@ namespace FlyDockTool erm5.sampleNo = sampleNo1; erm5.testDate = testDate1; erm5.chanelNo = "PRO";//项目代号 - erm5.itemValue = resulteArray[i + 9].Replace("PRO", "").Replace("g/L", "").Trim().Split(' ')[0].Trim(); + if (resulteArray[i + 9].Contains("*")) + { + erm5.itemValue = resulteArray[i + 9].Replace("*PRO", "").Replace("g/L", "").Trim().Split(' ')[0].Trim(); + } + else + { + erm5.itemValue = resulteArray[i + 9].Replace("PRO", "").Replace("g/L", "").Trim().Split(' ')[0].Trim(); + } + erm5.itemUnit = ""; ermList.Add(erm5); @@ -2723,7 +2769,15 @@ namespace FlyDockTool erm6.sampleNo = sampleNo1; erm6.testDate = testDate1; erm6.chanelNo = "GLU";//项目代号 - erm6.itemValue = resulteArray[i + 10].Replace("GLU", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim(); + if (resulteArray[i + 10].Contains("*")) + { + erm6.itemValue = resulteArray[i + 10].Replace("*GLU", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim(); + } + else + { + erm6.itemValue = resulteArray[i + 10].Replace("GLU", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim(); + } + erm6.itemUnit = ""; ermList.Add(erm6); @@ -2733,7 +2787,15 @@ namespace FlyDockTool erm10.sampleNo = sampleNo1; erm10.testDate = testDate1; erm10.chanelNo = "SG";//项目代号 - erm10.itemValue = resulteArray[i + 11].Replace("SG", "").Trim().Split(' ')[0].Trim(); + if (resulteArray[i + 11].Contains("*")) + { + erm10.itemValue = resulteArray[i + 11].Replace("*SG", "").Trim().Split(' ')[0].Trim(); + } + else + { + erm10.itemValue = resulteArray[i + 11].Replace("SG", "").Trim().Split(' ')[0].Trim(); + } + erm10.itemUnit = ""; ermList.Add(erm10); @@ -2744,7 +2806,15 @@ namespace FlyDockTool erm7.sampleNo = sampleNo1; erm7.testDate = testDate1; erm7.chanelNo = "BLD";//项目代号 - erm7.itemValue = resulteArray[i + 12].Replace("BLD", "").Replace("CELL/uL", "").Trim().Split(' ')[0].Trim(); + if (resulteArray[i + 12].Contains("*")) + { + erm7.itemValue = resulteArray[i + 12].Replace("*BLD", "").Replace("CELL/uL", "").Trim().Split(' ')[0].Trim(); + } + else + { + erm7.itemValue = resulteArray[i + 12].Replace("BLD", "").Replace("CELL/uL", "").Trim().Split(' ')[0].Trim(); + } + erm7.itemUnit = ""; ermList.Add(erm7); @@ -2754,7 +2824,15 @@ namespace FlyDockTool erm8.sampleNo = sampleNo1; erm8.testDate = testDate1; erm8.chanelNo = "pH";//项目代号 - erm8.itemValue = resulteArray[i + 13].Replace("pH", "").Trim().Split(' ')[0].Trim(); + if (resulteArray[i + 13].Contains("*")) + { + erm8.itemValue = resulteArray[i + 13].Replace("*pH", "").Trim().Split(' ')[0].Trim(); + } + else + { + erm8.itemValue = resulteArray[i + 13].Replace("pH", "").Trim().Split(' ')[0].Trim(); + } + erm8.itemUnit = ""; ermList.Add(erm8); @@ -2764,7 +2842,15 @@ namespace FlyDockTool erm9.sampleNo = sampleNo1; erm9.testDate = testDate1; erm9.chanelNo = "Vc";//项目代号 - erm9.itemValue = resulteArray[i + 14].Replace("Vc", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim(); + if (resulteArray[i + 14].Contains("*")) + { + erm9.itemValue = resulteArray[i + 14].Replace("*Vc", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim(); + } + else + { + erm9.itemValue = resulteArray[i + 14].Replace("Vc", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim(); + } + erm9.itemUnit = ""; ermList.Add(erm9); @@ -3006,6 +3092,44 @@ namespace FlyDockTool } } + if (apiOptions.CurrentDevice == "BH-5390")//BH-5390 + { + string MachineCode = apiOptions.MachineCode; + string MachineID = apiOptions.MachineID; + deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", ""); + //string[] resulteArray = deviceDataStr.Split('\n'); + string sampleNo1 = string.Empty;//样本号 + + List ermList = new List(); + string[] itemArray = new string[] { "WBC", "LYM%", "MON%", "NEU%", "EOS%", "BASO%", "LYM#", "MON#", "NEU#", "EOS#", "BASO#", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW_SD", "RDW_CV", "PLT", "MPV", "PDW", "PCT", "P_LCR", "P_LCC", "*ALY%", "*LIC%", "*NRBC%" }; + + for (int i = 0; i < itemArray.Length; i++) + { + string itemStr = string.Empty; + itemStr = @"(" + itemArray[i] + @")^||"; + + string val1 = deviceDataStr.Substring(deviceDataStr.IndexOf("OBR"), 30); + sampleNo1 = val1.Split('|')[3]; + string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + + examResultMode erm1 = new examResultMode(); + erm1.machineCode = MachineCode; + erm1.machineID = MachineID; + erm1.sampleNo = sampleNo1; + erm1.testDate = testDate1; + erm1.chanelNo = itemArray[i];//项目代号 + erm1.itemValue = GetTestValue(deviceDataStr, itemArray[i]).ToString();//项目结果; + erm1.itemUnit = ""; + ermList.Add(erm1); + } + string jsonStr = JsonConvert.SerializeObject(ermList); + //将结果提交到LIS系统 + baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList); + if (bmm1.code == 200) + dataOutPutShow("数据提交成功:" + jsonStr, null); + else + dataOutPutShow("数据提交失败:" + jsonStr, null); + } return rerultJson; } @@ -3137,6 +3261,43 @@ namespace FlyDockTool return val1; } + /// + /// 从HL7消息中获取指定检验项目的值 + /// + /// HL7消息字符串 + /// 检验项目名称(如:WBC、LYM%等) + /// 检验项目的值,如果未找到则返回空字符串 + public string GetTestValue(string hl7Message, string testName) + { + try + { + // 查找包含目标名称的位置 + int index = hl7Message.IndexOf("^" + testName + "^"); + if (index == -1) + return string.Empty; + + // 找到后面的竖线位置 + int startIndex = hl7Message.IndexOf("||", index); + if (startIndex == -1) + return string.Empty; + + startIndex += 2; // 跳过竖线 + + // 找到下一个竖线位置 + int endIndex = hl7Message.IndexOf("|", startIndex); + if (endIndex == -1) + return string.Empty; + + // 提取值 + string value = hl7Message.Substring(startIndex, endIndex - startIndex); + return value.Trim(); + } + catch (Exception ex) + { + return string.Empty; + } + } + /// /// 从字符串中 解析出 jiexiBase64 图像 @@ -3668,6 +3829,22 @@ namespace FlyDockTool SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData); SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收 } + if (apiOptions.CurrentDevice == "BH-5390")//BH-5390 + { + // 设置IP地址和端口号 + string tcp_ip = ConfigurationManager.AppSettings[apiOptions.CurrentDevice].Split(',')[3]; + string tcp_port = ConfigurationManager.AppSettings[apiOptions.CurrentDevice].Split(',')[4]; + IPAddress ipAddress = IPAddress.Parse(tcp_ip); + // IPAddress ipAddress = IPAddress.Any; + //// 创建一个监听Socket + if (listener == null) + { + listener = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); + listener.Bind(new IPEndPoint(ipAddress, int.Parse(tcp_port))); + listener.Listen(10000); + } + _tcpResult.Change(0, 10);//开始tcp数据接收,10毫秒频率 + } } /// @@ -3875,6 +4052,13 @@ namespace FlyDockTool //_tResult.Change(5000, 5000);// 数据处理:延迟5秒开始 5秒计时 } + if (apiOptions.CurrentDevice == "BH-5390")//BH-5390 + { + string tempData_temp = tempData; + tempData = string.Empty; + if (!string.IsNullOrWhiteSpace(tempData_temp)) + deviceAnalysisOption(tempData_temp); + } if (apiOptions.CurrentDevice == "URIT-500B")//优利特尿常规URIT-500B _tResult.Change(5000, 5000);// 数据处理:延迟5秒开始 5秒计时 if (apiOptions.CurrentDevice == "URIT-330")//优利特尿常规URIT-300 @@ -4263,6 +4447,11 @@ namespace FlyDockTool { SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收 } + if (apiOptions.CurrentDevice == "BH-5390")//BH-5390 + { + _tcpResult.Change(-1, 10);//停止tcp数据接收 + clientSocket.Close(); + } } ///// diff --git a/mainForm.Designer.cs b/mainForm.Designer.cs index 40682e3..98da088 100644 --- a/mainForm.Designer.cs +++ b/mainForm.Designer.cs @@ -200,7 +200,7 @@ this.MinimizeBox = false; this.Name = "mainForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "福乐云软硬件数据对接工具V1.1(2025041503)"; + this.Text = "福乐云软硬件数据对接工具V1.1(2025042501)"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.mainForm_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); this.groupBox2.ResumeLayout(false); diff --git a/mainForm.cs b/mainForm.cs index a354f39..cb0f6fc 100644 --- a/mainForm.cs +++ b/mainForm.cs @@ -33,8 +33,8 @@ namespace FlyDockTool apiOptions.MachineID = ConfigurationManager.AppSettings[CurrentDevice].Split(',')[2]; lb_currentDeviceInfo.Text = CurrentDevice; //////测试代码 测试完毕后注释调一下两行代码 - //string resultDataStr = File.ReadAllText(@"C:\Users\10044\Desktop\尿常规URIT0-330.txt", Encoding.GetEncoding("GB18030")); - //deviceAnalysis.CreateInstance().deviceAnalysisOption(resultDataStr); + // string resultDataStr = File.ReadAllText(@"D:\工作\接受数据工具 list\生化URIT-8460.txt", Encoding.GetEncoding("GB18030")); + // deviceAnalysis.CreateInstance().deviceAnalysisOption(resultDataStr); btn_start_or_stop_Click(null,null);//启动数据接收