Пример #1
0
        /// <summary>
        /// Xử lý sau kkhi nhận được dữ liệu
        /// </summary>
        public override void ProcessData()
        {
            try
            {
                var       arrRecords  = new string[] {};
                ArrayList listRecords = new ArrayList();
                ArrayList listFields  = new ArrayList();

                if (BufferData != string.Empty)
                {
                    arrRecords = BufferData.Split(new[] { _clsRRecord.RecordDelimiter },
                                                  StringSplitOptions.RemoveEmptyEntries);
                }

                int i = 0;
                while (i < arrRecords.Length)
                {
                    string[] arrFields = arrRecords[i].Split(_clsPRecord.FieldDelimiter);

                    if (arrFields[0].Equals("H"))
                    {
                        while (!arrFields[0].Equals("L"))
                        {
                            if (++i > arrRecords.Length - 1)
                            {
                                break;
                            }
                            arrFields = arrRecords[i].Split(_clsPRecord.FieldDelimiter);
                            listFields.Add(arrFields);
                        }
                        listRecords.Add(listFields);
                    }

                    foreach (ArrayList l in listRecords)
                    {
                        foreach (string[] fields in l)
                        {
                            if (fields[0].StartsWith(_clsPRecord.RecordType))
                            {
                                _clsPRecord = new CentaurPatientRecord(fields);
                            }
                            else if (fields[0].StartsWith(_clsORecord.RecordType))
                            {
                                _clsORecord        = new CentaurOrderRecord(fields);
                                TestResult.Barcode = _clsORecord.Barcode;
                            }
                            else if (fields[0].StartsWith(_clsRRecord.RecordType))
                            {
                                _clsRRecord = new CentaurResultRecord(fields);

                                AddResult(new TestResult.ResultItem(_clsRRecord.TestId,
                                                                    _clsRRecord.DataValue.PubFieldData));
                                TestResult.TestDate = _clsRRecord.TestDate;
                                _newResult          = true;
                            }
                            else if (fields[0].StartsWith(_clsQRecord.RecordType))
                            {
                                _clsQRecord = new CentaurQueryRecord(fields);

                                _sQBarcode = _clsQRecord.QueryBarcode;
                                _newQuery  = true;
                            }
                        }

                        //if(_newResult )
                        //{
                        //    ImportResults();
                        //    _newResult = false;
                        //}
                        if (_newQuery)
                        {
                            Send((int)EventID.OpenNewOutputSession, _sQBarcode);
                            _newQuery = false;
                        }
                    }
                    ++i;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }