Beispiel #1
0
        public override void ProcessRawData()
        {
            try
            {
                Log.Trace("Begin Process Data");
                //Lưu lại Data
                Log.Trace("RawData:\n{0}", StringData);
                //Kiểm tra nếu là kí tự STX thì nhận dữ liệu
                if (
                    !(StringData.StartsWith(DeviceHelper.STX.ToString()) &&
                      StringData.EndsWith(DeviceHelper.ETX.ToString())))
                {
                    Log.Trace("Dữ liệu không hợp lệ");
                    return;
                }

                string[] rawData = StringData.Split(DeviceHelper.CR);

                //Lấy ngày:
                TestResult.TestDate = string.Format("{0}/{1}/{2}", rawData[17], rawData[16], rawData[15]);

                //Lấy barcode:
                TestResult.Barcode = rawData[22].Trim();

                //Add Kết quả:
                AddResult(new ResultItem("WBC", rawData[23].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("NE%", rawData[24].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("LY%", rawData[25].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("MO%", rawData[26].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("EO%", rawData[27].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("BA%", rawData[28].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("NE", rawData[29].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("LY", rawData[30].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("MO", rawData[31].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("EO", rawData[32].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("BA", rawData[33].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("RBC", rawData[34].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("HGB", rawData[35].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("HCT", rawData[36].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("MCV", rawData[37].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("MCH", rawData[38].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("MCHC", rawData[39].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("RDW", rawData[40].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("PLT", rawData[41].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));
                AddResult(new ResultItem("MPV", rawData[43].Replace("*", "").Replace("H", "").Replace("L", "").Trim()));

                Log.Trace("Begin Import Result");
                Log.Trace(ImportResults() ? "Import Result Success" : "Error while import result");
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("Error while process data {0}", ex));
            }
            finally
            {
                ClearData();
            }
        }
Beispiel #2
0
 private Boolean ValidData()
 {
     try
     {
         if (!StringData.StartsWith(DeviceHelper.STX.ToString(CultureInfo.InvariantCulture)) &&
             StringData.Length <= 8 && String.IsNullOrEmpty(StringData))
         {
             return(false);
         }
         if (StringData.Length <= 8)
         {
             return(false);
         }
         return(!String.IsNullOrEmpty(StringData));
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #3
0
 private Boolean ValidData()
 {
     try
     {
         if (String.IsNullOrEmpty(StringData))
         {
             return(false);
         }
         //  if (StringData.Length <= 4) return false;
         // if (!StringData.StartsWith(DeviceHelper.STX + "DB"))return false;
         if (!StringData.StartsWith(DeviceHelper.STX + "DB" + DeviceHelper.ETX))
         {
             return(false);
         }
         // if (!StringData.EndsWith(DeviceHelper.STX + DeviceHelper.STX + "DE" + DeviceHelper.ETX)) return false;
         //if (!StringData.EndsWith("DE" + DeviceHelper.ETX)) return false;
         // if (!StringData.EndsWith(DeviceHelper.STX+DeviceHelper.STX + "DE" + DeviceHelper.ETX)) return false;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #4
0
        public override void ProcessRawData()
        {
            try
            {
                Log.Trace("Begin Process Data");
                //Lưu lại Data
                Log.Trace(StringData);
                //Kiểm tra nếu là kí tự STX thì nhận dữ liệu
                if (StringData.StartsWith(DeviceHelper.STX.ToString(CultureInfo.InvariantCulture)) &&
                    StringData.Length >= 0 &&
                    String.IsNullOrEmpty(StringData))
                {
                    Log.Trace("Dữ liệu không hợp lệ");
                    return;
                }

                string[] arrPatients = DeviceHelper.DeleteAllBlankLine(StringData,
                                                                       DeviceHelper.STX.ToString(CultureInfo.InvariantCulture));

                foreach (string record in arrPatients)
                {
                    string[] result = record.Split(DeviceHelper.CR);
                    result = DeviceHelper.DeleteAllBlankLine(result);
                    //lay tháng
                    string pMonth = arrPatients[0].Substring(3, 3);
                    pMonth = GetMonth(pMonth);
                    //lấy ngày
                    string pday = result[0].Substring(0, 2);
                    //năm
                    string pYear = result[0].Substring(7, 2);

                    // lấy ngày tháng
                    TestResult.TestDate = string.Format("{0}/{1}/{2}", pday, pMonth,
                                                        string.Format("{0}{1}", DateTime.Now.Year.ToString(CultureInfo.InvariantCulture).Substring(0, 2),
                                                                      pYear));

                    //lấy barcode
                    TestResult.Barcode = result[1].Trim().Split()[0].Length < 1 ? "0" : result[1].Trim().Split()[0];

                    Log.Trace(string.Format("Barcode: {0}", TestResult.Barcode));
                    //add result
                    AddResult(new ResultItem("WBC", result[3].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("RBC", result[14].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    string hgb = result[15].Replace("L", "").Replace("H", "").Trim().Replace("*", "");
                    try
                    {
                        hgb = (Convert.ToDouble(hgb) * 10).ToString(CultureInfo.InvariantCulture);
                    }
                    catch
                    {
                    }
                    AddResult(new ResultItem("HGB", hgb));
                    AddResult(new ResultItem("HCT", result[16].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("MCV", result[17].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("MCH", result[18].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    string mchc = result[19].Replace("L", "").Replace("H", "").Trim().Replace("*", "");
                    try
                    {
                        mchc = (Convert.ToDouble(mchc) * 10).ToString(CultureInfo.InvariantCulture);
                    }
                    catch
                    {
                    }
                    AddResult(new ResultItem("MCHC", mchc));
                    AddResult(new ResultItem("PLT", result[21].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("%NE", result[6].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("%LY", result[4].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("%MO", result[5].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("%EO", result[7].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("%BA", result[8].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("#NE", result[11].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("#LY", result[9].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("#MO", result[10].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("#EO", result[12].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("#BA", result[13].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("RDW", result[20].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    AddResult(new ResultItem("MPV", result[23].Replace("L", "").Replace("H", "").Trim().Replace("*", "")));
                    ImportResults();
                    Log.Trace("Finish Import Result");
                }
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("{0} /n {1}", "Lỗi Trong quá trình xử lý dữ liệu", ex));
            }
            finally
            {
                ClearData();
            }
        }