Exemplo n.º 1
0
        internal void End(int count, WebSocketMessageType messageType)
        {
            _bs.AddRange(ReceiveData.Take(count));
            ByteData   = _bs.ToArray();
            StringData = Encoding.UTF8.GetString(ByteData);
            var index = StringData.IndexOf(",");

            if (index >= 0 && index < StringData.Length)
            {
                Tag  = StringData.Substring(0, index);
                Body = StringData.Substring(index + 1);
            }
            MessageType = messageType;
        }
Exemplo n.º 2
0
        public override void ProcessRawData()
        {
            try
            {
                var myArr = new ArrayList
                {
                    "WBC",
                    "RBC",
                    "HGB",
                    "HCT",
                    "MCV",
                    "MCH",
                    "MCHC",
                    "PLT",
                    "LYM%",
                    "MXD%",
                    "NEUT%",
                    "LYM#",
                    "MXD#",
                    "NEUT#",
                    "RDW",
                    "UNUSE",
                    "PDW",
                    "MPV",
                    "P-LCR"
                };

                Log.Trace("Begin Process Data");
                //Lưu lại Data
                Log.Trace(StringData);
                int idStx = StringData.IndexOf(DeviceHelper.STX);

                if ((StringData.Length < 457) || (idStx < 0))
                {
                    return;
                }

                string[] allPatients = SeparatorData(StringData.Substring(idStx));
                Log.Debug("Result has {0} patient(s)", allPatients.Length);

                foreach (string patient in allPatients)
                {
                    string[] tempdate = patient.Substring(1, 8).Split('/');
                    TestResult.TestDate = string.Format("{0}/{1}/{2}{3}", tempdate[2].Trim().PadLeft(2, '0'),
                                                        tempdate[1].Trim().PadLeft(2, '0'),
                                                        DateTime.Now.Year.ToString(CultureInfo.InvariantCulture).Substring(0, 2),
                                                        tempdate[0].Trim().PadLeft(2, '0'));
                    TestResult.Barcode = patient.Substring(14, 13).Trim();

                    string tempResult = patient.Substring(82, 120);
                    foreach (string testName in myArr)
                    {
                        string testValue = tempResult.Substring(0, 5);
                        tempResult = tempResult.Substring(5);
                        if (testName != "UNUSE")
                        {
                            AddResult(new ResultItem(testName, testValue));
                        }
                    }

                    Log.Debug("Begin Import Result");
                    ImportResults();
                    Log.Debug("Import Result Success");
                }
                Log.Trace("Finish Process Data");
                ClearData();
            }
            catch (Exception ex)
            {
                Log.Error("Error while process data Error:" + ex);
            }
            finally
            {
                //ClearData();
            }
        }
