private void Search()
        {
            if (pnlResults.InvokeRequired)
            {
                EmptyDelegate ed = new EmptyDelegate(Search);
                Invoke(ed);
            }
            else
            {
                eligibility_data ed       = new eligibility_data();
                DataTable        matches  = ed.Search(BuildSQL());
                DateTime?        lastDate = new DateTime(1900, 1, 1);
                numAppointmentsFound = matches.Rows.Count;

                pnlResults.SuspendLayout();
                pnlResults.Controls.Clear();

                foreach (DataRow aRow in matches.Rows)
                {
                    ed = new eligibility_data();
                    ed.Load(aRow);
                    AddAppointment(ed, lastDate);
                    lastDate = ed.appt_date;
                }
                pnlResults.ResumeLayout();
                UpdateLastLabelSafe(lastDateLabel, numAppointmentsCurrentDate);
                UpdateBinCounts();
            }
        }
        /// <summary>
        /// Checks to see if a given record exists in our system. If so, updates it. If not, creates it.
        /// </summary>
        /// <param name="aRow"></param>
        /// <returns></returns>
        private void CheckCreateEligibility(DataRow aRow)
        {
            eligibility_data egd = new eligibility_data();

            egd.dentrix_id = Convert.ToInt32(aRow["APPTID"].ToString());
            egd.dentrix_db = Convert.ToInt32(aRow["APPTDB"].ToString());
            DataTable matches = egd.Search();

            if (matches.Rows.Count > 0)
            {
                // We have a copy of this stored locally
                egd.Load(matches.Rows[0]);
            }

            // appt_date PatName, ApptLen, Time_Hour, Time_Minute, ApptReason
            egd.patient_name = aRow["PatName"].ToString();
            egd.appt_length  = Convert.ToInt32(aRow["ApptLen"]);
            DateTime apptDay = Convert.ToDateTime(aRow["apptdate"].ToString());

            egd.appt_date      = new DateTime(apptDay.Year, apptDay.Month, apptDay.Day, Convert.ToInt32(aRow["Time_Hour"]), Convert.ToInt32(aRow["Time_Minute"]), 0);
            egd.procedure_info = aRow["apptReason"].ToString();

            egd.Save();
        }