Exemplo n.º 1
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string strTestTime   = ""; //检验时间
            string strSampleNo   = ""; //标本号
            string strBarCode    = ""; //条码
            string strOperator   = ""; //检验医师
            string strSampleType = ""; //检验类型
            string StrSpecimen   = ""; //标本类型


            //连接access数据库
            //配置文件中读取密码,查询语句
            //读取配置文件
            try
            {
                string       file                = "FC3样本号重复处理.txt";
                StreamReader sr                  = new StreamReader(@".\FC3.txt", System.Text.Encoding.GetEncoding("GB2312"));
                string       correspondence      = sr.ReadLine();
                string[]     correspondenceArray = correspondence.Split('|');
                string       configPath          = sr.ReadLine();
                string       pwd                 = sr.ReadLine().Replace("pwd:", "");
                sr.Close();
                string    connStr  = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password="******"yyyy-MM-dd");
                string    sql      = "SELECT   distinct(testno) as testNo   from samples   where  Format(gatherdate, 'yyyy-mm-dd') ='" + dateTime + "'";
                DataTable dt       = OleDBHelper.GetOledbDataTable(sql, connStr);
                foreach (DataRow item in dt.Rows)
                {
                    string testNo = item["testNo"].ToString();
                    strSampleNo = testNo;
                    strTestTime = dateTime;
                    string sqlSelect = @"select *  from  samples  where  Format(gatherdate, 'yyyy-mm-dd') ='in_testTime' and  testno=in_testNo";
                    sqlSelect = sqlSelect.Replace("in_testTime", dateTime);
                    sqlSelect = sqlSelect.Replace("in_testNo", testNo);

                    DataTable     dt2        = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);
                    List <string> TestValues = new List <string>();

                    StringBuilder sBuilder = new StringBuilder();
                    foreach (DataRow subItem in dt2.Rows)
                    {
                        string lisTestName  = subItem["outname"].ToString();
                        string lisTestValue = subItem["result"].ToString();
                        sBuilder.Append(lisTestName + "," + lisTestValue + "|");
                        TestValues.Add(lisTestName + ":" + lisTestValue);
                    }
                    if (Helper.CompareSampleNoAndTime(file, testNo, strTestTime, TestValues))
                    {
                        continue;
                    }
                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                    string[] strs = str.Split('|');
                    sBuilder = null;
                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);


                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }

                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, e.ToString(), "log");
            }
        }
Exemplo n.º 2
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string strTestTime = ""; //检验时间
            string strSampleNo = ""; //标本号
            string strBarCode  = ""; //条码
            string replaceChar = Convert.ToChar(0x00) + "";

            strSource = strSource.Replace(replaceChar, "");
            string endStr  = Convert.ToChar(0x0A) + "";
            string endStr1 = Convert.ToChar(0x0A) + "" + Convert.ToChar(0x00);

            //  string endStr2 = Convert.ToChar(0x09) + "" + Convert.ToChar(0x0A);
            char[] charArray = strSource.ToCharArray();
            writelog.Write(strDevice, "最后一个字符: " + Convert.ToInt16(charArray[charArray.Length - 1]), "log");
            strResult += strSource;
            if (strResult.EndsWith(endStr) || strResult.EndsWith(endStr1) || strResult.EndsWith("test"))
            {
                writelog.Write(strDevice, "all数据:" + strResult, "log");
                char     split1         = Convert.ToChar(0x0A);
                char     split2         = Convert.ToChar(0x0D);
                string[] strResultArray = strResult.Split(new char[] { split1, split2 }, StringSplitOptions.RemoveEmptyEntries);
                for (int kkk = 0; kkk < strResultArray.Length; kkk++)
                {
                    if (strResultArray[kkk].Length > 20)
                    {
                        string dealStr = strResultArray[kkk].Trim();

                        try
                        {
                            writelog.Write(strDevice, "接收到数据开始: " + dealStr, "log");
                            // writelog.Write(strDevice, "接收到数据完成: " + dealStr, "log");


                            string[] analysis1 = dealStr.Split(new char[] { ' ', '=' }, StringSplitOptions.RemoveEmptyEntries);
                            strTestTime = analysis1[0].Split(' ')[0].Replace('/', '-');
                            strSampleNo = analysis1[3].Split(new char[] { ' ', '(', '=' })[0].Replace('/', '-');

                            StringBuilder sBuilder = new StringBuilder();
                            sBuilder.Append("K," + analysis1[5].Replace("(L)", "").Replace("(?)", "") + "|");
                            sBuilder.Append("Na," + analysis1[7].Replace("(L)", "").Replace("(?)", "") + "|");
                            sBuilder.Append("Cl," + analysis1[9].Replace("(L)", "").Replace("(?)", "") + "|");
                            sBuilder.Append("Ca," + analysis1[11].Replace("(L)", "").Replace("(?)", "") + "|");
                            sBuilder.Append("pH," + analysis1[13].Replace("(L)", "").Replace("(?)", "") + "|");
                            sBuilder.Append("n-Ca," + analysis1[15].Replace("(L)", "").Replace("(?)", "") + "|");
                            sBuilder.Append("T-Ca," + analysis1[17].Replace("(L)", "").Replace("(?)", "").Replace("\r\n", "") + "|");
                            string   str             = sBuilder.ToString().Remove(sBuilder.Length - 1);
                            string[] strs            = str.Split('|');
                            string   ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                            string   testItemID      = "";
                            string   TestResultValue = "";
                            for (int i = 0; i < strs.Length; i++)
                            {
                                FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                                if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                                {
                                    ChannelType = null;
                                    writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                                }
                                else
                                {
                                    testItemID      = FindRow[0]["项目id"].ToString();
                                    ChannelType     = "0"; //普通结果
                                    TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1].Replace("RuPT", "阴性") + "|";
                                }
                            }
                            TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                            saveResult      = new SaveResult();
                            if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                            {
                                saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                                if (ImmediatelyUpdate)
                                {
                                    saveResult.UpdateData();
                                }
                            }
                            if (!ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                        catch (Exception e)
                        {
                            writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                            strResult = "";
                        }
                    }
                    strResult = "";
                }
            }
        }
Exemplo n.º 3
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string result = may.sendQCK(strSource, strDevice, strDeviceID);

            //如果是质控到话
            if (result.StartsWith("4"))
            {
                try
                {
                    writelog.Write(strDevice, "接收到数据: " + strSource, "log");
                    StreamReader sr = new StreamReader(@".\BS400.txt");
                    //解析结果检验项目标识符和zlchs定义的变量对应 lis,zlchs|lis1,zlchs1
                    StringBuilder sBuilder       = new StringBuilder("");
                    string        correspondence = sr.ReadLine();
                    sr.Close();
                    string[] correspondenceArray = correspondence.Split('|');
                    string[] analysis            = strSource.Split('|');
                    string   strTestTime         = DateTime.Now.ToString("yyyyMMddHHmmss");
                    string   messageTime         = analysis[6];
                    string   messageID           = analysis[9];
                    string   ACK_R01_OK          = may.SB + @"MSH|^~\&|||||{0}||ACK^R01|{1}|P|2.3.1||||2||ASCII|||" + may.CR
                                                   + "MSA|AA|{1}|Message accepted|||0|" + may.CR
                                                   + may.EB + may.CR;
                    strCmd = string.Format(ACK_R01_OK, strTestTime, messageID);
                    string[] strSourceArray = strSource.Split(may.CR);
                    for (int i = 0; i < strSourceArray.Length; i++)
                    {
                        string s = strSourceArray[i];
                        if (s.IndexOf("OBR") > -1)
                        {
                            string times = s.Split('|')[7];
                            strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2) + " " + times.Substring(8, 2) + ":" + times.Substring(10, 2) + ":" + times.Substring(12, 2);
                            string[] no = s.Split('|')[13].Split('^');
                            if (no.Length > 1)
                            {
                                strSampleNo = "900" + no[1];
                            }
                            else
                            {
                                strSampleNo = "900" + s.Split('|')[12];
                            }
                            for (int j = 0; j < correspondenceArray.Length; j++)
                            {
                                string lis   = correspondenceArray[j].Split(',')[0];
                                string zlchs = correspondenceArray[j].Split(',')[1];
                                if (s.IndexOf('|' + lis + '|') > 0)
                                {
                                    sBuilder.Append(zlchs + ',' + s.Split('|')[20] + '|');
                                }
                            }
                        }
                    }

                    string str = sBuilder.ToString().Remove(sBuilder.Length - 1);
                    writelog.Write(strDevice, "BS400质控数据sBuilder:" + str, "log");
                    string[] strs = str.Split('|');

                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1].Replace("RuPT", "阴性") + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    writelog.Write(strDevice, "BS400质控数据|TestResultValue:" + str, "log");
                    saveResult = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "质控异常:" + e.ToString(), "log");
                }
            }
            //如果是样本结果的话
            else if (result.StartsWith("5"))
            {
                try
                {
                    writelog.Write(strDevice, "接收到数据: " + strSource, "log");
                    //
                    string[]     analysis    = strSource.Split('|');
                    string       strTestTime = DateTime.Now.ToString("yyyyMMddHHmmss");
                    string       messageTime = analysis[6];
                    string       messageID   = analysis[9];
                    StreamReader sr          = new StreamReader(@".\BS400.txt");
                    //解析结果检验项目标识符和zlchs定义的变量对应 lis,zlchs|lis1,zlchs1
                    StringBuilder sBuilder       = new StringBuilder("");
                    string        correspondence = sr.ReadLine();
                    sr.Close();
                    string ACK_R01_OK = may.SB + @"MSH|^~\&|||||{0}||ACK^R01|{1}|P|2.3.1||||0||ASCII|||" + may.CR
                                        + "MSA|AA|{1}|Message accepted|||0|" + may.CR
                                        + may.EB + may.CR;
                    strCmd = string.Format(ACK_R01_OK, strTestTime, messageID);
                    string   times = "";
                    string[] correspondenceArray = correspondence.Split('|');
                    string[] strSourceArray      = strSource.Split(new char[] { '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strSourceArray.Length; i++)
                    {
                        if (strSourceArray[i].Split(new char[] { '|' })[0].Replace("\n", "").Equals("OBR"))
                        {
                            strSampleNo = strSourceArray[i].Split('|')[3];
                            if ("".Equals(strSourceArray[i].Split('|')[6]))
                            {
                                times = DateTime.Now.ToString("yyyyMMddHHmmss");
                            }
                            else
                            {
                                times = strSourceArray[i].Split('|')[6];
                            }
                            //如果有条码号,取核收时间作为检验时间
                            string sampleBarstr = strSourceArray[i].Split(new char[] { '|' })[2];
                            if (!string.IsNullOrEmpty(sampleBarstr))
                            {
                                IniFile ConfigIni = new IniFile("SOLVESET.INI");
                                string  encode    = ConfigIni.IniReadValue("EQUIPMENT", "Encode");
                                DataSet ds        = new DataSet();
                                string  orgId     = ConfigIni.IniReadValue("EQUIPMENT", "Agencies");
                                string  sql       = @"to_char(核收时间,'yyyymmddhh24miss') as 核收时间,样本序号";
                                string where = @" 机构id='" + orgId + "' and  样本条码='" + sampleBarstr + "'";
                                ds           = dsHandle.GetDataSet(sql, "检验记录", where);
                                times        = ds.Tables[0].Rows[0]["核收时间"].ToString();//20160202145321
                                strSampleNo  = ds.Tables[0].Rows[0]["样本序号"].ToString();
                            }

                            strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                        }
                        if (strSourceArray[i].Split(new char[] { '|' })[0].Replace("\n", "").Equals("OBX"))
                        {
                            for (int j = 0; j < correspondenceArray.Length; j++)
                            {
                                string lis   = correspondenceArray[j].Split(',')[0];
                                string zlchs = correspondenceArray[j].Split(',')[1];
                                if (strSourceArray[i].IndexOf('|' + lis + '|') > 0)
                                {
                                    sBuilder.Append(zlchs + ',' + strSourceArray[i].Split('|')[5] + '|');
                                }
                            }
                        }
                    }
                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1);
                    string[] strs = str.Split('|');

                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1].Replace("RuPT", "阴性") + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }
            }

            else
            {
                strCmd = result;
            }
        }
