史德卫生院 5390 8460 对接

This commit is contained in:
lxd 2025-04-25 11:11:49 +08:00
parent 0c88dd19da
commit dda0aa0aa2
4 changed files with 206 additions and 15 deletions

View File

@ -86,6 +86,8 @@
<add key="BH-5380CRP" value="PC-202106061449,BH-5380CRP,121,127.0.0.1,5600,GB18030" />
<!-- URIT-8400 -->
<add key="URIT-8400" value="CHINAMI-7VR1TBO,URIT-8400,121,192.169.13.27,5150,UTF-8" />
<add key="CurrentDevice" value="URIT-330"/>
<!-- BH-5390 -->
<add key="BH-5390" value="PC-202106061449,BH-5390,121,127.0.0.1,5600,GB18030" />
<add key="CurrentDevice" value="URIT-8460"/>
</appSettings>
</configuration>

View File

@ -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";//项目代号
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";//项目代号
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";//项目代号
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";//项目代号
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";//项目代号
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";//项目代号
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";//项目代号
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";//项目代号
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";//项目代号
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";//项目代号
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<examResultMode> ermList = new List<examResultMode>();
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;
}
/// <summary>
/// 从HL7消息中获取指定检验项目的值
/// </summary>
/// <param name="hl7Message">HL7消息字符串</param>
/// <param name="testName">检验项目名称WBC、LYM%等)</param>
/// <returns>检验项目的值,如果未找到则返回空字符串</returns>
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;
}
}
/// <summary>
/// 从字符串中 解析出 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毫秒频率
}
}
/// <summary>
@ -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();
}
}
///// <summary>

2
mainForm.Designer.cs generated
View File

@ -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);

View File

@ -33,7 +33,7 @@ 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"));
// string resultDataStr = File.ReadAllText(@"D:\工作\接受数据工具 list\生化URIT-8460.txt", Encoding.GetEncoding("GB18030"));
// deviceAnalysis.CreateInstance().deviceAnalysisOption(resultDataStr);
btn_start_or_stop_Click(null,null);//启动数据接收