Exemple #1
0
 public static void Update(AsapComm asapComm, AsapComm asapCommOld)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), asapComm, asapCommOld);
         return;
     }
     Crud.AsapCommCrud.Update(asapComm, asapCommOld);
 }
Exemple #2
0
 ///<summary></summary>
 public static long Insert(AsapComm asapComm)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         asapComm.AsapCommNum = Meth.GetLong(MethodBase.GetCurrentMethod(), asapComm);
         return(asapComm.AsapCommNum);
     }
     return(Crud.AsapCommCrud.Insert(asapComm));
 }
Exemple #3
0
        ///<summary>Creates a list of AsapComms for sending.</summary>
        public static AsapListSender CreateSendList(List <Appointment> listAppts, List <Recall> listRecalls, List <PatComm> listPatComms, SendMode sendMode,
                                                    string textTemplate, string emailTemplate, string emailSubject, DateTime dtSlotStart, DateTime dtStartSend, long clinicNum)
        {
            //No need to check RemotingRole; no call to db.
            AsapListSender sender = new AsapListSender(sendMode, listPatComms, clinicNum, dtSlotStart, dtStartSend);

            //Order matters here. We will send messages to appointments that are unscheduled first, then scheduled appointments, then recalls. This is
            //because we would prefer to create a brand new appointment than create a hole in the schedule where another appointment was scheduled.
            //We're doing recalls last because cleanings would be lower priority than other types of dental work.
            foreach (Appointment appt in listAppts.OrderBy(x => x.AptStatus != ApptStatus.UnschedList)
                     .ThenBy(x => x.AptStatus != ApptStatus.Planned)
                     .ThenByDescending(x => x.AptDateTime))
            {
                AsapComm asapComm = new AsapComm();
                asapComm.DateTimeOrig   = appt.AptDateTime;
                asapComm.FKey           = appt.AptNum;
                asapComm.ClinicNum      = clinicNum;
                asapComm.DateTimeExpire = dtSlotStart.AddDays(7);              //Give a 7 day buffer so that the link will still be active a little longer.
                switch (appt.AptStatus)
                {
                case ApptStatus.Scheduled:
                    asapComm.FKeyType = AsapCommFKeyType.ScheduledAppt;
                    break;

                case ApptStatus.UnschedList:
                    asapComm.FKeyType = AsapCommFKeyType.UnscheduledAppt;
                    break;

                case ApptStatus.Broken:
                    asapComm.FKeyType = AsapCommFKeyType.Broken;
                    break;

                case ApptStatus.Planned:
                default:
                    asapComm.FKeyType = AsapCommFKeyType.PlannedAppt;
                    break;
                }
                if (sender.DoSendText(appt.PatNum, appt.AptNum, asapComm.FKeyType))               //This will record in the Note why the patient can't be sent a text.
                {
                    asapComm.DateTimeSmsScheduled = sender.GetNextTextSendTime();
                    asapComm.SmsSendStatus        = AutoCommStatus.SendNotAttempted;
                    asapComm.TemplateText         = textTemplate;
                    sender.CountTextsToSend++;
                }
                else
                {
                    asapComm.SmsSendStatus = AutoCommStatus.DoNotSend;
                }
                if (sender.DoSendEmail(appt.PatNum, appt.AptNum, asapComm.FKeyType))               //This will record in the Note why the patient can't be sent a email.
                {
                    asapComm.EmailSendStatus   = AutoCommStatus.SendNotAttempted;
                    asapComm.TemplateEmail     = emailTemplate;
                    asapComm.TemplateEmailSubj = emailSubject;
                    sender.CountEmailsToSend++;
                }
                else
                {
                    asapComm.EmailSendStatus = AutoCommStatus.DoNotSend;
                }
                asapComm.PatNum = appt.PatNum;
                if (asapComm.SmsSendStatus == AutoCommStatus.DoNotSend && asapComm.EmailSendStatus == AutoCommStatus.DoNotSend)
                {
                    asapComm.ResponseStatus = AsapRSVPStatus.UnableToSend;
                }
                else
                {
                    asapComm.ResponseStatus = AsapRSVPStatus.AwaitingTransmit;
                }
                sender.ListAsapComms.Add(asapComm);
            }
            sender.CopyNotes();
            //Now do recalls
            foreach (Recall recall in listRecalls.OrderByDescending(x => x.DateDue))
            {
                AsapComm asapComm = new AsapComm();
                asapComm.DateTimeOrig   = recall.DateDue;
                asapComm.FKey           = recall.RecallNum;
                asapComm.FKeyType       = AsapCommFKeyType.Recall;
                asapComm.ClinicNum      = clinicNum;
                asapComm.DateTimeExpire = dtSlotStart.AddDays(7);                                //Give a 7 day buffer so that the link will still be active a little longer.
                if (sender.DoSendText(recall.PatNum, recall.RecallNum, AsapCommFKeyType.Recall)) //This will record in the Note why the patient can't be sent a text.
                {
                    asapComm.DateTimeSmsScheduled = sender.GetNextTextSendTime();
                    asapComm.SmsSendStatus        = AutoCommStatus.SendNotAttempted;
                    asapComm.TemplateText         = textTemplate;
                    sender.CountTextsToSend++;
                }
                else
                {
                    asapComm.SmsSendStatus = AutoCommStatus.DoNotSend;
                }
                if (sender.DoSendEmail(recall.PatNum, recall.RecallNum, AsapCommFKeyType.Recall))               //This will record in the Note why the patient can't be sent a email.
                {
                    asapComm.EmailSendStatus   = AutoCommStatus.SendNotAttempted;
                    asapComm.TemplateEmail     = emailTemplate;
                    asapComm.TemplateEmailSubj = emailSubject;
                    sender.CountEmailsToSend++;
                }
                else
                {
                    asapComm.EmailSendStatus = AutoCommStatus.DoNotSend;
                }
                asapComm.PatNum = recall.PatNum;
                if (asapComm.SmsSendStatus == AutoCommStatus.DoNotSend && asapComm.EmailSendStatus == AutoCommStatus.DoNotSend)
                {
                    asapComm.ResponseStatus = AsapRSVPStatus.UnableToSend;
                }
                else
                {
                    asapComm.ResponseStatus = AsapRSVPStatus.AwaitingTransmit;
                }
                sender.ListAsapComms.Add(asapComm);
            }
            return(sender);
        }