Exemplo n.º 4
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            #region 设置为串口通讯的时候
            //char c03 = Convert.ToChar(0x03);
            //char c0f = Convert.ToChar(0x0F);
            //char c00 = Convert.ToChar(0x00);
            //#region
            ////存储每次接收后的10进制字符串
            //char[] chars = strSource.ToCharArray();
            //writelog.Write(strDevice, "接收数据开始:"+strSource, "log");
            //string output = "";
            //for (int i = 0; i < chars.Length; i++)
            //{
            //    output = output + Convert.ToInt32(chars[i]) + " ";
            //}
            //writelog.Write(strDevice, "10进制接收数据:"+output, "log");

            ////
            //#endregion

            ////去掉空
            //strSource = strSource.Replace(c00, ' ').Trim();
            //strResult += strSource;
            //if (strSource.EndsWith(c03+""))
            //{
            // try
            //    {
            //        bool isSampleBar = true;
            //        //将接收到的字符串写入到日志文件中
            //        writelog.Write(strDevice, "接收数据开始:\r\n " + strResult, "log");
            //        writelog.Write(strDevice, "接收数据完成 ", "log");
            //        StreamReader sr = new StreamReader(@".\MVIS2010.txt");
            //        string correspondence = sr.ReadLine();
            //        sr.Close();
            //        string[] correspondenceArray = correspondence.Split('|');
            //        StringBuilder sBuilder = new StringBuilder("");
            //        string[] ss = strResult.Split(new char[] { '\r','\n' }, StringSplitOptions.RemoveEmptyEntries);
            //        string ChannelCode = "";
            //        for (int i = 0; i < ss.Length; i++)
            //        {
            //            if (ss[i].Trim().ToUpper().StartsWith("SN"))
            //            {
            //                strSampleNo = ss[i].Split(':')[1].Trim();
            //            }
            //            if (ss[i].Trim().ToUpper().StartsWith("DATE"))
            //            {
            //                strTestTime = ss[i].Replace("Date:","").Trim();
            //            }
            //            for (int j = 0; j < correspondenceArray.Length; j++)
            //            {
            //                string sTemp = ss[i].Trim();
            //                string lis = correspondenceArray[j].Split(',')[0];
            //                string zlchs = correspondenceArray[j].Split(',')[1];
            //                if (ss[i].StartsWith(lis))
            //                {
            //                    string itemValue = ss[i].Split(':')[1].Trim();
            //                    if (itemValue.IndexOf(" ") > -1)
            //                        itemValue = itemValue.Split(' ')[0];
            //                    sBuilder.Append(zlchs + ',' + itemValue + '|');
            //                }
            //            }
            //        }

            //        string str = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);

            //        writelog.Write(strDevice, "数据处理结果:" + str, "log");

            //        string[] strs = str.Split('|');

            //        string ChannelType = "";     //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
            //        string testItemID = "";
            //        string TestResultValue = "";
            //        for (int i = 0; i < strs.Length; i++)
            //        {
            //            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
            //            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
            //            {
            //                ChannelType = null;
            //                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
            //            }
            //            else
            //            {
            //                testItemID = FindRow[0]["项目id"].ToString();
            //                ChannelType = "0"; //普通结果
            //                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
            //            }
            //        }
            //        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
            //        saveResult = new SaveResult();
            //        if (!string.IsNullOrEmpty(strSampleNo))
            //        {
            //          saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);       if (ImmediatelyUpdate)
            //            {
            //                saveResult.UpdateData();
            //            }
            //        }
            //        if (!ImmediatelyUpdate)
            //        {
            //            saveResult.UpdateData();
            //        }
            //    }
            //    catch (Exception e)
            //    {
            //        writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            //    }
            //    strResult = "";
            //}
            //strCmd = Convert.ToChar(0x06) + "";
            #endregion
            try
            {
                string       file                = "MVIS2010样本号重复处理.txt";
                StreamReader sr                  = new StreamReader(@".\MVIS2010.txt", System.Text.Encoding.GetEncoding("GB2312"));
                string       correspondence      = sr.ReadLine();
                string[]     correspondenceArray = correspondence.Split('|');
                string       configPath          = sr.ReadLine();
                string       configPathSrc       = configPath;
                string       password            = sr.ReadLine();
                string       dateTime            = DateTime.Now.ToString("yyyy-MM-dd");
                sr.Close();
                //拆分路径,寻找地址
                string[] configPaths      = configPath.Split('_');
                string   configPathRoot   = configPaths[0] + '_' + configPaths[1] + '_';
                string   configPathEndStr = DateTime.Now.ToString("yyyy_MM");
                configPath = configPathRoot + configPathEndStr + ".mdb";
                if (!File.Exists(configPath))
                {
                    writelog.Write(strDevice,
                                   configPath + "没有找到本月源数据,尝试寻找上一月", "log");
                    string configPathLastMonth = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddMonths(-1).ToString("yyyy_MM");
                    configPath = configPathRoot + configPathLastMonth + ".mdb";
                    if (!File.Exists(configPath))
                    {
                        writelog.Write(strDevice,
                                       configPath + "没有找到上月源数据,尝试寻找原始配置文件", "log");
                        configPath = configPathSrc;;
                        if (!File.Exists(configPath))
                        {
                            writelog.Write(strDevice,
                                           configPath + "没有找到,系统进入下一个循环周期", "log");
                            return;
                        }
                    }
                }
                string    connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password="******"select distinct(SN) as ItemNo  from  Test where Format(todaydate, 'yyyy-mm-dd')='" + dateTime + "'";
                DataTable dt      = OleDBHelper.GetOledbDataTable(sql, connStr);
                strTestTime = dateTime;

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        StringBuilder sBuilder = new StringBuilder("");
                        strSampleNo = item["ItemNo"].ToString();
                        string sqlSelect = @"select  *  from  Test where    SN=in_编号 and  Format(todaydate, 'yyyy-mm-dd')=  'in_clrq' ";
                        sqlSelect = sqlSelect.Replace("in_编号", strSampleNo);
                        sqlSelect = sqlSelect.Replace("in_clrq", dateTime);
                        DataTable dt2 = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);

                        List <string> TestValues = new List <string>();
                        if (dt2.Rows.Count > 0)
                        {
                            foreach (DataRow item2 in dt2.Rows)
                            {
                                foreach (var subItem in correspondenceArray)
                                {
                                    string lis   = subItem.Split(',')[0].Trim();
                                    string zlchs = subItem.Split(',')[1].Trim();

                                    string itemName  = zlchs;
                                    double itemValue = Convert.ToDouble(item2[lis].ToString());
                                    itemValue = Math.Round(itemValue, 2);
                                    TestValues.Add(itemName + ":" + itemValue.ToString());
                                    sBuilder.Append(itemName + ',' + itemValue + '|');
                                }
                            }
                        }

                        /////
                        if (Helper.CompareSampleNoAndTime(file, strSampleNo, strTestTime, TestValues))
                        {
                            continue;
                        }
                        string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                        string[] strs = str.Split('|');

                        string ChannelType     = "";     //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string testItemID      = "";
                        string TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0)     //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                            }
                        }

                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                    }
                }
            }

            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }

            System.Threading.Thread.Sleep(3000);
        }
Exemplo n.º 5
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string picPath = "";

            try
            {
                //将接收到的字符串写入到日志文件中
                writelog.Write(strDevice, "接收数据开始:\r\n " + strSource, "log");
                writelog.Write(strDevice, "接收数据完成 ", "log");
                //设置读取AVE761文本文件
                StreamReader  sr                  = new StreamReader(@".\AVE761.txt", Encoding.Default);
                string        correspondence      = sr.ReadLine();
                string[]      correspondenceArray = correspondence.Split('|');
                StringBuilder sBuilder            = new StringBuilder("");
                if (strSource.Contains("SickSampleID"))
                {
                    string[] ss          = strSource.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    string   ChannelCode = "";
                    for (int i = 0; i < ss.Length; i++)
                    {
                        string sCompare   = new string(ss[i].Split(new char[] { '=' })[0].Trim().ToCharArray());
                        string sDate      = "SickDate";//SickDate
                        string sNO        = "SickExamineID";
                        string pic        = "UriPrintPath";
                        string PrintImage = "PrintImage";
                        if (sCompare.Equals(sNO))
                        {
                            strSampleNo = ss[i].Split('=')[1];
                        }
                        if (sCompare.Equals(sDate))
                        {
                            string times = ss[i].Split('=')[1];
                            strTestTime = times.Substring(0, 10);
                        }
                        if (sCompare.Equals(pic))
                        {
                            picPath = ss[i].Split('=')[1];
                        }
                        if (sCompare.Equals("PrintImage") && !picPath.Equals(""))
                        {
                            string   strList  = ss[i].Split('=')[1];
                            string[] strLists = strList.Split(',');
                            foreach (string item in strLists)
                            {
                                if (!item.Equals(""))
                                {
                                    //直接存放图片,加入到图像列表中
                                    TestGraph.Add(picPath + item + ".jpg");
                                }
                            }
                        }


                        //处理图像

                        for (int j = 0; j < correspondenceArray.Length; j++)
                        {
                            string lis   = correspondenceArray[j].Split(',')[0];
                            string zlchs = correspondenceArray[j].Split(',')[1];

                            if (ss[i].Split('=')[0].Equals(lis))
                            {
                                //比重结果值有冲突, SG=>=1.030
                                if (ss[i].Split('=').Length > 2)
                                {
                                    sBuilder.Append(zlchs + ',' + ss[i].Split('=')[1] + '=' + ss[i].Split('=')[2] + '|');
                                }
                                else
                                {
                                    sBuilder.Append(zlchs + ',' + ss[i].Split('=')[1] + '|');
                                }
                            }
                        }
                    }
                }
                string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                string[] strs = str.Split('|');

                string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                string testItemID      = "";
                string TestResultValue = "";
                for (int i = 0; i < strs.Length; i++)
                {
                    FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                    if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                    {
                        ChannelType = null;
                        writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                    }
                    else
                    {
                        testItemID      = FindRow[0]["项目id"].ToString();
                        ChannelType     = "0"; //普通结果
                        TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                    }
                }

                TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                saveResult      = new SaveResult();
                if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                {
                    //添加图片的路径

                    //添加图片的路径
                    saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                    TestGraph.Clear();
                    if (ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }

                if (!ImmediatelyUpdate)
                {
                    saveResult.UpdateData();
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }
        }
Exemplo n.º 6
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            char c03 = Convert.ToChar(0x00);

            if (strSource.EndsWith(c03 + "") || strSource.EndsWith("--test--") || strSource.EndsWith("End"))
            {
                strResult += strSource;
                try
                {
                    bool isSampleBar = true;
                    //将接收到的字符串写入到日志文件中
                    writelog.Write(strDevice, "接收数据开始:\r\n " + strResult, "log");
                    writelog.Write(strDevice, "接收数据完成 ", "log");
                    StreamReader sr             = new StreamReader(@".\IMS972.txt");
                    string       correspondence = sr.ReadLine();
                    sr.Close();
                    string[] correspondenceArray = correspondence.Split('|');
                    string   sBuilder            = "";
                    strTestTime = DateTime.Now.ToString("yyyyMMddHHmmss");
                    strTestTime = strTestTime.Substring(0, 4) + "-" + strTestTime.Substring(4, 2) + "-" + strTestTime.Substring(6, 2) + " " + strTestTime.Substring(8, 2) + ":" + strTestTime.Substring(10, 2) + ":" + strTestTime.Substring(12, 2);
                    strSampleNo = strResult.Split(new string[] { "PAT_ID" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0];;
                    string firstSplit  = "";
                    string secondSplit = "";
                    for (int i = 0; i < correspondenceArray.Length; i++)
                    {
                        if (i == correspondenceArray.Length - 1)
                        {
                            firstSplit  = correspondenceArray[i].Split(',')[0];
                            secondSplit = "PAT_ID";
                        }
                        else
                        {
                            firstSplit  = correspondenceArray[i].Split(',')[0];
                            secondSplit = correspondenceArray[i + 1].Split(',')[0];
                        }

                        if (strResult.IndexOf(correspondenceArray[i].Split(',')[0]) != -1)
                        {
                            string mm   = strResult.Split(new string[] { firstSplit }, StringSplitOptions.None)[1];
                            string item = mm.Split(new string[] { secondSplit }, StringSplitOptions.RemoveEmptyEntries)[0].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                            sBuilder += correspondenceArray[i].Split(',')[1] + "," + item + "|";
                        }
                    }


                    string   str             = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                    string[] strs            = str.Split('|');
                    string   ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string   testItemID      = "";
                    string   TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }
                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo))
                    {
                        //strInstrument_id 替换到目标设备
                        if (string.IsNullOrEmpty(strReserved))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        else
                        {
                            saveResult.SaveTextResult(strReserved, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }
                strResult = "";
            }
            else
            {
                strResult += strSource;
            }
        }
Exemplo n.º 7
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            try
            {
                string       file           = "KHB330样本号重复处理.txt";
                StreamReader sr             = new StreamReader(@".\KHB330.txt", Encoding.Default);
                string       correspondence = sr.ReadLine();
                string       info           = sr.ReadLine();
                sr.Close();
                string[] correspondenceArray = correspondence.Split('|');
                string   ip       = info.Split('|')[0];
                string   database = info.Split('|')[1];
                string   uname    = info.Split('|')[2];
                string   pwd      = info.Split('|')[3];
                string   con      = "server=in_ip\\;database=in_database;uid=in_uname;pwd=in_pwd";
                con = con.Replace("in_ip", ip);
                con = con.Replace("in_database", database);
                con = con.Replace("in_uname", uname);
                con = con.Replace("in_pwd", pwd);
                string        dateTime = DateTime.Now.ToString("yyyyMMdd");
                string        sqlCount = "select distinct(SampleNo) as  SampleNo  from dbo.labLISItemResult where CONVERT(varchar(100), TestTime, 112)  =" + dateTime;
                SqlConnection mycon    = new SqlConnection(con);
                mycon.Open();
                SqlDataAdapter adapter = new SqlDataAdapter(sqlCount, mycon);
                DataSet        ds      = new DataSet();
                adapter.Fill(ds);
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow item in ds.Tables[0].Rows)
                    {
                        string         time1     = "";
                        string         no1       = "";
                        StringBuilder  sBuilder  = new StringBuilder("");
                        string         s         = item["SampleNo"].ToString();
                        string         sqlSelect = "select ItemCode,TestValue ,CONVERT(varchar(100), TestTime, 20) TestTime  from  dbo.labLISItemResult where CONVERT(varchar(100), TestTime, 112)  =" + dateTime + " and SampleNo=" + s;
                        SqlDataAdapter adapter1  = new SqlDataAdapter(sqlSelect, mycon);
                        DataSet        ds1       = new DataSet();
                        adapter1.Fill(ds1);
                        List <string> TestValues = new List <string>();
                        if (ds1.Tables[0] != null && ds1.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow item1 in ds1.Tables[0].Rows)
                            {
                                strTestTime = item1["TestTime"].ToString();
                                strSampleNo = s;
                                time1       = strTestTime;
                                no1         = strSampleNo;
                                TestValues.Add(item1["ItemCode"].ToString() + ":" + item1["TestValue"].ToString());
                                string itemName  = item1["ItemCode"].ToString();
                                string itemValue = item1["TestValue"].ToString();
                                sBuilder.Append(itemName + ',' + itemValue + '|');
                            }
                        }
                        /////
                        if (Helper.CompareSampleNoAndTime(file, no1, strTestTime, TestValues))
                        {
                            continue;
                        }
                        string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                        string[] strs = str.Split('|');

                        string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string testItemID      = "";
                        string TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                            }
                        }

                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }

            System.Threading.Thread.Sleep(3000);
        }
Exemplo n.º 8
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            char c03 = Convert.ToChar(0x03);

            if (strSource.EndsWith(c03 + ""))
            {
                strResult += strSource;
                try
                {
                    bool isSampleBar = true;
                    //将接收到的字符串写入到日志文件中
                    writelog.Write(strDevice, "接收数据开始:\r\n " + strResult, "log");
                    writelog.Write(strDevice, "接收数据完成 ", "log");

                    StreamReader sr             = new StreamReader(@".\URIT180.txt", Encoding.Default);
                    string       correspondence = sr.ReadLine();
                    sr.Close();
                    string[]      correspondenceArray = correspondence.Split('|');
                    StringBuilder sBuilder            = new StringBuilder("");

                    string[] ss          = strResult.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    string   ChannelCode = "";
                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (ss[i].Trim().IndexOf("NO.") != -1 && isSampleBar)
                        {
                            string   mm      = ss[i];
                            string   timeStr = ss[i + 1].Trim();
                            string[] temp    = mm.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            strSampleNo = temp[0].Split('.')[1].Trim();
                            string mm1 = temp[1].Trim();
                            strTestTime = mm1;
                            //如果有条码号,通过条码号查询核收时间作为样本时间,核收的样本编号作为编号,用于单向通讯
                        }
                        if (ss[i].IndexOf("ID") != -1)
                        {
                            string times = "";
                            string mm    = ss[i];
                            strBarCode = mm.Split(':')[1].Trim();
                            if (!string.IsNullOrEmpty(strBarCode))
                            {
                                IniFile ConfigIni = new IniFile("SOLVESET.INI");
                                string  encode    = ConfigIni.IniReadValue("EQUIPMENT", "Encode");
                                DataSet ds        = new DataSet();
                                string  orgId     = ConfigIni.IniReadValue("EQUIPMENT", "Agencies");
                                string  sql       = @"to_char(核收时间,'yyyymmddhh24miss') as 核收时间,样本序号";
                                string where = @" 机构id='" + orgId + "' and  样本条码='" + strBarCode + "'";
                                ds           = dsHandle.GetDataSet(sql, "检验记录", where);
                                DataTable dt1 = ds.Tables[0];
                                if (dt1.Rows.Count > 0)
                                {
                                    times       = ds.Tables[0].Rows[0]["核收时间"].ToString();//20160202145321
                                    strSampleNo = ds.Tables[0].Rows[0]["样本序号"].ToString();
                                    strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                                    isSampleBar = false;
                                }
                            }
                        }
                        for (int j = 0; j < correspondenceArray.Length; j++)
                        {
                            string lis   = correspondenceArray[j].Split(',')[0];
                            string zlchs = correspondenceArray[j].Split(',')[1];
                            if (ss[i].IndexOf(lis) >= 0)
                            {
                                string temp = ss[i].Trim();


                                sBuilder.Append(zlchs + ',' + temp.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1] + '|');
                            }
                        }
                    }

                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                    string[] strs = str.Split('|');

                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }
                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo))
                    {
                        //strInstrument_id 替换到目标设备
                        if (string.IsNullOrEmpty(strReserved))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        else
                        {
                            saveResult.SaveTextResult(strReserved, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }
                strResult = "";
            }
            else
            {
                strResult += strSource;
            }
        }
