public void Go()
        {
            if (string.IsNullOrEmpty(Data))
            {
                throw new ArgumentNullException();
            }

            if ((Data.Length % 2011) != 0)
            {
                throw new ArgumentException("Invalid data length");
            }

            var blockCount = Data.Length / 2011;

            for (var i = 0; i < blockCount; i += 2011)
            {
                var chunk  = Data.Substring(i, 2011);
                var record = new PsEdiData();
                using (var dataBlock = new FixedLengthReader(chunk))
                {
                    dataBlock.Read(record);
                    ProcessRecord(record);
                }
            }

            WriteListToGateway();
        }
        private void ProcessRecord(PsEdiData ediData)
        {
            try
            {
                var ediRecord = new EdiRecord();

                ediRecord.Patient.LastName      = ediData.PatientLastName;
                ediRecord.Patient.FirstName     = ediData.PatientFirstName;
                ediRecord.Patient.MiddleInitial = ediData.PatientMiddleInitial;

                ediRecord.Scrip.DrugID         = ediData.Ndc11;
                ediRecord.Scrip.PrescriptionID = ediData.RXOrderNumber;
                ediRecord.Scrip.RxStartDate    = ediData.MedAdminDate;
                ediRecord.Scrip.DoseTimesQtys  = ediData.MedAdminTime.ToString("HHmm") + ediData.Dose.ToString("00");
                ediRecord.Scrip.QtyPerDose     = Convert.ToDouble(ediData.Dose);
                ediRecord.Scrip.Refills        = Convert.ToInt32(ediData.RefillsRemaining ?? "0");
                ediRecord.Scrip.Sig            = $"{ediData.Sig}\n{ediData.ExpandedDirections}";

                ediRecord.Facility.LocationID   = ediData.FacilityId;
                ediRecord.Facility.LocationName = ediData.FacilityName;

                //
                // Apparently the system will send over a record per dose.  We'll treat the first data found as the start date
                // and carry on from there.
                //
                if (_recordList.Find(x => x.Scrip.PrescriptionID == ediRecord.Scrip.PrescriptionID) == null)
                {
                    _recordList.Add(ediRecord);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }