private void ProcessAll()
        {
            // *** Non -1 is success ***
            string           entryId     = "";
            string           prevEntryId = "";
            DsioTrackingItem item        = null;

            // *** Use flag to indicate if first line is count ***
            //bool first = (this.operation == DsioGetTrackingOperation.All) ? true : false;
            bool first = true;

            // *** Loop through all lines ***
            foreach (string line in this.Response.Lines)
            {
                if (first)
                {
                    int count;
                    if (int.TryParse(line, out count))
                    {
                        this.TotalResults = count;
                    }
                    first = false;
                }
                else
                {
                    // *** Get type first ***
                    string lineType = Util.Piece(line, Caret, 1);

                    switch (lineType)
                    {
                    case "L":
                        // *** Add the previous item before creating a new one ***
                        AddTrackedItem(item);

                        // *** New tracking item ***
                        item = GetNewTrackingItem(line);

                        // *** Keep track of what the previous entry was ***
                        prevEntryId = entryId;

                        break;

                    case "P":
                        break;

                    case "C":
                        // *** Comment for previous tracking item ***
                        if (item != null)
                        {
                            item.Comment += Util.Piece(line, Caret, 3) + Environment.NewLine;
                        }

                        break;
                    }
                }
            }

            // *** Add the last (or only) item ***
            AddTrackedItem(item);
        }
        private void AddTrackedItem(DsioTrackingItem item)
        {
            // *** Check if we already have an item ***
            if (item != null)
            {
                // *** Create the list if necessary ***
                if (this.TrackingItems == null)
                {
                    this.TrackingItems = new List <DsioTrackingItem>();
                }

                // *** Add our previous item before we move on to next ***
                this.TrackingItems.Add(item);
            }
        }
        private DsioTrackingItem GetFlaggedTrackingItemFromLine(string line)
        {
            // *** New tracking item ***
            DsioTrackingItem item = new DsioTrackingItem();

            // *** Add the values ***
            item.Id = Util.Piece(line, Caret, 2).Substring(1);
            item.TrackingItemDateTime = Util.Piece(line, Caret, 3);
            item.Dfn          = Util.Piece(line, Caret, 4);
            item.PatientName  = Util.Piece(line, Caret, 5);
            item.User         = Util.Piece(line, Caret, 6);
            item.TrackingType = Util.Piece(line, Caret, 7);
            item.Source       = Util.Piece(line, Caret, 8);

            // TODO: Support list of reasons...
            item.Reason = Util.Piece(line, Caret, 9);

            return(item);
        }
        private void ProcessFlagged()
        {
            string currentPatient      = "";
            string currentTrackingItem = "";

            this.FlaggedPatientResult = new DsioFlaggedPatientResult();

            bool first = true;

            // *** Loop through all lines ***
            foreach (string line in this.Response.Lines)
            {
                if (first)
                {
                    int count;
                    if (int.TryParse(line, out count))
                    {
                        this.TotalResults = count;
                    }
                    first = false;
                }
                else
                {
                    string lineType = Util.Piece(line, Caret, 1);

                    switch (lineType)
                    {
                    case "P":
                        // Patient line
                        DsioFlaggedPatient flaggedPatient = new DsioFlaggedPatient();

                        flaggedPatient.Dfn = Util.Piece(line, Caret, 2);
                        string fullName = Util.Piece(line, CommandBase.Caret, 3);
                        flaggedPatient.LastName    = Util.Piece(fullName, ",", 1);
                        flaggedPatient.FirstName   = Util.Piece(fullName, ",", 2);
                        flaggedPatient.Last4       = Util.Piece(line, Caret, 4);
                        flaggedPatient.DateOfBirth = Util.Piece(line, Caret, 5);

                        this.FlaggedPatientResult.FlaggedPatients.Add(flaggedPatient.Dfn, flaggedPatient);

                        currentPatient = flaggedPatient.Dfn;
                        break;

                    case "C":
                        // Comment line
                        string comment = Util.Piece(line, Caret, 3);

                        if (this.FlaggedPatientResult.FlaggedPatients.ContainsKey(currentPatient))
                        {
                            if (this.FlaggedPatientResult.FlaggedPatients[currentPatient].TrackingItems.ContainsKey(currentTrackingItem))
                            {
                                this.FlaggedPatientResult.FlaggedPatients[currentPatient].TrackingItems[currentTrackingItem].Comment += string.Format("{0}{1}", comment, Environment.NewLine);
                            }
                        }

                        break;

                    case "L":

                        // Entry line
                        DsioTrackingItem trackingItem = GetFlaggedTrackingItemFromLine(line);

                        if (this.FlaggedPatientResult.FlaggedPatients.ContainsKey(currentPatient))
                        {
                            this.FlaggedPatientResult.FlaggedPatients[currentPatient].TrackingItems.Add(trackingItem.Id, trackingItem);
                        }

                        currentTrackingItem = trackingItem.Id;
                        break;
                    }
                }
            }
        }