예제 #1
0
 private void RefreshList()
 {
     Cache.Refresh(InvalidType.Operatories);
     _listOps    = Operatories.GetDeepCopy();       //Already ordered by ItemOrder
     _listOpsOld = _listOps.Select(x => x.Copy()).ToList();
     FillGrid();
 }
예제 #2
0
        private void FormScheduleBlockEdit_Load(object sender, System.EventArgs e)
        {
            listType.Items.Clear();
            //This list will be null if there isn't a passed in list.  We pass in lists if we want to show a special modified list.
            if (_listBlockoutCatDefs == null)
            {
                _listBlockoutCatDefs = Defs.GetDefsForCategory(DefCat.BlockoutTypes, true);
            }
            for (int i = 0; i < _listBlockoutCatDefs.Count; i++)
            {
                listType.Items.Add(_listBlockoutCatDefs[i].ItemName);
                if (_schedCur.BlockoutType == _listBlockoutCatDefs[i].DefNum)
                {
                    listType.SelectedIndex = i;
                }
            }
            if (listType.Items.Count == 0)
            {
                MsgBox.Show(this, "You must setup blockout types first in Setup-Definitions.");
                DialogResult = DialogResult.Cancel;
                return;
            }
            if (listType.SelectedIndex == -1)
            {
                listType.SelectedIndex = 0;
            }
            listOp.Items.Clear();
            //Filter clinics by the clinic passed in.
            List <Operatory> listOpsShort = Operatories.GetDeepCopy(true);

            _listOps = new List <Operatory>();
            for (int i = 0; i < listOpsShort.Count; i++)
            {
                if (!PrefC.GetBool(PrefName.EasyNoClinics) && _clinicNum != 0)               //Using clinics and a clinic filter was passed in.
                {
                    if (listOpsShort[i].ClinicNum != _clinicNum)
                    {
                        continue;
                    }
                }
                listOp.Items.Add(listOpsShort[i].OpName);
                _listOps.Add(listOpsShort[i]);
                if (_schedCur.Ops.Contains(listOpsShort[i].OperatoryNum))
                {
                    listOp.SetSelected(listOp.Items.Count - 1, true);                 //Select the item that was just added.
                }
            }
            DateTime time;

            for (int i = 0; i < 24; i++)
            {
                time = DateTime.Today + TimeSpan.FromHours(7) + TimeSpan.FromMinutes(30 * i);
                comboStart.Items.Add(time.ToShortTimeString());
                comboStop.Items.Add(time.ToShortTimeString());
            }
            comboStart.Text = _schedCur.StartTime.ToShortTimeString();
            comboStop.Text  = _schedCur.StopTime.ToShortTimeString();
            textNote.Text   = _schedCur.Note;
            comboStart.Select();
        }
