public Cobase6000BiManager() { try { //if (DateTime.Now > new DateTime(2013, 06, 06)) throw new Exception("XXX"); _clsHRecord = new CobasE6000HeaderRecord(); _clsPRecord = new CobasE6000PatientInformationRecord(); _clsORecord = new CobasE6000TestOrderRecord(); _clsQRecord = new CobasE6000RequestInformationRecord(); _clsRRecord = new CobasE6000ResultRecord(); _clsTRecord = new CobasE6000TerminationRecord(); } catch (Exception ex) { Log.Error("Fatal Error: {0}", ex); } }
public void OrderTest() { try { const string rawHeader = @"O|1|000003 |3^5238^3^^S1^SC|^^^2^1|R||20000529125556||||N||||1|||||||20000529125645|||F"; var order = new CobasE6000TestOrderRecord(rawHeader); var neworder = new CobasE6000TestOrderRecord( @"O|1| 0003|0^5020^5^^S1^SC|^^^10^1|R||20121105163859||||N||||1|||||||20121105163860|||F"); Debug.WriteLine(order.Create()); Debug.WriteLine(neworder.Create()); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }
public Cobase6000Bi() { try { _clsHRecord = new CobasE6000HeaderRecord(); _clsPRecord = new CobasE6000PatientInformationRecord(); _clsORecord = new CobasE6000TestOrderRecord(); _clsQRecord = new CobasE6000RequestInformationRecord(); _clsRRecord = new CobasE6000ResultRecord(); _clsTRecord = new CobasE6000TerminationRecord(); _prvRequestArray = new Queue <List <string> >(); _objService = new ExternalDataExchangeService(); _failSending = 0; _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) { WaitForIdle = true }; DumpStateMachine(_objWorkFlowRuntime, _instanceId); } catch (Exception ex) { Log.Error("Fatal Error: {0}", ex); } }
private List <string> CreateOrderFrame(List <string> orderList) { var retList = new List <string>(); //Tạo Header mới var newHeaderRecord = (CobasE6000HeaderRecord)_clsHRecord.Clone(); newHeaderRecord.CommentOrSpecialInstructions.Data = "TSDWN^REPLY"; newHeaderRecord.SenderNameOrId.Data = _clsHRecord.ReveiverId.Data; newHeaderRecord.ReveiverId.Data = _clsHRecord.SenderNameOrId.Data; var sTemp = string.Format("{0}{1}{2}{3}", DeviceHelper.STX, "1", newHeaderRecord.Create(), DeviceHelper.ETB); var checksum = DeviceHelper.GetCheckSumValue(sTemp); retList.Add(string.Format("{0}{1}{2}", sTemp, checksum, DeviceHelper.CRLF)); //Xử lý kết quả if ((orderList != null) && (orderList.Count != 0)) { //Add Patient Record _clsPRecord.SequenceNumber.Data = "1"; _clsPRecord.PatientSex.Data = "U"; _clsPRecord.LaboratoryAssignedPatientId.Data = _sQBarcode; sTemp = string.Format("{0}{1}{2}{3}", DeviceHelper.STX, "2", _clsPRecord.Create(), DeviceHelper.ETB); checksum = DeviceHelper.GetCheckSumValue(sTemp); retList.Add(string.Format("{0}{1}{2}", sTemp, checksum, DeviceHelper.CRLF)); //Add OrderRecord _clsORecord = new CobasE6000TestOrderRecord(); _clsORecord.SequenceNumber.Data = "1"; _clsORecord.SpecimenId.Data = _sQBarcode.PadRight(22); var tempIsId = _clsQRecord.StartingRangeIdNumber.Data.Split(_clsQRecord.Rules.ComponentDelimiter); _clsORecord.InstrumentSpecimenId.Data = string.Join(_clsORecord.Rules.ComponentDelimiter.ToString(), new[] { tempIsId[3], tempIsId[4], tempIsId[5], tempIsId[6], tempIsId[7], tempIsId[8] }); _clsORecord.UniversalTestId.Data = _clsORecord.CreateUniversalTestid(orderList); _clsORecord.Priority.Data = "R"; _clsORecord.SpecimenCollectionDateAndTime.Data = DateTime.Now.ToString("yyyyMMddHHmmss"); _clsORecord.DateTimeResultReportedOrLastModified.Data = DateTime.Now.ToString("yyyyMMddHHmmss"); _clsORecord.ActionCode.Data = "A"; _clsORecord.SpecimenDescriptor.Data = "1"; _clsORecord.ReportTypes.Data = "O"; sTemp = string.Format("{0}{1}{2}{3}", DeviceHelper.STX, "3", _clsORecord.Create(), DeviceHelper.ETB); checksum = DeviceHelper.GetCheckSumValue(sTemp); retList.Add(string.Format("{0}{1}{2}", sTemp, checksum, DeviceHelper.CRLF)); _clsTRecord = new CobasE6000TerminationRecord(); sTemp = String.Concat(DeviceHelper.STX, "4", _clsTRecord.Create(), DeviceHelper.ETX); checksum = DeviceHelper.GetCheckSumValue(sTemp); retList.Add(string.Format("{0}{1}{2}", sTemp, checksum, DeviceHelper.CRLF)); } else { _clsTRecord = new CobasE6000TerminationRecord { TerminationCode = { Data = "N" } }; sTemp = String.Concat(DeviceHelper.STX, "2", _clsTRecord.Create(), DeviceHelper.ETX); checksum = DeviceHelper.GetCheckSumValue(sTemp); retList.Add(string.Format("{0}{1}{2}", sTemp, checksum, DeviceHelper.CRLF)); } return(retList); }
private void ProcessData() { try { var arrRecords = new string[] {}; if (_bufferData != string.Empty) { arrRecords = _bufferData.Split(new[] { _clsRRecord.Rules.EndOfRecordCharacter }, StringSplitOptions.RemoveEmptyEntries); } var i = 0; while (i < arrRecords.Length) { var arrFields = arrRecords[i].Split(_clsPRecord.Rules.FieldDelimiter); if (arrFields[0].Equals(_clsRRecord.RecordType.Data)) { _clsRRecord = new CobasE6000ResultRecord(arrRecords[i]); AddResult(_clsRRecord.GetResult()); _newResult = true; } if (arrFields[0].StartsWith(_clsPRecord.RecordType.Data)) { _clsPRecord = new CobasE6000PatientInformationRecord(arrRecords[i]); } else if (arrFields[0].StartsWith(_clsORecord.RecordType.Data)) { _clsORecord = new CobasE6000TestOrderRecord(arrRecords[i]); TestResult.Barcode = _clsORecord.SpecimenId.Data.Trim(); var tempDate = _clsORecord.DateTimeResultReportedOrLastModified.Data; TestResult.TestDate = string.Format("{0}/{1}/{2}", tempDate.Substring(6, 2), tempDate.Substring(4, 2), tempDate.Substring(0, 4)); } else if (arrFields[0].Equals(_clsQRecord.RecordType.Data)) { _clsQRecord = new CobasE6000RequestInformationRecord(arrRecords[i]); _sQBarcode = _clsQRecord.GetOrderBarcode(); _newQuery = true; var regList = GetRegList(_sQBarcode); if (regList != null) { if (regList.Count > 0) { Log.Debug(string.Format("So order: {0}", regList.Count.ToString())); foreach (string s in regList) { Log.Debug(string.Format("{0}\r\n", s)); } } else { Log.Debug("No order!"); } } else { Log.Debug("No order!"); } _prvRequestArray.Enqueue(CreateOrderFrame(regList)); } else if (arrFields[0].Equals(_clsHRecord.RecordType.Data)) { _clsHRecord = new CobasE6000HeaderRecord(arrRecords[i]); } i++; } if (_newQuery) { //Send((int)EventID.OpenNewOutputSession, _sQBarcode); _objAstm.CallGetQuery(_objDataEventArgs); if ((_prvRequestArray != null) && (_prvRequestArray.Count != 0)) { _currentOrder.Clear(); _currentOrder = _prvRequestArray.Dequeue(); _currentOrderIdx = 0; } //SendByte((byte)DeviceHelper.ENQ); _newQuery = false; } if (_newResult) { Log.Debug("Begin Import Result"); Log.Debug(ImportResults() ? "Import Result Success" : "Error While Import Result"); _newResult = false; } } catch (Exception ex) { Log.Error("Fatal Error:{0}", ex.ToString()); } }
public override bool ProcessData(string inputBuffer, ref List <string> orderList) { try { var arrRecords = new string[] {}; if (inputBuffer != string.Empty) { arrRecords = inputBuffer.Split(new[] { _clsRRecord.Rules.EndOfRecordCharacter }, StringSplitOptions.RemoveEmptyEntries); } int i = 0; bool _newResult = false; while (i < arrRecords.Length) { string[] arrFields = arrRecords[i].Split(_clsPRecord.Rules.FieldDelimiter); if (arrFields[0].Equals(_clsRRecord.RecordType.Data)) { _clsRRecord = new CobasE6000ResultRecord(arrRecords[i]); AddResult(_clsRRecord.GetResult()); _newResult = true; } if (arrFields[0].StartsWith(_clsPRecord.RecordType.Data)) { _clsPRecord = new CobasE6000PatientInformationRecord(arrRecords[i]); } else if (arrFields[0].StartsWith(_clsORecord.RecordType.Data)) { _clsORecord = new CobasE6000TestOrderRecord(arrRecords[i]); TestResult.Barcode = _clsORecord.SpecimenId.Data.Trim(); string tempDate = _clsORecord.DateTimeResultReportedOrLastModified.Data; TestResult.TestDate = string.Format("{0}/{1}/{2}", tempDate.Substring(6, 2), tempDate.Substring(4, 2), tempDate.Substring(0, 4)); } else if (arrFields[0].Equals(_clsQRecord.RecordType.Data)) { _clsQRecord = new CobasE6000RequestInformationRecord(arrRecords[i]); _sQBarcode = _clsQRecord.GetOrderBarcode(); List <string> regList = GetRegList(_sQBarcode); 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); return(true); } else if (arrFields[0].Equals(_clsHRecord.RecordType.Data)) { _clsHRecord = new CobasE6000HeaderRecord(arrRecords[i]); } i++; } if (_newResult) { Log.Debug("Begin Import Result"); Log.Debug(ImportResults() ? "Import Result Success" : "Error While Import Result"); return(false); } } catch (Exception ex) { Log.Error("Fatal Error:{0}", ex.ToString()); } return(false); }