Exemplo n.º 9
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            strCmd = Convert.ToChar(6) + "";
            char c03 = Convert.ToChar(0x03);

            strResult += strSource;
            if (strSource.EndsWith(c03 + ""))
            {
                try
                {
                    //将接收到的字符串写入到日志文件中
                    writelog.Write(strDevice, "接收数据开始:\r\n " + strResult, "log");
                    writelog.Write(strDevice, "接收数据完成 ", "log");

                    StreamReader sr             = new StreamReader(@".\URIT600.txt");
                    string       correspondence = sr.ReadLine();
                    sr.Close();
                    string[]      correspondenceArray = correspondence.Split('|');
                    StringBuilder sBuilder            = new StringBuilder("");

                    string[] ss          = strResult.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    string   ChannelCode = "";
                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (ss[i].Trim().ToUpper().IndexOf("NO.") != -1)
                        {
                            string mm = ss[i];
                            strTestTime = ss[i + 1].Trim();
                            string[] temp = mm.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            strSampleNo = temp[0].Split('.')[1].Trim();
                        }
                    }
                    for (int j = 0; j < correspondenceArray.Length; j++)
                    {
                        string lis   = correspondenceArray[j].Split(',')[0] + ':';
                        string zlchs = correspondenceArray[j].Split(',')[1];
                        if (strResult.IndexOf("APTT-s") >= 0)
                        {
                            if (strResult.IndexOf(lis) >= 0 && lis != "TT-s:")
                            {
                                string strValue = strResult.Split(new string[] { lis }, StringSplitOptions.RemoveEmptyEntries)[1];
                                strValue = strValue.Split(new char[] { ' ', '\r', '\n', 'g' }, StringSplitOptions.RemoveEmptyEntries)[0];
                                if (lis.ToUpper().Equals("FIB:"))
                                {
                                    strValue = strResult.Split(new string[] { lis }, StringSplitOptions.RemoveEmptyEntries)[1];
                                    strValue = strValue.Split(new char[] { ',', 's' }, StringSplitOptions.RemoveEmptyEntries)[1];
                                }

                                sBuilder.Append(zlchs + ',' + strValue + '|');
                            }
                            if (strResult.IndexOf(lis) >= 0 && lis == "TT-s:")
                            {
                                string strResult_TT_s = strResult.Replace("APTT-s", "");

                                string strValue = strResult_TT_s.Split(new string[] { lis }, StringSplitOptions.RemoveEmptyEntries)[1];
                                strValue = strValue.Split(new char[] { ' ', '\r', '\n', 'g' }, StringSplitOptions.RemoveEmptyEntries)[0];

                                sBuilder.Append(zlchs + ',' + strValue + '|');
                            }
                        }
                        else
                        {
                            if (strResult.IndexOf(lis) >= 0)
                            {
                                string strValue = strResult.Split(new string[] { lis }, StringSplitOptions.RemoveEmptyEntries)[1];
                                strValue = strValue.Split(new char[] { ' ', '\r', '\n', 'g' }, StringSplitOptions.RemoveEmptyEntries)[0];
                                if (lis.ToUpper().Equals("FIB:"))
                                {
                                    strValue = strResult.Split(new string[] { lis }, StringSplitOptions.RemoveEmptyEntries)[1];
                                    strValue = strValue.Split(new char[] { ',', 's' }, StringSplitOptions.RemoveEmptyEntries)[1];
                                }

                                sBuilder.Append(zlchs + ',' + strValue + '|');
                            }
                        }
                    }



                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                    string[] strs = str.Split('|');

                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }
                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo))
                    {
                        //strInstrument_id 替换到目标设备
                        if (string.IsNullOrEmpty(strReserved))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        else
                        {
                            saveResult.SaveTextResult(strReserved, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }
                strResult = "";
            }
        }
Exemplo n.º 10
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            strCmd     = Convert.ToChar(0x06) + "";
            strResult += strSource;
            string strEnd = Convert.ToChar(0x03) + "";

            if (strSource.EndsWith(strEnd) || strSource.EndsWith("test-end"))
            {
                try
                {
                    writelog.Write(strDevice, "接收数据开始:\r\n " + strResult, "log");
                    writelog.Write(strDevice, "接收数据完成 ", "log");
                    string       correspondence = "";
                    StreamReader sr             = new StreamReader(@".\AUDICOM.AC9800.txt", Encoding.Default);
                    correspondence = sr.ReadLine();
                    sr.Close();
                    string[]      correspondenceArray = correspondence.Split('|');
                    StringBuilder sBuilder            = new StringBuilder("");
                    string[]      ss = strResult.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (i == 0)
                        {
                            strTestTime = ss[0].Replace(Convert.ToChar(2), ' ').Trim();
                        }

                        if (i == 2)
                        {
                            strSampleNo = ss[2];
                        }
                    }
                    strResult = strResult.ToUpper();
                    for (int j = 0; j < correspondenceArray.Length; j++)
                    {
                        string lis   = correspondenceArray[j].Split(',')[0].ToUpper();
                        string zlchs = correspondenceArray[j].Split(',')[1].ToUpper();
                        if (strResult.IndexOf(lis) >= 0)
                        {
                            string[] strValues = strResult.Split(new string[] { lis }, StringSplitOptions.RemoveEmptyEntries);
                            if (strValues.Length > 1)
                            {
                                string strValue = strValues[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0];
                                sBuilder.Append(zlchs + ',' + strValue + '|');
                            }
                        }
                    }
                    string   str             = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                    string[] strs            = str.Split('|');
                    string   testItemID      = "";
                    string   TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }
                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }
                strResult = "";
            }
        }
Exemplo n.º 11
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            try
            {
                //将接收到的字符串写入到日志文件中
                writelog.Write(strDevice, "接收数据开始:\r\n " + strSource, "log");
                writelog.Write(strDevice, "接收数据完成 ", "log");
                //设置读取E411文本文件
                StreamReader  sr                  = new StreamReader(@".\BS300.txt", Encoding.Default);
                string        correspondence      = sr.ReadLine();
                string[]      correspondenceArray = correspondence.Split('|');
                StringBuilder sBuilder            = new StringBuilder("");
                if (strSource.Contains(((char)5).ToString()))
                {
                    string[] ss          = strSource.Split(new char[] { '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    string   ChannelCode = "";
                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (ss[i].Split(new char[] { '|' })[0].Replace("\n", "").Equals("3O"))
                        {
                            strSampleNo = ss[i].Split('|')[2];
                            string times = ss[i].Split('|')[6];
                            strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                            //设置为当前接收到到时间
                            strTestTime = DateTime.Now.ToString("yyyy-MM-dd");
                        }

                        for (int j = 0; j < correspondenceArray.Length; j++)
                        {
                            string lis   = correspondenceArray[j].Split(',')[0];
                            string zlchs = correspondenceArray[j].Split(',')[1];
                            if (ss[i].IndexOf('|' + lis + '|') > 0)
                            {
                                sBuilder.Append(zlchs + ',' + ss[i].Split('|')[3] + '|');
                            }
                        }
                    }
                }
                string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                string[] strs = str.Split('|');

                string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                string testItemID      = "";
                string TestResultValue = "";
                for (int i = 0; i < strs.Length; i++)
                {
                    FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                    if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                    {
                        ChannelType = null;
                        writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                    }
                    else
                    {
                        testItemID      = FindRow[0]["项目id"].ToString();
                        ChannelType     = "0"; //普通结果
                        TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                    }
                }

                TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                saveResult      = new SaveResult();
                if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                {
                    saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                    if (ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }

                if (!ImmediatelyUpdate)
                {
                    saveResult.UpdateData();
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }
        }
Exemplo n.º 12
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            try
            {
                string       file                      = "URIT1500样本号重复处理.txt";
                StreamReader sr                        = new StreamReader(@".\URIT1500.txt", Encoding.Default);
                string       correspondence            = sr.ReadLine();
                string[]     correspondenceArray       = correspondence.Split('|');
                string       unameAndPwdAndIpAndDBname = sr.ReadLine();
                string       uname                     = unameAndPwdAndIpAndDBname.Split(',')[0].Trim();
                string       pwd                       = unameAndPwdAndIpAndDBname.Split(',')[1].Trim();
                string       ip                        = unameAndPwdAndIpAndDBname.Split(',')[2].Trim();
                string       dbName                    = unameAndPwdAndIpAndDBname.Split(',')[3].Trim();
                strTestTime = DateTime.Now.ToString("yyyy-MM-dd");
                //  strTestTime = "2018-11-05";
                sr.Close();
                string conn;
                //if (checkBox1.Checked)
                //    con = "server=.;database=in_database;integrated security=SSPI";
                //else
                conn = "server=in_ip;database=in_database;uid=in_uname;pwd=in_pwd";
                conn = conn.Replace("in_ip", ip);
                conn = conn.Replace("in_database", dbName);
                conn = conn.Replace("in_uname", uname);
                conn = conn.Replace("in_pwd", pwd);
                string sql = "select  distinct(b.sxh) as itemNo   from  th_us2020.dbo.jzxx b  where Convert(varchar(100),b.rq,112)='in_strTestTime'";
                sql = sql.Replace("in_strTestTime", strTestTime);
                DataTable dt = SQLServerHelper.GetDataTable(sql, conn);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        StringBuilder sBuilder = new StringBuilder("");
                        strSampleNo = item["ItemNo"].ToString();
                        string sqlSelect = @"select  a.caption as itemName ,a.tag as itemName2 ,a.val as itemVal from th_us2020.dbo.jz_item a,th_us2020.dbo.jzxx b where a.id=b.id and Convert(varchar(100),rq,112)='in_strTestTime' and  b.sxh='in_strSampleNo'";
                        sqlSelect = sqlSelect.Replace("in_strTestTime", strTestTime);
                        sqlSelect = sqlSelect.Replace("in_strSampleNo", strSampleNo);
                        DataTable     dt2        = SQLServerHelper.GetDataTable(sqlSelect, conn);
                        List <string> TestValues = new List <string>();
                        if (dt2.Rows.Count > 0)
                        {
                            foreach (DataRow item2 in dt2.Rows)
                            {
                                string itemName  = item2["itemName"].ToString().ToUpper() + item2["itemName2"].ToString().ToUpper();
                                string itemValue = item2["itemVal"].ToString().ToUpper();
                                foreach (var itemCorres in correspondenceArray)
                                {
                                    sBuilder.Append(itemName + ',' + itemValue + '|');
                                }
                                TestValues.Add(itemName + ":" + itemValue.ToString());
                            }
                        }
                        /////
                        if (Helper.CompareSampleNoAndTime(file, strSampleNo, strTestTime, TestValues))
                        {
                            continue;
                        }
                        string   str             = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                        string[] strs            = str.Split('|');
                        string   ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string   testItemID      = "";
                        string   TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                            }
                        }

                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                    }
                }
            }
            catch (Exception eex)
            {
            }


            System.Threading.Thread.Sleep(3000);
        }
Exemplo n.º 13
0
        /// <summary>
        ///     '设备标准接口
        //'功能:解析数据
        //'参数:
        //'strSource:要解析的原始串
        //'strResult:返回的检验结果(各仪器解析程序必须按以下标准组织结果)
        //'   每组检验结果以||分隔,元素之间以|分隔
        //'   第0个元素:检验时间
        //'   第1个元素:样本序号(标本号^条码号^样本类型)
        //'   第2个元素:检验人
        //'   第3个元素:标本
        //'   第4个元素:预留
        //'   从第5个元素开始为检验结果,每2个元素表示一个检验项目。
        //'       如:第5i个元素为检验项目,第5i+1个元素为检验结果
        //'strReserved:最后不能完成解析的原始串,需要返回作后续处理
        //'strCmd:如果需要,可返回向设备发送的命令
        //'补充图像的方式:
        //'                   1.图像数据跟随指标数据后,使用回车换行符来分隔。
        //'                   2.有多个图像数据时使用"^"来分隔
        //'                   3.单个图像数据格式: 图像画法 0=直方图  1=散点图
        //'                     a) 直方图: 图像名称;图像画法(0=直方图  1=散点图);X1;X2;X3;X4;X5...
        //'                     b) 散点图: 图像名称;图像画法(0=直方图  1=散点图):
        //'                        例:00000100001000010000100010;00000100001000010000100010;
        //'                        说明:1.散点图以点阵方式保存每一行使用分号来分隔.
        //'                             2.有多少个分号就有多少行
        //'                             3.每一行有多少个点由每一行的长度来确定
        //'                             3.画图的方向是从最上边向下画,如有65*65的图就是从65行开始画(最上边开始画)
        /// 检验日期|
        /// </summary>
        /// <param name="ResultString"></param>
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string channel = "0";
            // string testItemID = "";
            string  result           = "";
            decimal CONVERSION_RATIO = 0;
            decimal DECIMAL_LEVEL    = 2;
            string  ParString        = "";
            string  SingleResult     = "";
            string  ResultString     = "";
            string  UnknownResult    = ""; //未知项目
            string  TempCmd          = "";

            DataSet ds_GraphChannel = new DataSet();
            DataSet dsGUID          = new DataSet();
            DataSet dsTestItem      = new DataSet();

            string TestResultInfo = "";

            strReserved = "";
            strResult   = "";
            strCmd      = "";

            string connSting;

            connSting = "server=localhost;database=ave2;Integrated Security=True ";
            SqlConnection sConn = new SqlConnection(connSting);

            try
            {
                sConn.Open();
            }
            catch (Exception ex)
            {
                Console.WriteLine("链接错误:" + ex.Message);
            }

            init();//初始化

            try
            {
                string    strTestTime;        //检验时间
                string    strSampleNo;        //标本号
                string    strBarCode    = ""; //条码
                string    strOperator   = ""; //检验医师
                string    strSampleType = ""; //检验类型
                string    StrSpecimen   = ""; //标本类型
                string    ChannelType;        //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                string    testItemID = "";    //通道项目ID
                DataRow[] FindRow;            //解析设置
                TestGraph  = new List <string>();
                saveResult = new SaveResult();
                IsUpdate(strSource);//重新检查是否有新数据

                //tItemChannel得到数据集,提供样本号为后面判断是否有新数据

                tItemChannel = OracleHelper.GetDataTable(@"Select 通道编码, m.项目id, Nvl(小数位数, 2) As 小数位数, Nvl(换算比, 0) As 换算比, Nvl(加算值, 0) As 加算值, j.结果类型
                                                                                From 仪器检测项目 m, 检验项目 j
                                                                                Where m.项目id = j.项目id and m.仪器Id='" + strInstrument_id + "'");
                if (dsResult.Tables[0].Rows.Count == 0)//判断是否有新标本
                {
                    writelog.Write(strDevice, DateTime.Now.ToString() + "未检测到新数据!", "log");
                    return;
                }
                DataTable dt1 = SelectDistinct(dsResult.Tables[0], "sample_id");
                foreach (DataRow dr in dt1.Rows) //循环标本号
                {
                    strTestTime = dr["sample_id"].ToString().Substring(0, 4) + "-" + dr["sample_id"].ToString().Substring(4, 2) + "-" + dr["sample_id"].ToString().Substring(6, 2);
                    strSampleNo = dr["sample_id"].ToString().Substring(8, 4);
                    string TestResultValue = "";

                    foreach (DataRow dr1 in dsResult.Tables[0].Select("sample_id='" + dr["sample_id"].ToString() + "'"))
                    {
                        string _channelNo = dr1["item"].ToString();
                        FindRow = tItemChannel.Select("通道编码='" + _channelNo.Trim() + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + _channelNo, "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + dr1["result"].ToString() + "|";
                        }
                    }
                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    try
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, null);
                        saveResult.UpdateData();
                        writelog.Write(strDevice, "解析结果: " + TestResultValue, "result");
                    }
                    catch (Exception ex)
                    {
                        writelog.Write(strDevice, "保存失败: " + ex.ToString(), "log");
                    }
                }
            }
            catch (Exception exp1)
            {
                writelog.Write(strDevice, "处理失败: " + exp1.ToString(), "log");
            }
        }
Exemplo n.º 14
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            try
            {
                string       file                = "D280样本号重复处理.txt";
                StreamReader sr                  = new StreamReader(@".\D280.txt", Encoding.Default);
                string       correspondence      = sr.ReadLine();
                string[]     correspondenceArray = correspondence.Split('|');
                string       configPath          = sr.ReadLine();

                strTestTime = DateTime.Now.ToString("yyyy-MM-dd");
                sr.Close();
                if (!File.Exists(configPath))
                {
                    writelog.Write(strDevice, "找不到数据库文件: " + configPath, "log");
                    return;
                }
                string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password=iamysh";
                string sql     = "select distinct(sample_id) as ItemNo  from  SAMPLE_ITEM_TEST_RESULT   where   format(time,'yyyy-MM-dd')='in_dateTimeName'";
                sql = sql.Replace("in_dateTimeName", strTestTime);
                DataTable dt = OleDBHelper.GetOledbDataTable(sql, connStr);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        StringBuilder sBuilder = new StringBuilder("");
                        strSampleNo = item["ItemNo"].ToString();
                        string sqlSelect = @"  select *  from SAMPLE_ITEM_TEST_RESULT where sample_id='in_strSampleNo' and format(time,'yyyy-MM-dd')='in_dateTimeName' ";
                        sqlSelect = sqlSelect.Replace("in_dateTimeName", strTestTime);
                        sqlSelect = sqlSelect.Replace("in_strSampleNo", strSampleNo);
                        DataTable     dt2        = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);
                        List <string> TestValues = new List <string>();
                        if (dt2.Rows.Count > 0)
                        {
                            foreach (DataRow item2 in dt2.Rows)
                            {
                                string itemName  = item2["item"].ToString().ToUpper();
                                string itemValue = item2["result"].ToString().ToUpper();
                                TestValues.Add(itemName + ":" + itemValue.ToString());
                                sBuilder.Append(itemName + ',' + itemValue + '|');
                            }
                        }

                        /////
                        if (Helper.CompareSampleNoAndTime(file, strSampleNo, strTestTime, TestValues))
                        {
                            continue;
                        }
                        string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                        string[] strs = str.Split('|');

                        string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string testItemID      = "";
                        string TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                            }
                        }

                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }

            System.Threading.Thread.Sleep(5000);
        }
Exemplo n.º 15
0
        /// <summary>
        ///     '设备标准接口
        //'功能:解析数据
        //'参数:
        //'strSource:要解析的原始串
        //'strResult:返回的检验结果(各仪器解析程序必须按以下标准组织结果)
        //'   每组检验结果以||分隔,元素之间以|分隔
        //'   第0个元素:检验时间
        //'   第1个元素:样本序号(标本号^条码号^样本类型)
        //'   第2个元素:检验人
        //'   第3个元素:标本
        //'   第4个元素:预留
        //'   从第5个元素开始为检验结果,每2个元素表示一个检验项目。
        //'       如:第5i个元素为检验项目,第5i+1个元素为检验结果
        //'strReserved:最后不能完成解析的原始串,需要返回作后续处理
        //'strCmd:如果需要,可返回向设备发送的命令
        //'补充图像的方式:
        //'                   1.图像数据跟随指标数据后,使用回车换行符来分隔。
        //'                   2.有多个图像数据时使用"^"来分隔
        //'                   3.单个图像数据格式: 图像画法 0=直方图  1=散点图
        //'                     a) 直方图: 图像名称;图像画法(0=直方图  1=散点图);X1;X2;X3;X4;X5...
        //'                     b) 散点图: 图像名称;图像画法(0=直方图  1=散点图):
        //'                        例:00000100001000010000100010;00000100001000010000100010;
        //'                        说明:1.散点图以点阵方式保存每一行使用分号来分隔.
        //'                             2.有多少个分号就有多少行
        //'                             3.每一行有多少个点由每一行的长度来确定
        //'                             3.画图的方向是从最上边向下画,如有65*65的图就是从65行开始画(最上边开始画)
        /// 检验日期|
        /// </summary>
        /// <param name="ResultString"></param>
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string channel = "0";
            // string testItemID = "";
            string  result           = "";
            decimal CONVERSION_RATIO = 0;
            decimal DECIMAL_LEVEL    = 2;
            string  ParString        = "";
            string  SingleResult     = "";
            string  ResultString     = "";
            string  UnknownResult    = ""; //未知项目
            string  TempCmd          = "";

            DataSet ds_GraphChannel = new DataSet();
            DataSet dsGUID          = new DataSet();
            DataSet dsTestItem      = new DataSet();

            string TestResultInfo = "";

            strReserved = "";
            strResult   = "";
            strCmd      = "";

            init();//初始化

            try
            {
                string    strTestTime;        //检验时间
                string    strSampleNo;        //标本号
                string    strBarCode    = ""; //条码
                string    strOperator   = ""; //检验医师
                string    strSampleType = ""; //检验类型
                string    StrSpecimen   = ""; //标本类型
                string    ChannelType;        //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                string    testItemID = "";    //通道项目ID
                DataRow[] FindRow;            //解析设置
                TestGraph  = new List <string>();
                saveResult = new SaveResult();
                string[] strTemp;
                //通讯串口配置:19200 8 1 无
                //strSource = "A00005111101116290003000000003640B";

                writelog.Write(strDevice, "原始字符串:" + strSource, "raw");
                //完整字符串
                if (strSource.Contains(Microsoft.VisualBasic.Strings.Chr(3).ToString()))
                {
                    strTemp = strSource.Split('#');
                    //标本号
                    strSampleNo = strTemp[1].Substring(4, 5);
                    //检验时间
                    strTestTime = strTemp[1].Substring(11, 10) + " " + strTemp[2].TrimStart();
                    for (int i = 4; i < strTemp.Length - 1; i++)
                    {
                        strTemp[i]       = strTemp[i].TrimStart();
                        strTemp[i]       = strTemp[i].Replace("*", "");
                        TestResultValue += strTemp[i].Substring(0, strTemp[i].IndexOf(" ") + 1).Trim() + "^" + strTemp[i].Substring(strTemp[i].IndexOf(" ") + 1).Trim() + "|";
                    }
                    strSampleType = "0";//样本类型
                    //一个标本号的检验信息
                    //组合标准:检验时间|样本号^样本类型^试管号|检验医师|标本类型|检验结果
                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    //保存分析结果日志
                    writelog.Write(strDevice, "分析结果:" + TestResultValue, "result");
                    //保存数据
                    saveResult = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                else
                {
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }
        }
Exemplo n.º 16
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            try
            {
                string       file                = "HZK320P样本号重复处理.txt";
                StreamReader sr                  = new StreamReader(@".\HZK320P.txt", System.Text.Encoding.GetEncoding("GB2312"));
                string       correspondence      = sr.ReadLine();
                string[]     correspondenceArray = correspondence.Split('|');
                string       configPath          = sr.ReadLine();
                string       password            = sr.ReadLine();
                string       dateTime            = DateTime.Now.ToString("yyyy-MM-dd");
                sr.Close();
                //拆分路径,寻找地址
                string configPathDateTime = DateTime.Now.ToString("yyyyMMdd");
                configPath = configPath + "yb" + configPathDateTime + ".mdb";

                if (!File.Exists(configPath))
                {
                    writelog.Write(strDevice,
                                   configPath + "没有找到,系统进入下一个循环周期", "log");
                    return;
                }
                string    connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password="******"select distinct(ybno) as ItemNo  from  zzjgb ";
                DataTable dt      = OleDBHelper.GetOledbDataTable(sql, connStr);
                strTestTime = dateTime;

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        StringBuilder sBuilder = new StringBuilder("");
                        strSampleNo = item["ItemNo"].ToString();
                        string sqlSelect = @"select  *  from  zzjgb where    ybno=in_编号  ";
                        sqlSelect = sqlSelect.Replace("in_编号", strSampleNo);

                        DataTable dt2 = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);

                        List <string> TestValues = new List <string>();
                        if (dt2.Rows.Count > 0)
                        {
                            foreach (DataRow item2 in dt2.Rows)
                            {
                                string itemName  = item2["ywjc"].ToString();
                                double itemValue = Convert.ToDouble(item2["zzjg"].ToString());
                                itemValue = Math.Round(itemValue, 2);
                                TestValues.Add(itemName + ":" + itemValue.ToString());
                                sBuilder.Append(itemName + ',' + itemValue + '|');
                            }
                        }

                        /////
                        if (Helper.CompareSampleNoAndTime(file, strSampleNo, strTestTime, TestValues))
                        {
                            continue;
                        }
                        string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                        string[] strs = str.Split('|');

                        string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string testItemID      = "";
                        string TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                            }
                        }

                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                    }
                }
            }

            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }

            System.Threading.Thread.Sleep(3000);
        }
Exemplo n.º 17
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string strTestTime = ""; //检验时间
            string strSampleNo = ""; //标本号
            string strBarCode  = ""; //条码
            string strOperator = ""; //检验医师

            /////
            char   CR     = Convert.ToChar(13); //换行符
            char   SB     = Convert.ToChar(11); //开始符
            char   EB     = Convert.ToChar(28); //结束符
            string endStr = CR + "" + EB + CR;;

            strResult += strSource;
            strCmd     = Convert.ToChar(0x06) + "";
            if (strResult.EndsWith(endStr) || strResult.EndsWith("test_end"))
            {
                strSource = strResult;
                strResult = "";
                string[] analysis = strSource.Split('|');
                //取当前时间
                string       CurrentTime    = DateTime.Now.ToString("yyyyMMddHHmmss");
                string       messageTime    = analysis[6];
                string       messageID      = analysis[9];
                StreamReader sr             = new StreamReader(@".\Tzone.YZDC1.txt", Encoding.Default);
                string       correspondence = sr.ReadLine();
                sr.Close();
                string ACK_R01_OK = SB + @"MSH|^~\&|||||{0}||ACK^R01|{1}|P|2.3.1||||0||ASCII|||" + CR
                                    + "MSA|AA|{1}|Message accepted|||0|" + CR
                                    + EB + CR;
                // strCmd = string.Format(ACK_R01_OK, strTestTime, messageID);
                string[]      correspondenceArray = correspondence.Split('|');
                StringBuilder sBuilder            = new StringBuilder("");
                try
                {
                    writelog.Write(strDevice, "接收数据开始:" + strSource, "log");
                    writelog.Write(strDevice, "接收数据完成", "log");
                    string[] strSourceArray = strSource.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strSourceArray.Length; i++)
                    {
                        if (strSourceArray[i].IndexOf("PID") != -1)
                        {
                            strSampleNo = strSourceArray[i].Split(new char[] { '|' })[1];
                        }

                        if (strSourceArray[i].IndexOf("OBR") != -1)
                        {
                            if (!"".Equals(strSourceArray[i].Split('|')[6]))
                            {
                                CurrentTime = strSourceArray[i].Split('|')[6];
                            }
                            strTestTime = CurrentTime.Substring(0, 4) + "-"
                                          + CurrentTime.Substring(4, 2) + "-" + CurrentTime.Substring(6, 2);
                        }
                        if (strSourceArray[i].IndexOf("OBX") != -1)
                        {
                            for (int j = 0; j < correspondenceArray.Length; j++)
                            {
                                string lis       = correspondenceArray[j].Split(',')[0].ToUpper();
                                string zlchs     = correspondenceArray[j].Split(',')[1].ToUpper();
                                string ItemName  = strSourceArray[i].Split('|')[3].ToUpper();
                                string ItemValue = strSourceArray[i].Split('|')[5];
                                if (ItemName == lis)
                                {
                                    sBuilder.Append(zlchs + ',' + ItemValue + '|');
                                }
                            }
                        }
                    }
                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1);
                    string[] strs = str.Split('|');

                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }
                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo))
                    {
                        //strInstrument_id 替换到目标设备

                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);

                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }
                strResult = "";
            }
            else
            {
                strResult += strSource;
            }
        }
