DockTool/deviceAnalysis.cs
2025-01-15 16:28:32 +08:00

3909 lines
202 KiB
C#
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Net;
using System.Text;
using System.Threading;
using System.Configuration;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Data;
using System.Security.Cryptography;
using System.Runtime.InteropServices.ComTypes;
using System.Text.RegularExpressions;
namespace FlyDockTool
{
public class deviceAnalysis
{
public EventHandler dataOutPutShow;
public static deviceAnalysis Instance; //申明一个EcgDrawing对象复制Null
private static readonly object LockHelper = new object();
string tempData = string.Empty;//存储串口和TCP接收到的 累计数据
private System.Threading.Timer _tResult;//串口数据接收 声明一个计时器变量
private System.Threading.Timer _tcpResult;//tcp数据接收 声明一个计时器变量
private System.Threading.Timer _AccessResult;//定时读取Access数据库的数据 声明一个计时器变量
public static deviceAnalysis CreateInstance()
{
if (Instance == null)
lock (LockHelper)
{
if (Instance == null)
Instance = new deviceAnalysis();
}
return Instance;
}
deviceAnalysis()
{
_tResult = new System.Threading.Timer(obj => TResultTick(), null, -1, 5000);//调用方法TResultTick 作为定时执行的方法 处于暂停状态
_tcpResult = new System.Threading.Timer(obj => tcpResultTick(), null, -1, 10);//调用方法TResultTick 作为定时执行的方法 处于暂停状态
_AccessResult = new System.Threading.Timer(obj => accessResultTick(), null, -1, 10000);//调用方法TResultTick 作为定时执行的方法 处于暂停状态
}
//赖浩1
/// <summary>
/// 查找某个字符小串在 字符大串中出现的位置数组
/// </summary>
/// <param name="keyWords"></param>
/// <param name="stringStr"></param>
/// <returns></returns>
int[] strCount(string keyWords, string stringStr)
{
List<int> posList = new List<int>();
for (int i = 0; (i + keyWords.Length) < stringStr.Length; i++)
{
string val1 = stringStr.Substring(i, keyWords.Length);
if (val1 == keyWords)
posList.Add(i);
}
return posList.ToArray();
}
/// <summary>
/// 数据处理
/// </summary>
/// <param name="deviceDataStr"></param>
/// <returns></returns>
public string deviceAnalysisOption(string deviceDataStr)
{
//MessageBox.Show(deviceDataStr);
string rerultJson = string.Empty;
if (apiOptions.CurrentDevice == "HSYH-II")//华晟源尿常规型号H-II
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] resulteArray = deviceDataStr.Split('\n');
for (int i = 0; i < resulteArray.Length; i += 16)
{
//这里需要判断一下数据是否超过了 当前数据的长度
ermList.Clear();
if (i + 16 > resulteArray.Length)
break;
string[] spArray = resulteArray[i + 1].Trim().Split(' ');
string sampleNo1 = spArray[0].Trim().Replace("NO", "").TrimStart('0');
//string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]);
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
examResultMode erm = new examResultMode();
erm.machineCode = MachineCode;
erm.machineID = MachineID;
erm.sampleNo = sampleNo1;
erm.testDate = testDate1;
erm.chanelNo = "LEU";//项目代号
erm.itemValue = resulteArray[i + 4].Replace("LEU", "").Replace("cells/uL", "").Trim().Split(' ')[0].Trim();//项目结果
erm.itemUnit = "cells/uL";
ermList.Add(erm);
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = sampleNo1;
erm1.testDate = testDate1;
erm1.chanelNo = "NIT";//项目代号
erm1.itemValue = resulteArray[i + 5].Replace("NIT", "").Trim();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
examResultMode erm2 = new examResultMode();
erm2.machineCode = MachineCode;
erm2.machineID = MachineID;
erm2.sampleNo = sampleNo1;
erm2.testDate = testDate1;
erm2.chanelNo = "URO";//项目代号
erm2.itemValue = resulteArray[i + 6].Replace("URO", "").Replace("umol/L", "").Trim().Split(' ')[0].Trim();//项目结果
erm2.itemUnit = "umol/L";
ermList.Add(erm2);
examResultMode erm3 = new examResultMode();
erm3.machineCode = MachineCode;
erm3.machineID = MachineID;
erm3.sampleNo = sampleNo1;
erm3.testDate = testDate1;
erm3.chanelNo = "PRO";//项目代号
erm3.itemValue = resulteArray[i + 7].Replace("PRO", "").Replace("g/L", "").Trim().Split(' ')[0].Trim();//项目结果
erm3.itemUnit = "g/L";
ermList.Add(erm3);
examResultMode erm4 = new examResultMode();
erm4.machineCode = MachineCode;
erm4.machineID = MachineID;
erm4.sampleNo = sampleNo1;
erm4.testDate = testDate1;
erm4.chanelNo = "PH";//项目代号
erm4.itemValue = resulteArray[i + 8].Replace("PH", "").Trim();//项目结果
erm4.itemUnit = "";
ermList.Add(erm4);
examResultMode erm5 = new examResultMode();
erm5.machineCode = MachineCode;
erm5.machineID = MachineID;
erm5.sampleNo = sampleNo1;
erm5.testDate = testDate1;
erm5.chanelNo = "BLD";//项目代号
erm5.itemValue = resulteArray[i + 9].Replace("BLD", "").Replace("cells/uL", "").Trim().Split(' ')[0].Trim();//项目结果
erm5.itemUnit = "cells/uL";
ermList.Add(erm5);
examResultMode erm6 = new examResultMode();
erm6.machineCode = MachineCode;
erm6.machineID = MachineID;
erm6.sampleNo = sampleNo1;
erm6.testDate = testDate1;
erm6.chanelNo = "SG";//项目代号
erm6.itemValue = resulteArray[i + 10].Replace("SG", "").Trim();//项目结果
erm6.itemUnit = "";
ermList.Add(erm6);
examResultMode erm7 = new examResultMode();
erm7.machineCode = MachineCode;
erm7.machineID = MachineID;
erm7.sampleNo = sampleNo1;
erm7.testDate = testDate1;
erm7.chanelNo = "KET";//项目代号
erm7.itemValue = resulteArray[i + 11].Replace("KET", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim();//项目结果
erm7.itemUnit = "mmol/L";
ermList.Add(erm7);
examResultMode erm8 = new examResultMode();
erm8.machineCode = MachineCode;
erm8.machineID = MachineID;
erm8.sampleNo = sampleNo1;
erm8.testDate = testDate1;
erm8.chanelNo = "BIL";//项目代号
erm8.itemValue = resulteArray[i + 12].Replace("BIL", "").Replace("umol/L", "").Trim().Split(' ')[0].Trim();//项目结果
erm8.itemUnit = "umol/L";
ermList.Add(erm8);
examResultMode erm9 = new examResultMode();
erm9.machineCode = MachineCode;
erm9.machineID = MachineID;
erm9.sampleNo = sampleNo1;
erm9.testDate = testDate1;
erm9.chanelNo = "GLU";//项目代号
erm9.itemValue = resulteArray[i + 13].Replace("GLU", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim();//项目结果
erm9.itemUnit = "mmol/L";
ermList.Add(erm9);
examResultMode erm10 = new examResultMode();
erm10.machineCode = MachineCode;
erm10.machineID = MachineID;
erm10.sampleNo = sampleNo1;
erm10.testDate = testDate1;
erm10.chanelNo = "VC";//项目代号
erm10.itemValue = resulteArray[i + 14].Replace("VC", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim();//项目结果
erm10.itemUnit = "mmol/L";
ermList.Add(erm10);
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
dataOutPutShow("数据提交失败:" + jsonStr, null);
}
}
if (apiOptions.CurrentDevice == "BT-200")//盛世东唐BT-200尿常规
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] resulteArray = deviceDataStr.Split('\n');
// File.WriteAllText("BT-200.TXT", deviceDataStr);
for (int i = 0; i < resulteArray.Length; i += 15)
{
//这里需要判断一下数据是否超过了 当前数据的长度
ermList.Clear();
if (i + 15 > resulteArray.Length)
break;
//string[] spArray = resulteArray[i + 1].Trim().Split(' ');
string sampleNo1 = resulteArray[2].Trim().Replace("Seq:", "").TrimStart('0');
//string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]);
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
examResultMode erm = new examResultMode();
erm.machineCode = MachineCode;
erm.machineID = MachineID;
erm.sampleNo = sampleNo1;
erm.testDate = testDate1;
erm.chanelNo = "LEU";//项目代号
erm.itemValue = resulteArray[i + 3].Replace("LEU", "").Replace("Neg", "").Trim().Split(' ')[0].Trim();//项目结果
erm.itemUnit = "";
ermList.Add(erm);
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = sampleNo1;
erm1.testDate = testDate1;
erm1.chanelNo = "NIT";//项目代号
erm1.itemValue = resulteArray[i + 4].Replace("NIT", "").Trim();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
examResultMode erm2 = new examResultMode();
erm2.machineCode = MachineCode;
erm2.machineID = MachineID;
erm2.sampleNo = sampleNo1;
erm2.testDate = testDate1;
erm2.chanelNo = "URO";//项目代号
erm2.itemValue = resulteArray[i + 5].Replace("URO", "").Replace("umol/L", "").Trim().Split(' ')[0].Trim();//项目结果
erm2.itemUnit = "umol/L";
ermList.Add(erm2);
examResultMode erm3 = new examResultMode();
erm3.machineCode = MachineCode;
erm3.machineID = MachineID;
erm3.sampleNo = sampleNo1;
erm3.testDate = testDate1;
erm3.chanelNo = "PRO";//项目代号
erm3.itemValue = resulteArray[i + 6].Replace("PRO", "").Replace("Neg", "").Trim().Split(' ')[0].Trim();//项目结果
erm3.itemUnit = "";
ermList.Add(erm3);
examResultMode erm4 = new examResultMode();
erm4.machineCode = MachineCode;
erm4.machineID = MachineID;
erm4.sampleNo = sampleNo1;
erm4.testDate = testDate1;
erm4.chanelNo = "PH";//项目代号
erm4.itemValue = resulteArray[i + 7].Replace("PH", "").Trim();//项目结果
erm4.itemUnit = "";
ermList.Add(erm4);
examResultMode erm5 = new examResultMode();
erm5.machineCode = MachineCode;
erm5.machineID = MachineID;
erm5.sampleNo = sampleNo1;
erm5.testDate = testDate1;
erm5.chanelNo = "BLD";//项目代号
erm5.itemValue = resulteArray[i + 8].Replace("BLD", "").Replace("Neg", "").Trim().Split(' ')[0].Trim();//项目结果
erm5.itemUnit = "";
ermList.Add(erm5);
examResultMode erm6 = new examResultMode();
erm6.machineCode = MachineCode;
erm6.machineID = MachineID;
erm6.sampleNo = sampleNo1;
erm6.testDate = testDate1;
erm6.chanelNo = "SG";//项目代号
erm6.itemValue = resulteArray[i + 9].Replace("SG", "").Trim();//项目结果
erm6.itemUnit = "";
ermList.Add(erm6);
examResultMode erm10 = new examResultMode();
erm10.machineCode = MachineCode;
erm10.machineID = MachineID;
erm10.sampleNo = sampleNo1;
erm10.testDate = testDate1;
erm10.chanelNo = "VC";//项目代号
erm10.itemValue = resulteArray[i + 10].Replace("VC", "").Replace("Neg", "").Trim().Split(' ')[0].Trim();//项目结果
erm10.itemUnit = "";
ermList.Add(erm10);
examResultMode erm7 = new examResultMode();
erm7.machineCode = MachineCode;
erm7.machineID = MachineID;
erm7.sampleNo = sampleNo1;
erm7.testDate = testDate1;
erm7.chanelNo = "KET";//项目代号
erm7.itemValue = resulteArray[i + 11].Replace("KET", "").Replace("Neg", "").Trim().Split(' ')[0].Trim();//项目结果
erm7.itemUnit = "";
ermList.Add(erm7);
examResultMode erm8 = new examResultMode();
erm8.machineCode = MachineCode;
erm8.machineID = MachineID;
erm8.sampleNo = sampleNo1;
erm8.testDate = testDate1;
erm8.chanelNo = "BIL";//项目代号
erm8.itemValue = resulteArray[i + 12].Replace("BIL", "").Replace("Neg", "").Trim().Split(' ')[0].Trim();//项目结果
erm8.itemUnit = "";
ermList.Add(erm8);
examResultMode erm9 = new examResultMode();
erm9.machineCode = MachineCode;
erm9.machineID = MachineID;
erm9.sampleNo = sampleNo1;
erm9.testDate = testDate1;
erm9.chanelNo = "GLU";//项目代号
erm9.itemValue = resulteArray[i + 13].Replace("GLU", "").Replace("Neg", "").Trim().Split(' ')[0].Trim();//项目结果
erm9.itemUnit = "mmol/L";
ermList.Add(erm9);
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
dataOutPutShow("数据提交失败:" + jsonStr, null);
}
}
if (apiOptions.CurrentDevice == "URIT-5181")//优利特血常规 5181
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[31] { "WBC", "LYM%", "MON%", "NEU%", "EOS%", "BASO%", "LYM#", "MON#", "NEU#", "EOS#", "BASO#", "ALY%", "ALY#", "LIC%", "LIC#", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW_CV", "RDW_SD", "PLT", "MPV", "PDW", "PCT", "P_LCR", "P_LCC", "NRBC%", "NRBC#" };
//string[] resulteArray = deviceDataStr.Split('\n');
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string sampleNo1 = string.Empty;//样本号
for (int i = 0; i < itemArray.Length; i++)
{
string itemStr = itemArray[i] + "||";
sampleNo1 = deviceDataStr.Substring(deviceDataStr.IndexOf("|URIT^URIT-5160|||") - 7, 7).TrimStart('0');
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 = jiexiItemValue(itemStr, deviceDataStr);//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
//把血常规的图也传上去
List<examImageParaModel> eipmList = new List<examImageParaModel>();
int[] array1 = strCount("^Base64^", deviceDataStr);
int[] array2 = strCount("||||||F||||||", deviceDataStr);
for (int i = 0; i < array2.Length; i++)
{
string base64Str = deviceDataStr.Substring(array1[i] + 8, array2[i] - array1[i] - 8);
examImageParaModel EIPM1 = new examImageParaModel();
EIPM1.machineCode = MachineCode;
EIPM1.machineID = MachineID;
EIPM1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
EIPM1.sampleNo = sampleNo1;
EIPM1.img = "data:image/jpeg;base64," + base64Str;
eipmList.Add(EIPM1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (eipmList.Count > 0)
{
baseMsgModel bmm2 = apiOptions.CreateInstance().uploadExamImage(eipmList);//传图像List
//if (bmm2.code == 200)
// dataOutPutShow("图像提交成功:" + jsonStr, null);
//else
// dataOutPutShow("图像提交失败:" + jsonStr, null);
}
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "DF55")//帝迈血常规DF55
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[27] { "WBC", "NEU%", "LYM%", "MON%", "EOS%", "BAS%", "NEU#", "LYM#", "MON#", "EOS#", "BAS#", "*ALY%", "*LIC#", "*LIC%", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW-SD", "PLT", "MPV", "PDW", "PCT", "*ALY#", "RDW-CV" };
//string[] resulteArray = deviceDataStr.Split('\n');
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string sampleNo1 = string.Empty;//样本号
for (int i = 0; i < itemArray.Length; i++)
{
string itemStr = string.Empty;
if (itemArray[i] == "*LIC#" || itemArray[i] == "*LIC%" || itemArray[i] == "PCT")
itemStr = itemArray[i] + "^99MRC||";
else
itemStr = itemArray[i] + "^LN||";
string val1 = jiexiVal(deviceDataStr.IndexOf("PID|"), "PID|", deviceDataStr).ToString();
sampleNo1 = val1;
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 = jiexiVal(deviceDataStr.IndexOf(itemStr), itemStr, deviceDataStr).ToString();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
string jsonStr12 = JsonConvert.SerializeObject(ermList);
//把血常规的图也传上去
List<examImageParaModel> eipmList = new List<examImageParaModel>();
int[] array1 = strCount("^Base64^", deviceDataStr);
string keyStr = "||||||F";//结束符
List<string> imgBase64StrList = jiexiBase64(array1, keyStr, deviceDataStr);//解析出数据中的图片base64
//int[] array2 = strCount("||||||F||||||", deviceDataStr);
for (int i = 0; i < imgBase64StrList.Count; i++)
{
string base64Str = imgBase64StrList[i];
examImageParaModel EIPM1 = new examImageParaModel();
EIPM1.machineCode = MachineCode;
EIPM1.machineID = MachineID;
EIPM1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
EIPM1.sampleNo = sampleNo1;
EIPM1.img = "data:image/jpeg;base64," + base64Str;
eipmList.Add(EIPM1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (eipmList.Count > 0)
{
baseMsgModel bmm2 = apiOptions.CreateInstance().uploadExamImage(eipmList);//传图像List
//if (bmm2.code == 200)
// dataOutPutShow("图像提交成功:" + jsonStr, null);
//else
// dataOutPutShow("图像提交失败:" + jsonStr, null);
}
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "TCPTEST")//tcp数据接收测试 数据不做任何处理
{
}
if (apiOptions.CurrentDevice == "CS-480")//迪瑞全自动生化分析仪 CS-480
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[10] { "ALT", "AST", "TBIL", "UREA", "CRE-E", "GLU", "TC", "TG", "HDL-C", "LDL-C" };
//deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string[] valArray = deviceDataStr.Split('\n');
string sampleNo1 = string.Empty;//样本号
for (int A = 0; A < valArray.Length; A++)
{
if (valArray[A].Contains("|480^480|"))
{
// int index3 = jiexisampleNo(valArray[A].IndexOf("|480^480|"), valArray[A]);
sampleNo1 = jiexisampleNo(valArray[A].IndexOf("|480^480|"), valArray[A]).ToString();
// File.WriteAllText("test1.txt","哈哈哈 " + index3.ToString() + " " + valArray[A] + " 原样字符串:" + deviceDataStr);
// MessageBox.Show("哈哈哈 "+index3.ToString()+" "+ valArray[A]+" 原样字符串:"+ deviceDataStr);
}
for (int i = 0; i < itemArray.Length; i++)
{
if (valArray[A].Contains(itemArray[i]))
{
string itemStr = itemArray[i] + "^1|";
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 = jiexiItemValue(itemStr, valArray[A]);//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
}
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "SL300C")//Senlo生化SL300C
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[20] { "ALT", "AST", "AST/ALT", "ALP", "GGT", "TBIL", "DBIL", "IBIL", "TP", "ALB", "GLB", "A/G", "Urea", "CREA", "UA", "GLU", "TCHO", "TG", "HDL-C", "LDL-C" };
//deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string[] valArray = deviceDataStr.Split('\n');
string sampleNo1 = string.Empty;//样本号
for (int A = 0; A < valArray.Length; A++)
{
if (valArray[A].Contains("OBR||"))
{
// int index3 = jiexisampleNo(valArray[A].IndexOf("|480^480|"), valArray[A]);
sampleNo1 = jiexiVal(valArray[A].IndexOf("OBR||"), "OBR||", valArray[A]).ToString();
// File.WriteAllText("test1.txt","哈哈哈 " + index3.ToString() + " " + valArray[A] + " 原样字符串:" + deviceDataStr);
// MessageBox.Show("哈哈哈 "+index3.ToString()+" "+ valArray[A]+" 原样字符串:"+ deviceDataStr);
}
for (int i = 0; i < itemArray.Length; i++)
{
if (valArray[A].Contains(itemArray[i]))
{
string itemStr = itemArray[i] + "^1|";
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 = jiexiItemValue(itemStr, valArray[A]);//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
}
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "BA600")//尿常规 GeniusBA600
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] resulteArray = deviceDataStr.Split('\n');
// File.WriteAllText("BT-200.TXT", deviceDataStr);
for (int i = 0; i < resulteArray.Length; i += 16)
{
//这里需要判断一下数据是否超过了 当前数据的长度
ermList.Clear();
if (i + 16 > resulteArray.Length)
break;
//string[] spArray = resulteArray[i + 1].Trim().Split(' ');
string sampleNo1 = resulteArray[2].Trim().Replace("0", " ").Trim();
//string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]);
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
examResultMode erm = new examResultMode();
erm.machineCode = MachineCode;
erm.machineID = MachineID;
erm.sampleNo = sampleNo1;
erm.testDate = testDate1;
erm.chanelNo = "VC";//项目代号
erm.itemValue = resulteArray[i + 4].Replace("VC", "").Trim().Split(' ')[0].Trim();//项目结果
erm.itemUnit = "";
ermList.Add(erm);
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = sampleNo1;
erm1.testDate = testDate1;
erm1.chanelNo = "URO";//项目代号
erm1.itemValue = resulteArray[i + 5].Replace("URO", "").Trim().Split(' ')[0].Trim();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
examResultMode erm2 = new examResultMode();
erm2.machineCode = MachineCode;
erm2.machineID = MachineID;
erm2.sampleNo = sampleNo1;
erm2.testDate = testDate1;
erm2.chanelNo = "BIL";//项目代号
erm2.itemValue = resulteArray[i + 6].Replace("BIL", "").Trim().Trim().Split(' ')[0].Trim();//项目结果
erm2.itemUnit = "";
ermList.Add(erm2);
examResultMode erm3 = new examResultMode();
erm3.machineCode = MachineCode;
erm3.machineID = MachineID;
erm3.sampleNo = sampleNo1;
erm3.testDate = testDate1;
erm3.chanelNo = "KET";//项目代号
erm3.itemValue = resulteArray[i + 7].Replace("KET", "").Trim().Split(' ')[0].Trim();//项目结果
erm3.itemUnit = "";
ermList.Add(erm3);
examResultMode erm4 = new examResultMode();
erm4.machineCode = MachineCode;
erm4.machineID = MachineID;
erm4.sampleNo = sampleNo1;
erm4.testDate = testDate1;
erm4.chanelNo = "BLD";//项目代号
erm4.itemValue = resulteArray[i + 8].Replace("BLD", "").Replace("Cell/uL", "").Trim();//项目结果
erm4.itemUnit = "Cell/uL";
ermList.Add(erm4);
examResultMode erm5 = new examResultMode();
erm5.machineCode = MachineCode;
erm5.machineID = MachineID;
erm5.sampleNo = sampleNo1;
erm5.testDate = testDate1;
erm5.chanelNo = "PRO";//项目代号
erm5.itemValue = resulteArray[i + 9].Replace("PRO", "").Trim().Split(' ')[0].Trim();//项目结果
erm5.itemUnit = "";
ermList.Add(erm5);
examResultMode erm6 = new examResultMode();
erm6.machineCode = MachineCode;
erm6.machineID = MachineID;
erm6.sampleNo = sampleNo1;
erm6.testDate = testDate1;
erm6.chanelNo = "NIT";//项目代号
erm6.itemValue = resulteArray[i + 10].Replace("NIT", "").Trim().Split(' ')[0].Trim();//项目结果
erm6.itemUnit = "";
ermList.Add(erm6);
examResultMode erm10 = new examResultMode();
erm10.machineCode = MachineCode;
erm10.machineID = MachineID;
erm10.sampleNo = sampleNo1;
erm10.testDate = testDate1;
erm10.chanelNo = "LEU";//项目代号
erm10.itemValue = resulteArray[i + 11].Replace("LEU", "").Trim().Split(' ')[0].Trim();//项目结果
erm10.itemUnit = "";
ermList.Add(erm10);
examResultMode erm7 = new examResultMode();
erm7.machineCode = MachineCode;
erm7.machineID = MachineID;
erm7.sampleNo = sampleNo1;
erm7.testDate = testDate1;
erm7.chanelNo = "GLU";//项目代号
erm7.itemValue = resulteArray[i + 12].Replace("GLU", "").Trim().Split(' ')[0].Trim();//项目结果
erm7.itemUnit = "";
ermList.Add(erm7);
examResultMode erm8 = new examResultMode();
erm8.machineCode = MachineCode;
erm8.machineID = MachineID;
erm8.sampleNo = sampleNo1;
erm8.testDate = testDate1;
erm8.chanelNo = "SG";//项目代号
erm8.itemValue = resulteArray[i + 13].Replace("SG", "").Trim().Split(' ')[0].Trim();//项目结果
erm8.itemUnit = "";
ermList.Add(erm8);
examResultMode erm9 = new examResultMode();
erm9.machineCode = MachineCode;
erm9.machineID = MachineID;
erm9.sampleNo = sampleNo1;
erm9.testDate = testDate1;
erm9.chanelNo = "PH";//项目代号
erm9.itemValue = resulteArray[i + 14].Replace("PH", "").Trim().Split(' ')[0].Trim();//项目结果
erm9.itemUnit = "";
ermList.Add(erm9);
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
dataOutPutShow("数据提交失败:" + jsonStr, null);
}
}
if (apiOptions.CurrentDevice == "BA600MY")//煤窑中心卫生院的尿常规 GeniusBA600
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] resulteArray = deviceDataStr.Split('\n');
// File.WriteAllText("BT-200.TXT", deviceDataStr);
for (int i = 0; i < resulteArray.Length; i += 16)
{
//这里需要判断一下数据是否超过了 当前数据的长度
ermList.Clear();
if (i + 16 > resulteArray.Length)
break;
//string[] spArray = resulteArray[i + 1].Trim().Split(' ');
string sampleNo1 = resulteArray[2].TrimStart('0').Trim();
//string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]);
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
examResultMode erm = new examResultMode();
erm.machineCode = MachineCode;
erm.machineID = MachineID;
erm.sampleNo = sampleNo1;
erm.testDate = testDate1;
erm.chanelNo = "VC";//项目代号
erm.itemValue = resulteArray[i + 4].Replace("VC", "").Trim().Split(' ')[0].Trim();//项目结果
erm.itemUnit = "";
ermList.Add(erm);
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = sampleNo1;
erm1.testDate = testDate1;
erm1.chanelNo = "URO";//项目代号
erm1.itemValue = resulteArray[i + 5].Replace("URO", "").Trim();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
examResultMode erm2 = new examResultMode();
erm2.machineCode = MachineCode;
erm2.machineID = MachineID;
erm2.sampleNo = sampleNo1;
erm2.testDate = testDate1;
erm2.chanelNo = "BIL";//项目代号
erm2.itemValue = resulteArray[i + 6].Replace("BIL", "").Trim().Trim();//项目结果
erm2.itemUnit = "";
ermList.Add(erm2);
examResultMode erm3 = new examResultMode();
erm3.machineCode = MachineCode;
erm3.machineID = MachineID;
erm3.sampleNo = sampleNo1;
erm3.testDate = testDate1;
erm3.chanelNo = "KET";//项目代号
erm3.itemValue = resulteArray[i + 7].Replace("KET", "").Trim();//项目结果
erm3.itemUnit = "";
ermList.Add(erm3);
examResultMode erm4 = new examResultMode();
erm4.machineCode = MachineCode;
erm4.machineID = MachineID;
erm4.sampleNo = sampleNo1;
erm4.testDate = testDate1;
erm4.chanelNo = "BLD";//项目代号
erm4.itemValue = resulteArray[i + 8].Replace("BLD", "").Replace("Cell/uL", "").Trim();//项目结果
erm4.itemUnit = "Cell/uL";
ermList.Add(erm4);
examResultMode erm5 = new examResultMode();
erm5.machineCode = MachineCode;
erm5.machineID = MachineID;
erm5.sampleNo = sampleNo1;
erm5.testDate = testDate1;
erm5.chanelNo = "PRO";//项目代号
erm5.itemValue = resulteArray[i + 9].Replace("PRO", "").Trim();//项目结果
erm5.itemUnit = "";
ermList.Add(erm5);
examResultMode erm6 = new examResultMode();
erm6.machineCode = MachineCode;
erm6.machineID = MachineID;
erm6.sampleNo = sampleNo1;
erm6.testDate = testDate1;
erm6.chanelNo = "NIT";//项目代号
erm6.itemValue = resulteArray[i + 10].Replace("NIT", "").Trim();//项目结果
erm6.itemUnit = "";
ermList.Add(erm6);
examResultMode erm10 = new examResultMode();
erm10.machineCode = MachineCode;
erm10.machineID = MachineID;
erm10.sampleNo = sampleNo1;
erm10.testDate = testDate1;
erm10.chanelNo = "LEU";//项目代号
erm10.itemValue = resulteArray[i + 11].Replace("LEU", "").Trim();//项目结果
erm10.itemUnit = "";
ermList.Add(erm10);
examResultMode erm7 = new examResultMode();
erm7.machineCode = MachineCode;
erm7.machineID = MachineID;
erm7.sampleNo = sampleNo1;
erm7.testDate = testDate1;
erm7.chanelNo = "GLU";//项目代号
erm7.itemValue = resulteArray[i + 12].Replace("GLU", "").Trim();//项目结果
erm7.itemUnit = "";
ermList.Add(erm7);
examResultMode erm8 = new examResultMode();
erm8.machineCode = MachineCode;
erm8.machineID = MachineID;
erm8.sampleNo = sampleNo1;
erm8.testDate = testDate1;
erm8.chanelNo = "SG";//项目代号
erm8.itemValue = resulteArray[i + 13].Replace("SG", "").Trim();//项目结果
erm8.itemUnit = "";
ermList.Add(erm8);
examResultMode erm9 = new examResultMode();
erm9.machineCode = MachineCode;
erm9.machineID = MachineID;
erm9.sampleNo = sampleNo1;
erm9.testDate = testDate1;
erm9.chanelNo = "PH";//项目代号
erm9.itemValue = resulteArray[i + 14].Replace("PH", "").Trim();//项目结果
erm9.itemUnit = "";
ermList.Add(erm9);
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
dataOutPutShow("数据提交失败:" + jsonStr, null);
}
}
if (apiOptions.CurrentDevice == "MC-600")//血常规MAC-600
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray1 = new string[20] { "WBC", "Lymph#", "Mid#", "Gran#", "Lymph%", "Mid%", "Gran%", "RBC", "HGB", "MCV", "MCH", "MCHC", "RDW-CV", "RDW-SD", "HCT", "PLT", "MPV", "PDW", "PCT", "P-LCR" };
string[] itemArray = new string[20] { "WBC", "LYMC", "MIDC", "GRNC", "LYMR", "MIDR", "GRNR", "RBC", "HGB", "MCV", "MCH", "MCHC", "RDW-CV", "RDW-SD", "HCT", "PLT", "MPV", "PDW", "PCT", "P-LCR" };
//string[] resulteArray = deviceDataStr.Split('\n');
// deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string[] valArray = deviceDataStr.Split('\n');
string sampleNo1 = string.Empty;//样本号
for (int A = 0; A < valArray.Length; A++)
{
if (valArray[A].Contains("<p><n>ID</n><v>"))
{
sampleNo1 = jiexiVal(valArray[A].IndexOf("<p><n>ID</n><v>"), "<p><n>ID</n><v>", valArray[A]).ToString().TrimStart('0');
}
for (int i = 0; i < itemArray.Length; i++)
{
string keyItem = "<p><n>" + itemArray[i];
if (valArray[A].Contains(keyItem))
{
string itemStr = itemArray[i] + "</n><v>";
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 = itemArray1[i];//项目代号 这是屏幕上显示的代号
erm1.itemValue = valArray[A].Substring(valArray[A].IndexOf("<v>") + 3, valArray[A].IndexOf("</v>") - valArray[A].IndexOf("<v>") - 3);//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
}
}
string jsonStr12 = JsonConvert.SerializeObject(ermList);
//把血常规的图也传上去
List<examImageParaModel> eipmList = new List<examImageParaModel>();
int[] array1 = strCount("^Base64^", deviceDataStr);
string keyStr = "||||||F";//结束符
List<string> imgBase64StrList = jiexiBase64(array1, keyStr, deviceDataStr);//解析出数据中的图片base64
//int[] array2 = strCount("||||||F||||||", deviceDataStr);
for (int i = 0; i < imgBase64StrList.Count; i++)
{
string base64Str = imgBase64StrList[i];
examImageParaModel EIPM1 = new examImageParaModel();
EIPM1.machineCode = MachineCode;
EIPM1.machineID = MachineID;
EIPM1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
EIPM1.sampleNo = sampleNo1;
EIPM1.img = "data:image/jpeg;base64," + base64Str;
eipmList.Add(EIPM1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (eipmList.Count > 0)
{
baseMsgModel bmm2 = apiOptions.CreateInstance().uploadExamImage(eipmList);//传图像List
//if (bmm2.code == 200)
// dataOutPutShow("图像提交成功:" + jsonStr, null);
//else
// dataOutPutShow("图像提交失败:" + jsonStr, null);
}
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "CS-1300B")//迪瑞全自动生化分析仪 CS-1300B
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[16] { "ALT", "AST", "TBIL", "UREA", "CRE-E", "GLU", "TC", "TG", "HDL-C", "LDL-C", "TP", "ALB", "DBIL", "ALP", "GGT", "UA" };
//deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string[] valArray = deviceDataStr.Split('\n');
string sampleNo1 = string.Empty;//样本号
for (int A = 0; A < valArray.Length; A++)
{
if (valArray[A].Contains("|1200^1300B|"))
{
// int index3 = jiexisampleNo(valArray[A].IndexOf("|480^480|"), valArray[A]);
sampleNo1 = jiexisampleNo(valArray[A].IndexOf("|1200^1300B|"), valArray[A]).ToString();
// File.WriteAllText("test1.txt","哈哈哈 " + index3.ToString() + " " + valArray[A] + " 原样字符串:" + deviceDataStr);
// MessageBox.Show("哈哈哈 "+index3.ToString()+" "+ valArray[A]+" 原样字符串:"+ deviceDataStr);
}
for (int i = 0; i < itemArray.Length; i++)
{
if (valArray[A].Contains(itemArray[i]))
{
string itemStr = itemArray[i] + "^1|";
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 = jiexiItemValue(itemStr, valArray[A]);//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
}
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "URIT-1500")//优利特尿常规URIT-1500
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[11] { "VC", "WBC", "KET", "NIT", "URO", "BIL", "PRO", "GLU", "SG", "BLD", "pH" };
string[] resulteArray = deviceDataStr.Split('\n');
for (int i = 0; i < resulteArray.Length; i += 18)
{
//这里需要判断一下数据是否超过了 当前数据的长度
ermList.Clear();
if (i + 18 > resulteArray.Length)
break;
string[] spArray = resulteArray[i + 2].Trim().Split(' ');
string sampleNo1 = spArray[0].Trim().Replace("NO.", "").TrimStart('0');
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
examResultMode erm = new examResultMode();
erm.machineCode = MachineCode;
erm.machineID = MachineID;
erm.sampleNo = sampleNo1;
erm.testDate = testDate1;
erm.chanelNo = "VC";//项目代号
erm.itemValue = resulteArray[i + 5].Substring(resulteArray[i + 5].IndexOf("VC") + 2, 6).Trim();//项目结果
erm.itemUnit = "mmol/L";
ermList.Add(erm);
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = sampleNo1;
erm1.testDate = testDate1;
erm1.chanelNo = "WBC";//项目代号
erm1.itemValue = resulteArray[i + 6].Substring(resulteArray[i + 6].IndexOf("WBC") + 3, 6).Trim();//项目结果
erm1.itemUnit = "CELL/uL";
ermList.Add(erm1);
examResultMode erm2 = new examResultMode();
erm2.machineCode = MachineCode;
erm2.machineID = MachineID;
erm2.sampleNo = sampleNo1;
erm2.testDate = testDate1;
erm2.chanelNo = "KET";//项目代号
erm2.itemValue = resulteArray[i + 7].Substring(resulteArray[i + 7].IndexOf("KET") + 3, 6).Trim();//项目结果
erm2.itemUnit = "mmol/L";
ermList.Add(erm2);
examResultMode erm3 = new examResultMode();
erm3.machineCode = MachineCode;
erm3.machineID = MachineID;
erm3.sampleNo = sampleNo1;
erm3.testDate = testDate1;
erm3.chanelNo = "NIT";//项目代号
erm3.itemValue = resulteArray[i + 8].Substring(resulteArray[i + 8].IndexOf("NIT") + 3, 6).Trim();//项目结果
erm3.itemUnit = "Neg";
ermList.Add(erm3);
examResultMode erm4 = new examResultMode();
erm4.machineCode = MachineCode;
erm4.machineID = MachineID;
erm4.sampleNo = sampleNo1;
erm4.testDate = testDate1;
erm4.chanelNo = "URO";//项目代号
string[] sss = resulteArray[i + 9].Split(' ');
erm4.itemValue = resulteArray[i + 9].Substring(resulteArray[i + 9].IndexOf("URO") + 3, 6).Trim();//项目结果
erm4.itemUnit = "Normal";
ermList.Add(erm4);
examResultMode erm5 = new examResultMode();
erm5.machineCode = MachineCode;
erm5.machineID = MachineID;
erm5.sampleNo = sampleNo1;
erm5.testDate = testDate1;
erm5.chanelNo = "BIL";//项目代号
erm5.itemValue = resulteArray[i + 10].Substring(resulteArray[i + 10].IndexOf("BIL") + 3, 6).Trim();//项目结果
erm5.itemUnit = "umol/L";
ermList.Add(erm5);
examResultMode erm6 = new examResultMode();
erm6.machineCode = MachineCode;
erm6.machineID = MachineID;
erm6.sampleNo = sampleNo1;
erm6.testDate = testDate1;
erm6.chanelNo = "PRO";//项目代号
erm6.itemValue = resulteArray[i + 11].Substring(resulteArray[i + 11].IndexOf("PRO") + 3, 6).Trim();//项目结果
erm6.itemUnit = "g/L";
ermList.Add(erm6);
examResultMode erm7 = new examResultMode();
erm7.machineCode = MachineCode;
erm7.machineID = MachineID;
erm7.sampleNo = sampleNo1;
erm7.testDate = testDate1;
erm7.chanelNo = "GLU";//项目代号
erm7.itemValue = resulteArray[i + 12].Substring(resulteArray[i + 12].IndexOf("GLU") + 3, 6).Trim();//项目结果
erm7.itemUnit = "mmol/L";
ermList.Add(erm7);
examResultMode erm8 = new examResultMode();
erm8.machineCode = MachineCode;
erm8.machineID = MachineID;
erm8.sampleNo = sampleNo1;
erm8.testDate = testDate1;
erm8.chanelNo = "SG";//项目代号
erm8.itemValue = resulteArray[i + 13].Replace("SG", "").Trim();//项目结果
erm8.itemUnit = "";
ermList.Add(erm8);
examResultMode erm9 = new examResultMode();
erm9.machineCode = MachineCode;
erm9.machineID = MachineID;
erm9.sampleNo = sampleNo1;
erm9.testDate = testDate1;
erm9.chanelNo = "BLD";//项目代号
erm9.itemValue = resulteArray[i + 14].Substring(resulteArray[i + 14].IndexOf("BLD") + 3, 6).Trim();//项目结果
erm9.itemUnit = "CELL/uL";
ermList.Add(erm9);
examResultMode erm10 = new examResultMode();
erm10.machineCode = MachineCode;
erm10.machineID = MachineID;
erm10.sampleNo = sampleNo1;
erm10.testDate = testDate1;
erm10.chanelNo = "pH";//项目代号
erm10.itemValue = resulteArray[i + 15].Replace("pH", "").Trim();//项目结果
erm10.itemUnit = "";
ermList.Add(erm10);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "URIT-5180")//优利特血常规 5180
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[31] { "WBC", "LYM%", "MON%", "NEU%", "EOS%", "BASO%", "LYM#", "MON#", "NEU#", "EOS#", "BASO#", "ALY%", "ALY#", "LIC%", "LIC#", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW_CV", "RDW_SD", "PLT", "MPV", "PDW", "PCT", "P_LCR", "P_LCC", "NRBC%", "NRBC#" };
//string[] resulteArray = deviceDataStr.Split('\n');
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string sampleNo1 = string.Empty;//样本号
for (int i = 0; i < itemArray.Length; i++)
{
string itemStr = itemArray[i] + "||";
sampleNo1 = deviceDataStr.Substring(deviceDataStr.IndexOf("|URIT^URIT-5160|||") - 7, 7).TrimStart('0');
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 = jiexiItemValue(itemStr, deviceDataStr);//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
////把血常规的图也传上去
//List<examImageParaModel> eipmList = new List<examImageParaModel>();
//int[] array1 = strCount("^Base64^", deviceDataStr);
//int[] array2 = strCount("||||||F||||||", deviceDataStr);
//for (int i = 0; i < array2.Length; i++)
//{
// string base64Str = deviceDataStr.Substring(array1[i] + 8, array2[i] - array1[i] - 8);
// examImageParaModel EIPM1 = new examImageParaModel();
// EIPM1.machineCode = MachineCode;
// EIPM1.machineID = MachineID;
// EIPM1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
// EIPM1.sampleNo = sampleNo1;
// EIPM1.img = "data:image/jpeg;base64," + base64Str;
// eipmList.Add(EIPM1);
//}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
//if (eipmList.Count > 0)
//{
// baseMsgModel bmm2 = apiOptions.CreateInstance().uploadExamImage(eipmList);//传图像List
// //if (bmm2.code == 200)
// // dataOutPutShow("图像提交成功:" + jsonStr, null);
// //else
// // dataOutPutShow("图像提交失败:" + jsonStr, null);
//}
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "BS-430")//生化BS-430
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[10] { "Glu-G", "TG", "TC", "LDL-C", "HDL-C", "T-Bil-V", "ALT", "AST", "CREA-S", "UREA" };
string[] itemArrayC = new string[10] { "葡萄糖(葡萄糖氧化酶法)", "甘油三酯", "总胆固醇", "低密度脂蛋白胆固醇", "高密度脂蛋白胆固醇", "总胆红素(钒酸盐氧化法)", "丙氨酸氨基转移酶", "天门冬氨酸氨基转移酶", "肌酐(肌氨酸氧化酶法)", "尿素" };
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
//string[] valArray = deviceDataStr.Split(',');
string[] valArray = deviceDataStr.Split('|');
string sampleNo1 = valArray[54];//样本号
for (int i = 0; i < itemArrayC.Length; i++)
{
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];//项目代号
// MessageBox.Show(deviceDataStr+"\r\n\r\n :"+ggg[5]);
string itemStr = itemArrayC[i] + "|";
int index1 = deviceDataStr.IndexOf(itemStr);
string valueS = jiexiVal(index1, itemStr, deviceDataStr);
double roundedValue = Math.Round(double.Parse(valueS), 2);
erm1.itemValue = roundedValue.ToString();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "DF55-1")//帝迈血常规DF55-1
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[27] { "WBC", "NEU%", "LYM%", "MON%", "EOS%", "BAS%", "NEU#", "LYM#", "MON#", "EOS#", "BAS#", "*ALY%", "*LIC#", "*LIC%", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW-SD", "PLT", "MPV", "PDW", "PCT", "*ALY#", "RDW-CV" };
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string sampleNo1 = string.Empty;//样本号
for (int i = 0; i < itemArray.Length; i++)
{
string itemStr = string.Empty;
if (itemArray[i] == "*LIC#" || itemArray[i] == "*LIC%" || itemArray[i] == "PCT")
itemStr = itemArray[i] + "^99MRC||";
else
itemStr = itemArray[i] + "^LN||";
string val1 = jiexiVal(deviceDataStr.IndexOf("OBR|1||"), "OBR|1||", deviceDataStr).ToString();
sampleNo1 = val1;
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 = jiexiVal(deviceDataStr.IndexOf(itemStr), itemStr, deviceDataStr).ToString();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
string jsonStr12 = JsonConvert.SerializeObject(ermList);
//把血常规的图也传上去
List<examImageParaModel> eipmList = new List<examImageParaModel>();
int[] array1 = strCount("^Base64^", deviceDataStr);
string keyStr = "||||||F";//结束符
List<string> imgBase64StrList = jiexiBase64(array1, keyStr, deviceDataStr);//解析出数据中的图片base64
//int[] array2 = strCount("||||||F||||||", deviceDataStr);
for (int i = 0; i < imgBase64StrList.Count; i++)
{
string base64Str = imgBase64StrList[i];
examImageParaModel EIPM1 = new examImageParaModel();
EIPM1.machineCode = MachineCode;
EIPM1.machineID = MachineID;
EIPM1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
EIPM1.sampleNo = sampleNo1;
EIPM1.img = "data:image/jpeg;base64," + base64Str;
eipmList.Add(EIPM1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (eipmList.Count > 0)
{
baseMsgModel bmm2 = apiOptions.CreateInstance().uploadExamImage(eipmList);//传图像List
//if (bmm2.code == 200)
// dataOutPutShow("图像提交成功:" + jsonStr, null);
//else
// dataOutPutShow("图像提交失败:" + jsonStr, null);
}
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "URIT-1600")//优利特URIT-1600
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[12] { "Vc", "WBC", "KET", "NIT", "URO", "BIL", "PRO", "GLU", "SG", "BLD", "pH", "Color" };
// deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
//string[] valArray = deviceDataStr.Split(',');
string[] valArray = deviceDataStr.Split('\r');
string sampleNo1 = string.Empty;
for (int A = 0; A < valArray.Length; A++)
{
if (valArray[A].Contains("OBR"))
{
string[] valStrArray = valArray[A].Split('|');
sampleNo1 = valStrArray[3].TrimStart('0');
}
for (int i = 0; i < itemArray.Length; i++)
{
if (valArray[A].Contains(itemArray[i]))
{
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];//项目代号
string[] reArray = valArray[A].Replace("||", "|").Split('|');
erm1.itemValue = reArray[4].Split('^')[0];//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
}
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "DH56")//帝迈血常规DH56
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[29] { "WBC", "NEU%", "LYM%", "MON%", "EOS%", "BAS%", "NEU#", "LYM#", "MON#", "EOS#", "BAS#", "*ALY#", "*ALY%", "*LIC#", "*LIC%", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW-CV", "RDW-SD", "PLT", "MPV", "PDW", "PCT", "P-LCR", "P-LCC" };
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string sampleNo1 = string.Empty;//样本号
for (int i = 0; i < itemArray.Length; i++)
{
string itemStr = string.Empty;
if (itemArray[i] == "*LIC#" || itemArray[i] == "*LIC%" || itemArray[i] == "PCT")
itemStr = itemArray[i] + "^99MRC||";
else
itemStr = itemArray[i] + "^LN||";
string val1 = jiexiVal(deviceDataStr.IndexOf("OBR|1||"), "OBR|1||", deviceDataStr).ToString();
sampleNo1 = val1;
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 = jiexiVal(deviceDataStr.IndexOf(itemStr), itemStr, deviceDataStr).ToString();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
// string jsonStr12 = JsonConvert.SerializeObject(ermList);
////把血常规的图也传上去
//List<examImageParaModel> eipmList = new List<examImageParaModel>();
//int[] array1 = strCount("^Base64^", deviceDataStr);
//string keyStr = "||||||F";//结束符
//List<string> imgBase64StrList = jiexiBase64(array1, keyStr, deviceDataStr);//解析出数据中的图片base64
////int[] array2 = strCount("||||||F||||||", deviceDataStr);
//for (int i = 0; i < imgBase64StrList.Count; i++)
//{
// string base64Str = imgBase64StrList[i];
// examImageParaModel EIPM1 = new examImageParaModel();
// EIPM1.machineCode = MachineCode;
// EIPM1.machineID = MachineID;
// EIPM1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
// EIPM1.sampleNo = sampleNo1;
// EIPM1.img = "data:image/jpeg;base64," + base64Str;
// eipmList.Add(EIPM1);
//}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
//if (eipmList.Count > 0)
//{
// baseMsgModel bmm2 = apiOptions.CreateInstance().uploadExamImage(eipmList);//传图像List
// //if (bmm2.code == 200)
// // dataOutPutShow("图像提交成功:" + jsonStr, null);
// //else
// // dataOutPutShow("图像提交失败:" + jsonStr, null);
//}
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "URIT-5380")//优利特血常规URIT-5380
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[25] { "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" };
//string[] resulteArray = deviceDataStr.Split('\n');
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string sampleNo1 = string.Empty;//样本号
for (int i = 0; i < itemArray.Length; i++)
{
string itemStr = itemArray[i] + "||";
//sampleNo1 = deviceDataStr.Substring(deviceDataStr.IndexOf("||Urit^UT5380||||") - 7, 7).TrimStart('0');
sampleNo1 = jiexisampleNo(deviceDataStr.IndexOf("||Urit^UT5380||||"), deviceDataStr).ToString();
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 = jiexiItemValue(itemStr, deviceDataStr);//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
//把血常规的图也传上去
List<examImageParaModel> eipmList = new List<examImageParaModel>();
int[] array1 = strCount("^Base64^", deviceDataStr);
int[] array2 = strCount("||||||F||||||", deviceDataStr);
for (int i = 0; i < array2.Length; i++)
{
string base64Str = deviceDataStr.Substring(array1[i] + 8, array2[i] - array1[i] - 8);
examImageParaModel EIPM1 = new examImageParaModel();
EIPM1.machineCode = MachineCode;
EIPM1.machineID = MachineID;
EIPM1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
EIPM1.sampleNo = sampleNo1;
EIPM1.img = "data:image/jpeg;base64," + base64Str;
eipmList.Add(EIPM1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (eipmList.Count > 0)
{
baseMsgModel bmm2 = apiOptions.CreateInstance().uploadExamImage(eipmList);//传图像List
//if (bmm2.code == 200)
// dataOutPutShow("图像提交成功:" + jsonStr, null);
//else
// dataOutPutShow("图像提交失败:" + jsonStr, null);
}
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "U500")//尿常规U500
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] resulteArray = deviceDataStr.Split('\n');
// File.WriteAllText("BT-200.TXT", deviceDataStr);
for (int i = 0; i < resulteArray.Length; i += 20)
{
//这里需要判断一下数据是否超过了 当前数据的长度
ermList.Clear();
if (i + 20 > resulteArray.Length)
break;
string[] spArray = resulteArray[3].Trim().Split(' ');
string sampleNo1 = resulteArray[3].Trim().Split(' ')[2].Replace("-", "0").TrimStart('0');
//string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]);
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
examResultMode erm = new examResultMode();
erm.machineCode = MachineCode;
erm.machineID = MachineID;
erm.sampleNo = sampleNo1;
erm.testDate = testDate1;
erm.chanelNo = "LEU";//项目代号
erm.itemValue = resulteArray[i + 4].Substring(4, 15).Trim();//项目结果//项目结果
erm.itemUnit = "";
ermList.Add(erm);
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = sampleNo1;
erm1.testDate = testDate1;
erm1.chanelNo = "URO";//项目代号
erm1.itemValue = resulteArray[i + 5].Substring(4, 11).Trim();//项目结果
erm1.itemUnit = "mg/dL";
ermList.Add(erm1);
examResultMode erm2 = new examResultMode();
erm2.machineCode = MachineCode;
erm2.machineID = MachineID;
erm2.sampleNo = sampleNo1;
erm2.testDate = testDate1;
erm2.chanelNo = "ALB";//项目代号
erm2.itemValue = resulteArray[i + 6].Substring(4, 13).Trim();//项目结果
erm2.itemUnit = "mg/L";
ermList.Add(erm2);
examResultMode erm3 = new examResultMode();
erm3.machineCode = MachineCode;
erm3.machineID = MachineID;
erm3.sampleNo = sampleNo1;
erm3.testDate = testDate1;
erm3.chanelNo = "PRO";//项目代号
erm3.itemValue = resulteArray[i + 7].Substring(4, 15).Trim();//项目结果
erm3.itemUnit = "";
ermList.Add(erm3);
examResultMode erm4 = new examResultMode();
erm4.machineCode = MachineCode;
erm4.machineID = MachineID;
erm4.sampleNo = sampleNo1;
erm4.testDate = testDate1;
erm4.chanelNo = "BIL";//项目代号
erm4.itemValue = resulteArray[i + 8].Substring(5, 13).Trim();//项目结果
erm4.itemUnit = "";
ermList.Add(erm4);
examResultMode erm5 = new examResultMode();
erm5.machineCode = MachineCode;
erm5.machineID = MachineID;
erm5.sampleNo = sampleNo1;
erm5.testDate = testDate1;
erm5.chanelNo = "GLU";//项目代号
erm5.itemValue = resulteArray[i + 9].Substring(4, 15).Trim();//项目结果
erm5.itemUnit = "";
ermList.Add(erm5);
examResultMode erm6 = new examResultMode();
erm6.machineCode = MachineCode;
erm6.machineID = MachineID;
erm6.sampleNo = sampleNo1;
erm6.testDate = testDate1;
erm6.chanelNo = "ASC";//项目代号
erm6.itemValue = resulteArray[i + 10].Substring(5, 13).Trim();//项目结果
erm6.itemUnit = "";
ermList.Add(erm6);
examResultMode erm10 = new examResultMode();
erm10.machineCode = MachineCode;
erm10.machineID = MachineID;
erm10.sampleNo = sampleNo1;
erm10.testDate = testDate1;
erm10.chanelNo = "SG";//项目代号
erm10.itemValue = resulteArray[i + 11].Replace("SG", "").Trim();//项目结果
erm10.itemUnit = "";
ermList.Add(erm10);
examResultMode erm7 = new examResultMode();
erm7.machineCode = MachineCode;
erm7.machineID = MachineID;
erm7.sampleNo = sampleNo1;
erm7.testDate = testDate1;
erm7.chanelNo = "KET";//项目代号
erm7.itemValue = resulteArray[i + 12].Substring(4, 13).Trim();//项目结果
erm7.itemUnit = "";
ermList.Add(erm7);
examResultMode erm8 = new examResultMode();
erm8.machineCode = MachineCode;
erm8.machineID = MachineID;
erm8.sampleNo = sampleNo1;
erm8.testDate = testDate1;
erm8.chanelNo = "NIT";//项目代号
erm8.itemValue = resulteArray[i + 13].Substring(4, 14).Trim();//项目结果
erm8.itemUnit = "";
ermList.Add(erm8);
examResultMode erm9 = new examResultMode();
erm9.machineCode = MachineCode;
erm9.machineID = MachineID;
erm9.sampleNo = sampleNo1;
erm9.testDate = testDate1;
erm9.chanelNo = "CRE";//项目代号
erm9.itemValue = resulteArray[i + 14].Substring(4, 12).Trim();//项目结果
erm9.itemUnit = "mmol/L";
ermList.Add(erm9);
examResultMode erm11 = new examResultMode();
erm11.machineCode = MachineCode;
erm11.machineID = MachineID;
erm11.sampleNo = sampleNo1;
erm11.testDate = testDate1;
erm11.chanelNo = "PH";//项目代号
erm11.itemValue = resulteArray[i + 15].Replace("PH", "").Trim();//项目结果
erm11.itemUnit = "mmol/L";
ermList.Add(erm11);
examResultMode erm12 = new examResultMode();
erm12.machineCode = MachineCode;
erm12.machineID = MachineID;
erm12.sampleNo = sampleNo1;
erm12.testDate = testDate1;
erm12.chanelNo = "BLO";//项目代号
erm12.itemValue = resulteArray[i + 16].Substring(4, 15).Trim();//项目结果
erm12.itemUnit = "mmol/L";
ermList.Add(erm12);
examResultMode erm13 = new examResultMode();
erm13.machineCode = MachineCode;
erm13.machineID = MachineID;
erm13.sampleNo = sampleNo1;
erm13.testDate = testDate1;
erm13.chanelNo = "CA";//项目代号
erm13.itemValue = resulteArray[i + 17].Substring(4, 12).Trim();//项目结果
erm13.itemUnit = "mmol/L";
ermList.Add(erm13);
examResultMode erm14 = new examResultMode();
erm14.machineCode = MachineCode;
erm14.machineID = MachineID;
erm14.sampleNo = sampleNo1;
erm14.testDate = testDate1;
erm14.chanelNo = "P:C";//项目代号
erm14.itemValue = resulteArray[i + 18].Substring(4, 8).Trim();//项目结果
erm14.itemUnit = "mmol/L";
ermList.Add(erm14);
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
dataOutPutShow("数据提交失败:" + jsonStr, null);
}
}
if (apiOptions.CurrentDevice == "BC-5130")//BC-5130
{
try
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
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[] resulteArray = deviceDataStr.Split('\n');
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string sampleNo1 = string.Empty;//样本号
for (int i = 0; i < itemArray.Length; i++)
{
string itemStr = string.Empty;
if (itemArray[i] == "*LIC#" || itemArray[i] == "*LIC%" || itemArray[i] == "PCT" || itemArray[i] == "PLCC" || itemArray[i] == "PLCR" || itemArray[i] == "Lymphocytosis")
itemStr = itemArray[i] + "^99MRC||";
else
itemStr = itemArray[i] + "^LN||";
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]; //项目代号
if (itemArray[i] != "Lymphocytosis")
erm1.itemValue = jiexiVal(deviceDataStr.IndexOf(itemStr), itemStr, deviceDataStr).ToString();//项目结果
else
erm1.itemValue = jiexiItemValue11(itemStr, deviceDataStr);
erm1.itemUnit = "";
ermList.Add(erm1);
}
string jsonStr12 = JsonConvert.SerializeObject(ermList);
//把血常规的图也传上去
List<examImageParaModel> eipmList = new List<examImageParaModel>();
int[] array1 = strCount("^Base64^", deviceDataStr);
string keyStr = "||||||F";//结束符
List<string> imgBase64StrList = jiexiBase64(array1, keyStr, deviceDataStr);//解析出数据中的图片base64
//int[] array2 = strCount("||||||F||||||", deviceDataStr);
for (int i = 0; i < imgBase64StrList.Count; i++)
{
string base64Str = imgBase64StrList[i];
examImageParaModel EIPM1 = new examImageParaModel();
EIPM1.machineCode = MachineCode;
EIPM1.machineID = MachineID;
EIPM1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
EIPM1.sampleNo = sampleNo1;
EIPM1.img = "data:image/jpeg;base64," + base64Str;
eipmList.Add(EIPM1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (eipmList.Count > 0)
{
baseMsgModel bmm2 = apiOptions.CreateInstance().uploadExamImage(eipmList);//传图像List
//if (bmm2.code == 200)
// dataOutPutShow("图像提交成功:" + jsonStr, null);
//else
// dataOutPutShow("图像提交失败:" + jsonStr, null);
}
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
catch (Exception ex) { /*MessageBox.Show(ex.ToString()); */}
}
if (apiOptions.CurrentDevice == "SD1")//斯玛特SD1
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[22] { "ALT", "AST", "ALP", "GGT", "IBIL", "TP", "ALB", "Crea", "UA", "GLU", "TG", "HDL", "LDL", "TB|TB", "TC", "DB", "CHE", "BUN|BUN", "TBA", "A/G", "BUN/CREA", "GLOB" };
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
deviceDataStr = deviceDataStr.Replace("OBX", "。");
string[] valArray = deviceDataStr.Split('。');
string sampleNo1 = string.Empty;//样本号
for (int A = 0; A < valArray.Length; A++)
{
if (valArray[A].Contains("OBR|"))
{
int index1 = valArray[A].Substring(valArray[A].IndexOf("OBR|"), 20).IndexOf("||") + 2;
sampleNo1 = jiexisampleNo8(index1, valArray[A].Substring(valArray[A].IndexOf("OBR|"), 18)).ToString();
}
for (int i = 0; i < itemArray.Length; i++)
{
if (valArray[A].Contains(itemArray[i]))
{
string itemStr = itemArray[i];
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 = jiexiItemValueLast(itemStr, valArray[A]);//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
}
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "DF55-2")//帝迈血常规DF55-2
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[27] { "WBC", "NEU%", "LYM%", "MON%", "EOS%", "BAS%", "NEU#", "LYM#", "MON#", "EOS#", "BAS#", "*ALY%", "*LIC#", "*LIC%", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW-SD", "PLT", "MPV", "PDW", "PCT", "*ALY#", "RDW-CV" };
//string[] resulteArray = deviceDataStr.Split('\n');
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string sampleNo1 = string.Empty;//样本号
for (int i = 0; i < itemArray.Length; i++)
{
string itemStr = string.Empty;
if (itemArray[i] == "*LIC#" || itemArray[i] == "*LIC%" || itemArray[i] == "PCT")
itemStr = itemArray[i] + "^99MRC||";
else
itemStr = itemArray[i] + "^LN||";
int index1 = deviceDataStr.Substring(deviceDataStr.IndexOf("OBR|"), 20).IndexOf("||") + 2;
sampleNo1 = jiexisampleNo8(index1, deviceDataStr.Substring(deviceDataStr.IndexOf("OBR|"), 18)).ToString();
//string val1 = jiexiVal(deviceDataStr.IndexOf("PID|"), "PID|", deviceDataStr).ToString();
//sampleNo1 = val1;
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 = jiexiVal(deviceDataStr.IndexOf(itemStr), itemStr, deviceDataStr).ToString();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
string jsonStr12 = JsonConvert.SerializeObject(ermList);
//把血常规的图也传上去
List<examImageParaModel> eipmList = new List<examImageParaModel>();
int[] array1 = strCount("^Base64^", deviceDataStr);
string keyStr = "||||||F";//结束符
List<string> imgBase64StrList = jiexiBase64(array1, keyStr, deviceDataStr);//解析出数据中的图片base64
//int[] array2 = strCount("||||||F||||||", deviceDataStr);
for (int i = 0; i < imgBase64StrList.Count; i++)
{
string base64Str = imgBase64StrList[i];
examImageParaModel EIPM1 = new examImageParaModel();
EIPM1.machineCode = MachineCode;
EIPM1.machineID = MachineID;
EIPM1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
EIPM1.sampleNo = sampleNo1;
EIPM1.img = "data:image/jpeg;base64," + base64Str;
eipmList.Add(EIPM1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (eipmList.Count > 0)
{
baseMsgModel bmm2 = apiOptions.CreateInstance().uploadExamImage(eipmList);//传图像List
//if (bmm2.code == 200)
// dataOutPutShow("图像提交成功:" + jsonStr, null);
//else
// dataOutPutShow("图像提交失败:" + jsonStr, null);
}
if (bmm1.code == 200)
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "MA-4210")//华晟源尿常规型号H-II
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] resulteArray = deviceDataStr.Split('\n');
for (int i = 0; i < resulteArray.Length; i += 17)
{
//这里需要判断一下数据是否超过了 当前数据的长度
ermList.Clear();
if (i + 17 > resulteArray.Length)
break;
string[] spArray = resulteArray[i + 1].Trim().Split(' ');
string sampleNo1 = spArray[0].Replace("No.", "").TrimStart('0');
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
examResultMode erm = new examResultMode();
erm.machineCode = MachineCode;
erm.machineID = MachineID;
erm.sampleNo = sampleNo1;
erm.testDate = testDate1;
erm.chanelNo = "GLU";//项目代号
erm.itemValue = resulteArray[i + 4].Substring(4, 6).Trim();//项目结果
erm.itemUnit = "cells/uL";
ermList.Add(erm);
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = sampleNo1;
erm1.testDate = testDate1;
erm1.chanelNo = "URO";//项目代号
erm1.itemValue = resulteArray[i + 5].Substring(4, 6).Trim();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
examResultMode erm2 = new examResultMode();
erm2.machineCode = MachineCode;
erm2.machineID = MachineID;
erm2.sampleNo = sampleNo1;
erm2.testDate = testDate1;
erm2.chanelNo = "BIL";//项目代号
erm2.itemValue = resulteArray[i + 6].Substring(4, 6).Trim();//项目结果
erm2.itemUnit = "";
ermList.Add(erm2);
examResultMode erm3 = new examResultMode();
erm3.machineCode = MachineCode;
erm3.machineID = MachineID;
erm3.sampleNo = sampleNo1;
erm3.testDate = testDate1;
erm3.chanelNo = "KET";//项目代号
erm3.itemValue = resulteArray[i + 7].Substring(4, 6).Trim();//项目结果
erm3.itemUnit = "";
ermList.Add(erm3);
examResultMode erm4 = new examResultMode();
erm4.machineCode = MachineCode;
erm4.machineID = MachineID;
erm4.sampleNo = sampleNo1;
erm4.testDate = testDate1;
erm4.chanelNo = "SG";//项目代号
erm4.itemValue = resulteArray[i + 8].Substring(3, 16).Trim();//项目结果
erm4.itemUnit = "";
ermList.Add(erm4);
examResultMode erm5 = new examResultMode();
erm5.machineCode = MachineCode;
erm5.machineID = MachineID;
erm5.sampleNo = sampleNo1;
erm5.testDate = testDate1;
erm5.chanelNo = "BLD";//项目代号
erm5.itemValue = resulteArray[i + 9].Substring(4, 6).Trim();//项目结果
erm5.itemUnit = "";
ermList.Add(erm5);
examResultMode erm6 = new examResultMode();
erm6.machineCode = MachineCode;
erm6.machineID = MachineID;
erm6.sampleNo = sampleNo1;
erm6.testDate = testDate1;
erm6.chanelNo = "PH";//项目代号
erm6.itemValue = resulteArray[i + 10].Substring(3, 16).Trim();//项目结果
erm6.itemUnit = "";
ermList.Add(erm6);
examResultMode erm7 = new examResultMode();
erm7.machineCode = MachineCode;
erm7.machineID = MachineID;
erm7.sampleNo = sampleNo1;
erm7.testDate = testDate1;
erm7.chanelNo = "PRO";//项目代号
erm7.itemValue = resulteArray[i + 11].Substring(4, 6).Trim();//项目结果
erm7.itemUnit = "";
ermList.Add(erm7);
examResultMode erm8 = new examResultMode();
erm8.machineCode = MachineCode;
erm8.machineID = MachineID;
erm8.sampleNo = sampleNo1;
erm8.testDate = testDate1;
erm8.chanelNo = "NIT";//项目代号
erm8.itemValue = resulteArray[i + 12].Substring(4, 6).Trim();//项目结果
erm8.itemUnit = "";
ermList.Add(erm8);
examResultMode erm9 = new examResultMode();
erm9.machineCode = MachineCode;
erm9.machineID = MachineID;
erm9.sampleNo = sampleNo1;
erm9.testDate = testDate1;
erm9.chanelNo = "LEU";//项目代号
erm9.itemValue = resulteArray[i + 13].Substring(4, 6).Trim();//项目结果
erm9.itemUnit = "mmol/L";
ermList.Add(erm9);
examResultMode erm10 = new examResultMode();
erm10.machineCode = MachineCode;
erm10.machineID = MachineID;
erm10.sampleNo = sampleNo1;
erm10.testDate = testDate1;
erm10.chanelNo = "VC";//项目代号
erm10.itemValue = resulteArray[i + 14].Substring(3, 6).Trim();//项目结果
erm10.itemUnit = "mmol/L";
ermList.Add(erm10);
examResultMode erm11 = new examResultMode();
erm11.machineCode = MachineCode;
erm11.machineID = MachineID;
erm11.sampleNo = sampleNo1;
erm11.testDate = testDate1;
erm11.chanelNo = "Color";//项目代号
erm11.itemValue = resulteArray[i + 15].Replace("Color:", "").Trim();//项目结果
erm11.itemUnit = "mmol/L";
ermList.Add(erm11);
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
dataOutPutShow("数据提交失败:" + jsonStr, null);
}
}
if (apiOptions.CurrentDevice == "U120")//尿常规U120
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] resulteArray = deviceDataStr.Split('\n');
// File.WriteAllText("BT-200.TXT", deviceDataStr);
for (int i = 0; i < resulteArray.Length; i += 15)
{
//这里需要判断一下数据是否超过了 当前数据的长度
ermList.Clear();
if (i + 15 > resulteArray.Length)
break;
string[] spArray = resulteArray[2].Trim().Split(' ');
string sampleNo1 = spArray[2].Substring(0, 1).TrimStart('0');
// string sampleNo1 = resulteArray[2].Trim().Split(' ')[1]; .Replace("-", "0").TrimStart('0')
//string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]);
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
examResultMode erm = new examResultMode();
erm.machineCode = MachineCode;
erm.machineID = MachineID;
erm.sampleNo = sampleNo1;
erm.testDate = testDate1;
erm.chanelNo = "LEU";//项目代号
erm.itemValue = resulteArray[i + 3].Substring(4, 15).Trim();//项目结果//项目结果
erm.itemUnit = "";
ermList.Add(erm);
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = sampleNo1;
erm1.testDate = testDate1;
erm1.chanelNo = "NIT";//项目代号
erm1.itemValue = resulteArray[i + 4].Substring(4, 11).Trim();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
examResultMode erm2 = new examResultMode();
erm2.machineCode = MachineCode;
erm2.machineID = MachineID;
erm2.sampleNo = sampleNo1;
erm2.testDate = testDate1;
erm2.chanelNo = "URO";//项目代号
erm2.itemValue = resulteArray[i + 5].Substring(4, 13).Trim();//项目结果
erm2.itemUnit = "";
ermList.Add(erm2);
examResultMode erm3 = new examResultMode();
erm3.machineCode = MachineCode;
erm3.machineID = MachineID;
erm3.sampleNo = sampleNo1;
erm3.testDate = testDate1;
erm3.chanelNo = "PRO";//项目代号
erm3.itemValue = resulteArray[i + 6].Substring(5, 15).Trim();//项目结果
erm3.itemUnit = "";
ermList.Add(erm3);
examResultMode erm4 = new examResultMode();
erm4.machineCode = MachineCode;
erm4.machineID = MachineID;
erm4.sampleNo = sampleNo1;
erm4.testDate = testDate1;
erm4.chanelNo = "pH";//项目代号
erm4.itemValue = resulteArray[i + 7].Substring(4, 12).Trim();//项目结果
erm4.itemUnit = "";
ermList.Add(erm4);
examResultMode erm5 = new examResultMode();
erm5.machineCode = MachineCode;
erm5.machineID = MachineID;
erm5.sampleNo = sampleNo1;
erm5.testDate = testDate1;
erm5.chanelNo = "BLO";//项目代号
erm5.itemValue = resulteArray[i + 8].Substring(4, 15).Trim();//项目结果
erm5.itemUnit = "";
ermList.Add(erm5);
examResultMode erm6 = new examResultMode();
erm6.machineCode = MachineCode;
erm6.machineID = MachineID;
erm6.sampleNo = sampleNo1;
erm6.testDate = testDate1;
erm6.chanelNo = "SG";//项目代号
erm6.itemValue = resulteArray[i + 9].Substring(4, 13).Trim();//项目结果
erm6.itemUnit = "";
ermList.Add(erm6);
examResultMode erm10 = new examResultMode();
erm10.machineCode = MachineCode;
erm10.machineID = MachineID;
erm10.sampleNo = sampleNo1;
erm10.testDate = testDate1;
erm10.chanelNo = "KET";//项目代号
erm10.itemValue = resulteArray[i + 10].Substring(4, 15).Trim();//项目结果
erm10.itemUnit = "";
ermList.Add(erm10);
examResultMode erm7 = new examResultMode();
erm7.machineCode = MachineCode;
erm7.machineID = MachineID;
erm7.sampleNo = sampleNo1;
erm7.testDate = testDate1;
erm7.chanelNo = "BIL";//项目代号
erm7.itemValue = resulteArray[i + 11].Substring(4, 13).Trim();//项目结果
erm7.itemUnit = "";
ermList.Add(erm7);
examResultMode erm8 = new examResultMode();
erm8.machineCode = MachineCode;
erm8.machineID = MachineID;
erm8.sampleNo = sampleNo1;
erm8.testDate = testDate1;
erm8.chanelNo = "GLU";//项目代号
erm8.itemValue = resulteArray[i + 12].Substring(4, 14).Trim();//项目结果
erm8.itemUnit = "";
ermList.Add(erm8);
examResultMode erm9 = new examResultMode();
erm9.machineCode = MachineCode;
erm9.machineID = MachineID;
erm9.sampleNo = sampleNo1;
erm9.testDate = testDate1;
erm9.chanelNo = "ASC";//项目代号
erm9.itemValue = resulteArray[i + 13].Substring(4, 12).Trim();//项目结果
erm9.itemUnit = "";
ermList.Add(erm9);
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
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-1; 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);
}
if (apiOptions.CurrentDevice == "BC-5120")//BC-5120
{
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", "BAS#", "BAS%", "NEU#", "NEU%", "EOS#", "EOS%", "LYM#", "LYM%", "MON#", "MON%", "RBC", "HGB", "MCV", "MCH", "MCHC", "RDW-CV", "RDW-SD", "HCT", "PLT", "MPV", "PDW", "PCT", "PLCC", "PLCR" };
string[] itemArray_2 = new string[] { "PCT", "PLCC", "PLCR" };
for (int i = 0; i < itemArray.Length; i++)
{
string itemStr = string.Empty;
if (itemArray_2.Contains(itemArray[i]))
itemStr = itemArray[i] + "^99MRC||";
else
itemStr = itemArray[i] + "^LN||";
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 = jiexiVal(deviceDataStr.IndexOf(itemStr), itemStr, deviceDataStr).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);
}
if (apiOptions.CurrentDevice == "URIT-8460")//URIT-8460
{
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[] { "A/G", "ALT/AST", "GLB", "ALT", "AST", "TP", "ALB", "TB", "UREA", "Cr", "UA", "TG", "CHOL", "HDL_C", "LDL_C" };
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 = jiexiVal(deviceDataStr.IndexOf(itemStr), itemStr, deviceDataStr).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);
}
if (apiOptions.CurrentDevice == "BS-460")//生化BS-460
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[18] { "Glu-G", "T-Bil-V", "D-Bil-V", "ALT", "AST", "ALP", "γ-GT", "TG", "LDL-C", "HDL-C", "TC", "CREA-S", "UREA", "ALB_II", "TP_II", "AST/ALT", "IBIL-V", "UA" };//
string[] itemArrayC = new string[18] { "葡萄糖", "总胆红素", "直接胆红素", "丙氨酸氨基转移酶", "天门冬氨酸氨基转移酶", "碱性磷酸酶", "γ-谷氨酰转移酶", "甘油三酯", "低密度脂蛋白胆固醇", "高密度脂蛋白胆固醇", "总胆固醇", "肌酐(肌氨酸氧化酶法)", "尿素", "白蛋白", "总蛋白(双缩脲法)", "AST/ALT", "IBIL-V", "尿酸" };//
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
//string[] valArray = deviceDataStr.Split(',');
string[] valArray = deviceDataStr.Split('|');
string sampleNo1 = valArray[54];//样本号
for (int i = 0; i < itemArrayC.Length; i++)
{
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];//项目代号
// MessageBox.Show(deviceDataStr+"\r\n\r\n :"+ggg[5]);
string itemStr = itemArrayC[i] + "|";
int index1 = deviceDataStr.IndexOf(itemStr);
string valueS = jiexiVal(index1, itemStr, deviceDataStr);
double roundedValue = Math.Round(double.Parse(valueS), 2);
erm1.itemValue = roundedValue.ToString();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
dataOutPutShow("数据提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "BS-460-1")//生化BS-460
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[14] { "Glu-G", "T-Bil-V", "D-Bil-V", "ALT", "AST", "TG", "LDL-C", "HDL-C", "TC", "CREA-S", "UREA", "ALB_II", "AST/ALT", "IBIL-V" };//
string[] itemArrayC = new string[14] { "葡萄糖(葡萄糖氧化酶法)", "总胆红素(钒酸盐氧化法)", "直接胆红素(钒酸盐氧化法)", "丙氨酸氨基转移酶", "天门冬氨酸氨基转移酶", "甘油三酯", "低密度脂蛋白胆固醇", "高密度脂蛋白胆固醇", "总胆固醇", "肌酐(肌氨酸氧化酶法)", "尿素", "白蛋白", "AST/ALT", "IBIL-V" };//
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
//string[] valArray = deviceDataStr.Split(',');
string[] valArray = deviceDataStr.Split('|');
string sampleNo1 = valArray[54];//样本号
for (int i = 0; i < itemArrayC.Length; i++)
{
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];//项目代号
// MessageBox.Show(deviceDataStr+"\r\n\r\n :"+ggg[5]);
string itemStr = itemArrayC[i] + "|";
int index1 = deviceDataStr.IndexOf(itemStr);
string valueS = jiexiVal(index1, itemStr, deviceDataStr);
double roundedValue = Math.Round(double.Parse(valueS), 2);
erm1.itemValue = roundedValue.ToString();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
dataOutPutShow("数据提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "BS-460-2")//生化BS-460
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[16] { "Glu-G", "T-Bil-V", "D-Bil-V", "ALT", "AST", "ALP", "γ-GT", "TG", "LDL-C", "HDL-C", "TC", "CREA-S", "UREA", "AST/ALT", "IBIL-V", "UA" };//
string[] itemArrayC = new string[16] { "葡萄糖", "总胆红素", "直接胆红素", "丙氨酸氨基转移酶", "天门冬氨酸氨基转移酶", "碱性磷酸酶", "γ-谷氨酰转移酶", "甘油三酯", "低密度脂蛋白胆固醇", "高密度脂蛋白胆固醇", "总胆固醇", "肌酐", "尿素", "AST/ALT", "IBIL-V", "尿酸" };//
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
//string[] valArray = deviceDataStr.Split(',');
string[] valArray = deviceDataStr.Split('|');
string sampleNo1 = valArray[54];//样本号
for (int i = 0; i < itemArrayC.Length; i++)
{
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];//项目代号
// MessageBox.Show(deviceDataStr+"\r\n\r\n :"+ggg[5]);
string itemStr = itemArrayC[i] + "|";
int index1 = deviceDataStr.IndexOf(itemStr);
string valueS = jiexiVal(index1, itemStr, deviceDataStr);
double roundedValue = Math.Round(double.Parse(valueS), 2);
erm1.itemValue = roundedValue.ToString();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
dataOutPutShow("数据提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "BA600-1")//尿常规 GeniusBA600
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] resulteArray = deviceDataStr.Split('\n');
// File.WriteAllText("BT-200.TXT", deviceDataStr);
for (int i = 0; i < resulteArray.Length; i += 16)
{
//这里需要判断一下数据是否超过了 当前数据的长度
ermList.Clear();
if (i + 16 > resulteArray.Length)
break;
//string[] spArray = resulteArray[i + 1].Trim().Split(' ');
string sampleNo1 = resulteArray[2].Trim().Replace("0", " ").Trim();
//string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]);
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
examResultMode erm = new examResultMode();
erm.machineCode = MachineCode;
erm.machineID = MachineID;
erm.sampleNo = sampleNo1;
erm.testDate = testDate1;
erm.chanelNo = "VC";//项目代号
erm.itemValue = resulteArray[i + 4].Replace("VC", "").Trim().Split(' ')[0].Trim();//项目结果
erm.itemUnit = "";
ermList.Add(erm);
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = sampleNo1;
erm1.testDate = testDate1;
erm1.chanelNo = "URO";//项目代号
erm1.itemValue = resulteArray[i + 5].Replace("URO", "").Trim().Split(' ')[0].Trim();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
examResultMode erm2 = new examResultMode();
erm2.machineCode = MachineCode;
erm2.machineID = MachineID;
erm2.sampleNo = sampleNo1;
erm2.testDate = testDate1;
erm2.chanelNo = "BIL";//项目代号
erm2.itemValue = resulteArray[i + 6].Replace("BIL", "").Trim().Trim().Split(' ')[0].Trim();//项目结果
erm2.itemUnit = "";
ermList.Add(erm2);
examResultMode erm3 = new examResultMode();
erm3.machineCode = MachineCode;
erm3.machineID = MachineID;
erm3.sampleNo = sampleNo1;
erm3.testDate = testDate1;
erm3.chanelNo = "KET";//项目代号
erm3.itemValue = resulteArray[i + 7].Replace("KET", "").Trim().Split(' ')[0].Trim();//项目结果
erm3.itemUnit = "";
ermList.Add(erm3);
examResultMode erm4 = new examResultMode();
erm4.machineCode = MachineCode;
erm4.machineID = MachineID;
erm4.sampleNo = sampleNo1;
erm4.testDate = testDate1;
erm4.chanelNo = "BLD";//项目代号
erm4.itemValue = resulteArray[i + 8].Replace("BLD", "").Trim().Split(' ')[0].Trim();//项目结果
erm4.itemUnit = "Cell/uL";
ermList.Add(erm4);
examResultMode erm5 = new examResultMode();
erm5.machineCode = MachineCode;
erm5.machineID = MachineID;
erm5.sampleNo = sampleNo1;
erm5.testDate = testDate1;
erm5.chanelNo = "PRO";//项目代号
erm5.itemValue = resulteArray[i + 9].Replace("PRO", "").Trim().Split(' ')[0].Trim();//项目结果
erm5.itemUnit = "";
ermList.Add(erm5);
examResultMode erm6 = new examResultMode();
erm6.machineCode = MachineCode;
erm6.machineID = MachineID;
erm6.sampleNo = sampleNo1;
erm6.testDate = testDate1;
erm6.chanelNo = "NIT";//项目代号
erm6.itemValue = resulteArray[i + 10].Replace("NIT", "").Trim().Split(' ')[0].Trim();//项目结果
erm6.itemUnit = "";
ermList.Add(erm6);
examResultMode erm10 = new examResultMode();
erm10.machineCode = MachineCode;
erm10.machineID = MachineID;
erm10.sampleNo = sampleNo1;
erm10.testDate = testDate1;
erm10.chanelNo = "LEU";//项目代号
erm10.itemValue = resulteArray[i + 11].Replace("LEU", "").Trim().Split(' ')[0].Trim();//项目结果
erm10.itemUnit = "";
ermList.Add(erm10);
examResultMode erm7 = new examResultMode();
erm7.machineCode = MachineCode;
erm7.machineID = MachineID;
erm7.sampleNo = sampleNo1;
erm7.testDate = testDate1;
erm7.chanelNo = "GLU";//项目代号
erm7.itemValue = resulteArray[i + 12].Replace("GLU", "").Trim().Split(' ')[0].Trim();//项目结果
erm7.itemUnit = "";
ermList.Add(erm7);
examResultMode erm8 = new examResultMode();
erm8.machineCode = MachineCode;
erm8.machineID = MachineID;
erm8.sampleNo = sampleNo1;
erm8.testDate = testDate1;
erm8.chanelNo = "SG";//项目代号
erm8.itemValue = resulteArray[i + 13].Replace("SG", "").Trim().Split(' ')[0].Trim();//项目结果
erm8.itemUnit = "";
ermList.Add(erm8);
examResultMode erm9 = new examResultMode();
erm9.machineCode = MachineCode;
erm9.machineID = MachineID;
erm9.sampleNo = sampleNo1;
erm9.testDate = testDate1;
erm9.chanelNo = "PH";//项目代号
erm9.itemValue = resulteArray[i + 14].Replace("PH", "").Trim().Split(' ')[0].Trim();//项目结果
erm9.itemUnit = "";
ermList.Add(erm9);
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
dataOutPutShow("数据提交失败:" + jsonStr, null);
}
}
if (apiOptions.CurrentDevice == "Z3 CRP")//Z3 血常规
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] itemArray = new string[21] { "WBC", "LYM#", "MID#", "GRAN#", "LYM%", "MID%", "GRAN%", "RBC", "HGB", "HCT", "MCV", "MCH", "MCHC", "RDW-CV", "RDW-SD", "PLT", "MPV", "PDW", "PCT", "P-LCC", "P-LCR" };
//string[] resulteArray = deviceDataStr.Split('\n');
deviceDataStr = deviceDataStr.Replace("\r", "").Replace("\n", "");
string sampleNo1 = string.Empty;//样本号
for (int i = 0; i < itemArray.Length; i++)
{
string itemStr = string.Empty;
if (itemArray[i] == "*LIC#" || itemArray[i] == "*LIC%" || itemArray[i] == "PCT")
itemStr = itemArray[i] + "^99MRC||";
else
itemStr = itemArray[i] + "^LN||";
string val1 = jiexiVal(deviceDataStr.IndexOf("OBR|1||"), "OBR|1||", deviceDataStr).ToString();
sampleNo1 = val1;
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 = jiexiVal(deviceDataStr.IndexOf(itemStr), itemStr, deviceDataStr).ToString();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
}
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
dataOutPutShow("数据提交成功:" + jsonStr, null);
else
dataOutPutShow("数据提交失败:" + jsonStr, null);
}
if (apiOptions.CurrentDevice == "URIT-500B")//URIT-500B
{
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
List<examResultMode> ermList = new List<examResultMode>();
string[] resulteArray = deviceDataStr.Split('\n');
// File.WriteAllText("BT-200.TXT", deviceDataStr);
for (int i = 0; i < resulteArray.Length; i += 15)
{
//这里需要判断一下数据是否超过了当前数据的长度
ermList.Clear();
if (i + 15 > resulteArray.Length)
break;
string[] spArray = resulteArray[1].Trim().Split(' ');
string sampleNo1 = spArray[0].Replace("NO.","").Replace("0", " ").Trim();
// string sampleNo1 = spArray.Length > 2 ? spArray[2].Substring(0, 1).TrimStart('0') : "0";
// string sampleNo1 = resulteArray[2].Trim().Split(' ')[1]; .Replace("-", "0").TrimStart('0')
//string testDate1 = jiexiDate(resulteArray[i + 1], resulteArray[i + 2]);
string testDate1 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
examResultMode erm = new examResultMode();
erm.machineCode = MachineCode;
erm.machineID = MachineID;
erm.sampleNo = sampleNo1;
erm.testDate = testDate1;
erm.chanelNo = "WBC";//项目代号
erm.itemValue = resulteArray[i + 4].Replace("WBC", "").Replace("CELL/uL", "").Trim().Split(' ')[0].Trim(); //项目结果
erm.itemUnit = "";
ermList.Add(erm);
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = sampleNo1;
erm1.testDate = testDate1;
erm1.chanelNo = "KET";//项目代号
erm1.itemValue = resulteArray[i + 5].Replace("KET", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim();
erm1.itemUnit = "";
ermList.Add(erm1);
examResultMode erm2 = new examResultMode();
erm2.machineCode = MachineCode;
erm2.machineID = MachineID;
erm2.sampleNo = sampleNo1;
erm2.testDate = testDate1;
erm2.chanelNo = "NIT";//项目代号
erm2.itemValue = resulteArray[i + 6].Replace("NIT", "").Replace("Neg", "").Trim().Split(' ')[0].Trim();
erm2.itemUnit = "";
ermList.Add(erm2);
examResultMode erm3 = new examResultMode();
erm3.machineCode = MachineCode;
erm3.machineID = MachineID;
erm3.sampleNo = sampleNo1;
erm3.testDate = testDate1;
erm3.chanelNo = "URO";//项目代号
erm3.itemValue = resulteArray[i + 7].Replace("*URO", "").Replace("umol/L", "").Trim().Split(' ')[0].Trim();
erm3.itemUnit = "";
ermList.Add(erm3);
examResultMode erm4 = new examResultMode();
erm4.machineCode = MachineCode;
erm4.machineID = MachineID;
erm4.sampleNo = sampleNo1;
erm4.testDate = testDate1;
erm4.chanelNo = "BIL";//项目代号
erm4.itemValue = resulteArray[i + 8].Replace("BIL", "").Replace("umol/L", "").Trim().Split(' ')[0].Trim();
erm4.itemUnit = "";
ermList.Add(erm4);
examResultMode erm5 = new examResultMode();
erm5.machineCode = MachineCode;
erm5.machineID = MachineID;
erm5.sampleNo = sampleNo1;
erm5.testDate = testDate1;
erm5.chanelNo = "PRO";//项目代号
erm5.itemValue = resulteArray[i + 9].Replace("PRO", "").Replace("g/L", "").Trim().Split(' ')[0].Trim();
erm5.itemUnit = "";
ermList.Add(erm5);
examResultMode erm6 = new examResultMode();
erm6.machineCode = MachineCode;
erm6.machineID = MachineID;
erm6.sampleNo = sampleNo1;
erm6.testDate = testDate1;
erm6.chanelNo = "GLU";//项目代号
erm6.itemValue = resulteArray[i + 10].Replace("GLU", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim();
erm6.itemUnit = "";
ermList.Add(erm6);
examResultMode erm10 = new examResultMode();
erm10.machineCode = MachineCode;
erm10.machineID = MachineID;
erm10.sampleNo = sampleNo1;
erm10.testDate = testDate1;
erm10.chanelNo = "SG";//项目代号
erm10.itemValue = resulteArray[i + 11].Replace("SG", "").Trim().Split(' ')[0].Trim();
erm10.itemUnit = "";
ermList.Add(erm10);
examResultMode erm7 = new examResultMode();
erm7.machineCode = MachineCode;
erm7.machineID = MachineID;
erm7.sampleNo = sampleNo1;
erm7.testDate = testDate1;
erm7.chanelNo = "BLD";//项目代号
erm7.itemValue = resulteArray[i + 12].Replace("BLD", "").Replace("CELL/uL", "").Trim().Split(' ')[0].Trim();
erm7.itemUnit = "";
ermList.Add(erm7);
examResultMode erm8 = new examResultMode();
erm8.machineCode = MachineCode;
erm8.machineID = MachineID;
erm8.sampleNo = sampleNo1;
erm8.testDate = testDate1;
erm8.chanelNo = "pH";//项目代号
erm8.itemValue = resulteArray[i + 13].Replace("pH", "").Trim().Split(' ')[0].Trim();
erm8.itemUnit = "";
ermList.Add(erm8);
examResultMode erm9 = new examResultMode();
erm9.machineCode = MachineCode;
erm9.machineID = MachineID;
erm9.sampleNo = sampleNo1;
erm9.testDate = testDate1;
erm9.chanelNo = "Vc";//项目代号
erm9.itemValue = resulteArray[i + 14].Replace("Vc", "").Replace("mmol/L", "").Trim().Split(' ')[0].Trim();
erm9.itemUnit = "";
ermList.Add(erm9);
//将结果提交到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;
}
/// <summary>
/// 从结果字符串中截取 结果
/// </summary>
/// <param name="itemStr"></param>
/// <param name="deviceDataStr"></param>
/// <returns></returns>
string jiexiItemValue(string itemStr, string deviceDataStr)
{
string ItemValueStr = "";
try
{
string Str1 = deviceDataStr.Substring(deviceDataStr.IndexOf(itemStr) + itemStr.Length, 30);
int firstIndex = Str1.IndexOf('|');
ItemValueStr = Str1.Substring(0, firstIndex);
}
catch (Exception ex) { MessageBox.Show(itemStr + "," + deviceDataStr); }
return ItemValueStr;
}
/// <summary>
/// 从结果字符串中截取 结果
/// </summary>
/// <param name="itemStr"></param>
/// <param name="deviceDataStr"></param>
/// <returns></returns>
string jiexiItemValue11(string itemStr, string deviceDataStr)
{
string ItemValueStr = "";
try
{
string Str1 = deviceDataStr.Substring(deviceDataStr.IndexOf(itemStr) + itemStr.Length, 6);
int firstIndex = Str1.IndexOf('|');
ItemValueStr = Str1.Substring(0, firstIndex);
}
catch (Exception ex) { /*MessageBox.Show(itemStr + "," + deviceDataStr);*/ }
return ItemValueStr;
}
/// <summary>
/// 从结果字符串中截取 结果
/// </summary>
/// <param name="itemStr"></param>
/// <param name="deviceDataStr"></param>
/// <returns></returns>
string jiexiItemValueLast(string itemStr, string deviceDataStr)
{
string ItemValueStr = "";
string Str1 = deviceDataStr.Substring(deviceDataStr.LastIndexOf(itemStr) + itemStr.Length + 1, 10);
int firstIndex = Str1.IndexOf('|');
ItemValueStr = Str1.Substring(0, firstIndex);
return ItemValueStr;
}
/// <summary>
/// 从字符串中找到 样本编号
/// </summary>
/// <param name="itemStr"></param>
/// <param name="deviceDataStr"></param>
/// <returns></returns>
int jiexisampleNo(int index1, string dataStr)
{
int val1 = -1;
for (int i = 1; i < 100; i++)
{
try
{
string str1 = dataStr.Substring(index1 - i, i);
val1 = int.Parse(str1);
}
catch { break; }
}
return val1;
}
/// <summary>
/// 从字符串中找到 样本编号
/// </summary>
/// <param name="itemStr"></param>
/// <param name="deviceDataStr"></param>
/// <returns></returns>
int jiexisampleNo8(int index1, string dataStr)
{
int val1 = -1;
for (int i = 1; i < 100; i++)
{
try
{
string str1 = dataStr.Substring(index1, i);
val1 = int.Parse(str1);
}
catch { break; }
}
return val1;
}
/// <summary>
/// 从字符串中 解析出数字
/// </summary>
/// <param name="itemStr"></param>
/// <param name="deviceDataStr"></param>
/// <returns></returns>
string jiexiVal(int index1, string keyStr, string dataStr)
{
string val1 = "";
for (int i = 1; i < 100; i++)
{
try
{
string str1 = dataStr.Substring(index1 + keyStr.Length, i);
double valx = double.Parse(str1);
val1 = str1;
}
catch { break; }
}
return val1;
}
/// <summary>
/// 从字符串中 解析出 jiexiBase64 图像
/// </summary>
/// <param name="itemStr"></param>
/// <param name="deviceDataStr"></param>
/// <returns></returns>
List<string> jiexiBase64(int[] array1, string keyStr, string dataStr)
{
List<string> imageBase64List = new List<string>();
for (int i = 0; i < array1.Length; i++)
{
for (int b = array1[i]; b < dataStr.Length; b++)
{
string str1 = dataStr.Substring(b, keyStr.Length);
if (str1 == keyStr)
{
string ImgBase64Str = dataStr.Substring(array1[i] + 8, b - array1[i] - 8);
imageBase64List.Add(ImgBase64Str);
break;
}
}
}
return imageBase64List;
}
static string jiexiDate(string dateStr, string TimeStr)
{
string[] spArray = dateStr.Trim().Split(' ');
string[] varArray = spArray[2].Trim().Trim('\r').Split('-');
return varArray[2] + "-" + varArray[0] + "-" + varArray[1] + " " + TimeStr.Trim().Trim('\r');
}
Socket listener;
//TcpListener listener = null;
/// <summary>
/// 开启数据接收
/// </summary>
public void startDataReceive()
{
if (apiOptions.CurrentDevice == "HSYH-II")//华晟源尿常规型号H-II
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "BT-200")//盛世东唐BT-200尿常规
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "URIT-5181")//优利特血常规5181
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "URIT-1500")//优利特尿常规URIT-1500
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "DF55")//帝迈血常规DF55
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "TCPTEST")//TCP接收测试数据
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "CS-480")//迪瑞全自动生化分析仪 CS-480
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "SL300C")//Senlo生化SL300C
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "BK600")//Senlo生化SL300C
{
_AccessResult.Change(10000, 10000);//开始循环从access数据库中读取数据10秒频率
}
if (apiOptions.CurrentDevice == "BA600")//尿常规 GeniusBA600
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "BA600-1")//尿常规 GeniusBA600
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "BA600MY")//煤窑中心卫生院的尿常规 GeniusBA600
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "MC-600")//血常规MAC-600
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "CS-1300B")//迪瑞全自动生化分析仪 CS-1300B
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "URIT-5180")//优利特血常规5180
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "BS-430")//生化BS-430
{
// 设置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 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
listener.Bind(new IPEndPoint(IPAddress.Any, int.Parse(tcp_port)));
listener.Listen(10000);
}
_tcpResult.Change(0, 10);//开始tcp数据接收10毫秒频率
}
if (apiOptions.CurrentDevice == "DF55-1")//帝迈血常规DF55
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "URIT-1600")//优利特1600
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "HTSH-4000")//HTSH-4000 全自动生化分析仪
{
_AccessResult.Change(10000, 10000);//开始循环从access数据库中读取数据10秒频率
}
if (apiOptions.CurrentDevice == "DH56")//帝迈血常规DH56
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "URIT-5380")//优利特血常规URIT-5380
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "U500")//尿常规U500
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "BC-5130")//BC-5130 这个设备是需要主动TCP连接 血常规仪器
{
// 设置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);
//}
clientSocket = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
clientSocket.Connect(ipAddress, int.Parse(tcp_port));
_tcpResult.Change(0, 10);//开始tcp数据接收10毫秒频率
}
if (apiOptions.CurrentDevice == "SD1")//斯玛特SD1
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "DF55-2")//帝迈血常规DF55
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "U120")//尿常规U120
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
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毫秒频率
}
if (apiOptions.CurrentDevice == "BC-5120")//BC-5120
{
// 设置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
clientSocket = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
clientSocket.Connect(ipAddress, int.Parse(tcp_port));
_tcpResult.Change(0, 10);//开始tcp数据接收10毫秒频率
}
if (apiOptions.CurrentDevice == "URIT-8460")//URIT-8460
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "hhh5")//BC-5130
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "MA-4210")//MA-4210
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "BS-460")//迈瑞生化BS-430
{
// 设置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 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
listener.Bind(new IPEndPoint(IPAddress.Any, int.Parse(tcp_port)));
listener.Listen(10000);
}
_tcpResult.Change(0, 10);//开始tcp数据接收10毫秒频率
}
if (apiOptions.CurrentDevice == "BS-460-1")//迈瑞生化BS-460
{
// 设置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 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
listener.Bind(new IPEndPoint(IPAddress.Any, int.Parse(tcp_port)));
listener.Listen(10000);
}
_tcpResult.Change(0, 10);//开始tcp数据接收10毫秒频率
}
if (apiOptions.CurrentDevice == "BS-460-2")//迈瑞生化BS-460
{
// 设置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 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
listener.Bind(new IPEndPoint(IPAddress.Any, int.Parse(tcp_port)));
listener.Listen(10000);
}
_tcpResult.Change(0, 10);//开始tcp数据接收10毫秒频率
}
if (apiOptions.CurrentDevice == "Z3 CRP")//血常规 Z3
{
// 设置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毫秒频率
}
if (apiOptions.CurrentDevice == "URIT-500B")//URIT-500B
{
SerialPortOption.CreateInstance().IniserialPortOption();//初始化串口
SerialPortOption.CreateInstance().dataOutPutShow += new EventHandler(onReData);
SerialPortOption.CreateInstance().StartDataReadThread();//开启数据接收
}
}
/// <summary>
/// 将接收到的数据进行处理并显示在软件界面上
/// </summary>
/// <param name="o"></param>
/// <param name="e"></param>
void onReData(object o, EventArgs e)
{
if (o.ToString().Length > 2)
{
tempData += o.ToString();//把串口数据积累起来
//MessageBox.Show(o.ToString().Length.ToString());
dataOutPutShow(o, null);//把数据显示到屏幕上
}
if (apiOptions.CurrentDevice == "HSYH-II")//华晟源尿常规型号H-II
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "BT-200")//盛世东唐BT-200尿常规
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "URIT-5181")//优利特血常规5181
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "DF55")//帝迈血常规DF55
{
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "TCPTEST")//tcp数据接收测试
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "CS-480")
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "SL300C")//Senlo生化SL300C
_tResult.Change(10000, 10000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "BA600")//尿常规 GeniusBA600
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "BA600-1")//尿常规 GeniusBA600
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "MC-600")//血常规MAC-600
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "CS-1300B")//迪瑞全自动生化分析仪 CS-1300B
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "BA600MY")//煤窑中心卫生院的尿常规 GeniusBA600
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "URIT-1500")//优利特尿常规URIT-1500
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "URIT-5180")//优利特血常规5180
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "BS-430")//生化BS-430
{
//File.WriteAllText("deviceDataLog.txt", deviceDataStr, Encoding.GetEncoding("GB18030"));
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
// _tResult.Change(10000, 10000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "DF55-1")//帝迈血常规DF55
{
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
//_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "URIT-1600")//优利特1600
{
if (tempData.Contains("OBX|12|ST|"))//OBX|12|ST| 为结束符 说明字符串完整了
{
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
}
//_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "DH56")//帝迈血常规DH56
{
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "URIT-5380")//优利特血常规URIT-5380
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "U500")//尿常规U500
{
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "BC-5130")//BC-5130
{
// _tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (tempData.Contains("OBX|30|") || tempData.Contains("OBX|29|"))//OBX|12|ST| 为结束符 说明字符串完整了
{
// MessageBox.Show(tempData);
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
}
}
if (apiOptions.CurrentDevice == "SD1")//斯玛特SD1
{
if (tempData.Contains("OBX|22|"))//OBX|22| 为结束符 说明字符串完整了
{
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
}
//_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "DF55-2")//帝迈血常规DF55
{
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "hhh5")//BC-5130
{
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "MA-4210")//MA-4210
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
if (apiOptions.CurrentDevice == "U120")//尿常规U120
{
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "BS-330E")//BS-330E
{
if (tempData.Split('').Length>=12&& (tempData.Contains("LDL-C")&& Regex.Matches(tempData, "LDL-C").Count>1))
{
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
}
}
if (apiOptions.CurrentDevice == "BC-5120")//BC-5120
{
if (tempData.Contains(@"OBR|1||Background|"))
{
tempData = string.Empty;
}
else
{
string tempData_temp = tempData;
tempData = string.Empty;
deviceAnalysisOption(tempData_temp);
}
}
if (apiOptions.CurrentDevice == "URIT-8460")//URIT-8460
{
string tempData_temp = tempData;
tempData = string.Empty;
if (!string.IsNullOrWhiteSpace(tempData_temp))
deviceAnalysisOption(tempData_temp);
}
if (apiOptions.CurrentDevice == "BS-460")//生化BS-460
{
//File.WriteAllText("deviceDataLog.txt", deviceDataStr, Encoding.GetEncoding("GB18030"));
if (tempData.Contains("OBX|17|"))//OBX|22| 为结束符 说明字符串完整了 OBX|17|
{
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
}
// _tResult.Change(10000, 10000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "BS-460-1")//生化BS-460
{
//File.WriteAllText("deviceDataLog.txt", deviceDataStr, Encoding.GetEncoding("GB18030"));
//if (tempData.Contains("OBX|14|"))//OBX|22| 为结束符 说明字符串完整了
//{
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
// }
// _tResult.Change(10000, 10000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "BS-460-2")//生化BS-460
{
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
}
if (apiOptions.CurrentDevice == "Z3 CRP")//血常规Z3
{
if (tempData.Contains("OBX|26|"))//OBX|25| 为结束符 说明字符串完整了
{
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
}
//_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
}
if (apiOptions.CurrentDevice == "URIT-500B")//优利特尿常规URIT-500B
_tResult.Change(5000, 5000);// 数据处理延迟5秒开始 5秒计时
}
/// <summary>
/// 定时器 定时来处理接收到的累计临时数据
/// </summary>
void TResultTick()
{
_tResult.Change(-1, 5000);//暂停计时
deviceAnalysisOption(tempData);
tempData = string.Empty;//执行完以后 将临时积累数据清空 以便接收下一个样本数据
}
Socket clientSocket;
int msgindex = 1;
/// <summary>
/// 定时器 定时来处理TCP接收到的累计临时数据
/// </summary>
void tcpResultTick()
{
byte[] data = new byte[40048];
//如果设备是BC-5130这类的则表示这个设备在启动时就已经主动连上了。BC-5130设备这里就无需初始化连接直接跳过
List<string> ConnectDevices = new List<string>(new string[] { "BC-5130", "BC-5120" });
if (!ConnectDevices.Contains(apiOptions.CurrentDevice))
{
if (clientSocket == null)
clientSocket = listener.Accept(); //一旦接受连接,创建一个客户端
}
int recv = clientSocket.Receive(data);
if (recv > 0)
{
byte[] data1 = new byte[recv];
for (int i = 0; i < recv; i++)
data1[i] = data[i];
string encodingStr = ConfigurationManager.AppSettings[apiOptions.CurrentDevice].Split(',')[5];
string stringData = Encoding.GetEncoding(encodingStr).GetString(data1);
if (apiOptions.CurrentDevice == "SL300C")//Senlo生化SL300C 接收一条数据就需要应答一次
{
string[] msgArray = stringData.Split('\n');
for (int i = 0; i < msgArray.Length; i++)
{
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 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>";
byte[] sendBytes = Encoding.Unicode.GetBytes(responseMsg);
clientSocket.Send(sendBytes);
onReData("应答消息:" + responseMsg, null);//数据处理 并将数据显示在软件界面上
}
}
}
onReData(stringData, null);//数据处理 并将数据显示在软件界面上
}
}
void accessResultTick()
{
if (apiOptions.CurrentDevice == "BK600")
{
_AccessResult.Change(-1, 10000);//开始循环从access数据库中读取数据10秒频率
if (!File.Exists("uploadedRecord.txt"))
File.Create("uploadedRecord.txt");
string accessDbPath = ConfigurationManager.AppSettings[apiOptions.CurrentDevice].Split(',')[3];
if (!accessDbPath.Contains(".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";
DataTable dt_2 = new DataTable();
try
{
dt_2 = accessOptions.CreateInstance(accessDbPath).ExcuteSql(sql);
}
catch { dt_2 = null; }
if (dt_2 == null)
return;
List<examResultMode> ermList = new List<examResultMode>();
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
string uploadedRecordStr = File.ReadAllText("uploadedRecord.txt");
for (int i = 0; i < dt_2.Rows.Count; i++)
{
if (!uploadedRecordStr.Contains(dt_2.Rows[i]["sampleProgramID"].ToString()))
{
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = dt_2.Rows[i]["SampleNo"].ToString();
erm1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
erm1.chanelNo = dt_2.Rows[i]["ItemCode"].ToString();//项目代号
erm1.itemValue = dt_2.Rows[i]["ItemValue"].ToString();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
uploadedRecordStr += (dt_2.Rows[i]["sampleProgramID"].ToString() + ",");
}
}
if (ermList.Count > 0)
{
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
{
//for (int i = 0; i < dt_2.Rows.Count; i++)
//{
// string sql1 = "update sampleProgram set stateS=1 where sampleProgramID='" + dt_2.Rows[i]["sampleProgramID"].ToString() + "'";
// bool flag1 = accessOptions.CreateInstance(accessDbPath).SqlUpdate(sql1);
//}
File.WriteAllText("uploadedRecord.txt", uploadedRecordStr);//记录写入本地
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
}
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
_AccessResult.Change(10000, 10000);//开始循环从access数据库中读取数据10秒频率
}
if (apiOptions.CurrentDevice == "HTSH-4000")
{
_AccessResult.Change(-1, 10000);//开始循环从access数据库中读取数据10秒频率
if (!File.Exists("uploadedRecord.txt"))
File.Create("uploadedRecord.txt");
string accessDbPath = ConfigurationManager.AppSettings[apiOptions.CurrentDevice].Split(',')[3];
if (!accessDbPath.ToLower().Contains(".mdb"))
accessDbPath = DateTime.Now.ToString("yyyy-MM-dd") + ".mdb";
string CHECKDATE = DateTime.Now.ToString("yyyy-MM-dd");
// string CHECKDATE = DateTime.Now.ToString("2024-04-01");
//string sql = "SELECT ITEM as ItemCode,cint(Right(str(id), 3)) as SampleNO, `RESULT` as ItemValue FROM `CHECK_RESULT202404` where mid(id,1,4) +'-' + mid(id,5,2) + '-' + mid(id,7,2)='"+ CHECKDATE + "'";
string tableName = "CHECK_RESULT" + DateTime.Now.ToString("yyyyMM");
//string sql = "SELECT ITEM as ItemCode,id,cint(Right(str(id), 3)) as SampleNO, `RESULT` as ItemValue FROM "+ tableName + " where mid(id,1,4) +'-' + mid(id,5,2) + '-' + mid(id,7,2)='"+ CHECKDATE + "'";
string sql = "SELECT ITEM as ItemCode,id,cint(Right(str(id), 3)) as SampleNO, `RESULT` as ItemValue FROM " + tableName + "";
DataTable dt_2 = accessOptions.CreateInstance(accessDbPath).ExcuteSql(sql);
List<examResultMode> ermList = new List<examResultMode>();
string MachineCode = apiOptions.MachineCode;
string MachineID = apiOptions.MachineID;
string uploadedRecordStr = File.ReadAllText("uploadedRecord.txt");
for (int i = 0; i < dt_2.Rows.Count; i++)
{
string uploadedRecordId = dt_2.Rows[i]["id"].ToString().Trim() + dt_2.Rows[i]["ItemCode"].ToString().Trim();
if (!uploadedRecordStr.Contains(uploadedRecordId))
{
examResultMode erm1 = new examResultMode();
erm1.machineCode = MachineCode;
erm1.machineID = MachineID;
erm1.sampleNo = dt_2.Rows[i]["SampleNo"].ToString().Trim();
erm1.testDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
erm1.chanelNo = dt_2.Rows[i]["ItemCode"].ToString().Trim();//项目代号
erm1.itemValue = dt_2.Rows[i]["ItemValue"].ToString().Trim();//项目结果
erm1.itemUnit = "";
ermList.Add(erm1);
uploadedRecordStr += (uploadedRecordId + ",");
}
}
if (ermList.Count > 0)
{
//将结果提交到LIS系统
baseMsgModel bmm1 = apiOptions.CreateInstance().upLoadExamResult(ermList);
string jsonStr = JsonConvert.SerializeObject(ermList);
if (bmm1.code == 200)
{
//for (int i = 0; i < dt_2.Rows.Count; i++)
//{
// string sql1 = "update sampleProgram set stateS=1 where sampleProgramID='" + dt_2.Rows[i]["sampleProgramID"].ToString() + "'";
// bool flag1 = accessOptions.CreateInstance(accessDbPath).SqlUpdate(sql1);
//}
File.WriteAllText("uploadedRecord.txt", uploadedRecordStr);//记录写入本地
dataOutPutShow("数据和图像提交成功:" + jsonStr, null);
}
else
dataOutPutShow("数据和图像提交失败:" + jsonStr, null);
}
_AccessResult.Change(10000, 10000);//开始循环从access数据库中读取数据10秒频率
}
}
/// <summary>
/// 停止数据接收
/// </summary>
public void stopDataReceive()
{
if (apiOptions.CurrentDevice == "HSYH-II")//华晟源尿常规型号H-II
{
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "BT-200")//盛世东唐BT-200尿常规
{
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "URIT-5181")//优利特血常规 5181
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "URIT-1500")//优利特尿常规URIT-1500
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "DF55")//帝迈血常规DF55
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "TCPTEST")//tcp数据接收测试
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "CS-480")
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "SL300C")//Senlo生化SL300C
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "BA600")//尿常规 GeniusBA600
{
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "BA600-1")//尿常规 GeniusBA600
{
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "BA600MY")//煤窑中心卫生院的尿常规 GeniusBA600
{
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "MC-600")//血常规MAC-600
{
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "CS-1300B")//迪瑞全自动生化分析仪 CS-1300B
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "URIT-5180")//优利特血常规5180
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "BS-430")//生化BS-430
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "DF55-1")//帝迈血常规DF55
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "URIT-1600")//优利特1600
{
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "BK600")//
{
_AccessResult.Change(-1, 10000);//停止从access数据库中读取数据10秒频率
}
if (apiOptions.CurrentDevice == "HTSH-4000")//HTSH-4000 全自动生化分析仪
{
_AccessResult.Change(-1, 10000);//停止从access数据库中读取数据10秒频率
}
if (apiOptions.CurrentDevice == "DH56")//帝迈血常规DH56
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "URIT-5380")//优利特血常规 URIT-5380
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "U500")//尿常规U500
{
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "BC-5130")//BC-5130
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "SD1")//斯玛特
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "DF55-2")//帝迈血常规DF55
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "hhh5")//BC-5130
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "MA-4210")//MA-4210
{
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
if (apiOptions.CurrentDevice == "U120")//尿常规U120
{
SerialPortOption.CreateInstance().StopDataReadThread();//停止数据接收
}
if (apiOptions.CurrentDevice == "BS-330E")//BS-330E
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "BC-5120")//BC-5120
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "URIT-8460")//URIT-8460
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "BS-460")//生化BS-460
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "BS-460-1")//生化BS-460
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "BS-460-2")//生化BS-460
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "Z3 CRP")//帝迈血常规DH56
{
_tcpResult.Change(-1, 10);//停止tcp数据接收
clientSocket.Close();
}
if (apiOptions.CurrentDevice == "URIT-500B")//优利特血常规 URIT-500B
{
SerialPortOption.CreateInstance().StopDataReadThread();//开启数据接收
}
}
///// <summary>
///// 开启tcp数据接收
///// </summary>
//public void tcpDataReceive()
//{
// while (true)
// {
// byte[] data = new byte[1024];//对data清零
// Socket clientSocket = listener.Accept(); //一旦接受连接,创建一个客户端
// int recv = clientSocket.Receive(data);
// if (recv == 0) //如果收到的数据长度小于0则退出
// continue;
// string stringData = Encoding.Unicode.GetString(data);
// onReData(stringData, null);//将数据显示在软件界面上
// }
//}
}
}