///<summary>Gets up to 30 days of open time slots based on the RecallType passed in. ///Open time slots are found by looping through operatories flagged for Web Sched and finding openings that can hold the RecallType. ///The RecallType passed in must be a valid recall type. ///Providers passed in will be the only providers considered when looking for available time slots. ///Passing in a null clinic will only consider operatories with clinics set to 0 (unassigned). ///The timeslots on and between the Start and End dates passed in will be considered and potentially returned as available. ///Optionally pass in a recall object in order to consider all other recalls due for the patient. This will potentially affect the time pattern. ///Throws exceptions.</summary> public static List <TimeSlot> GetAvailableWebSchedTimeSlots(RecallType recallType, List <Provider> listProviders, Clinic clinic , DateTime dateStart, DateTime dateEnd, Recall recallCur = null) { //No need to check RemotingRole; no call to db. if (recallType == null) //Validate that recallType is not null. { throw new ODException(Lans.g("WebSched", "The recall appointment you are trying to schedule is no longer available.") + "\r\n" + Lans.g("WebSched", "Please call us to schedule your appointment.")); } //Get all the Operatories that are flagged for Web Sched. List <Operatory> listOperatories = Operatories.GetOpsForWebSched(); if (listOperatories.Count < 1) //This is very possible for offices that aren't set up the way that we expect them to be. { throw new ODException(Lans.g("WebSched", "There are no operatories set up for Web Sched.") + "\r\n" + Lans.g("WebSched", "Please call us to schedule your appointment."), ODException.ErrorCodes.NoOperatoriesSetup); } List <long> listProvNums = listProviders.Select(x => x.ProvNum).Distinct().ToList(); List <Schedule> listSchedules = Schedules.GetSchedulesAndBlockoutsForWebSched(listProvNums, dateStart, dateEnd, true , (clinic == null) ? 0 : clinic.ClinicNum); string timePatternRecall = recallType.TimePattern; //Apparently scheduling this one recall can potentially schedule a bunch of other recalls at the same time. //We need to potentially bloat our time pattern based on the other recalls that are due for this specific patient. if (recallCur != null) { Patient patCur = Patients.GetLim(recallCur.PatNum); List <Recall> listRecalls = Recalls.GetList(recallCur.PatNum); timePatternRecall = Recalls.GetRecallTimePattern(recallCur, listRecalls, patCur, new List <string>()); } string timePatternAppointment = RecallTypes.ConvertTimePattern(timePatternRecall); return(GetTimeSlotsForRange(dateStart, dateEnd, timePatternAppointment, listProvNums, listOperatories, listSchedules, clinic)); }
///<summary>Gets up to 30 days of open time slots based on the RecallType passed in. ///Open time slots are found by looping through operatories flagged for Web Sched and finding openings that can hold the RecallType. ///The RecallType passed in must be a valid recall type. ///Providers passed in will be the only providers considered when looking for available time slots. ///Passing in a null clinic will only consider operatories with clinics set to 0 (unassigned). ///The timeslots on and between the Start and End dates passed in will be considered and potentially returned as available. ///Optionally pass in a recall object in order to consider all other recalls due for the patient. This will potentially affect the time pattern. ///Throws exceptions.</summary> public static List <TimeSlot> GetAvailableWebSchedTimeSlots(RecallType recallType, List <Provider> listProviders, Clinic clinic , DateTime dateStart, DateTime dateEnd, Recall recallCur = null, Logger.IWriteLine log = null) { //No need to check RemotingRole; no call to db. if (recallType == null) //Validate that recallType is not null. { throw new ODException(Lans.g("WebSched", "The recall appointment you are trying to schedule is no longer available.") + "\r\n" + Lans.g("WebSched", "Please call us to schedule your appointment.")); } //Get all the Operatories that are flagged for Web Sched. List <Operatory> listOperatories = Operatories.GetOpsForWebSched(); if (listOperatories.Count < 1) //This is very possible for offices that aren't set up the way that we expect them to be. { throw new ODException(Lans.g("WebSched", "There are no operatories set up for Web Sched.") + "\r\n" + Lans.g("WebSched", "Please call us to schedule your appointment."), ODException.ErrorCodes.NoOperatoriesSetup); } log?.WriteLine("listOperatories:\r\n\t" + string.Join(",\r\n\t", listOperatories.Select(x => x.OperatoryNum + " - " + x.Abbrev)), LogLevel.Verbose); List <long> listProvNums = listProviders.Select(x => x.ProvNum).Distinct().ToList(); List <Schedule> listSchedules = Schedules.GetSchedulesAndBlockoutsForWebSched(listProvNums, dateStart, dateEnd, true , (clinic == null) ? 0 : clinic.ClinicNum, log); log?.WriteLine("listSchedules:\r\n\t" + string.Join(",\r\n\t", listSchedules.Select(x => x.ScheduleNum + " - " + x.SchedDate + " " + x.StartTime)) , LogLevel.Verbose); string timePatternRecall = recallType.TimePattern; //Apparently scheduling this one recall can potentially schedule a bunch of other recalls at the same time. //We need to potentially bloat our time pattern based on the other recalls that are due for this specific patient. if (recallCur != null) { Patient patCur = Patients.GetPat(recallCur.PatNum); List <Recall> listRecalls = Recalls.GetList(recallCur.PatNum); timePatternRecall = Recalls.GetRecallTimePattern(recallCur, listRecalls, patCur, new List <string>()); } string timePatternAppointment = RecallTypes.ConvertTimePattern(timePatternRecall); return(GetTimeSlotsForRange(dateStart, dateEnd, timePatternAppointment, listProvNums, listOperatories, listSchedules, clinic, log: log, isDoubleBookingAllowed: PrefC.GetInt(PrefName.WebSchedRecallDoubleBooking) == 0));//is double booking allowed according to the preference }