예제 #3
0
        ///<summary>When looking at a daily appointment module and the current appointment view is has 'OnlyScheduleProvs' turned on, this method will dynamically add additional operatories to visOps for providers that are scheduled to work.</summary>
        public static void AddOpsForScheduledProvs(bool isWeekly, List <Schedule> dailySched, ApptView apptViewCur, ref List <Operatory> visOps)
        {
            //if this appt view has the option to show only scheduled providers and this is daily view.
            //Remember that there is no intelligence in weekly view for this option, and it behaves just like it always did.
            if (ApptViews.IsNoneView(apptViewCur) ||
                dailySched == null ||
                visOps == null ||
                !apptViewCur.OnlyScheduledProvs ||
                isWeekly)
            {
                return;
            }
            //intelligently decide what ops to show.  It's based on the schedule for the day.
            //visOps will be totally empty right now because it looped out of the above section of code.
            List <long>      listSchedOps;
            bool             opAdded;
            int              indexOp;
            List <Operatory> listOpsShort       = Operatories.GetDeepCopy(true);
            List <long>      listApptViewOpNums = ApptViewItems.GetOpsForView(apptViewCur.ApptViewNum);

            for (int i = 0; i < listOpsShort.Count; i++)       //loop through all ops for all views (except the hidden ones, of course)
            //If this operatory was not one of the selected Ops from the Appt View Edit window, skip it.
            {
                if (!listApptViewOpNums.Contains(listOpsShort[i].OperatoryNum))
                {
                    continue;
                }
                //find any applicable sched for the op
                opAdded = false;
                for (int s = 0; s < dailySched.Count; s++)
                {
                    if (dailySched[s].SchedType != ScheduleType.Provider)
                    {
                        continue;
                    }
                    if (dailySched[s].StartTime == new TimeSpan(0))                   //skip if block starts at midnight.
                    {
                        continue;
                    }
                    if (dailySched[s].StartTime == dailySched[s].StopTime)                   //skip if block has no length.
                    {
                        continue;
                    }
                    if (apptViewCur.OnlySchedAfterTime > new TimeSpan(0, 0, 0))
                    {
                        if (dailySched[s].StartTime < apptViewCur.OnlySchedAfterTime ||
                            dailySched[s].StopTime < apptViewCur.OnlySchedAfterTime)
                        {
                            continue;
                        }
                    }
                    if (apptViewCur.OnlySchedBeforeTime > new TimeSpan(0, 0, 0))
                    {
                        if (dailySched[s].StartTime > apptViewCur.OnlySchedBeforeTime ||
                            dailySched[s].StopTime > apptViewCur.OnlySchedBeforeTime)
                        {
                            continue;
                        }
                    }
                    //this 'sched' must apply to this situation.
                    //listSchedOps is the ops for this 'sched'.
                    listSchedOps = dailySched[s].Ops;
                    //Add all the ops for this 'sched' to the list of visible ops
                    for (int p = 0; p < listSchedOps.Count; p++)
                    {
                        //Filter the ops if the clinic option was set for the appt view.
                        if (apptViewCur.ClinicNum > 0 && apptViewCur.ClinicNum != Operatories.GetOperatory(listSchedOps[p]).ClinicNum)
                        {
                            continue;
                        }
                        if (listSchedOps[p] == listOpsShort[i].OperatoryNum)
                        {
                            Operatory op = listOpsShort[i];
                            indexOp = Operatories.GetOrder(listSchedOps[p]);
                            if (indexOp != -1 && !visOps.Contains(op))                           //prevents adding duplicate ops
                            {
                                visOps.Add(op);
                                opAdded = true;
                                break;
                            }
                        }
                    }
                    //If the provider is not scheduled to any op(s), add their default op(s).
                    if (listOpsShort[i].ProvDentist == dailySched[s].ProvNum && listSchedOps.Count == 0)                 //only if the sched does not specify any ops
                    //Only add the op if the clinic option was not set in the appt view or if the op is assigned to that clinic.
                    {
                        if (apptViewCur.ClinicNum == 0 || apptViewCur.ClinicNum == listOpsShort[i].ClinicNum)
                        {
                            indexOp = Operatories.GetOrder(listOpsShort[i].OperatoryNum);
                            if (indexOp != -1 && !visOps.Contains(listOpsShort[i]))
                            {
                                visOps.Add(listOpsShort[i]);
                                opAdded = true;
                            }
                        }
                    }
                    if (opAdded)
                    {
                        break;                        //break out of the loop of schedules.  Continue with the next op.
                    }
                }
            }
            //Remove any duplicates before return.
            visOps = visOps.GroupBy(x => x.OperatoryNum).Select(x => x.First()).ToList();
        }
예제 #4
0
        private void FormScheduleEdit_Load(object sender, System.EventArgs e)
        {
            _isHolidayOrNote = (SchedCur.StartTime == TimeSpan.Zero && SchedCur.StopTime == TimeSpan.Zero);
            if (PrefC.HasClinicsEnabled)
            {
                if (ClinicNum == 0)
                {
                    Text += " - " + Lan.g(this, "Headquarters");
                }
                else
                {
                    string abbr = Clinics.GetAbbr(ClinicNum);
                    if (!string.IsNullOrWhiteSpace(abbr))
                    {
                        Text += " - " + abbr;
                    }
                }
                //if clinics are enabled and this is a holiday or practice note, set visible and fill the clinic combobox and private list of clinics
                if (_isHolidayOrNote && SchedCur.SchedType == ScheduleType.Practice)
                {
                    comboClinic.Visible = true;                  //only visible for holidays and practice notes and only if clinics are enabled
                    labelClinic.Visible = true;
                    _listClinics        = Clinics.GetForUserod(Security.CurUser);
                    if (!Security.CurUser.ClinicIsRestricted)
                    {
                        comboClinic.Items.Add(Lan.g(this, "Headquarters"));
                        if (SchedCur.ClinicNum == 0)                       //new sched and HQ selected or opened one from db for HQ
                        {
                            comboClinic.SelectedIndex = 0;
                        }
                    }
                    foreach (Clinic clinicCur in _listClinics)
                    {
                        comboClinic.Items.Add(clinicCur.Abbr);
                        if (clinicCur.ClinicNum == SchedCur.ClinicNum)
                        {
                            comboClinic.SelectedIndex = comboClinic.Items.Count - 1;
                        }
                    }
                    if (comboClinic.SelectedIndex < 0)                                                                                                 //current sched's clinic not found or set to 0 and user is restricted, default to clinic sent in
                    {
                        comboClinic.SelectedIndex = _listClinics.FindIndex(x => x.ClinicNum == ClinicNum) + (Security.CurUser.ClinicIsRestricted?0:1); //add one for HQ if not restricted
                    }
                }
            }
            textNote.Text = SchedCur.Note;
            if (_isHolidayOrNote)
            {
                comboStart.Visible = false;
                labelStart.Visible = false;
                comboStop.Visible  = false;
                labelStop.Visible  = false;
                listOps.Visible    = false;
                labelOps.Visible   = false;
                textNote.Select();
                return;
            }
            //from here on, NOT a practice note or holiday
            DateTime time;

            for (int i = 0; i < 24; i++)
            {
                time = DateTime.Today + TimeSpan.FromHours(7) + TimeSpan.FromMinutes(30 * i);
                comboStart.Items.Add(time.ToShortTimeString());
                comboStop.Items.Add(time.ToShortTimeString());
            }
            comboStart.Text = SchedCur.StartTime.ToShortTimeString();
            comboStop.Text  = SchedCur.StopTime.ToShortTimeString();
            listOps.Items.Add(Lan.g(this, "not specified"));
            //filter list if using clinics and if a clinic filter was passed in to only ops assigned to the specified clinic, otherwise all non-hidden ops
            _listOps = Operatories.GetDeepCopy(true);
            if (PrefC.HasClinicsEnabled && ClinicNum > 0)
            {
                _listOps.RemoveAll(x => x.ClinicNum != ClinicNum);
            }
            foreach (Operatory opCur in _listOps)
            {
                int curIndex = listOps.Items.Add(opCur.OpName);
                //Select the item that was just added if the schedule's Ops contains the current OpNum.
                listOps.SetSelected(curIndex, SchedCur.Ops.Contains(opCur.OperatoryNum));
            }
            listOps.SetSelected(0, listOps.SelectedIndices.Count == 0);         //select 'not specified' if no ops were selected in the loop
            comboStart.Select();
        }
예제 #5
0
        ///<summary></summary>
        public static List <DateTime> GetSearchResults(long aptNum, DateTime afterDate, List <long> providerNums, int resultCount, TimeSpan beforeTime, TimeSpan afterTime)
        {
            if (beforeTime == TimeSpan.FromSeconds(0))           //if they didn't set a before time, set it to a large timespan so that we can use the same logic for checking appointment times.
            {
                beforeTime = TimeSpan.FromHours(25);             //bigger than any time of day.
            }
            SearchBehaviorCriteria SearchType   = (SearchBehaviorCriteria)PrefC.GetInt(PrefName.AppointmentSearchBehavior);
            List <DateTime>        retVal       = new List <DateTime>();
            DateTime           dayEvaluating    = afterDate.AddDays(1);
            Appointment        appointmentToAdd = Appointments.GetOneApt(aptNum);
            List <DateTime>    potentialProvAppointmentTime;
            List <DateTime>    potentialOpAppointmentTime;
            List <Operatory>   opsListAll                          = Operatories.GetDeepCopy();                 //all operatory Numbers
            List <Schedule>    scheduleListAll                     = Schedules.GetTwoYearPeriod(dayEvaluating); // Schedules for the given day.
            List <Appointment> appointmentListAll                  = Appointments.GetForPeriodList(dayEvaluating, dayEvaluating.AddYears(2));
            List <ScheduleOp>  schedOpListAll                      = ScheduleOps.GetForSchedList(scheduleListAll);
            List <ApptSearchProviderSchedule>  provScheds          = new List <ApptSearchProviderSchedule>();  //Provider Bar, ProviderSched Bar, Date and Provider
            List <ApptSearchOperatorySchedule> operatrorySchedules = new List <ApptSearchOperatorySchedule>(); //filtered based on SearchType
            List <long> operatoryNums = new List <long>();                                                     //more usefull than a list of operatories.

            for (int i = 0; i < opsListAll.Count; i++)
            {
                operatoryNums.Add(opsListAll[i].OperatoryNum);
            }
            while (retVal.Count < resultCount && dayEvaluating < afterDate.AddYears(2))
            {
                potentialOpAppointmentTime = new List <DateTime>();               //clear or create
                //Providers-------------------------------------------------------------------------------------------------------------------------------------
                potentialProvAppointmentTime = new List <DateTime>();             //clear or create
                provScheds = Appointments.GetApptSearchProviderScheduleForProvidersAndDate(providerNums, dayEvaluating, scheduleListAll, appointmentListAll);
                for (int i = 0; i < provScheds.Count; i++)
                {
                    for (int j = 0; j < 288; j++)               //search every 5 minute increment per day
                    {
                        if (j + appointmentToAdd.Pattern.Length > 288)
                        {
                            break;
                        }
                        if (potentialProvAppointmentTime.Contains(dayEvaluating.AddMinutes(j * 5)))
                        {
                            continue;
                        }
                        bool addDateTime = true;
                        for (int k = 0; k < appointmentToAdd.Pattern.Length; k++)
                        {
                            if ((provScheds[i].ProvBar[j + k] == false && appointmentToAdd.Pattern[k] == 'X') || provScheds[i].ProvSchedule[j + k] == false)
                            {
                                addDateTime = false;
                                break;
                            }
                        }
                        if (addDateTime)
                        {
                            potentialProvAppointmentTime.Add(dayEvaluating.AddMinutes(j * 5));
                        }
                    }
                }
                if (SearchType == SearchBehaviorCriteria.ProviderTimeOperatory)               //Handle Operatories here----------------------------------------------------------------------------
                {
                    operatrorySchedules        = GetAllForDate(dayEvaluating, scheduleListAll, appointmentListAll, schedOpListAll, operatoryNums, providerNums);
                    potentialOpAppointmentTime = new List <DateTime>(); //create or clear
                    //for(int j=0;j<operatrorySchedules.Count;j++) {//for each operatory
                    for (int i = 0; i < 288; i++)                       //search every 5 minute increment per day
                    {
                        if (i + appointmentToAdd.Pattern.Length > 288)  //skip if appointment would span across midnight
                        {
                            break;
                        }
                        for (int j = 0; j < operatrorySchedules.Count; j++)                   //for each operatory
                        //if(potentialOpAppointmentTime.Contains(dayEvaluating.AddMinutes(i*5))) {//skip if we already have this dateTime
                        //  break;
                        //}
                        {
                            bool addDateTime = true;
                            for (int k = 0; k < appointmentToAdd.Pattern.Length; k++)                       //check appointment against operatories
                            {
                                if (operatrorySchedules[j].OperatorySched[i + k] == false)
                                {
                                    addDateTime = false;
                                    break;
                                }
                            }
                            if (!addDateTime)
                            {
                                continue;
                            }
                            if (addDateTime)                            // && SearchType==SearchBehaviorCriteria.ProviderTimeOperatory) {//check appointment against providers available for the given operatory
                            {
                                bool provAvail = false;
                                for (int k = 0; k < providerNums.Count; k++)
                                {
                                    if (!operatrorySchedules[j].ProviderNums.Contains(providerNums[k]))
                                    {
                                        continue;
                                    }
                                    provAvail = true;
                                    for (int m = 0; m < appointmentToAdd.Pattern.Length; m++)
                                    {
                                        if ((provScheds[k].ProvBar[i + m] == false && appointmentToAdd.Pattern[m] == 'X') || provScheds[k].ProvSchedule[i + m] == false)                               //if provider bar time slot
                                        {
                                            provAvail = false;
                                            break;
                                        }
                                    }
                                    if (provAvail)                                     //found a provider with an available operatory
                                    {
                                        break;
                                    }
                                }
                                if (provAvail && addDateTime)                                 //operatory and provider are available
                                {
                                    potentialOpAppointmentTime.Add(dayEvaluating.AddMinutes(i * 5));
                                }
                            }
                            else                              //not using SearchBehaviorCriteria.ProviderTimeOperatory
                            {
                                if (addDateTime)
                                {
                                    potentialOpAppointmentTime.Add(dayEvaluating.AddMinutes(i * 5));
                                }
                            }
                        }
                    }
                }
                //At this point the potentialOpAppointmentTime is already filtered and only contains appointment times that match both provider time and operatory time.
                switch (SearchType)
                {
                case SearchBehaviorCriteria.ProviderTime:
                    //Add based on provider bars
                    for (int i = 0; i < potentialProvAppointmentTime.Count; i++)
                    {
                        if (potentialProvAppointmentTime[i].TimeOfDay > beforeTime || potentialProvAppointmentTime[i].TimeOfDay < afterTime)
                        {
                            continue;
                        }
                        retVal.Add(potentialProvAppointmentTime[i]); //add one for this day
                        break;                                       //stop looking through potential times for today.
                    }
                    break;

                case SearchBehaviorCriteria.ProviderTimeOperatory:
                    //add based on provider bar and operatory bar
                    for (int i = 0; i < potentialOpAppointmentTime.Count; i++)
                    {
                        if (potentialOpAppointmentTime[i].TimeOfDay > beforeTime || potentialOpAppointmentTime[i].TimeOfDay < afterTime)
                        {
                            continue;
                        }
                        retVal.Add(potentialOpAppointmentTime[i]); //add one for this day
                        break;                                     //stop looking through potential times for today.
                    }
                    break;
                }
                dayEvaluating = dayEvaluating.AddDays(1);
            }
            return(retVal);
        }
