Exemplo n.º 1
0
 public Ca500Manager()
 {
     try
     {
         _clsHRecord = new Ca500HeaderRecord();
         _clsPRecord = new Ca500PatientRecord();
         _clsORecord = new Ca500TestOrderRecord();
         _clsQRecord = new Ca500RequestInformationRecord();
         _clsRRecord = new Ca500ResultRecord();
         _clsTRecord = new Ca500TerminationRecord();
     }
     catch (Exception ex)
     {
         Log.Error("Fatal Error: {0}", ex);
     }
 }
Exemplo n.º 2
0
        public override bool ProcessData(string inputBuffer, ref List <string> orderList)
        {
            try
            {
                var arrRecords  = new string[] {};
                var listRecords = new ArrayList();


                if (inputBuffer != string.Empty)
                {
                    arrRecords = inputBuffer.Split(new[] { _clsRRecord.Rules.EndOfRecordCharacter },
                                                   StringSplitOptions.RemoveEmptyEntries);
                }
                int  i         = 0;
                bool newResult = false;
                bool newQuery  = false;
                while (i < arrRecords.Length)
                {
                    string[] arrFields = arrRecords[i].Split(_clsPRecord.Rules.FieldDelimiter);


                    if (arrFields[0].Equals(_clsHRecord.RecordType.Data))
                    {
                        var listFields = new ArrayList();
                        //listFields.Clear();
                        listFields.Add(arrFields);
                        listRecords.Add(listFields);

                        do
                        {
                            if (++i > arrRecords.Length - 1)
                            {
                                break;
                            }
                            arrFields = arrRecords[i].Split(_clsHRecord.Rules.FieldDelimiter);
                            //if (arrFields[0].Equals(_clsORecord.RecordType.Data) ||
                            //    arrFields[0].Equals(_clsRRecord.RecordType.Data))

                            listFields.Add(arrFields);
                        } while (!arrFields[0].Equals(_clsTRecord.RecordType.Data));
                    }

                    //else
                    ++i;
                }
                foreach (ArrayList l in listRecords)
                {
                    foreach (string[] fields in l)
                    {
                        if (fields[0].StartsWith(_clsPRecord.RecordType.Data))
                        {
                            _clsPRecord = new Ca500PatientRecord(fields);
                        }
                        else if (fields[0].StartsWith(_clsORecord.RecordType.Data))
                        {
                            _clsORecord        = new Ca500TestOrderRecord(fields);
                            TestResult.Barcode = _clsORecord.GetBarcode();
                        }
                        else if (fields[0].StartsWith(_clsRRecord.RecordType.Data))
                        {
                            _clsRRecord = new Ca500ResultRecord(fields);
                            string tempDate = _clsRRecord.DateTimeTestCompleted.Data;
                            TestResult.TestDate = string.Format("{0}/{1}/{2}", tempDate.Substring(6, 2),
                                                                tempDate.Substring(4, 2), tempDate.Substring(0, 4));

                            AddResult(_clsRRecord.GetResult());
                            newResult = true;
                        }
                        else if (fields[0].Equals(_clsQRecord.RecordType.Data))
                        {
                            _clsQRecord = new Ca500RequestInformationRecord(fields);
                            //_sQBarcode = _clsQRecord.GetOrderBarcode();
                            newQuery = true;

                            List <string> regList = GetRegList(_sQBarcode, ref _patientName);
                            if (regList != null)
                            {
                                if (regList.Count > 0)
                                {
                                    Log.Debug(string.Format("So order: {0}", regList.Count));
                                    foreach (string s in regList)
                                    {
                                        Log.Debug(string.Format("{0}\r\n", s));
                                    }
                                }
                                else
                                {
                                    Log.Debug("No order!");
                                }
                            }
                            else
                            {
                                Log.Debug("No order!");
                            }
                            orderList = CreateOrderFrame(regList);
                            //++i;
                        }
                        if (newResult)
                        {
                            Log.Debug("Begin Import Result");
                            Log.Debug(ImportResults() ? "Import Result Success" : "Error While Import Result");
                            newResult = false;
                            break;
                        }
                    }
                }

                if (newQuery)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                Log.Error("Fatal Error:{0}", ex.ToString());
            }
            return(false);
        }