Beispiel #1
0
        ///<summary>Updates the Schedule note with the number of sent and waiting to send AsapComms.</summary>
        public static void UpdateSchedule(long scheduleNum)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), scheduleNum);
                return;
            }
            List <Schedule> listSchedules = Schedules.GetByScheduleNum(new List <long> {
                scheduleNum
            });

            if (listSchedules.Count == 0)
            {
                return;
            }
            Schedule        sched      = listSchedules[0];
            List <SQLWhere> listWheres = new List <SQLWhere> {
                SQLWhere.Create(nameof(AsapComm.ScheduleNum), ComparisonOperator.Equals, scheduleNum)
            };
            List <AsapComm> listAsapComms  = GetMany(listWheres);
            int             textsSent      = listAsapComms.Count(x => x.SmsSendStatus == AutoCommStatus.SendSuccessful);
            int             textsToBeSent  = listAsapComms.Count(x => x.SmsSendStatus == AutoCommStatus.SendNotAttempted);
            int             emailsSent     = listAsapComms.Count(x => x.EmailSendStatus == AutoCommStatus.SendSuccessful);
            int             emailsToBeSent = listAsapComms.Count(x => x.EmailSendStatus == AutoCommStatus.SendNotAttempted);

            sched.Note = textsSent + " " + Lans.g("ContrAppt", "text" + (textsSent == 1 ? "" : "s") + " sent,") + " "
                         + textsToBeSent + " " + Lans.g("ContrAppt", "text" + (textsToBeSent == 1 ? "" : "s") + " to be sent") + "\r\n"
                         + emailsSent + " " + Lans.g("ContrAppt", "email" + (emailsSent == 1 ? "" : "s") + " sent") + " "
                         + emailsToBeSent + " " + Lans.g("ContrAppt", "email" + (emailsToBeSent == 1 ? "" : "s") + " to be sent");
            Schedules.Update(sched);
        }
Beispiel #2
0
        ///<summary>Inserts these AsapComms into the database. Also creates a block on the schedule recording this communication.</summary>
        public static void InsertForSending(List <AsapComm> listAsapComms, DateTime dtSlotStart, DateTime dtSlotEnd, long opNum)
        {
            //No need to check RemotingRole; no call to db.
            int textsToBeSent  = listAsapComms.Count(x => x.SmsSendStatus != AutoCommStatus.DoNotSend);
            int emailsToBeSent = listAsapComms.Count(x => x.EmailSendStatus != AutoCommStatus.DoNotSend);
            //Create a slot on the appointment schedule.
            Schedule sched = new Schedule();

            sched.SchedDate = dtSlotStart.Date;
            sched.SchedType = ScheduleType.WebSchedASAP;
            sched.StartTime = dtSlotStart.TimeOfDay;
            if (dtSlotEnd.Date > dtSlotStart.Date)
            {
                sched.StopTime = new TimeSpan(23, 59, 59);            //Last second of the day
            }
            else
            {
                sched.StopTime = dtSlotEnd.TimeOfDay;
            }
            sched.Ops = new List <long> {
                opNum
            };
            sched.Note = textsToBeSent + " " + Lans.g("ContrAppt", "text" + (textsToBeSent == 1 ? "" : "s") + " to be sent") + "\r\n"
                         + emailsToBeSent + " " + Lans.g("ContrAppt", "email" + (emailsToBeSent == 1 ? "" : "s") + " to be sent");
            Schedules.Insert(sched, false);
            listAsapComms.ForEach(x => x.ScheduleNum = sched.ScheduleNum);
            InsertMany(listAsapComms);
        }
Beispiel #3
0
        ///<summary>Each date should have one (and only 1) PhoneGraph entry per employee. Some may already be entered as exceptions to the default. We will fill in the gaps here. This will only be done for today's date (once Today has passed the opportunity to fill the gaps has passed). We don't want to presume that if it was missing on a past date then we should add it. This assumption would fill in gaps on past dates for employees that may not even have worked here on that date.</summary>
        public static void AddMissingEntriesForToday(List <PhoneEmpDefault> peds)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), peds);
                return;
            }
            //get all overrides created for this date
            List <PhoneGraph> listPhoneGraphs = GetAllForDate(DateTime.Today);
            List <Schedule>   listSchedules   = Schedules.GetDayList(DateTime.Today);

            //loop through all defaults and check if there are overrides added
            for (int iPed = 0; iPed < peds.Count; iPed++)
            {
                PhoneEmpDefault ped = peds[iPed];
                bool            hasPhoneGraphEntry = false;
                //we have a default, now loop through all known overrides and find a match
                for (int iPG = 0; iPG < listPhoneGraphs.Count; iPG++)
                {
                    PhoneGraph pg = listPhoneGraphs[iPG];
                    if (ped.EmployeeNum == listPhoneGraphs[iPG].EmployeeNum)                   //found a match so no op necessary for this employee
                    {
                        hasPhoneGraphEntry = true;
                        break;
                    }
                }
                if (hasPhoneGraphEntry)                 //no entry needed, it's already there
                {
                    continue;
                }
                //does employee have a schedule table entry for this date
                bool hasScheduleEntry = false;
                for (int iSch = 0; iSch < listSchedules.Count; iSch++)
                {
                    Schedule schedule = listSchedules[iSch];
                    if (ped.EmployeeNum == listSchedules[iSch].EmployeeNum)                   //found a match so no op necessary for this employee
                    {
                        hasScheduleEntry = true;
                        break;
                    }
                }
                if (!hasScheduleEntry)                  //no entry needed if not on the schedule
                {
                    continue;
                }
                //employee is on the schedule but does not have a phonegraph entry, so create one
                PhoneGraph pgNew = new PhoneGraph();
                pgNew.EmployeeNum = ped.EmployeeNum;
                pgNew.DateEntry   = DateTime.Today;
                pgNew.IsGraphed   = ped.IsGraphed;
                Insert(pgNew);
            }
        }
Beispiel #4
0
        ///<summary></summary>
        private static bool Overlaps(Schedule sched)
        {
            //No need to check RemotingRole; no call to db.
            List <Schedule> SchedListDay = Schedules.GetDayList(sched.SchedDate);

            Schedule[] ListForType = Schedules.GetForType(SchedListDay, sched.SchedType, sched.ProvNum);
            bool       opsMatch;

            for (int i = 0; i < ListForType.Length; i++)
            {
                if (ListForType[i].SchedType == ScheduleType.Blockout)
                {
                    //skip if blockout, and ops don't interfere
                    opsMatch = false;
                    for (int s1 = 0; s1 < sched.Ops.Count; s1++)
                    {
                        if (ListForType[i].Ops.Contains(sched.Ops[s1]))
                        {
                            opsMatch = true;
                            break;
                        }
                    }
                    if (!opsMatch)
                    {
                        continue;
                    }
                }
                if (sched.ScheduleNum != ListForType[i].ScheduleNum &&
                    sched.StartTime >= ListForType[i].StartTime &&
                    sched.StartTime < ListForType[i].StopTime)
                {
                    return(true);
                }
                if (sched.ScheduleNum != ListForType[i].ScheduleNum &&
                    sched.StopTime > ListForType[i].StartTime &&
                    sched.StopTime <= ListForType[i].StopTime)
                {
                    return(true);
                }
                if (sched.ScheduleNum != ListForType[i].ScheduleNum &&
                    sched.StartTime <= ListForType[i].StartTime &&
                    sched.StopTime >= ListForType[i].StopTime)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #5
0
        ///<summary>Gets the data necessary from the database to run the appointment search logic.</summary>
        public static ApptSearchData GetDataForSearch(long aptNum, DateTime dateAfter, DateTime dateBefore, List <long> listProvNums, List <long> listOpNums
                                                      , List <long> listClinicNums, long blockoutType)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <ApptSearchData>(MethodBase.GetCurrentMethod(), aptNum, dateAfter, dateBefore, listProvNums, listOpNums, listClinicNums
                                                       , blockoutType));
            }
            ApptSearchData data = new ApptSearchData();

            data.DateEvaluating   = dateAfter.AddDays(1);
            data.AppointmentToAdd = Appointments.GetOneApt(aptNum);
            data.ListSchedules    = Schedules.GetSchedulesForAppointmentSearch(data.DateEvaluating, dateBefore, listClinicNums, listOpNums
                                                                               , listProvNums, blockoutType);
            //Get all appointments that exist in the operaotries we will be searching to find an opening, not just for provider we're looking for
            //so we can get conflicts when multiple provs work in a single operaotry.
            data.ListAppointments = Appointments.GetForPeriodList(data.DateEvaluating, dateBefore, listOpNums, listClinicNums);
            data.ListSchedOps     = ScheduleOps.GetForSchedList(data.ListSchedules, listOpNums);     //ops filter for case when a prov is scheduled in multiple ops
            return(data);
        }
Beispiel #6
0
        ///<summary>Calculates the due date by adding the number of business days listed.  Adds an additional day for each office holiday.</summary>
        public static DateTime ComputeDueDate(DateTime startDate, int days)
        {
            //No need to check RemotingRole; no call to db.
            DateTime date    = startDate;
            int      counter = 0;

            while (counter < days)
            {
                date = date.AddDays(1);
                if (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday)
                {
                    continue;
                }
                if (Schedules.DateIsHoliday(date))
                {
                    continue;
                }
                counter++;
            }
            return(date + TimeSpan.FromHours(17));         //always due at 5pm on day specified.
        }