Exemplo n.º 18
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            try
            {
                string wbc    = ""; //白细胞数目
                string neu    = ""; //中性粒细胞百分比
                string neu2   = ""; //中性粒细胞数目
                string bas    = ""; //嗜碱性粒细胞百分比
                string bas2   = ""; //嗜碱性粒细胞数目
                string eos    = ""; //嗜酸性粒细胞百分比
                string eos2   = ""; //嗜酸性粒细胞数目
                string lym    = ""; //淋巴细胞百分比
                string lym2   = ""; //淋巴细胞数目
                string mon    = ""; //单核细胞百分比
                string mon2   = ""; //单核细胞数目
                string rbc    = ""; //红细胞数目
                string hgb    = ""; //血红蛋白浓度
                string mcv    = ""; //平均红细胞体积
                string mch    = ""; //平均红细胞血红蛋白含量
                string mchc   = ""; //平均红细胞血红蛋白浓度
                string rdw_cv = ""; //红细胞分布宽度变异系数
                string rdw_sd = ""; //红细胞分布宽度标准差
                string hct    = ""; //红细胞压积
                string plt    = ""; //血小板数目
                string mpv    = ""; //平均血小板体积
                string pdw    = ""; //血小板分布宽度
                string pct    = ""; //血小板压积

                if (strSource.Contains(((char)11).ToString()))
                {
                    string[] ss          = strSource.Split(new char[] { '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    string   ChannelCode = "";
                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (ss[i].Split(new char[] { '|' })[0].Replace("\n", "").Equals("OBR"))
                        {
                            strSampleNo = ss[i].Split('|')[3];
                            string times = ss[i].Split('|')[7];
                            strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                        }
                        else if (ss[i].Split(new char[] { '|' })[0].Replace("\n", "").Equals("OBX"))
                        {
                            //OBX|6|NM|6690-2^WBC^LN||5.68|10*9/L|4.00-10.00|N|||F
                            if (ss[i].IndexOf("6690-2^WBC^LN") > 0)
                            {
                                wbc = ss[i].Split('|')[5];
                            }
                            //OBX|7|NM|704-7^BAS#^LN||0.01|10*9/L|0.00-0.10|N|||F
                            else if (ss[i].IndexOf("704-7^BAS#^LN") > 0)
                            {
                                bas2 = ss[i].Split('|')[5];
                            }
                            //OBX|8|NM|706-2^BAS%^LN||0.2|%|0.0-1.0|N|||F
                            else if (ss[i].IndexOf("706-2^BAS%^LN") > 0)
                            {
                                bas = ss[i].Split('|')[5];
                            }
                            //OBX|9|NM|751-8^NEU#^LN||2.92|10*9/L|2.00-7.00|N|||F
                            else if (ss[i].IndexOf("751-8^NEU#^LN") > 0)
                            {
                                neu = ss[i].Split('|')[5];
                            }
                            //OBX|10|NM|770-8^NEU%^LN||51.3|%|50.0-70.0|N|||F
                            else if (ss[i].IndexOf("770-8^NEU%^LN") > 0)
                            {
                                neu2 = ss[i].Split('|')[5];
                            }
                            //OBX|11|NM|711-2^EOS#^LN||0.14|10*9/L|0.02-0.50|N|||F
                            else if (ss[i].IndexOf("711-2^EOS#^LN") > 0)
                            {
                                eos = ss[i].Split('|')[5];
                            }
                            //OBX|12|NM|713-8^EOS%^LN||2.5|%|0.5-5.0|N|||F
                            else if (ss[i].IndexOf("713-8^EOS%^LN") > 0)
                            {
                                eos2 = ss[i].Split('|')[5];
                            }
                            //OBX|13|NM|731-0^LYM#^LN||2.32|10*9/L|0.80-4.00|N|||F
                            else if (ss[i].IndexOf("731-0^LYM#^LN") > 0)
                            {
                                lym = ss[i].Split('|')[5];
                            }
                            //OBX|14|NM|736-9^LYM%^LN||40.8|%|20.0-40.0|H|||F
                            else if (ss[i].IndexOf("736-9^LYM%^LN") > 0)
                            {
                                lym2 = ss[i].Split('|')[5];
                            }
                            //OBX|15|NM|742-7^MON#^LN||0.29|10*9/L|0.12-1.20|N|||F
                            else if (ss[i].IndexOf("742-7^MON#^LN") > 0)
                            {
                                mon = ss[i].Split('|')[5];
                            }
                            //OBX|16|NM|5905-5^MON%^LN||5.2|%|3.0-12.0|N|||F
                            else if (ss[i].IndexOf("5905-5^MON%^LN") > 0)
                            {
                                mon2 = ss[i].Split('|')[5];
                            }
                            else if (ss[i].IndexOf("789-8^RBC^LN") > 0)
                            {
                                rbc = ss[i].Split('|')[5];
                            }
                            //OBX|22|NM|718-7^HGB^LN||114|g/L|110-150|N|||F
                            else if (ss[i].IndexOf("718-7^HGB^LN") > 0)
                            {
                                hgb = ss[i].Split('|')[5];
                            }
                            //OBX|23|NM|787-2^MCV^LN||87.5|fL|80.0-100.0|N|||F
                            else if (ss[i].IndexOf("787-2^MCV^LN") > 0)
                            {
                                mcv = ss[i].Split('|')[5];
                            }
                            //OBX|24|NM|785-6^MCH^LN||30.4|pg|27.0-34.0|N|||F
                            else if (ss[i].IndexOf("785-6^MCH^LN") > 0)
                            {
                                mch = ss[i].Split('|')[5];
                            }
                            //OBX|25|NM|786-4^MCHC^LN||347|g/L|320-360|N|||F
                            else if (ss[i].IndexOf("786-4^MCHC^LN") > 0)
                            {
                                mchc = ss[i].Split('|')[5];
                            }
                            //OBX|26|NM|788-0^RDW-CV^LN||10.8|%|11.0-16.0|L|||F
                            else if (ss[i].IndexOf("788-0^RDW-CV^LN") > 0)
                            {
                                rdw_cv = ss[i].Split('|')[5];
                            }
                            //OBX|27|NM|21000-5^RDW-SD^LN||39.9|fL|35.0-56.0|N|||F
                            else if (ss[i].IndexOf("21000-5^RDW-SD^LN") > 0)
                            {
                                rdw_sd = ss[i].Split('|')[5];
                            }
                            //OBX|28|NM|4544-3^HCT^LN||32.8|%|37.0-47.0|L|||F
                            else if (ss[i].IndexOf("4544-3^HCT^LN") > 0)
                            {
                                hct = ss[i].Split('|')[5];
                            }
                            //OBX|29|NM|777-3^PLT^LN||299|10*9/L|100-300|N|||F
                            else if (ss[i].IndexOf("777-3^PLT^LN") > 0)
                            {
                                plt = ss[i].Split('|')[5];
                            }
                            //OBX|30|NM|32623-1^MPV^LN||8.9|fL|6.5-12.0|N|||F
                            else if (ss[i].IndexOf("32623-1^MPV^LN") > 0)
                            {
                                mpv = ss[i].Split('|')[5];
                            }
                            //OBX|31|NM|32207-3^PDW^LN||15.9||9.0-17.0|N|||F
                            else if (ss[i].IndexOf("32207-3^PDW^LN") > 0)
                            {
                                pdw = ss[i].Split('|')[5];
                            }
                            //OBX|32|NM|10002^PCT^99MRC||0.266|%|0.108-0.282|N|||F
                            else if (ss[i].IndexOf("10002^PCT^99MRC") > 0)
                            {
                                pct = ss[i].Split('|')[5];
                            }
                        }
                    }
                }

                string[] strs = ("wbc," + wbc + "|neu," + neu + "|neu2," + neu2 + "|bas," + bas + "|bas2," + bas2 + "|eos," + eos + "|eos2," + eos2 + "|lym," + lym + "|lym2," + lym2 + "|mon," + mon + "|mon2," + mon2 + "|rbc," + rbc + "|hgb," + hgb + "|mcv," + mcv + "|mch," + mch + "|mchc," + mchc + "|rdw_cv," + rdw_cv + "|rdw_sd," + rdw_sd + "|hct," + hct + "|plt," + plt + "|mpv," + mpv + "|pdw," + pdw + "|pct," + pct).Split('|');

                //DataTable dt = new DataTable();
                //DataSet ds = new DataSet();
                //dt = ds.Tables[0];
                string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                string testItemID      = "";
                string TestResultValue = "";
                for (int i = 0; i < strs.Length; i++)
                {
                    // string ChannelCode = dt.Rows[i]["ChannelCode"].ToString();
                    // string _channelNo = ChannelCode;
                    FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                    if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                    {
                        ChannelType = null;
                        writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                    }
                    else
                    {
                        testItemID      = FindRow[0]["项目id"].ToString();
                        ChannelType     = "0"; //普通结果
                        TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                    }
                    //dt = ds.Tables[0];
                    //TestResultValue = TestResultValue + "testItemID项目ID" + "^" + strs[i][1] + "|";
                }

                TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                saveResult      = new SaveResult();
                if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                {
                    saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                    if (ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                // 2011-06-21|0007^0^||标本||62B16EF4-7F88-4498-BF82-C107EE528513^15  leu/uL|252260FD-EFFD-45C2-B79B-8309D678F20C^|A135CEC5-C8E2-4FF5-BEB1-BA0944093A59^Normal|D7F59AD1-4F9A-4995-A75B-1528FCC42448^|8F2E74E4-D1F0-47CD-97C5-EA35379F4CFC^0.6 mmol/L|869F1A2C-38A3-4613-91B5-A1EAD630FD0F^0      g/L|66E36E0A-B509-4FF2-B440-6B7D2D76CD24^80  ery/uL|54A2C7DF-1D92-4467-8FC0-C3642C170F37^5.0|4FEAF5E1-EDD4-4171-B0BA-FF1F2C6A6C9D^>1.030|16401182-86E3-4CE1-9302-3934311ED89B^0   mmol/L|F08FE403-B04D-4B34-8AA2-A5CF63453AB4^0   mmol/L|
                if (!ImmediatelyUpdate)
                {
                    saveResult.UpdateData();
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }
        }
Exemplo n.º 19
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string strSampleNoTemp = "";
            string msg             = "";
            string interface_name  = "UT55";

            try
            {
                string file     = "qiezixi样本重复处理.txt";
                string dateTime = DateTime.Now.ToString("yyyyMMdd");
                strTestTime = DateTime.Now.ToString("yyyy-MM-dd");
                string connStr = "server=.;database=tjxt;integrated security=SSPI";

                string sql = @"select  distinct(jc_sqh)    as sampleNo  from  dbo.tj_tjxmjg a ,dbo.tj_item b  where  Convert(varchar(100),a.jg_tjtime,112) = 'in_datetime'
and  a.item_id=b.item_id  and  jg_outsys ='in_jg_outsys'";
                sql = sql.Replace("in_datetime", dateTime);
                sql = sql.Replace("in_jg_outsys", interface_name);
                DataTable dt = SQLServerHelper.GetDataTable(sql, connStr, ref msg);
                foreach (DataRow item in dt.Rows)
                {
                    StringBuilder sBuilder = new StringBuilder("");
                    strSampleNoTemp = item["sampleNo"].ToString().Trim();
                    string sqlSelect = @"select  b.item_name as ItemName,a.jg_tjjg as ItemValue from  tj_tjxmjg a ,tj_item b  where  Convert(varchar(100),a.jg_tjtime,112) = 'in_datetime'
and  a.item_id=b.item_id  and  jg_outsys ='in_jg_outsys' and jc_sqh=in_sampleNo  ";
                    sqlSelect = sqlSelect.Replace("in_datetime", dateTime);
                    sqlSelect = sqlSelect.Replace("in_sampleNo", strSampleNoTemp);
                    sqlSelect = sqlSelect.Replace("in_jg_outsys", interface_name);

                    DataTable     dt2        = SQLServerHelper.GetDataTable(sqlSelect, connStr, ref msg);
                    List <string> TestValues = new List <string>();
                    foreach (DataRow item1 in dt2.Rows)
                    {
                        string itemName  = item1["ItemName"].ToString().ToUpper();
                        string itemValue = item1["ItemValue"].ToString().ToUpper();
                        TestValues.Add(itemName + ":" + itemValue);
                        sBuilder.Append(itemName + ',' + itemValue + '|');
                    }
                    /////


                    if (Helper.CompareSampleNoAndTime(file, strSampleNoTemp, strTestTime, TestValues))
                    {
                        string abc = "";
                    }
                    else
                    {
                        strSampleNo = strSampleNoTemp;
                        string   str             = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                        string[] strs            = str.Split('|');
                        string   ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string   testItemID      = "";
                        string   TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                            }
                        }

                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                writelog.Write(strDevice, "msg处理失败: " + msg, "log");
            }
            System.Threading.Thread.Sleep(5000);
        }
Exemplo n.º 20
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            char CR;                         //换行符
            char SB;                         //开始符
            char EB;                         //结束符

            CR         = Convert.ToChar(13); //换行符
            SB         = Convert.ToChar(11); //开始符
            EB         = Convert.ToChar(04); //结束符
            strResult += strSource;
            strCmd     = Convert.ToChar(06) + "";
            if (strResult.EndsWith(EB + "") || strResult.EndsWith("test-end"))
            {
                try
                {
                    writelog.Write(strDevice, "接收到数据: " + strResult, "log");
                    StreamReader  sr             = new StreamReader(@".\AIA900.txt", Encoding.Default);
                    StringBuilder sBuilder       = new StringBuilder("");
                    string        correspondence = sr.ReadLine();
                    sr.Close();
                    string[] correspondenceArray = correspondence.Split('|');
                    string[] strSourceArray      = strResult.Split(new char[] { '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strSourceArray.Length; i++)
                    {
                        if (strSourceArray[i].IndexOf(Convert.ToChar(2) + "1H") != -1)
                        {
                            strTestTime = strSourceArray[i].Split('|')[13];
                            strTestTime = strTestTime.Substring(0, 4) + "-" + strTestTime.Substring(4, 2) + "-" + strTestTime.Substring(6, 2);
                        }

                        if (strSourceArray[i].Split('|')[0].IndexOf("O") != -1)
                        {
                            strSampleNo = strSourceArray[i].Split('|')[2];
                        }
                        if (strSourceArray[i].Split('|')[0].IndexOf("R") != -1)
                        {
                            string[] strNameValue = strSourceArray[i].Split('|');
                            string   strName      = strNameValue[2];
                            string   strValue     = strNameValue[3];
                            for (int j = 0; j < correspondenceArray.Length; j++)
                            {
                                string lis   = correspondenceArray[j].Split(',')[0];
                                string zlchs = correspondenceArray[j].Split(',')[1];
                                if (strName.IndexOf(lis) >= 0)
                                {
                                    sBuilder.Append(zlchs + ',' + strValue + '|');
                                }
                            }
                        }
                    }
                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1);
                    string[] strs = str.Split('|');

                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1].Replace("RuPT", "阴性") + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    strResult = "";
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }

                strResult = "";
            }
        }
Exemplo n.º 21
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            strResult += strSource;
            string endStr = Convert.ToInt16(0x03) + "";

            if (strSource.EndsWith(endStr))
            {
                strSource = strResult;
                try
                {
                    bool isSampleBar = true;
                    //将接收到的字符串写入到日志文件中
                    writelog.Write(strDevice, "接收数据开始:\r\n " + strSource, "log");
                    writelog.Write(strDevice, "接收数据完成 ", "log");
                    //设置读取E411文本文件
                    StreamReader sr             = new StreamReader(@".\U500.txt");
                    string       correspondence = sr.ReadLine();
                    sr.Close();
                    string[]      correspondenceArray = correspondence.Split('|');
                    StringBuilder sBuilder            = new StringBuilder("");

                    string[] ss          = strSource.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    string   ChannelCode = "";


                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (i == 1)
                        {
                            //2016 JUN 14   10:50:47
                            string[] times  = ss[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            string   year   = times[0];
                            string   mounth = times[1];
                            string   day    = times[2];
                            string   time   = times[3];
                            DateTime dt     = Convert.ToDateTime(year + mounth + day);
                            string   date   = dt.ToString("yyyy-MM-dd");
                            strTestTime = date + " " + time;
                        }
                        writelog.Write(strDevice, i + "  数据解析:" + ss[i] + "\r\n", "log");
                        // ID:  0-2217     (00002204)
                        if (ss[i].IndexOf("ID") != -1)
                        {
                            string[] temp = ss[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            strSampleNo = temp[1].Split('-')[1];
                        }

                        for (int j = 0; j < correspondenceArray.Length; j++)
                        {
                            string lis   = correspondenceArray[j].Split(',')[0];
                            string zlchs = correspondenceArray[j].Split(',')[1];
                            if (ss[i].IndexOf(lis) >= 0)
                            {
                                string temp = ss[i].Trim();
                                sBuilder.Append(zlchs + ',' + temp.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1] + '|');
                            }
                        }
                    }

                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                    string[] strs = str.Split('|');

                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        //strInstrument_id 替换到目标设备
                        if (string.IsNullOrEmpty(strReserved))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        else
                        {
                            saveResult.SaveTextResult(strReserved, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }

                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }

                strResult = "";
            }
        }
Exemplo n.º 22
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string strTestTime = ""; //检验时间
            string strSampleNo = ""; //标本号
            string strBarCode  = ""; //条码

            strResult += strSource;
            string endStr = Convert.ToChar(0x03) + "";

            if (strSource.EndsWith(endStr))
            {
                strSource = strResult;
                strResult = "";
                try
                {
                    bool isSampleBar = true;
                    writelog.Write(strDevice, "接收数据开始:\r\n " + strSource, "log");
                    writelog.Write(strDevice, "接收数据完成 ", "log");
                    StreamReader sr             = new StreamReader(@".\GEB400.txt", Encoding.Default);
                    string       correspondence = sr.ReadLine();
                    sr.Close();
                    string[]      correspondenceArray = correspondence.Split('|');
                    StringBuilder sBuilder            = new StringBuilder("");

                    string[] ss = strSource.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

                    for (int i = 0; i < ss.Length; i++)
                    {
                        if (ss[i].IndexOf("#") >= 0)
                        {
                            strSampleNo = ss[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0].Replace("#", "");
                            strTestTime = ss[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        }
                        for (int j = 0; j < correspondenceArray.Length; j++)
                        {
                            string lis   = correspondenceArray[j].Split(',')[0];
                            string zlchs = correspondenceArray[j].Split(',')[1];
                            if (ss[i].IndexOf(lis) >= 0)
                            {
                                string temp = ss[i].Trim();
                                sBuilder.Append(zlchs + ',' + temp.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[1] + '|');
                            }
                        }
                    }

                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                    string[] strs = str.Split('|');

                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        //strInstrument_id 替换到目标设备
                        if (string.IsNullOrEmpty(strReserved))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        else
                        {
                            saveResult.SaveTextResult(strReserved, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }

                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }

                strResult = "";
            }
        }
Exemplo n.º 23
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            strResult += strSource;
            char c03 = Convert.ToChar(0x03);

            if (strResult.EndsWith(c03 + ""))
            {
                strSource = strResult;
                try
                {
                    StreamReader sr             = new StreamReader(@".\GETEIN1100.txt");
                    string       correspondence = sr.ReadLine();
                    sr.Close();
                    string[]      correspondenceArray = correspondence.Split('|');
                    StringBuilder sBuilder            = new StringBuilder("");



                    bool isSampleBar = true;
                    //将接收到的字符串写入到日志文件中
                    writelog.Write(strDevice, "接收数据开始:\r\n " + strSource, "log");
                    writelog.Write(strDevice, "接收数据完成 ", "log");
                    string[] strSourceArray = strSource.Split('|');
                    //1||882|0|3|hs-CRP+CRP|mg/L|0.721|0.50^5.00|5.00^200.00|3.00^10.00|1|0|2016-11-08 09:40:40|||?
                    strTestTime = strSourceArray[13];
                    strSampleNo = strSourceArray[2];
                    string strTestValue = strSourceArray[7];
                    string str          = "";

                    for (int k = 0; k < correspondenceArray.Length; k++)
                    {
                        if (strSourceArray[5].IndexOf(correspondenceArray[k]) != -1 && correspondenceArray[k].ToUpper().IndexOf("CRP") != -1)
                        {
                            double strTestValueDouuble = Convert.ToDouble(strTestValue);
                            if (strTestValueDouuble > 5)
                            {
                                str = "hs-CRP,>5.0|CRP," + strTestValueDouuble;
                            }
                            else if (strTestValueDouuble > 0.5)
                            {
                                str = "hs-CRP," + strTestValueDouuble + "|CRP,<5.0";
                            }
                            else
                            {
                                str = "hs-CRP,<0.5|CRP,<5.0";
                            }
                        }
                        else if (strSourceArray[5].IndexOf(correspondenceArray[k]) != -1)
                        {
                            try
                            {
                                double strTestValueDouuble = Convert.ToDouble(strTestValue);
                                if (strTestValueDouuble < 0.1)
                                {
                                    strTestValue = "<0.1";
                                }
                            }
                            catch
                            {
                                str = strSourceArray[5] + "," + strTestValue;
                            }
                            str = strSourceArray[5] + "," + strTestValue;
                        }
                    }



                    string[] strs = str.Split('|');

                    string ChannelType     = "";   //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0)   //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        //strInstrument_id 替换到目标设备
                        if (string.IsNullOrEmpty(strReserved))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        else
                        {
                            saveResult.SaveTextResult(strReserved, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }

                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    strResult = "";
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }
                strResult = "";
            }
        }
Exemplo n.º 24
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string result = may.sendQCKXCG(strSource, strDevice, strDeviceID);

            //如果是质控到话

            if (result.StartsWith("5"))
            {
                try
                {
                    writelog.Write(strDevice, "接收到数据: " + strSource, "log");
                    //
                    string[]     analysis    = strSource.Split('|');
                    string       strTestTime = DateTime.Now.ToString("yyyyMMddHHmmss");
                    string       messageTime = analysis[6];
                    string       messageID   = analysis[9];
                    StreamReader sr          = new StreamReader(@".\ELAB.ES480.txt");
                    //解析结果检验项目标识符和zlchs定义的变量对应 lis,zlchs|lis1,zlchs1
                    StringBuilder sBuilder       = new StringBuilder("");
                    string        correspondence = sr.ReadLine();
                    sr.Close();
                    string ACK_R01_OK = may.SB + @"MSH|^~\&|||||{0}||ACK^R01|{1}|P|2.3.1||||0||ASCII|||" + may.CR
                                        + "MSA|AA|{1}|Message accepted|||0|" + may.CR
                                        + may.EB + may.CR;
                    strCmd = string.Format(ACK_R01_OK, strTestTime, messageID);
                    string   times = "";
                    string[] correspondenceArray = correspondence.Split('|');
                    string[] strSourceArray      = strSource.Split(new char[] { '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strSourceArray.Length; i++)
                    {
                        if (strSourceArray[i].Split(new char[] { '|' })[0].Replace("\n", "").Equals("OBR"))
                        {
                            strSampleNo = strSourceArray[i].Split('|')[3];
                            if ("".Equals(strSourceArray[i].Split('|')[6]))
                            {
                                times = DateTime.Now.ToString("yyyyMMddHHmmss");
                            }
                            else
                            {
                                times = strSourceArray[i].Split('|')[6];
                            }
                            strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                            //样本编号转换为条码号
                            string returns = Helper.SampleNoToSampleBar(strSampleNo);
                            if (!string.IsNullOrEmpty(returns))
                            {
                                strTestTime = returns.Split('|')[0];
                                strSampleNo = returns.Split('|')[1];
                                strBarCode  = strSampleNo;
                            }
                        }
                        if (strSourceArray[i].Split(new char[] { '|' })[0].Replace("\n", "").Equals("OBX"))
                        {
                            for (int j = 0; j < correspondenceArray.Length; j++)
                            {
                                string lis   = correspondenceArray[j].Split(',')[0];
                                string zlchs = correspondenceArray[j].Split(',')[1];
                                if (strSourceArray[i].IndexOf('|' + lis + '|') > 0)
                                {
                                    sBuilder.Append(zlchs + ',' + strSourceArray[i].Split('|')[5] + '|');
                                }
                            }
                        }
                    }
                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1);
                    string[] strs = str.Split('|');

                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1].Replace("RuPT", "阴性") + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }
            }

            else
            {
                strCmd = result;
            }
        }
Exemplo n.º 25
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            writelog.Write("发送对话", "接收到数据: " + strSource, "log");
            string result = may.sendQCK(strSource, strDevice, strDeviceID);

            //如果是质控到话
            #region  如果是质控到话
            if (result.StartsWith("4"))
            {
                try
                {
                    writelog.Write(strDevice, "接收到数据: " + strSource, "log");
                    StreamReader sr = new StreamReader(@".\Mindray.BS600.txt");
                    //解析结果检验项目标识符和zlchs定义的变量对应 lis,zlchs|lis1,zlchs1
                    StringBuilder sBuilder       = new StringBuilder("");
                    string        correspondence = sr.ReadLine();
                    sr.Close();
                    string[] correspondenceArray = correspondence.Split('|');
                    string[] analysis            = strSource.Split('|');
                    string   strTestTime         = DateTime.Now.ToString("yyyyMMddHHmmss");
                    string   messageTime         = analysis[6];
                    string   messageID           = analysis[9];
                    string   ACK_R01_OK          = may.SB + @"MSH|^~\&|||||{0}||ACK^R01|{1}|P|2.3.1||||2||ASCII|||" + may.CR
                                                   + "MSA|AA|{1}|Message accepted|||0|" + may.CR
                                                   + may.EB + may.CR;
                    strCmd = string.Format(ACK_R01_OK, strTestTime, messageID);
                    string[] strSourceArray = strSource.Split(may.CR);
                    for (int i = 0; i < strSourceArray.Length; i++)
                    {
                        string s = strSourceArray[i];
                        if (s.StartsWith("OBR"))
                        {
                            string times = s.Split('|')[7];
                            strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2) + " " + times.Substring(8, 2) + ":" + times.Substring(10, 2) + ":" + times.Substring(12, 2);
                            string[] no = s.Split('|')[13].Split('^');
                            if (no.Length > 1)
                            {
                                strSampleNo = "900" + no[1];
                            }
                            else
                            {
                                strSampleNo = "900" + s.Split('|')[12];
                            }
                            for (int j = 0; j < correspondenceArray.Length; j++)
                            {
                                string lis   = correspondenceArray[j].Split(',')[0];
                                string zlchs = correspondenceArray[j].Split(',')[1];
                                if (s.IndexOf('|' + lis + '|') > 0)
                                {
                                    sBuilder.Append(zlchs + ',' + s.Split('|')[20] + '|');
                                }
                            }
                        }
                    }

                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1);
                    string[] strs = str.Split('|');

                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1].Replace("RuPT", "阴性") + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "质控异常:" + e.ToString(), "log");
                }
            }
            #endregion
            #region 如果是样本结果的话
            else if (result.StartsWith("5"))
            {
                try
                {
                    writelog.Write(strDevice, "接收到数据: " + strSource, "log");
                    //
                    string[]     analysis    = strSource.Split('|');
                    string       strTestTime = DateTime.Now.ToString("yyyyMMddHHmmss");
                    string       messageTime = analysis[6];
                    string       messageID   = analysis[9];
                    StreamReader sr          = new StreamReader(@".\Mindray.BS600.txt");
                    //解析结果检验项目标识符和zlchs定义的变量对应 lis,zlchs|lis1,zlchs1
                    StringBuilder sBuilder       = new StringBuilder("");
                    string        correspondence = sr.ReadLine();
                    sr.Close();
                    string ACK_R01_OK = may.SB + @"MSH|^~\&|||||{0}||ACK^R01|{1}|P|2.3.1||||0||ASCII|||" + may.CR
                                        + "MSA|AA|{1}|Message accepted|||0|" + may.CR
                                        + may.EB + may.CR;
                    strCmd = string.Format(ACK_R01_OK, strTestTime, messageID);
                    string   times = "";
                    string[] correspondenceArray = correspondence.Split('|');
                    string[] strSourceArray      = strSource.Split(new char[] { '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < strSourceArray.Length; i++)
                    {
                        if (strSourceArray[i].Split(new char[] { '|' })[0].Replace("\n", "").Equals("OBR"))
                        {
                            strBarCode  = strSourceArray[i].Split('|')[2];
                            strSampleNo = strSourceArray[i].Split('|')[3];
                            if ("".Equals(strSourceArray[i].Split('|')[6]))
                            {
                                times = DateTime.Now.ToString("yyyyMMddHHmmss");
                            }
                            else
                            {
                                times = strSourceArray[i].Split('|')[6];
                            }
                            strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                            #region 优先在有条码存在的情况下进行优先以条码进行传递,如果查询条码没有对应的样本号,那么还是保持样本编号
                            if (strBarCode != "")
                            {
                                string returns = Helper.SampleNoToSampleBar(strBarCode);
                                if (!string.IsNullOrEmpty(returns))
                                {
                                    strTestTime = returns.Split('|')[0];
                                    strSampleNo = returns.Split('|')[1];
                                }
                                else
                                {
                                    returns = Helper.SampleNoToSampleBar(strSampleNo);
                                    if (!string.IsNullOrEmpty(returns))
                                    {
                                        strTestTime = returns.Split('|')[0];
                                        strSampleNo = returns.Split('|')[1];
                                    }
                                }
                            }
                            else
                            {
                                string returns = Helper.SampleNoToSampleBar(strSampleNo);
                                if (!string.IsNullOrEmpty(returns))
                                {
                                    strTestTime = returns.Split('|')[0];
                                    strSampleNo = returns.Split('|')[1];
                                }
                            }
                            #endregion
                        }
                        if (strSourceArray[i].Split(new char[] { '|' })[0].Replace("\n", "").Equals("OBX"))
                        {
                            string lisName  = strSourceArray[i].Split('|')[3];
                            string lisValue = strSourceArray[i].Split('|')[5];
                            if (!string.IsNullOrEmpty(strSourceArray[i].Split('|')[9]))
                            {
                                lisValue = strSourceArray[i].Split('|')[9];
                            }
                            sBuilder.Append(lisName + ',' + lisValue + '|');
                        }
                    }
                    string   str             = sBuilder.ToString().Remove(sBuilder.Length - 1);
                    string[] strs            = str.Split('|');
                    string   ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string   testItemID      = "";
                    string   TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1].Replace("RuPT", "阴性") + "|";
                        }
                    }
                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }
            }
            #endregion
            else
            {
                strCmd = result;
                if (string.IsNullOrEmpty(strReserved))
                {
                    strReserved = result;
                }

                if (strReserved.Contains(may.fengexian))
                {
                    //拆分strCmd命令如果包含---fengexian---到话表示多条样本信息需要反馈,需要分多次返回
                    string[] collection = strReserved.Split(new string[] { may.fengexian }, StringSplitOptions.RemoveEmptyEntries);
                    strCmd = collection[0];
                    string newStrReserved = "";

                    for (int q = 1; q < collection.Length; q++)
                    {
                        newStrReserved += collection[q] + may.fengexian;
                    }
                    strReserved = newStrReserved;
                }
            }
            writelog.Write("发送对话", "发送出去的数据: " + strCmd, "log");
        }
Exemplo n.º 26
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            char[] abc  = strSource.ToCharArray();
            int    abcd = Convert.ToInt16(abc[0]);

            //数据接收完成
            if (strSource.EndsWith(EOT + "") || strSource.EndsWith("test-end"))
            {
                string strTestTimeNow  = DateTime.Now.ToString("yyyyMMddHHmmss");
                string strTestTimeNow1 = DateTime.Now.ToString("yyyy-MM-dd");
                //把最后接受的消息补充完整
                strResult = strResult + strSource;
                //首先判断消息类型
                string[] strSourceArray = strResult.Split(new char[] { LF }, StringSplitOptions.RemoveEmptyEntries);
                writelog.Write("strSourceArray0" + strSourceArray[0], "log");
                //writelog.Write("strSourceArray1" + strSourceArray[1], "log");
                //取出消息头
                string[] infoTypeArray = strSourceArray[0].Split(new char[] { '|' });
                if (infoTypeArray.Length >= 10)
                {
                    string infoType = infoTypeArray[11];
                    #region//1.病人测试结果
                    if (infoType.Equals("SRLT"))
                    {
                        writelog.Write("全部数据:" + Convert.ToChar(13) + Convert.ToChar(10) + strResult, "log");
                        try
                        {
                            StreamReader sr = new StreamReader(@".\XC8001.txt");
                            //解析结果检验项目标识符和zlchs定义的变量对应 lis,zlchs|lis1,zlchs1
                            StringBuilder sBuilder       = new StringBuilder("");
                            string        correspondence = sr.ReadLine();

                            sr.Close();
                            string   times = "";
                            string[] correspondenceArray = correspondence.Split('|');

                            //检验时间
                            strTestTime = strSourceArray[0].Split('|')[13];
                            times       = strTestTime;
                            strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                            for (int i = 0; i < strSourceArray.Length; i++)
                            {
                                //取消息头
                                string header = strSourceArray[i].Split('|')[0];

                                if (header.EndsWith("O"))
                                {
                                    //样本条码^样本编号^盘号^位置^是否稀释  ^1^1^1^N
                                    string OInfo = strSourceArray[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[2];
                                    strSampleNo = OInfo.Split('^')[1];


                                    //if ("".Equals(strSourceArray[i].Split('|')[6])) { times = DateTime.Now.ToString("yyyyMMddHHmmss"); }
                                    //else { times = strSourceArray[i].Split('|')[6]; }


                                    //如果有条码号,取核收时间作为检验时间
                                    string sampleBarstr = OInfo.Split('^')[0];
                                    if (!string.IsNullOrEmpty(sampleBarstr))
                                    {
                                        IniFile ConfigIni = new IniFile("SOLVESET.INI");
                                        string  encode    = ConfigIni.IniReadValue("EQUIPMENT", "Encode");
                                        DataSet ds        = new DataSet();
                                        string  orgId     = ConfigIni.IniReadValue("EQUIPMENT", "Agencies");
                                        string  sql       = @"to_char(核收时间,'yyyymmddhh24miss') as 核收时间,样本序号";
                                        string where = @" 机构id='" + orgId + "' and  样本条码='" + sampleBarstr + "'";
                                        ds           = dsHandle.GetDataSet(sql, "检验记录", where);
                                        times        = ds.Tables[0].Rows[0]["核收时间"].ToString();//20160202145321
                                        strSampleNo  = ds.Tables[0].Rows[0]["样本序号"].ToString();
                                    }
                                    strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                                }
                                if (header.EndsWith("R"))
                                {
                                    string yiqi      = strSourceArray[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[2];
                                    string yiqiValue = strSourceArray[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[3];
                                    for (int j = 0; j < correspondenceArray.Length; j++)
                                    {
                                        string lis   = correspondenceArray[j].Split(',')[0].Trim();
                                        string zlchs = correspondenceArray[j].Split(',')[1].Trim();
                                        if (yiqi.Equals(lis))
                                        {
                                            sBuilder.Append(zlchs + ',' + yiqiValue + '|');
                                        }
                                    }
                                }
                            }
                            string   str             = sBuilder.ToString().Remove(sBuilder.Length - 1);
                            string[] strs            = str.Split('|');
                            string   ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                            string   testItemID      = "";
                            string   TestResultValue = "";
                            for (int i = 0; i < strs.Length; i++)
                            {
                                FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                                if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                                {
                                    ChannelType = null;
                                    writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                                }
                                else
                                {
                                    testItemID      = FindRow[0]["项目id"].ToString();
                                    ChannelType     = "0"; //普通结果
                                    TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1].Replace("RuPT", "阴性") + "|";
                                }
                            }
                            TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                            saveResult      = new SaveResult();
                            if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                            {
                                saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                                if (ImmediatelyUpdate)
                                {
                                    saveResult.UpdateData();
                                }
                            }
                            if (!ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                        catch (Exception e)
                        {
                            writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                            strResult = "";
                        }
                    }
                    #endregion
                    #region //2.质控结果
                    if (infoType.Equals("QRLT"))
                    {
                        writelog.Write("质控数据:" + Convert.ToChar(13) + Convert.ToChar(10) + strResult, "log");
                        try
                        {
                            StreamReader sr = new StreamReader(@".\XC8001.txt");
                            //解析结果检验项目标识符和zlchs定义的变量对应 lis,zlchs|lis1,zlchs1
                            StringBuilder sBuilder       = new StringBuilder("");
                            string        correspondence = sr.ReadLine();

                            sr.Close();
                            string   times = "";
                            string[] correspondenceArray = correspondence.Split('|');

                            //检验时间
                            strTestTime = strSourceArray[0].Split('|')[13];
                            times       = strTestTime;
                            strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                            for (int i = 0; i < strSourceArray.Length; i++)
                            {
                                //取消息头
                                string header = strSourceArray[i].Split('|')[0];

                                if (header.EndsWith("O"))
                                {
                                    string OInfo = strSourceArray[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[3];
                                    strSampleNo = "900" + OInfo.Split('^')[2];


                                    //if ("".Equals(strSourceArray[i].Split('|')[6])) { times = DateTime.Now.ToString("yyyyMMddHHmmss"); }
                                    //else { times = strSourceArray[i].Split('|')[6]; }


                                    //如果有条码号,取核收时间作为检验时间
                                    string sampleBarstr = OInfo.Split('^')[0];
                                    strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                                }
                                if (header.EndsWith("R"))
                                {
                                    string yiqi      = strSourceArray[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[2];
                                    string yiqiValue = strSourceArray[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[3];
                                    for (int j = 0; j < correspondenceArray.Length; j++)
                                    {
                                        string lis   = correspondenceArray[j].Split(',')[0].Trim();
                                        string zlchs = correspondenceArray[j].Split(',')[1].Trim();
                                        if (yiqi.Equals(lis))
                                        {
                                            sBuilder.Append(zlchs + ',' + yiqiValue + '|');
                                        }
                                    }
                                }
                            }
                            string   str             = sBuilder.ToString().Remove(sBuilder.Length - 1);
                            string[] strs            = str.Split('|');
                            string   ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                            string   testItemID      = "";
                            string   TestResultValue = "";
                            for (int i = 0; i < strs.Length; i++)
                            {
                                FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                                if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                                {
                                    ChannelType = null;
                                    writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                                }
                                else
                                {
                                    testItemID      = FindRow[0]["项目id"].ToString();
                                    ChannelType     = "0"; //普通结果
                                    TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1].Replace("RuPT", "阴性") + "|";
                                }
                            }
                            TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                            saveResult      = new SaveResult();
                            if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                            {
                                saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                                if (ImmediatelyUpdate)
                                {
                                    saveResult.UpdateData();
                                }
                            }
                            if (!ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                        catch (Exception e)
                        {
                            writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                            strResult = "";
                        }
                    }
                    #endregion
                    #region //3.样本请求查询
                    if (infoType.Equals("QREQ"))
                    {
                        //主动发起请求

                        //取出2Q|1|55|666|||||||||Oef
                        string[] infoTypeArrayQ = strSourceArray[1].Split(new char[] { '|' });
                        tiaomahao       = infoTypeArrayQ[4];
                        yangbenhaoStart = infoTypeArrayQ[2];
                        yangbenhaoEnd   = infoTypeArrayQ[3];
                        //如果是条码号申请
                        if (!string.IsNullOrEmpty(tiaomahao) && (tiaomahao != "0"))
                        {
                            Mindray   may = new Mindray();
                            DataTable dt  = may.GetSampleInfoXC8001(tiaomahao, strInstrument_id);
                            //
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                //校验
                                //发送病人信息  ETB中间帧,ETX结束帧
                                // string H = @"1H|\^&|||XC8001|||||LIS||SDWN|E1394-97|strTestTimeNow";
                                string H = @"1H|\^&|||XC8&|001|||||LIS||SDWN|E1394-97|strTestTimeNow";
                                ///
                                ///
                                string P = "2P|1||||PatientName|||Patient_Sex||||||23^年";
                                //(7.1.12 取值为SRLT/SDWN/QRES 时使用)样本条码^样本编号^盘号^位置^是否稀释
                                //ALB\ALP\ALT\APOA1\APOB\AST\B2MG\CHE\CREA-M\CYSC\DBIL\GGT\HDL-C\LDL-C\LPA\PA\TBA\TBIL\TC\TG\TP\UA\UREA
                                //样本 ID   样本条码^样本编号^盘号^位置^是否稀释
                                string O = "3O|1|strTestBar^strSampleNo^^^N||全局测试ID|R|strTestTimeNow1|||||||||0||||||||||F";
                                string L = "4L|1|N";
                                //发一个帧
                                string items = dt.Rows[0]["项目编号"].ToString().Replace(",", "\\");///////////////////////////////////////////////////////////////////////////  "/"   -> "\\"
                                H = H.Replace("strTestTimeNow", strTestTimeNow);
                                P = P.Replace("Patient_Name", dt.Rows[0]["病人姓名"].ToString());
                                P = P.Replace("Birthdate", dt.Rows[0]["出生日期"].ToString());
                                if (dt.Rows[0]["性别"].ToString().Equals("男"))
                                {
                                    P = P.Replace("Patient_Sex", "M");
                                }
                                else
                                {
                                    P = P.Replace("Patient_Sex", "F");
                                }
                                string ybtm = dt.Rows[0]["样本条码"].ToString();
                                string ybbh = dt.Rows[0]["样本编号"].ToString();

                                O = O.Replace("strTestBar", ybtm);
                                O = O.Replace("strSampleNo", ybbh);
                                O = O.Replace("全局测试ID", items);
                                O = O.Replace("strTestTimeNow1", strTestTimeNow1);
                                //处理完毕
                                //strReserved = STX + H + CR + P + CR + O + CR + L + ETX;
                                //string CS = this.CSValidate(strReserved);
                                //strReserved = strReserved + CS + CR + LF + fengefu;
                                string HInfo = H + CR + ETX;
                                string CS    = this.CSValidate(HInfo);
                                HInfo = STX + HInfo + CS + CR + LF + fengefu;
                                string PInfo = P + CR + ETX;
                                CS    = this.CSValidate(PInfo);
                                PInfo = STX + PInfo + CS + CR + LF + fengefu;
                                string OInfo = O + CR + ETB;
                                CS    = this.CSValidate(OInfo);
                                OInfo = STX + OInfo + CS + CR + LF + fengefu;
                                string LInfo = L + CR + ETB;
                                CS          = this.CSValidate(LInfo);
                                LInfo       = STX + LInfo + CS + CR + LF + fengefu;
                                strReserved = HInfo + PInfo + OInfo + LInfo;
                                strCmd      = ENQ + "";

                                /*
                                 *  string H = @"1H|\^&|||XC8&|001|||||LIS||SDWN|E1394-97|20161202163209";
                                 * string HInfo = H + CR + ETX;
                                 * string CS = this.CSValidate(HInfo);
                                 * HInfo = STX + HInfo + CS + CR + LF + fengefu;
                                 *
                                 * string P = @"2P|1||||王小明|||F||||||30^岁";
                                 * string PInfo = P + CR + ETX;
                                 * CS = this.CSValidate(PInfo);
                                 * PInfo = STX + PInfo + CS + CR + LF + fengefu;
                                 *
                                 * string O = @"3O|1|^2^1^2^||ALT\AST|R|2016-12-02|||||||||0||||||||||F";
                                 * string OInfo = O + CR + ETX;
                                 * CS = this.CSValidate(OInfo);
                                 * OInfo = STX + OInfo + CS + CR + LF + fengefu;
                                 *
                                 * string L = @"4L|1|N";
                                 * string LInfo = L + CR + ETX;
                                 * CS = this.CSValidate(LInfo);
                                 * LInfo = STX + LInfo + CS + CR + LF + fengefu;
                                 * strReserved = HInfo + PInfo + OInfo + LInfo;
                                 *
                                 * P = @"2P|1||||王小明1|||F||||||30^年";
                                 * PInfo = P + CR + ETX;
                                 * CS = this.CSValidate(PInfo);
                                 * PInfo = STX + PInfo + CS + CR + LF + fengefu;
                                 *
                                 * O = @"3O|1|^2^2^2^||ALT\AST|R|2016-12-02|||||||||0||||||||||F";
                                 * OInfo = O + CR + ETX;
                                 * CS = this.CSValidate(OInfo);
                                 * OInfo = STX + OInfo + CS + CR + LF + fengefu;
                                 *
                                 * strReserved = strReserved + HInfo + PInfo + OInfo + LInfo;
                                 * */
                            }
                            else
                            {
                                string H = @"1H|\^&||||||||||QRES|E1394-97|strTestTimeNow" + CR;//+ETB+CS+CR+LF;
                                string L = @"2L|1|I" + CR;
                                H      = H.Replace("strTestTimeNow", strTestTimeNow);
                                strCmd = STX + H + L + ETX;
                                string CS = this.CSValidate(strCmd);
                                strCmd = strCmd + CS + CR + LF;
                                //strReserved = strCmd;
                                //strCmd = ENQ + "";
                            }
                        }
                    }
                    #endregion
                    //4.样本请求回应
                    if (infoType.Equals("QRES"))
                    {
                    }
                    //5.样本查询回应
                    if (infoType.Equals("SDWN"))
                    {
                    }

                    //处理完毕后把数据还原为空
                    strResult = "";
                }
                else
                {
                    // 光是结束字符
                    strResult = "";
                    strCmd    = ACK + "";
                }
            }
            else if (strSource.Equals(ENQ + ""))
            {
                strResult = "";
                strCmd    = ACK + "";
            }
            else if (strSource.Equals(ACK + ""))
            {
                //如果收到ack请求,发送下载样本信息
                if (!string.IsNullOrEmpty(strReserved))
                {
                    //当没有发现样本的时候,把strReserved="",然后在发送EOT
                    if (strReserved.IndexOf("L|1|I") > 0)
                    {
                        strCmd      = strReserved;
                        strReserved = "";
                    }

                    else
                    {
                        string[] cmdInfoArray = strReserved.Split(new string[] { fengefu }, StringSplitOptions.RemoveEmptyEntries);
                        if (cmdInfoArray.Length > 1)
                        {
                            string temp = "";
                            strCmd = cmdInfoArray[0];
                            for (int i = 1; i < cmdInfoArray.Length; i++)
                            {
                                temp = temp + cmdInfoArray[i] + fengefu;
                            }
                            strReserved = temp;
                        }

                        else
                        {
                            strCmd      = strReserved.Replace(fengefu, "").Replace(ETB + "", ETX + "");
                            strReserved = "";
                        }
                    }
                }
                //直到发送完毕后,发送结束符号
                else
                {
                    strCmd = EOT + "";
                }
            }
            //拒绝接受信息
            else if (strSource.Equals(NAK + ""))
            {
                strResult   = "";
                strReserved = "";
                strCmd      = EOT + "";
            }
            else
            {
                //用于接受全部的数据
                strResult = strResult + strSource;
                strCmd    = ACK + "";
            }
        }
Exemplo n.º 27
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            strResult += strSource;
            char c3D = Convert.ToChar(0x3D);
            char c00 = Convert.ToChar(0x00);

            if (strResult.EndsWith(c3D + "" + c00) || strResult.EndsWith("test-end"))
            {
                strSource = strResult;
                try
                {
                    bool isSampleBar = true;
                    //将接收到的字符串写入到日志文件中
                    StreamReader  sr             = new StreamReader("BIOTYGI.txt", Encoding.Default);
                    StringBuilder sBuilder       = new StringBuilder("");
                    string        correspondence = sr.ReadLine();
                    sr.Close();
                    string[] correspondenceArray = correspondence.Split('|');
                    string   str = "";
                    writelog.Write(strDevice, "接收数据开始:\r\n " + strSource, "log");
                    writelog.Write(strDevice, "接收数据完成 ", "log");
                    string[] strSourceArray = strSource.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

                    for (int i = 0; i < strSourceArray.Length; i++)
                    {
                        if (strSourceArray[i].Contains("日    期"))
                        {
                            strTestTime = strSourceArray[i].Replace("日    期: ", "").Trim();
                        }
                        if (strSourceArray[i].Contains("流水号"))
                        {
                            strSampleNo = strSourceArray[i].Split(new char[] { ':', ':', ' ' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        }
                        if (!strSourceArray[i].Contains("参考值"))
                        {
                            for (int j = 0; j < correspondenceArray.Length; j++)
                            {
                                string strValueSource = strSourceArray[i].ToUpper();
                                string lis            = correspondenceArray[j].Split(',')[0].ToUpper();
                                string zlchs          = correspondenceArray[j].Split(',')[1];
                                if (strSourceArray[i].ToUpper().Contains(lis))
                                {
                                    string strValue = "";
                                    strValue = strValueSource.Split(new string[] { lis }, StringSplitOptions.RemoveEmptyEntries)[1];
                                    strValue = strValue.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0];
                                    str     += zlchs + "," + strValue + "|";
                                }
                            }
                        }
                    }

                    str = str.Remove(str.Length - 1, 1);
                    string[] strs            = str.Split('|');
                    string   ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string   testItemID      = "";
                    string   TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        //strInstrument_id 替换到目标设备

                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);

                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }

                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    strResult = "";
                    writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                }
                strResult = "";
            }
        }
Exemplo n.º 28
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string splite_lis = "L|1|N";

            strResult += strSource;
            //数据接收完成
            if (strSource.EndsWith(EOT + "") || strSource.EndsWith("test-end") || strSource.EndsWith(Convert.ToChar(4) + ""))
            {
                strSource = strResult;

                writelog.Write(strDevice, "全部数据:" + strSource, "log");
                string[] strResultArray = strResult.Split(new string[] { splite_lis }, StringSplitOptions.RemoveEmptyEntries);
                strResult = "";
                for (int wfw = 0; wfw < strResultArray.Length; wfw++)
                {
                    if (strResultArray [wfw].IndexOf("|CS-380|") == -1)
                    {
                        continue;
                    }
                    strSource = strResultArray[wfw];
                    writelog.Write(strDevice, "本次数据第" + (wfw + 1) + "条" + strSource, "log");
                    string strTestTimeNow  = DateTime.Now.ToString("yyyyMMddHHmmss");
                    string strTestTimeNow1 = DateTime.Now.ToString("yyyy-MM-dd");
                    //支持多个样本模式以"L|1|N<CR><ETX>"作为分隔符


                    string subStrSource = strSource;
                    //首先判断消息类型
                    string[] strSourceArray = strSource.Split(new char[] { LF }, StringSplitOptions.RemoveEmptyEntries);

                    //取出消息头
                    #region   //1.病人测试结果
                    try
                    {
                        StreamReader sr = new StreamReader(@".\Dirui.CS380.txt", Encoding.Default);
                        //解析结果检验项目标识符和zlchs定义的变量对应 lis,zlchs|lis1,zlchs1
                        StringBuilder sBuilder       = new StringBuilder("");
                        string        correspondence = sr.ReadLine();
                        sr.Close();
                        string   times = "";
                        string[] correspondenceArray = correspondence.Split('|');
                        //检验时间


                        for (int i = 0; i < strSourceArray.Length; i++)
                        {
                            string header = strSourceArray[i].Split('|')[0];
                            //取消息头
                            if (header.EndsWith("H"))
                            {
                                times       = strSourceArray[i].Split('|')[12];
                                strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                            }
                            if (header.EndsWith("O"))
                            {
                                //样本条码^样本编号^盘号^位置^是否稀释  ^1^1^1^N
                                string OInfo = strSourceArray[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[2];
                                strSampleNo = OInfo.Split('^')[1];


                                //if ("".Equals(strSourceArray[i].Split('|')[6])) { times = DateTime.Now.ToString("yyyyMMddHHmmss"); }
                                //else { times = strSourceArray[i].Split('|')[6]; }


                                //如果有条码号,取核收时间作为检验时间
                                string sampleBarstr = OInfo.Split('^')[0];
                                if (!string.IsNullOrEmpty(sampleBarstr))
                                {
                                    IniFile ConfigIni = new IniFile("SOLVESET.INI");
                                    string  encode    = ConfigIni.IniReadValue("EQUIPMENT", "Encode");
                                    DataSet ds        = new DataSet();
                                    string  orgId     = ConfigIni.IniReadValue("EQUIPMENT", "Agencies");
                                    string  sql       = @"to_char(核收时间,'yyyymmddhh24miss') as 核收时间,样本序号";
                                    string where = @" 机构id='" + orgId + "' and  样本条码='" + sampleBarstr + "'";
                                    ds           = dsHandle.GetDataSet(sql, "检验记录", where);
                                    times        = ds.Tables[0].Rows[0]["核收时间"].ToString();//20160202145321
                                    strSampleNo  = ds.Tables[0].Rows[0]["样本序号"].ToString();
                                }
                                strTestTime = times.Substring(0, 4) + "-" + times.Substring(4, 2) + "-" + times.Substring(6, 2);
                            }
                            if (header.EndsWith("R"))
                            {
                                string yiqi      = strSourceArray[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[2].Split('^')[3];
                                string yiqiValue = strSourceArray[i].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)[3];
                                for (int j = 0; j < correspondenceArray.Length; j++)
                                {
                                    string lis   = correspondenceArray[j].Split(',')[0].Trim();
                                    string zlchs = correspondenceArray[j].Split(',')[1].Trim();
                                    if (yiqi.Equals(lis))
                                    {
                                        sBuilder.Append(zlchs + ',' + yiqiValue + '|');
                                    }
                                }
                            }
                        }
                        string   str             = sBuilder.ToString().Remove(sBuilder.Length - 1);
                        string[] strs            = str.Split('|');
                        string   ChannelType     = "";  //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string   testItemID      = "";
                        string   TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0)    //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1].Replace("RuPT", "阴性") + "|";
                            }
                        }
                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                        if (!ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }
                    catch (Exception e)
                    {
                        writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
                        strResult = "";
                    }

                    #endregion
                }
            }
            strCmd = ACK + "";
        }
Exemplo n.º 29
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string strTestTime = DateTime.Now.ToString("yyyyMMddHHmmss");

            try
            {
                writelog.Write(strDevice, "接收到数据: " + strSource, "log");
                string   result = "";
                string[] str    = strSource.Split('\r');
                for (int i = 0; i < str.Length; i++)
                {
                    string s = str[i];
                    if (s.StartsWith("PID"))
                    {
                        strSampleNo = s.Split('|')[2];
                    }
                    if (s.StartsWith("OBR"))
                    {
                        strTestTime = s.Split('|')[7];
                        strTestTime = strTestTime.Substring(0, 4) + "-" + strTestTime.Substring(4, 2) + "-" + strTestTime.Substring(6, 2) + " " + strTestTime.Substring(8, 2) + ":" + strTestTime.Substring(10, 2) + ":" + strTestTime.Substring(12, 2);
                    }
                    if (s.IndexOf("|^^NT-proBNP|_conc|") != -1)
                    {
                        result = result + "proBNP," + s.Split('|')[5];
                    }
                }


                string[] strs            = result.Split('|');
                string   ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                string   testItemID      = "";
                string   TestResultValue = "";
                for (int i = 0; i < strs.Length; i++)
                {
                    FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                    if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                    {
                        ChannelType = null;
                        writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                    }
                    else
                    {
                        testItemID      = FindRow[0]["项目id"].ToString();
                        ChannelType     = "0"; //普通结果
                        TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1].Replace("RuPT", "阴性") + "|";
                    }
                }
                string returns = Helper.SampleNoToSampleBar(strSampleNo);
                if (!string.IsNullOrEmpty(returns))
                {
                    strTestTime = returns.Split('|')[0];
                    strSampleNo = returns.Split('|')[1];
                    strBarCode  = strSampleNo;
                }


                TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                saveResult      = new SaveResult();
                if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                {
                    //strInstrument_id 替换到目标设备
                    if (string.IsNullOrEmpty(strReserved))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                    }
                    else
                    {
                        saveResult.SaveTextResult(strReserved, TestResultValue, TestGraph, DrSampleNoField);
                    }
                    if (ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                if (!ImmediatelyUpdate)
                {
                    saveResult.UpdateData();
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }
        }
Exemplo n.º 30
0
        /// <summary>
        ///     '设备标准接口
        //'功能:解析数据
        //'参数:
        //'strSource:要解析的原始串
        //'strResult:返回的检验结果(各仪器解析程序必须按以下标准组织结果)
        //'   每组检验结果以||分隔,元素之间以|分隔
        //'   第0个元素:检验时间
        //'   第1个元素:样本序号(标本号^条码号^样本类型)
        //'   第2个元素:检验人
        //'   第3个元素:标本
        //'   第4个元素:预留
        //'   从第5个元素开始为检验结果,每2个元素表示一个检验项目。
        //'       如:第5i个元素为检验项目,第5i+1个元素为检验结果
        //'strReserved:最后不能完成解析的原始串,需要返回作后续处理
        //'strCmd:如果需要,可返回向设备发送的命令
        //'补充图像的方式:
        //'                   1.图像数据跟随指标数据后,使用回车换行符来分隔。
        //'                   2.有多个图像数据时使用"^"来分隔
        //'                   3.单个图像数据格式: 图像画法 0=直方图  1=散点图
        //'                     a) 直方图: 图像名称;图像画法(0=直方图  1=散点图);X1;X2;X3;X4;X5...
        //'                     b) 散点图: 图像名称;图像画法(0=直方图  1=散点图):
        //'                        例:00000100001000010000100010;00000100001000010000100010;
        //'                        说明:1.散点图以点阵方式保存每一行使用分号来分隔.
        //'                             2.有多少个分号就有多少行
        //'                             3.每一行有多少个点由每一行的长度来确定
        //'                             3.画图的方向是从最上边向下画,如有65*65的图就是从65行开始画(最上边开始画)
        /// 检验日期|
        /// </summary>
        /// <param name="ResultString"></param>
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string channel = "0";
            // string testItemID = "";
            string  result           = "";
            decimal CONVERSION_RATIO = 0;
            decimal DECIMAL_LEVEL    = 2;
            string  ParString        = "";
            string  SingleResult     = "";
            string  ResultString     = "";
            string  UnknownResult    = ""; //未知项目
            string  TempCmd          = "";

            DataSet ds_GraphChannel = new DataSet();
            DataSet dsGUID          = new DataSet();
            DataSet dsTestItem      = new DataSet();

            string TestResultInfo = "";

            strReserved = "";
            strResult   = "";
            strCmd      = "";

            init();//初始化

            try
            {
                string    strTestTime;        //检验时间
                string    strSampleNo;        //标本号
                string    strBarCode    = ""; //条码
                string    strOperator   = ""; //检验医师
                string    strSampleType = ""; //检验类型
                string    StrSpecimen   = ""; //标本类型
                string    ChannelType;        //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                string    testItemID = "";    //通道项目ID
                DataRow[] FindRow;            //解析设置
                TestGraph  = new List <string>();
                saveResult = new SaveResult();
                IsUpdate(strSource);//重新检查是否有新数据

                //获取样本序号:oracle
                string    strSql   = "select trim(wm_concat(样本序号)) 样本序号 from 检验记录 where 仪器ID = '" + strInstrument_id + "' and to_char(检验时间,'yyyy-mm-dd') = to_char(sysdate,'yyyy-mm-dd')";
                DataTable sampleNo = OracleHelper.GetDataTable(strSql);

                //判断是否有新的数据产生
                if (dsResult.Tables[0].Rows.Count == 0)
                {
                    writelog.Write(strDevice, DateTime.Now.ToShortDateString() + "未检测到任何检验数据!", "log");
                    return;
                }
                else
                {
                    for (int i = 0; i < dsResult.Tables[0].Rows.Count; i++)
                    {
                        strSampleNo = dsResult.Tables[0].Rows[i]["SAMPLE_ID"].ToString();
                        string _channelNo = "";
                        if (i == dsResult.Tables[0].Rows.Count - 1)
                        {
                            strTestTime = dsResult.Tables[0].Rows[i]["TIME"].ToString();
                            _channelNo  = dsResult.Tables[0].Rows[i]["ITEM"].ToString();
                            FindRow     = tItemChannel.Select("通道编码='" + _channelNo.Trim() + "'");
                            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + _channelNo, "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + dsResult.Tables[0].Rows[i]["RESULT"].ToString() + "|";
                            }
                            TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                            try
                            {
                                saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, null);
                                saveResult.UpdateData();
                                writelog.Write(strDevice, "解析结果: " + TestResultValue, "result");
                                TestResultValue = "";
                            }
                            catch (Exception ex)
                            {
                                writelog.Write(strDevice, "保存失败: " + ex.ToString(), "log");
                            }
                        }
                        else
                        {
                            if (dsResult.Tables[0].Rows[i + 1]["SAMPLE_ID"].ToString().Equals(dsResult.Tables[0].Rows[i]["SAMPLE_ID"].ToString()))
                            {
                                _channelNo = dsResult.Tables[0].Rows[i]["ITEM"].ToString();
                                FindRow    = tItemChannel.Select("通道编码='" + _channelNo.Trim() + "'");
                                if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                                {
                                    ChannelType = null;
                                    writelog.Write(strDevice, "未设置通道:" + _channelNo, "log");
                                }
                                else
                                {
                                    testItemID      = FindRow[0]["项目id"].ToString();
                                    ChannelType     = "0"; //普通结果
                                    TestResultValue = TestResultValue + testItemID + "^" + dsResult.Tables[0].Rows[i]["RESULT"].ToString() + "|";
                                }
                                //间接胆红素
                                if (dsResult.Tables[0].Rows[i]["ITEM"].ToString().Contains("DBIL"))
                                {
                                    FindRow = tItemChannel.Select("通道编码='IBILI'");
                                    if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                                    {
                                        ChannelType = null;
                                        writelog.Write(strDevice, "未设置通道:" + _channelNo, "log");
                                    }
                                    else
                                    {
                                        testItemID      = FindRow[0]["项目id"].ToString();
                                        ChannelType     = "0"; //普通结果
                                        result          = (Convert.ToDouble(dsResult.Tables[0].Rows[i - 1]["RESULT"].ToString()) - Convert.ToDouble(dsResult.Tables[0].Rows[i]["RESULT"].ToString())).ToString();
                                        TestResultValue = TestResultValue + testItemID + "^" + result + "|";
                                    }
                                }
                                //球蛋白
                                if (dsResult.Tables[0].Rows[i]["ITEM"].ToString().Contains("ALB"))
                                {
                                    FindRow = tItemChannel.Select("通道编码='GLB'");
                                    if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                                    {
                                        ChannelType = null;
                                        writelog.Write(strDevice, "未设置通道:GLB", "log");
                                    }
                                    else
                                    {
                                        testItemID      = FindRow[0]["项目id"].ToString();
                                        ChannelType     = "0"; //普通结果
                                        result          = (Convert.ToDouble(dsResult.Tables[0].Rows[i - 1]["RESULT"].ToString()) - Convert.ToDouble(dsResult.Tables[0].Rows[i]["RESULT"].ToString())).ToString();
                                        TestResultValue = TestResultValue + testItemID + "^" + result + "|";
                                    }
                                    #region 白球比
                                    FindRow = tItemChannel.Select("通道编码='A/G'");
                                    if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                                    {
                                        ChannelType = null;
                                        writelog.Write(strDevice, "未设置通道:A/G", "log");
                                    }
                                    else
                                    {
                                        testItemID      = FindRow[0]["项目id"].ToString();
                                        ChannelType     = "0"; //普通结果
                                        result          = Math.Round(Convert.ToDouble(dsResult.Tables[0].Rows[i - 1]["RESULT"].ToString()) / Convert.ToDouble(dsResult.Tables[0].Rows[i]["RESULT"].ToString()), 1).ToString();
                                        TestResultValue = TestResultValue + testItemID + "^" + result + "|";
                                    }
                                    #endregion
                                }
                            }
                            else
                            {
                                strTestTime = dsResult.Tables[0].Rows[i]["TIME"].ToString();
                                _channelNo  = dsResult.Tables[0].Rows[i]["ITEM"].ToString();
                                FindRow     = tItemChannel.Select("通道编码='" + _channelNo.Trim() + "'");
                                if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                                {
                                    ChannelType = null;
                                    writelog.Write(strDevice, "未设置通道:" + _channelNo, "log");
                                }
                                else
                                {
                                    testItemID      = FindRow[0]["项目id"].ToString();
                                    ChannelType     = "0"; //普通结果
                                    TestResultValue = TestResultValue + testItemID + "^" + dsResult.Tables[0].Rows[i]["RESULT"].ToString() + "|";
                                }
                                TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                                try
                                {
                                    saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, null);
                                    saveResult.UpdateData();
                                    writelog.Write(strDevice, "解析结果: " + TestResultValue, "result");
                                    TestResultValue = "";
                                }
                                catch (Exception ex)
                                {
                                    writelog.Write(strDevice, "保存失败: " + ex.ToString(), "log");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }
        }