Exemple #1
0
        private string CreateOrderFrame(List <string> orderList)
        {
            _clsPRecord = new CentaurPatientRecord();
            _clsORecord = new CentaurOrderRecord();
            _clsTRecord = new CentaurTerminationRecord();
            string sTemp = String.Concat("1", _clsHRecord.sHeaderRecord);

            if ((orderList != null) && (orderList.Count > 0))
            {
                sTemp = String.Concat(sTemp, _clsPRecord.CreateData());
                sTemp = String.Concat(sTemp, _clsORecord.CreateData(_sQBarcode, orderList));
                sTemp = String.Concat(sTemp, _clsTRecord.TerminationRecord);
            }
            else
            {
                _clsTRecord.TerminationCode = "I";
                sTemp = String.Concat(sTemp, _clsTRecord.CreateData());
            }


            sTemp = String.Concat(DeviceHelper.STX, sTemp, DeviceHelper.ETX);
            string checksum   = DeviceHelper.GetCheckSumValue(sTemp);
            string orderFrame = String.Concat(sTemp, checksum, DeviceHelper.CRLF);

            Log.Debug("Order frame: <", orderFrame);
            return(orderFrame);
        }
 public Centaur()
 {
     _clsHRecord          = new CentaurHeaderRecord();
     _clsPRecord          = new CentaurPatientRecord();
     _clsORecord          = new CentaurOrderRecord();
     _clsQRecord          = new CentaurQueryRecord();
     _clsRRecord          = new CentaurResultRecord();
     _clsTRecord          = new CentaurTerminationRecord();
     TransitionCompleted += HandleTransitionCompleted;
 }
 public CentaurManager()
 {
     try
     {
         _clsHRecord = new CentaurHeaderRecord();
         _clsPRecord = new CentaurPatientRecord();
         _clsORecord = new CentaurOrderRecord();
         _clsQRecord = new CentaurQueryRecord();
         _clsRRecord = new CentaurResultRecord();
         _clsTRecord = new CentaurTerminationRecord();
     }
     catch (Exception ex)
     {
         Log.Error(string.Format("Error: {0}", ex));
     }
 }
Exemple #4
0
        public Centaur()
        {
            try
            {
                _clsHRecord              = new CentaurHeaderRecord();
                _clsPRecord              = new CentaurPatientRecord();
                _clsORecord              = new CentaurOrderRecord();
                _clsQRecord              = new CentaurQueryRecord();
                _clsRRecord              = new CentaurResultRecord();
                _clsTRecord              = new CentaurTerminationRecord();
                PrvRequestArray          = new Queue <string>();
                _failSending             = 0;
                _timeoutManager          = new Timer(30000);
                _timeoutManager.Elapsed += _timeoutManager_Elapsed;
                objService = new ExternalDataExchangeService();

                InstanceId = Guid.NewGuid();
                objWorkFlowRuntime.AddService(objService);
                objASTM = new ClsAstm();
                objService.AddService(objASTM);
                objASTM.SendACKEvent += objASTM_SendACKEvent;
                objASTM.SendNAKEvent += objASTM_SendNAKEvent;
                objASTM.SendENQEvent += objASTM_SendENQEvent;
                objASTM.SendEOTEvent += objASTM_SendEOTEvent;
                //objASTM.ACKTimeoutEvent += new EventHandler(objASTM_ACKTimeoutEvent);
                objWorkFlowInstance = objWorkFlowRuntime.CreateWorkflow(typeof(ASTMWorkflow), null, InstanceId);
                objWorkFlowInstance.Start();
                Console.WriteLine(@"Work flow started");

                objDataEventArgs             = new ExternalDataEventArgs(InstanceId);
                objDataEventArgs.WaitForIdle = true;
                DumpStateMachine(objWorkFlowRuntime, InstanceId);
            }
            catch (Exception ex)
            {
                Log.FatalException("Fatal Error: ", ex);
            }
        }
Exemple #5
0
        /// <summary>
        ///     Xử lý sau kkhi nhận được dữ liệu
        /// </summary>
        public void ProcessData()
        {
            try
            {
                var arrRecords  = new string[] {};
                var listRecords = new ArrayList();
                var 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);

                                if (!string.IsNullOrEmpty(_clsRRecord.DataValue.PubFieldData))
                                {
                                    AddResult(new ResultItem(_clsRRecord.TestId,
                                                             _clsRRecord.DataValue.PubFieldData));
                                    TestResult.TestDate = _clsRRecord.TestDate;
                                    _newResult          = true;
                                    break;
                                }
                            }
                            else if (fields[0].StartsWith(_clsQRecord.RecordType))
                            {
                                _clsQRecord = new CentaurQueryRecord(fields);
                                _sQBarcode  = _clsQRecord.QueryBarcode;
                                _newQuery   = true;
                                List <string> regList = GetRegList(_clsQRecord.QueryBarcode);
                                PrvRequestArray.Enqueue(CreateOrderFrame(regList));
                            }
                        }
                    }
                    ++i;
                }
                if (_newResult)
                {
                    ImportResults();
                    _newResult = false;
                }
                if (_newQuery)
                {
                    //Send((int)EventID.OpenNewOutputSession, _sQBarcode);

                    objASTM.CallGetQuery(objDataEventArgs);
                    _timeoutManager.Start();
                    _timeoutManager.Stop();
                    _lastState = 0;
                    //SendByte((byte)DeviceHelper.ENQ);
                    _newQuery = false;
                }
            }
            catch (Exception ex)
            {
                Log.FatalException("Fatal Error: ", ex);
            }
        }
        /// <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;
            }
        }
        public override bool ProcessData(string inputBuffer, ref List <string> orderList)

        {
            try
            {
                var arrRecords  = new string[] {};
                var listRecords = new ArrayList();
                var listFields  = new ArrayList();

                if (inputBuffer != string.Empty)
                {
                    arrRecords = inputBuffer.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);

                                if ((_clsRRecord.TestId.ToUpper().StartsWith("HBS")) ||
                                    (_clsRRecord.TestId.ToUpper() == @"AHCV") ||
                                    (_clsRRecord.TestId.ToUpper() == @"EHIV"))
                                {
                                    if (_clsRRecord.ResultAspects.Trim() == @"INDX")
                                    {
                                        AddResult(new ResultItem(_clsRRecord.TestId,
                                                                 _clsRRecord.DataValue.PubFieldData));
                                        _newResult          = true;
                                        TestResult.TestDate = _clsRRecord.TestDate;
                                    }
                                    continue;
                                }
                                if (_clsRRecord.ResultAspects.Trim() == @"DOSE")
                                {
                                    AddResult(new ResultItem(_clsRRecord.TestId,
                                                             _clsRRecord.DataValue.PubFieldData));
                                    _newResult          = true;
                                    TestResult.TestDate = _clsRRecord.TestDate;
                                }
                            }
                            else if (fields[0].StartsWith(_clsQRecord.RecordType))
                            {
                                _clsQRecord = new CentaurQueryRecord(fields);

                                List <string> regList = GetRegList(_clsQRecord.QueryBarcode);
                                orderList.Add(CreateOrderFrame(regList));
                                return(true);
                            }
                        }
                        Log.Debug("Begin Import Result");
                        Log.Debug(ImportResults() ? "Import Result Success" : "Error While Import Result");
                    }

                    ++i;
                }
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("Error: {0}", ex));
            }
            return(false);
        }