新增BS-330E

This commit is contained in:
lxd 2024-12-16 10:00:55 +08:00
parent 5c5940913c
commit bc58e34d40

View File

@ -50,7 +50,7 @@ namespace FlyDockTool
/// <param name="keyWords"></param> /// <param name="keyWords"></param>
/// <param name="stringStr"></param> /// <param name="stringStr"></param>
/// <returns></returns> /// <returns></returns>
int[] strCount(string keyWords,string stringStr) int[] strCount(string keyWords, string stringStr)
{ {
List<int> posList = new List<int>(); List<int> posList = new List<int>();
for (int i = 0; (i + keyWords.Length) < stringStr.Length; i++) for (int i = 0; (i + keyWords.Length) < stringStr.Length; i++)
@ -1472,7 +1472,7 @@ namespace FlyDockTool
ermList.Clear(); ermList.Clear();
if (i + 20 > resulteArray.Length) if (i + 20 > resulteArray.Length)
break; break;
string[] spArray =resulteArray[3].Trim().Split(' '); string[] spArray = resulteArray[3].Trim().Split(' ');
string sampleNo1 = resulteArray[3].Trim().Split(' ')[2].Replace("-", "0").TrimStart('0'); string sampleNo1 = resulteArray[3].Trim().Split(' ')[2].Replace("-", "0").TrimStart('0');
//string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]); //string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]);
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
@ -1492,7 +1492,7 @@ namespace FlyDockTool
erm1.sampleNo = sampleNo1; erm1.sampleNo = sampleNo1;
erm1.testDate = testDate1; erm1.testDate = testDate1;
erm1.chanelNo = "URO";//项目代号 erm1.chanelNo = "URO";//项目代号
erm1.itemValue = resulteArray[i + 5].Substring(4,11).Trim();//项目结果 erm1.itemValue = resulteArray[i + 5].Substring(4, 11).Trim();//项目结果
erm1.itemUnit = "mg/dL"; erm1.itemUnit = "mg/dL";
ermList.Add(erm1); ermList.Add(erm1);
@ -1522,7 +1522,7 @@ namespace FlyDockTool
erm4.sampleNo = sampleNo1; erm4.sampleNo = sampleNo1;
erm4.testDate = testDate1; erm4.testDate = testDate1;
erm4.chanelNo = "BIL";//项目代号 erm4.chanelNo = "BIL";//项目代号
erm4.itemValue = resulteArray[i + 8].Substring(5,13).Trim();//项目结果 erm4.itemValue = resulteArray[i + 8].Substring(5, 13).Trim();//项目结果
erm4.itemUnit = ""; erm4.itemUnit = "";
ermList.Add(erm4); ermList.Add(erm4);
@ -1648,7 +1648,7 @@ namespace FlyDockTool
string MachineCode = apiOptions.MachineCode; string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID; string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>(); List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[26] { "WBC", "NEU%", "LYM%", "MON%", "EOS%", "BAS%", "NEU#", "LYM#", "MON#", "EOS#", "BAS#", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW-SD", "PLT", "MPV", "PDW", "PCT", "RDW-CV", "PLCC", "PLCR" , "Lymphocytosis" }; string[] itemArray = new string[26] { "WBC", "NEU%", "LYM%", "MON%", "EOS%", "BAS%", "NEU#", "LYM#", "MON#", "EOS#", "BAS#", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW-SD", "PLT", "MPV", "PDW", "PCT", "RDW-CV", "PLCC", "PLCR", "Lymphocytosis" };
//string[] resulteArray = deviceDataStr.Split('\n'); //string[] resulteArray = deviceDataStr.Split('\n');
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", ""); deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string sampleNo1 = string.Empty;//样本号 string sampleNo1 = string.Empty;//样本号
@ -1660,7 +1660,7 @@ namespace FlyDockTool
else else
itemStr = itemArray[i] + "^LN||"; itemStr = itemArray[i] + "^LN||";
string val1 = deviceDataStr.Substring(deviceDataStr.IndexOf("OBR"),30); string val1 = deviceDataStr.Substring(deviceDataStr.IndexOf("OBR"), 30);
sampleNo1 = val1.Split('|')[3]; sampleNo1 = val1.Split('|')[3];
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
examResultMode erm1 = new examResultMode(); examResultMode erm1 = new examResultMode();
@ -1729,8 +1729,8 @@ namespace FlyDockTool
{ {
if (valArray[A].Contains("OBR|")) if (valArray[A].Contains("OBR|"))
{ {
int index1 = valArray[A].Substring(valArray[A].IndexOf("OBR|"), 20).IndexOf("||")+2; int index1 = valArray[A].Substring(valArray[A].IndexOf("OBR|"), 20).IndexOf("||") + 2;
sampleNo1 = jiexisampleNo8(index1, valArray[A].Substring(valArray[A].IndexOf("OBR|"),18)).ToString(); sampleNo1 = jiexisampleNo8(index1, valArray[A].Substring(valArray[A].IndexOf("OBR|"), 18)).ToString();
} }
for (int i = 0; i < itemArray.Length; i++) for (int i = 0; i < itemArray.Length; i++)
@ -1859,7 +1859,7 @@ namespace FlyDockTool
erm.sampleNo = sampleNo1; erm.sampleNo = sampleNo1;
erm.testDate = testDate1; erm.testDate = testDate1;
erm.chanelNo = "GLU";//项目代号 erm.chanelNo = "GLU";//项目代号
erm.itemValue = resulteArray[i + 4].Substring(4,6).Trim();//项目结果 erm.itemValue = resulteArray[i + 4].Substring(4, 6).Trim();//项目结果
erm.itemUnit = "cells/uL"; erm.itemUnit = "cells/uL";
ermList.Add(erm); ermList.Add(erm);
@ -1971,7 +1971,7 @@ namespace FlyDockTool
erm11.sampleNo = sampleNo1; erm11.sampleNo = sampleNo1;
erm11.testDate = testDate1; erm11.testDate = testDate1;
erm11.chanelNo = "Color";//项目代号 erm11.chanelNo = "Color";//项目代号
erm11.itemValue = resulteArray[i + 15].Replace("Color:","").Trim();//项目结果 erm11.itemValue = resulteArray[i + 15].Replace("Color:", "").Trim();//项目结果
erm11.itemUnit = "mmol/L"; erm11.itemUnit = "mmol/L";
ermList.Add(erm11); ermList.Add(erm11);
//将结果提交到LIS系统 //将结果提交到LIS系统
@ -1999,7 +1999,7 @@ namespace FlyDockTool
if (i + 15 > resulteArray.Length) if (i + 15 > resulteArray.Length)
break; break;
string[] spArray = resulteArray[2].Trim().Split(' '); string[] spArray = resulteArray[2].Trim().Split(' ');
string sampleNo1 = spArray[2].Substring(0,1).TrimStart('0'); string sampleNo1 = spArray[2].Substring(0, 1).TrimStart('0');
// string sampleNo1 = resulteArray[2].Trim().Split(' ')[1]; .Replace("-", "0").TrimStart('0') // string sampleNo1 = resulteArray[2].Trim().Split(' ')[1]; .Replace("-", "0").TrimStart('0')
//string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]); //string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]);
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
@ -2127,6 +2127,53 @@ namespace FlyDockTool
dataOutPutShow("数据提交失败:" + jsonStr, null); dataOutPutShow("数据提交失败:" + jsonStr, null);
} }
}
if (apiOptions.CurrentDevice == "BS-330E")//BS-330E 他是一次性发一条样本 但一个样本号有多个项目 挨个发其中的项目 生化
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[10] { "ALT", "AST", "T-Bil", "UA", "UREA", "CREA-S", "TC", "TG", "HDL-C", "LDL-C" };
//string[] resulteArray = deviceDataStr.Split('\n');
//deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string[] valArray = deviceDataStr.Split('');
string sampleNo1 = string.Empty;//样本号
string itemStr = string.Empty;
string itemValue = string.Empty;
for (int i = 0; i < itemArray.Length; i++)
{
for (int j = 0; j < valArray.Length; j++)
{
if (itemArray[i] == valArray[j].Substring(valArray[j].IndexOf("OBX|1|NM|")).Split('|')[4])
{
sampleNo1 = valArray[j].Substring(valArray[j].IndexOf("OBR|1||") + "OBR|1||".Length, valArray[j].IndexOf("|Mindray^BS-330E|") - valArray[j].IndexOf("OBR|1||") - "OBR|1||".Length).Trim();
itemStr = valArray[j].Substring(valArray[j].IndexOf("OBX|1|NM|")).Split('|')[4];
itemValue = valArray[j].Substring(valArray[j].IndexOf("OBX|1|NM|")).Split('|')[5];
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 = itemStr;//项目代号
erm1.itemValue = itemValue;
erm1.itemUnit = "";
ermList.Add(erm1);
break;
}
}
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
} }
return rerultJson; return rerultJson;
} }
@ -2147,7 +2194,7 @@ namespace FlyDockTool
string ItemValueStr = ""; string ItemValueStr = "";
string Str1 = deviceDataStr.Substring(deviceDataStr.IndexOf(itemStr) + itemStr.Length, 30); string Str1 = deviceDataStr.Substring(deviceDataStr.IndexOf(itemStr) + itemStr.Length, 30);
int firstIndex = Str1.IndexOf('|'); int firstIndex = Str1.IndexOf('|');
ItemValueStr= Str1.Substring(0, firstIndex); ItemValueStr = Str1.Substring(0, firstIndex);
return ItemValueStr; return ItemValueStr;
} }
@ -2161,7 +2208,7 @@ namespace FlyDockTool
string jiexiItemValueLast(string itemStr, string deviceDataStr) string jiexiItemValueLast(string itemStr, string deviceDataStr)
{ {
string ItemValueStr = ""; string ItemValueStr = "";
string Str1 = deviceDataStr.Substring(deviceDataStr.LastIndexOf(itemStr) + itemStr.Length+1, 10); string Str1 = deviceDataStr.Substring(deviceDataStr.LastIndexOf(itemStr) + itemStr.Length + 1, 10);
int firstIndex = Str1.IndexOf('|'); int firstIndex = Str1.IndexOf('|');
ItemValueStr = Str1.Substring(0, firstIndex); ItemValueStr = Str1.Substring(0, firstIndex);
return ItemValueStr; return ItemValueStr;
@ -2217,14 +2264,14 @@ namespace FlyDockTool
/// <param name="itemStr"></param> /// <param name="itemStr"></param>
/// <param name="deviceDataStr"></param> /// <param name="deviceDataStr"></param>
/// <returns></returns> /// <returns></returns>
string jiexiVal(int index1,string keyStr, string dataStr) string jiexiVal(int index1, string keyStr, string dataStr)
{ {
string val1 =""; string val1 = "";
for (int i = 1; i < 100; i++) for (int i = 1; i < 100; i++)
{ {
try try
{ {
string str1 = dataStr.Substring(index1+ keyStr.Length, i); string str1 = dataStr.Substring(index1 + keyStr.Length, i);
double valx = double.Parse(str1); double valx = double.Parse(str1);
val1 = str1; val1 = str1;
} }
@ -2243,15 +2290,15 @@ namespace FlyDockTool
/// <returns></returns> /// <returns></returns>
List<string> jiexiBase64(int[] array1, string keyStr, string dataStr) List<string> jiexiBase64(int[] array1, string keyStr, string dataStr)
{ {
List<string> imageBase64List=new List<string>(); List<string> imageBase64List = new List<string>();
for (int i = 0; i < array1.Length; i++) for (int i = 0; i < array1.Length; i++)
{ {
for (int b = array1[i]; b< dataStr.Length; b++) for (int b = array1[i]; b < dataStr.Length; b++)
{ {
string str1 = dataStr.Substring(b, keyStr.Length); string str1 = dataStr.Substring(b, keyStr.Length);
if(str1== keyStr) if (str1 == keyStr)
{ {
string ImgBase64Str = dataStr.Substring(array1[i]+ 8, b- array1[i]- 8); string ImgBase64Str = dataStr.Substring(array1[i] + 8, b - array1[i] - 8);
imageBase64List.Add(ImgBase64Str); imageBase64List.Add(ImgBase64Str);
break; break;
} }
@ -2260,11 +2307,11 @@ namespace FlyDockTool
return imageBase64List; return imageBase64List;
} }
static string jiexiDate(string dateStr,string TimeStr) static string jiexiDate(string dateStr, string TimeStr)
{ {
string[] spArray = dateStr.Trim().Split(' '); string[] spArray = dateStr.Trim().Split(' ');
string[] varArray= spArray[2].Trim().Trim('\r').Split('-'); string[] varArray = spArray[2].Trim().Trim('\r').Split('-');
return varArray[2]+"-"+ varArray[0]+"-"+ varArray[1]+" "+ TimeStr.Trim().Trim('\r'); return varArray[2] + "-" + varArray[0] + "-" + varArray[1] + " " + TimeStr.Trim().Trim('\r');
} }
@ -2607,6 +2654,22 @@ namespace FlyDockTool
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData); SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收 SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
} }
if (apiOptions.CurrentDevice == "BS-330E")//BS-330E 生化
{
// 设置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毫秒频率
}
} }
@ -2692,7 +2755,7 @@ namespace FlyDockTool
if (apiOptions.CurrentDevice == "BC-5130")//BC-5130 if (apiOptions.CurrentDevice == "BC-5130")//BC-5130
{ {
// _tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时 // _tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (tempData.Contains("OBX|30|")|| tempData.Contains("OBX|29|"))//OBX|12|ST| 为结束符 说明字符串完整了 if (tempData.Contains("OBX|30|") || tempData.Contains("OBX|29|"))//OBX|12|ST| 为结束符 说明字符串完整了
{ {
// MessageBox.Show(tempData); // MessageBox.Show(tempData);
deviceAnalysisOption(tempData); deviceAnalysisOption(tempData);
@ -2729,6 +2792,14 @@ namespace FlyDockTool
{ {
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时 _tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
} }
if (apiOptions.CurrentDevice == "BS-330E")//BS-330E
{
if (tempData.Split('').Length>=12&&tempData.Contains("LDL-C"))
{
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
}
}
} }
/// <summary> /// <summary>
@ -2761,8 +2832,8 @@ namespace FlyDockTool
int recv = clientSocket.Receive(data); int recv = clientSocket.Receive(data);
if (recv > 0) if (recv > 0)
{ {
byte[] data1=new byte[recv]; byte[] data1 = new byte[recv];
for (int i = 0;i<recv;i++) for (int i = 0; i < recv; i++)
data1[i] = data[i]; data1[i] = data[i];
string encodingStr = ConfigurationManager.AppSettings[apiOptions.CurrentDevice].Split(',')[5]; string encodingStr = ConfigurationManager.AppSettings[apiOptions.CurrentDevice].Split(',')[5];
@ -2772,14 +2843,14 @@ namespace FlyDockTool
string[] msgArray = stringData.Split('\n'); string[] msgArray = stringData.Split('\n');
for (int i = 0; i < msgArray.Length; i++) for (int i = 0; i < msgArray.Length; i++)
{ {
if (msgArray[i].Contains("MSH|")&& msgArray[i].Contains("||UNICODE||")) if (msgArray[i].Contains("MSH|") && msgArray[i].Contains("||UNICODE||"))
{ {
string msgId = msgArray[i].Substring(msgArray[i].IndexOf("R01|") +4, msgArray[i].IndexOf("|P|") -msgArray[i].IndexOf("R01|") - 4); string msgId = msgArray[i].Substring(msgArray[i].IndexOf("R01|") + 4, msgArray[i].IndexOf("|P|") - msgArray[i].IndexOf("R01|") - 4);
string dateTimeNowStr = DateTime.Now.ToString("yyyyMMddHHmmss"); string dateTimeNowStr = DateTime.Now.ToString("yyyyMMddHHmmss");
string responseMsg = "<SB>MSH|^~\\&|1|1|11|1|"+ dateTimeNowStr + "||ACK^R01|"+ msgId + "|P|2.3.1||||0||UNICODE|||<CR>MSA|AA|"+ msgId + "||||0|<CR><EB><CR>"; string responseMsg = "<SB>MSH|^~\\&|1|1|11|1|" + dateTimeNowStr + "||ACK^R01|" + msgId + "|P|2.3.1||||0||UNICODE|||<CR>MSA|AA|" + msgId + "||||0|<CR><EB><CR>";
byte[] sendBytes = Encoding.Unicode.GetBytes(responseMsg); byte[] sendBytes = Encoding.Unicode.GetBytes(responseMsg);
clientSocket.Send(sendBytes); clientSocket.Send(sendBytes);
onReData("应答消息:"+responseMsg, null);//数据处理 并将数据显示在软件界面上 onReData("应答消息:" + responseMsg, null);//数据处理 并将数据显示在软件界面上
} }
} }
@ -2801,13 +2872,13 @@ namespace FlyDockTool
accessDbPath = DateTime.Now.ToString("yyyy-MM-dd") + ".mdb"; accessDbPath = DateTime.Now.ToString("yyyy-MM-dd") + ".mdb";
//string sql = "select a.sampleProgramID,b.SampleNo,a.ResultValue as ItemValue,a.EName as ItemCode from sampleProgram a inner join sampleInfo b on a.SampleInfoID=b.SampleInfoID where a.stateS is NULL "; //string sql = "select a.sampleProgramID,b.SampleNo,a.ResultValue as ItemValue,a.EName as ItemCode from sampleProgram a inner join sampleInfo b on a.SampleInfoID=b.SampleInfoID where a.stateS is NULL ";
string sql = "select a.sampleProgramID,b.SampleNo,a.ResultValue as ItemValue,a.EName as ItemCode from sampleProgram a inner join sampleInfo b on a.SampleInfoID=b.SampleInfoID"; string sql = "select a.sampleProgramID,b.SampleNo,a.ResultValue as ItemValue,a.EName as ItemCode from sampleProgram a inner join sampleInfo b on a.SampleInfoID=b.SampleInfoID";
DataTable dt_2=new DataTable(); DataTable dt_2 = new DataTable();
try try
{ {
dt_2 = accessOptions.CreateInstance(accessDbPath).ExcuteSql(sql); dt_2 = accessOptions.CreateInstance(accessDbPath).ExcuteSql(sql);
} }
catch { dt_2 = null; } catch { dt_2 = null; }
if(dt_2==null) if (dt_2 == null)
return; return;
List<examResultMode> ermList = new List<examResultMode>(); List<examResultMode> ermList = new List<examResultMode>();
string MachineCode = apiOptions.MachineCode; string MachineCode = apiOptions.MachineCode;
@ -3052,7 +3123,11 @@ namespace FlyDockTool
{ {
SerialPortOption.CreateInstance().StopDataReadThread();//停止数据接收 SerialPortOption.CreateInstance().StopDataReadThread();//停止数据接收
} }
if (apiOptions.CurrentDevice == "BS-330E")//BS-330E
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
} }
///// <summary> ///// <summary>