예제 #6
0
        /// <summary>Uses Inputs to construct a List&lt;ApptSearchOperatorySchedule&gt;. It is written to reduce the number of queries to the database.</summary>
        private static List <ApptSearchOperatorySchedule> GetAllForDate(DateTime ScheduleDate, List <Schedule> ScheduleList, List <Appointment> AppointmentList, List <ScheduleOp> ScheduleOpList, List <long> OperatoryNums, List <long> ProviderNums)
        {
            List <ApptSearchOperatorySchedule> retVal         = new List <ApptSearchOperatorySchedule>();
            List <ApptSearchOperatorySchedule> opSchedListAll = new List <ApptSearchOperatorySchedule>();
            List <Operatory> opsListAll = Operatories.GetDeepCopy();

            opsListAll.Sort(compareOpsByOpNum);                                    //sort by Operatory Num Ascending
            OperatoryNums.Sort();                                                  //Sort by operatory Num Ascending to match
            List <List <long> > opsProvPerSchedules   = new List <List <long> >(); //opsProvPerSchedules[<opIndex>][ProviderNums] based solely on schedules, lists of providers 'allowed' to work in the given operatory
            List <List <long> > opsProvPerOperatories = new List <List <long> >(); //opsProvPerSchedules[<opIndex>][ProviderNums] based solely on operatories, lists of providers 'allowed' to work in the given operatory
            List <List <long> > opsProvIntersect      = new List <List <long> >(); ////opsProvPerSchedules[<opIndex>][ProviderNums] based on the intersection of the two data sets above.

            ScheduleDate = ScheduleDate.Date;                                      //remove time component
            for (int i = 0; i < OperatoryNums.Count; i++)
            {
                opSchedListAll.Add(new ApptSearchOperatorySchedule());
                opSchedListAll[i].SchedDate      = ScheduleDate;
                opSchedListAll[i].ProviderNums   = new List <long>();
                opSchedListAll[i].OperatoryNum   = OperatoryNums[i];
                opSchedListAll[i].OperatorySched = new bool[288];
                for (int j = 0; j < 288; j++)
                {
                    opSchedListAll[i].OperatorySched[j] = true;                  //Set entire operatory schedule to true. True=available.
                }
                opsProvPerSchedules.Add(new List <long>());
                opsProvPerOperatories.Add(new List <long>());
                opsProvIntersect.Add(new List <long>());
            }
            #region fillOpSchedListAll.ProviderNums
            for (int i = 0; i < ScheduleList.Count; i++)            //use this loop to fill opsProvPerSchedules
            {
                if (ScheduleList[i].SchedDate.Date != ScheduleDate) //only schedules for the applicable day.
                {
                    continue;
                }
                int schedopsforschedule = 0;
                for (int j = 0; j < ScheduleOpList.Count; j++)
                {
                    if (ScheduleOpList[j].ScheduleNum != ScheduleList[i].ScheduleNum)                   //ScheduleOp does not apply to this schedule
                    {
                        continue;
                    }
                    schedopsforschedule++;
                    int indexofop = OperatoryNums.IndexOf(ScheduleOpList[j].OperatoryNum);                    //cache to increase speed
                    if (opsProvPerSchedules[indexofop].Contains(ScheduleList[i].ProvNum))                     //only add ones that have not been added.
                    {
                        continue;
                    }
                    opsProvPerSchedules[indexofop].Add(ScheduleList[i].ProvNum);
                }
                if (schedopsforschedule == 0)               //Provider is scheduled to work, but not limited to any specific operatory so add provider num to all operatories in opsProvPerSchedules
                {
                    for (int k = 0; k < opsProvPerSchedules.Count; k++)
                    {
                        if (opsProvPerSchedules[k].Contains(ScheduleList[i].ProvNum))
                        {
                            continue;
                        }
                        opsProvPerSchedules[k].Add(ScheduleList[i].ProvNum);
                    }
                }
            }
            for (int i = 0; i < opsListAll.Count; i++)       //use this loop to fill opsProvPerOperatories
            {
                opsProvPerOperatories[i].Add(opsListAll[i].ProvDentist);
                opsProvPerOperatories[i].Add(opsListAll[i].ProvHygienist);
            }
            for (int i = 0; i < opsProvPerSchedules.Count; i++)       //Use this loop to fill opsProvIntersect by finding matching pairs in opsProvPerSchedules and opsProvPerOperatories
            {
                for (int j = 0; j < opsProvPerSchedules[i].Count; j++)
                {
                    if (opsProvPerOperatories[i][0] == 0 && opsProvPerOperatories[i][1] == 0)                 //There are no providers set for this operatory, use all the provider nums from the schedules.
                    {
                        opsProvIntersect[i].Add(opsProvPerSchedules[i][j]);
                        opSchedListAll[i].ProviderNums.Add(opsProvPerSchedules[i][j]);
                        continue;
                    }
                    if (opsProvPerSchedules[i][j] == 0)
                    {
                        continue;                                                     //just in case a non valid prov num got through.
                    }
                    if (opsProvPerOperatories[i].Contains(opsProvPerSchedules[i][j])) //if a provider was assigned and matches
                    {
                        opsProvIntersect[i].Add(opsProvPerSchedules[i][j]);
                        opSchedListAll[i].ProviderNums.Add(opsProvPerSchedules[i][j]);
                    }
                }
            }
            #endregion fillOpSchedListAll.ProviderNums
            for (int i = 0; i < AppointmentList.Count; i++)              //use this loop to set all operatory schedules.
            {
                if (AppointmentList[i].AptDateTime.Date != ScheduleDate) //skip appointments that do not apply to this date
                {
                    continue;
                }
                if (AppointmentList[i].Op == 0)               //If the appointment isn't associated to an Op, it isn't on the schedule and won't interfere with available timeslots.
                {
                    continue;
                }
                int indexofop     = OperatoryNums.IndexOf(AppointmentList[i].Op);
                int aptstartindex = (int)AppointmentList[i].AptDateTime.TimeOfDay.TotalMinutes / 5;
                for (int j = 0; j < AppointmentList[i].Pattern.Length; j++)              //make unavailable all blocks of time during this appointment.
                {
                    opSchedListAll[indexofop].OperatorySched[aptstartindex + j] = false; //Set time block to false, meaning something is scheduled here.
                }
            }
            for (int i = 0; i < opSchedListAll.Count; i++)       //Filter out operatory schedules for ops that our selected providers don't work in.
            {
                if (retVal.Contains(opSchedListAll[i]))
                {
                    continue;
                }
                for (int j = 0; j < opSchedListAll[i].ProviderNums.Count; j++)
                {
                    if (ProviderNums.Contains(opSchedListAll[i].ProviderNums[j]))
                    {
                        retVal.Add(opSchedListAll[i]);
                        break;
                    }
                }
            }
            //For Future Use When adding third search behavior:
            //if((SearchBehaviorCriteria)PrefC.GetInt(PrefName.AppointmentSearchBehavior)==SearchBehaviorCriteria.OperatoryOnly) {
            //  return opSchedListAll;
            //}
            return(retVal);
        }