Exemplo n.º 3
0
        public override void ProcessRawData()
        {
            try
            {
                //Kiểm tra nếu chưa kết thúc nhận dữ liệu
                // if(!StringData.EndsWith(DeviceHelper.ETX.ToString())) return;
                if (StringData.IndexOf(DeviceHelper.ETX) < 0)
                {
                    return;
                }
                string[] strResult = DeviceHelper.DeleteAllBlankLine(StringData, DeviceHelper.CR.ToString());
                TestResult.Barcode  = strResult[15];
                TestResult.TestDate = string.Format("{0}/{1}/{2}", strResult[11], strResult[10], strResult[9]);

                ResultItem item;

                item = new ResultItem("WBC", strResult[16]);
                AddResult(item);

                item = new ResultItem("RBC", strResult[17]);
                AddResult(item);

                item = new ResultItem("HGB", strResult[18]);
                AddResult(item);

                item = new ResultItem("HCT", strResult[19]);
                AddResult(item);

                item = new ResultItem("MCV", strResult[20]);
                AddResult(item);

                item = new ResultItem("MCH", strResult[21]);
                AddResult(item);

                item = new ResultItem("MCHC", strResult[22]);
                AddResult(item);

                item = new ResultItem("PLT", strResult[24]);
                AddResult(item);

                item = new ResultItem("LY", strResult[28]);
                AddResult(item);

                item = new ResultItem("MO", strResult[29]);
                AddResult(item);

                item = new ResultItem("GR", strResult[30]);
                AddResult(item);

                item = new ResultItem("RDW", strResult[23]);
                AddResult(item);

                item = new ResultItem("PCT", strResult[25]);
                AddResult(item);

                item = new ResultItem("MPV", strResult[26]);
                AddResult(item);

                item = new ResultItem("PDW", strResult[27]);
                AddResult(item);
                ImportResults();
                ClearData();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public override void ProcessRawData()
        {
            try
            {
                //Kiểm tra ký tự STX khi kết thúc nhận dữ liệu.
                if (StringData.IndexOf(DeviceHelper.ETX) < 0)
                {
                    return;
                }
                string[] strResutl = DeviceHelper.DeleteAllBlankLine(StringData, DeviceHelper.CR.ToString());

                TestResult.TestSequence = strResutl[0];
                TestResult.TestDate     = strResutl[3].Substring(2, 8).Trim();
                TestResult.TestDate     = string.Format("{0}/{1}/20{2}", TestResult.TestDate.Substring(0, 2),
                                                        TestResult.TestDate.Substring(3, 2),
                                                        TestResult.TestDate.Substring(6, 2));

                //Barcode

                //TestResult.Barcode = strResutl[6].Substring(2);
                //Convert.ToInt32(strResutl[4].Split()[1]).ToString()

                //TestResult.Barcode = strResutl[6].Trim().Length < 2 ? "0" : strResutl[6].Substring(2);

                //Dệt May
                TestResult.Barcode = Convert.ToInt32(strResutl[4].Split()[1]).ToString();

                //Add Items

                AddResult(new ResultItem("WBC", strResutl[9].Substring(2, 5).Trim()));

                AddResult(new ResultItem("RBC", strResutl[10].Substring(2, 5).Trim()));

                AddResult(new ResultItem("HGB", strResutl[11].Substring(2, 5).Trim()));

                AddResult(new ResultItem("HTC", strResutl[12].Substring(2, 5).Trim()));

                AddResult(new ResultItem("MCV", strResutl[13].Substring(2, 5).Trim()));

                AddResult(new ResultItem("MCH", strResutl[14].Substring(2, 5).Trim()));

                AddResult(new ResultItem("MCHC", strResutl[15].Substring(2, 5).Trim()));

                AddResult(new ResultItem("RDW", strResutl[16].Substring(2, 5).Trim()));

                AddResult(new ResultItem("PLT", strResutl[17].Substring(2, 5).Trim()));

                AddResult(new ResultItem("MPV", strResutl[18].Substring(2, 5).Trim()));

                AddResult(new ResultItem("PCT", strResutl[19].Substring(2, 5).Trim()));

                AddResult(new ResultItem("PDW", strResutl[20].Substring(2, 5).Trim()));

                AddResult(new ResultItem("%LYM", strResutl[21].Substring(2, 5).Trim()));

                AddResult(new ResultItem("%MON", strResutl[22].Substring(2, 5).Trim()));

                AddResult(new ResultItem("%GRA", strResutl[23].Substring(2, 5).Trim()));

                AddResult(new ResultItem("#LYM", strResutl[24].Substring(2, 5).Trim()));

                AddResult(new ResultItem("#MON", strResutl[25].Substring(2, 5).Trim()));

                AddResult(new ResultItem("#GRA", strResutl[23].Substring(2, 5).Trim()));

                ImportResults();

                ClearData();
            }
            catch (Exception)
            {
                ClearData();
                throw;
            }
        }
Exemplo n.º 5
0
        public override void ProcessRawData()
        {
            try
            {
                Log.Trace(DeviceHelper.CRLF + StringData);
                string rawResult = StringData.Substring(StringData.IndexOf("SAMPLE RESULTS", StringComparison.Ordinal));
                if ((rawResult.IndexOf("Na") < 0) || (rawResult.IndexOf("K") < 0) || (rawResult.IndexOf("Cl") < 0))
                {
                    Log.Trace("Data is not valided");
                    return;
                }
                string[] strResutl = DeviceHelper.DeleteAllBlankLine(rawResult, DeviceHelper.CRLF.ToCharArray());
                Log.Trace("Begin Process Data");
                //Lưu lại Data
                //Lưu lại Data

                TestResult.TestDate = strResutl[strResutl.Length - 1].Substring(0, 9).Trim();
                string pTestDate = strResutl[strResutl.Length - 1].Substring(0, 3);
                pTestDate           = DeviceHelper.GetMonth(pTestDate);
                TestResult.TestDate = string.Format("{0}/{1}/{3}{2}", TestResult.TestDate.Substring(4, 2), pTestDate,
                                                    TestResult.TestDate.Substring(7, 2),
                                                    DateTime.Now.Year.ToString(CultureInfo.InvariantCulture).Substring(0, 2));

                //Lấy về dòng chứa ID
                int tempRowIndex = GetRowIndex(strResutl, "ID");
                if (tempRowIndex == -1)
                {
                    TestResult.Barcode = "0000";
                }
                else
                {
                    string[] tempId = strResutl[tempRowIndex].Split();
                    TestResult.Barcode = tempId.Length >= 2 ? Convert.ToInt32(tempId[1]).ToString() : "0000";
                }
                //Tìm đến phần tử đầu tien chứa kết quả.
                tempRowIndex = GetRowIndex(strResutl, "Na");
                if (tempRowIndex != -1)
                {
                    string[] tempResult = DeviceHelper.DeleteAllBlankLine(strResutl[tempRowIndex].Split());
                    AddResult(new ResultItem(tempResult[0].Replace("\"", "").Replace("^", "").Trim(),
                                             tempResult[1].Trim(), tempResult[2].Trim()));
                    tempResult = DeviceHelper.DeleteAllBlankLine(strResutl[tempRowIndex + 1].Split());
                    AddResult(new ResultItem(tempResult[0].Replace("\"", "").Replace("^", "").Trim(),
                                             tempResult[1].Trim(), tempResult[2].Trim()));
                    tempResult = DeviceHelper.DeleteAllBlankLine(strResutl[tempRowIndex + 2].Split());
                    AddResult(new ResultItem(tempResult[0].Replace("\"", "").Replace("^", "").Trim(),
                                             tempResult[1].Trim(), tempResult[2].Trim()));
                }

                Log.Debug("Begin Importdata");
                Log.Debug(ImportResults() ? "Finish Imported result" : "Error While Import Result to DB");
                ClearData();

                //  }
            }
            catch (Exception ex)
            {
                //throw ex;
                Log.Error("Error while processing data Error: {0}", ex);
                ClearData();
            }
        }