示例#1
0
        private void PromptTextASAPList()
        {
            if (!PrefC.GetBool(PrefName.WebSchedAsapEnabled) || Appointments.RefreshASAP(0, 0, _appt.ClinicNum, new List <ApptStatus>()).Count == 0 ||
                !MsgBox.Show("Appointment", MsgBoxButtons.YesNo, "Text patients on the ASAP List and offer them this opening?"))
            {
                return;
            }
            DateTime slotStart = AppointmentL.DateSelected.Date;            //Midnight
            DateTime slotEnd   = AppointmentL.DateSelected.Date.AddDays(1); //Midnight tomorrow
            //Loop through all other appts in the op to find a slot that will not overlap.
            List <Appointment> listApptsInOp = Appointments.GetAppointmentsForOpsByPeriod(new List <long> {
                _appt.Op
            }, _appt.AptDateTime);

            foreach (Appointment otherAppt in listApptsInOp.Where(x => x.AptNum != _appt.AptNum))
            {
                DateTime dateEndApt = otherAppt.AptDateTime.AddMinutes(otherAppt.Pattern.Length * 5);
                if (dateEndApt.Between(slotStart, _appt.AptDateTime))
                {
                    slotStart = dateEndApt;
                }
                if (otherAppt.AptDateTime.Between(_appt.AptDateTime, slotEnd))
                {
                    slotEnd = otherAppt.AptDateTime;
                }
            }
            slotStart = ODMathLib.Max(slotStart, _appt.AptDateTime.AddHours(-1));
            slotEnd   = ODMathLib.Min(slotEnd, _appt.AptDateTime.AddHours(3));
            FormASAP formASAP = new FormASAP(_appt.AptDateTime, slotStart, slotEnd, _appt.Op);

            formASAP.ShowDialog();
        }
示例#2
0
            ///<summary>Returns true if the time length requested will fit in the time slot and there are no other appointments in the slot.</summary>
            public bool IsApptSlotAvailable(int minutes, long opNum, DateTime slotStart, DateTime slotEnd)
            {
                if (!_listDateOps.Any(x => x.Item1 == slotStart.Date && x.Item2 == opNum))
                {
                    _listAppts.AddRange(Appointments.GetApptsForDatesOps(new List <ODTuple <DateTime, long> > {
                        new ODTuple <DateTime, long>(slotStart.Date, opNum)
                    }));
                    _listDateOps.Add(new Tuple <DateTime, long>(slotStart.Date, opNum));
                }
                DateTime newSlotEnd = ODMathLib.Min(slotStart.AddMinutes(minutes), slotEnd);

                if (_listAppts.Where(x => x.Op == opNum)
                    .Any(x => MiscUtils.DoSlotsOverlap(x.AptDateTime, x.AptDateTime.AddMinutes(x.Length), slotStart, newSlotEnd)))
                {
                    return(false);
                }
                return(true);
            }