private List <FlaggedPatient> ProcessDsioFlaggedPatients(Dictionary <string, DsioFlaggedPatient> dsioFlaggedPatients)
        {
            // *** Get list of flagged patients from dictionary of dsio flagged patients ***

            List <FlaggedPatient> returnList = new List <FlaggedPatient>();

            // *** Loop ***
            foreach (DsioFlaggedPatient dsioPatient in dsioFlaggedPatients.Values)
            {
                // *** Get tracking history for this patient ***

                DsioGetTrackingCommand command = new DsioGetTrackingCommand(broker);

                command.AddPatientLogsParameter(dsioPatient.Dfn);

                RpcResponse response = command.Execute();

                if (response.Status == RpcResponseStatus.Success)
                {
                    foreach (DsioTrackingItem item in command.TrackingItems)
                    {
                        dsioPatient.TrackingItems.Add(item.Id, item);
                    }
                }

                // *** Create new flagged patient and add to list ***
                FlaggedPatient patient = this.GetFlaggedPatient(dsioPatient);

                returnList.Add(patient);
            }
            return(returnList);
        }
        private FlaggedPatient GetFlaggedPatient(DsioFlaggedPatient dsioPatient)
        {
            // *** Create new flagged patient ***

            FlaggedPatient patient = new FlaggedPatient();

            patient.Dfn       = dsioPatient.Dfn;
            patient.FirstName = dsioPatient.FirstName;
            patient.LastName  = dsioPatient.LastName;

            if (dsioPatient.Last4.Length > 4)
            {
                if (dsioPatient.Last4.ToUpper().Contains("SENSITIVE"))
                {
                    patient.Last4   = "XXXX";
                    patient.FullSSN = dsioPatient.Last4;
                }
                else
                {
                    patient.Last4   = dsioPatient.Last4.Substring(5, 4);
                    patient.FullSSN = string.Format("XXX-XX-{0}", patient.Last4);
                }
            }
            else
            {
                patient.Last4   = dsioPatient.Last4;
                patient.FullSSN = string.Format("XXX-XX-{0}", patient.Last4);
            }

            //patient.FullSSN = string.Format("XXX-XX-{0}", dsioPatient.Last4);
            //patient.Last4 = dsioPatient.Last4;

            // *** Process/Parse dob ***
            DateTime dob;

            if (DateTime.TryParse(dsioPatient.DateOfBirth, out dob))
            {
                patient.DateOfBirth = dob;
            }
            else
            {
                patient.DateOfBirthInexact = Util.GetInexactDate(dsioPatient.DateOfBirth);
            }

            patient.FlagSummary = dsioPatient.FlagSummary;
            patient.FlaggedOn   = dsioPatient.FlaggedOn;

            return(patient);
        }