예제 #7
0
        private void DoSearch()
        {
            Cursor = Cursors.WaitCursor;
            DateTime startDate = dateSearchFrom.Value.Date.AddDays(-1);          //Text on boxes is To/From. This will effecitvely make it the 'afterDate'.
            DateTime endDate   = dateSearchTo.Value.Date.AddDays(1);

            _listOpenings.Clear();
            #region validation
            if (startDate.Year < 1880 || endDate.Year < 1880)
            {
                Cursor = Cursors.Default;
                MsgBox.Show(this, "Invalid date selection.");
                return;
            }
            TimeSpan beforeTime = new TimeSpan(0);
            if (textBefore.Text != "")
            {
                try {
                    beforeTime = GetBeforeAfterTime(textBefore.Text, radioBeforePM.Checked);
                }
                catch {
                    Cursor = Cursors.Default;
                    MsgBox.Show(this, "Invalid 'Starting before' time.");
                    return;
                }
            }
            TimeSpan afterTime = new TimeSpan(0);
            if (textAfter.Text != "")
            {
                try {
                    afterTime = GetBeforeAfterTime(textAfter.Text, radioAfterPM.Checked);
                }
                catch {
                    Cursor = Cursors.Default;
                    MsgBox.Show(this, "Invalid 'Starting after' time.");
                    return;
                }
            }
            if (comboBoxMultiProv.SelectedTags <Provider>().Contains(null) && comboBlockout.GetSelectedDefNum() == 0)
            {
                Cursor = Cursors.Default;
                MsgBox.Show(this, "Please pick a provider or a blockout type.");
                return;
            }
            #endregion
            //get lists of info to do the search
            List <long> listOpNums     = new List <long>();
            List <long> listClinicNums = new List <long>();
            List <long> listProvNums   = new List <long>();
            long        blockoutType   = 0;
            if (comboBlockout.GetSelectedDefNum() != 0)
            {
                blockoutType = comboBlockout.GetSelectedDefNum();
                listProvNums.Add(0);                //providers don't matter for blockouts
            }
            if (!comboBoxMultiProv.SelectedTags <Provider>().Contains(null))
            {
                foreach (ODBoxItem <Provider> provBoxItem in comboBoxMultiProv.ListSelectedItems)
                {
                    listProvNums.Add(provBoxItem.Tag.ProvNum);
                }
            }
            if (PrefC.HasClinicsEnabled)
            {
                if (comboBoxClinic.SelectedClinicNum != 0)
                {
                    listClinicNums.Add(comboBoxClinic.SelectedClinicNum);
                    listOpNums = Operatories.GetOpsForClinic(comboBoxClinic.SelectedClinicNum).Select(x => x.OperatoryNum).ToList();
                }
                else                  //HQ //and unassigned (which is clinic num 0)
                {
                    long apptViewNum = comboApptView.GetSelected <ApptView>().ApptViewNum;
                    //get the disctinct clinic nums for the operatories in the current appointment view
                    List <long>      listOpsForView  = ApptViewItems.GetOpsForView(apptViewNum);
                    List <Operatory> listOperatories = Operatories.GetOperatories(listOpsForView, true);
                    listClinicNums = listOperatories.Select(x => x.ClinicNum).Distinct().ToList();
                    listOpNums     = listOperatories.Select(x => x.OperatoryNum).ToList();
                }
            }
            else              //no clinics
            {
                listOpNums = Operatories.GetDeepCopy(true).Select(x => x.OperatoryNum).ToList();
            }
            if (blockoutType != 0 && listProvNums.Max() > 0)
            {
                _listOpenings.AddRange(ApptSearch.GetSearchResultsForBlockoutAndProvider(listProvNums, _appt.AptNum, startDate, endDate, listOpNums, listClinicNums
                                                                                         , beforeTime, afterTime, blockoutType, 15));
            }
            else
            {
                _listOpenings = ApptSearch.GetSearchResults(_appt.AptNum, startDate, endDate, listProvNums, listOpNums, listClinicNums
                                                            , beforeTime, afterTime, blockoutType, resultCount: 15);
            }
            Cursor = Cursors.Default;
            FillGrid();
        }