private void FormWebSchedASAPSend_Load(object sender, EventArgs e)
        {
            Clinic      curClinic   = Clinics.GetClinic(_clinicNum) ?? Clinics.GetDefaultForTexting() ?? Clinics.GetPracticeAsClinicZero();
            List <long> listPatNums = (_listAppts.Select(x => x.PatNum).Union(_listRecalls.Select(x => x.PatNum))).Distinct().ToList();

            _listPatComms = Patients.GetPatComms(listPatNums, curClinic, isGetFamily: false);
            string textTemplate  = ClinicPrefs.GetPrefValue(PrefName.WebSchedAsapTextTemplate, _clinicNum);
            string emailTemplate = ClinicPrefs.GetPrefValue(PrefName.WebSchedAsapEmailTemplate, _clinicNum);
            string emailSubject  = ClinicPrefs.GetPrefValue(PrefName.WebSchedAsapEmailSubj, _clinicNum);

            textTextTemplate.Text = AsapComms.ReplacesTemplateTags(textTemplate, _clinicNum, _dtSlotStart);
            _emailText            = AsapComms.ReplacesTemplateTags(emailTemplate, _clinicNum, _dtSlotStart, isHtmlEmail: true);
            RefreshEmail();
            textEmailSubject.Text = AsapComms.ReplacesTemplateTags(emailSubject, _clinicNum, _dtSlotStart);
            if (SmsPhones.IsIntegratedTextingEnabled())
            {
                radioTextEmail.Checked = true;
            }
            else
            {
                radioEmail.Checked = true;
            }
            FillSendDetails();
            timerUpdateDetails.Start();
        }
Beispiel #2
0
        ///<summary></summary>
        /// <param name="funcCreateShortGUID">If not null, then this function will be called to set AsapComm.ShortGUID.
        /// This simulates having already asked HQ for the short guid and allows this step to be skipped for the purpose of unit test.</param>
        /// <param name="dateTimeSmsScheduled">Allows due date of SMS send to be set manually. This is used to simulate an SMS that will be sent later. Allows email to be sent first.</param>
        public static AsapComm CreateAsapCommRecall(Recall recall, Schedule sched, long clinicNum, Func <string> funcCreateShortGUID = null,
                                                    DateTime dateTimeSmsScheduled = default(DateTime))
        {
            AsapComm asapComm = new AsapComm {
                ClinicNum            = clinicNum,
                DateTimeExpire       = sched.SchedDate.Date.Add(sched.StartTime),
                DateTimeOrig         = recall.DateDue,
                DateTimeSmsScheduled = (dateTimeSmsScheduled == default(DateTime) ? DateTime.Now : dateTimeSmsScheduled),
                EmailSendStatus      = AutoCommStatus.SendNotAttempted,
                FKey              = recall.RecallNum,
                FKeyType          = AsapCommFKeyType.Recall,
                Note              = "",
                PatNum            = recall.PatNum,
                ResponseStatus    = AsapRSVPStatus.AwaitingTransmit,
                ScheduleNum       = sched.ScheduleNum,
                ShortGUID         = (funcCreateShortGUID != null ? funcCreateShortGUID() : ""),
                SmsSendStatus     = AutoCommStatus.SendNotAttempted,
                TemplateEmail     = PrefC.GetString(PrefName.WebSchedAsapEmailTemplate),
                TemplateEmailSubj = PrefC.GetString(PrefName.WebSchedAsapEmailSubj),
                TemplateText      = PrefC.GetString(PrefName.WebSchedAsapTextTemplate)
            };

            AsapComms.Insert(asapComm);
            return(asapComm);
        }
        private void butOK_Click(object sender, EventArgs e)
        {
            AsapComms.InsertForSending(_asapListSender.ListAsapComms, _dtSlotStart, _dtSlotEnd, _opNum);
            string message = _asapListSender.CountTextsToSend + " " + Lan.g(this, "text" + (_asapListSender.CountTextsToSend == 1?"":"s") + " and") + " "
                             + _asapListSender.CountEmailsToSend + " " + Lan.g(this, "email" + (_asapListSender.CountEmailsToSend == 1?"":"s") + " have been entered to be sent.");

            PopupFade.Show(this, message);
            DialogResult = DialogResult.OK;
        }
        private void GetData()
        {
            Cursor = Cursors.WaitCursor;
            List <long> listClinicNums = null;

            if (PrefC.HasClinicsEnabled)
            {
                listClinicNums = comboClinic.ListSelectedClinicNums;
            }
            _listAsapCommHists      = AsapComms.GetHist(datePicker.GetDateTimeFrom(), datePicker.GetDateTimeTo(), listClinicNums: listClinicNums);
            _prevDateFrom           = datePicker.GetDateTimeFrom();
            _prevDateTo             = datePicker.GetDateTimeTo();
            _prevSelectedClinicNums = new List <long>(comboClinic.ListSelectedClinicNums);
            Cursor = Cursors.Default;
        }
Beispiel #5
0
        ///<summary></summary>
        /// <param name="funcCreateShortGUID">If not null, then this function will be called to set AsapComm.ShortGUID.
        /// This simulates having already asked HQ for the short guid and allows this step to be skipped for the purpose of unit test.</param>
        /// <param name="dateTimeSmsScheduled">Allows due date of SMS send to be set manually. This is used to simulate an SMS that will be sent later. Allows email to be sent first.</param>
        public static AsapComm CreateAsapComm(Appointment appt, Schedule sched, Func <string> funcCreateShortGUID = null,
                                              DateTime dateTimeSmsScheduled = default(DateTime))
        {
            AsapComm asapComm = new AsapComm {
                ClinicNum            = appt.ClinicNum,
                DateTimeExpire       = sched.SchedDate.Date.Add(sched.StartTime),
                DateTimeOrig         = appt.AptDateTime,
                DateTimeSmsScheduled = (dateTimeSmsScheduled == default(DateTime) ? DateTime.Now : dateTimeSmsScheduled),
                EmailSendStatus      = AutoCommStatus.SendNotAttempted,
                FKey              = appt.AptNum,
                Note              = "",
                PatNum            = appt.PatNum,
                ResponseStatus    = AsapRSVPStatus.AwaitingTransmit,
                ScheduleNum       = sched.ScheduleNum,
                ShortGUID         = (funcCreateShortGUID != null ? funcCreateShortGUID() : ""),
                SmsSendStatus     = AutoCommStatus.SendNotAttempted,
                TemplateEmail     = PrefC.GetString(PrefName.WebSchedAsapEmailTemplate),
                TemplateEmailSubj = PrefC.GetString(PrefName.WebSchedAsapEmailSubj),
                TemplateText      = PrefC.GetString(PrefName.WebSchedAsapTextTemplate)
            };

            if (appt.AptStatus == ApptStatus.UnschedList)
            {
                asapComm.FKeyType = AsapCommFKeyType.UnscheduledAppt;
            }
            else if (appt.AptStatus == ApptStatus.Planned)
            {
                asapComm.FKeyType = AsapCommFKeyType.PlannedAppt;
            }
            else if (appt.AptStatus == ApptStatus.Broken)
            {
                asapComm.FKeyType = AsapCommFKeyType.Broken;
            }
            else
            {
                asapComm.FKeyType = AsapCommFKeyType.ScheduledAppt;
            }
            AsapComms.Insert(asapComm);
            return(asapComm);
        }
        private void FillSendDetails()
        {
            labelAnticipated.Text = "";
            _asapListSender       = AsapComms.CreateSendList(_listAppts, _listRecalls, _listPatComms, GetSendMode(), textTextTemplate.Text, _emailText,
                                                             textEmailSubject.Text, _dtSlotStart, DateTime.Now, _clinicNum);
            int countTexts  = _asapListSender.CountTextsToSend;
            int countEmails = _asapListSender.CountEmailsToSend;

            gridSendDetails.BeginUpdate();
            gridSendDetails.ListGridColumns.Clear();
            GridColumn col;

            col = new GridColumn(Lan.g(this, "Patient"), 120);
            gridSendDetails.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Sending Text"), 100, HorizontalAlignment.Center);
            gridSendDetails.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Sending Email"), 100, HorizontalAlignment.Center);
            gridSendDetails.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Type"), 150);
            gridSendDetails.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Notes"), 300);
            gridSendDetails.ListGridColumns.Add(col);
            gridSendDetails.ListGridRows.Clear();
            foreach (AsapComm comm in _asapListSender.ListAsapComms)
            {
                GridRow row = new GridRow();
                AsapComms.AsapListSender.PatientDetail patDetail = _asapListSender.ListDetails.First(x => x.PatNum == comm.PatNum);
                row.Cells.Add(patDetail.PatName);
                row.Cells.Add(patDetail.IsSendingText ? "X" : "");
                row.Cells.Add(patDetail.IsSendingEmail ? "X" : "");
                row.Cells.Add(Lan.g(this, Enum.GetName(typeof(AsapCommFKeyType), comm.FKeyType)));
                row.Cells.Add(patDetail.Note);
                row.Tag = patDetail;
                gridSendDetails.ListGridRows.Add(row);
            }
            gridSendDetails.SortForced(0, false);
            gridSendDetails.EndUpdate();
            if (countTexts == 1)
            {
                labelAnticipated.Text += countTexts + " " + Lan.g(this, "text will be sent at") + " "
                                         + _asapListSender.DtStartSendText.ToShortTimeString() + ".\r\n";
            }
            else if (countTexts > 1)
            {
                int minutesBetweenTexts = _asapListSender.MinutesBetweenTexts;
                labelAnticipated.Text += countTexts + " " + Lan.g(this, "texts will be sent starting at") + " "
                                         + _asapListSender.DtStartSendText.ToShortTimeString() + " " + Lan.g(this, "with") + " " + minutesBetweenTexts + " "
                                         + Lan.g(this, "minute" + (minutesBetweenTexts == 1 ? "" : "s") + " between each text") + ".\r\n";
            }
            if (GetSendMode() != AsapComms.SendMode.Email && _asapListSender.IsOutsideSendWindow)
            {
                labelAnticipated.Text += Lan.g(this, "Because it is currently outside the automatic send window, texts will not start sending until") + " "
                                         + _asapListSender.DtStartSendText.ToString() + ".\r\n";
            }
            int countTextToSendAtEndTime = _asapListSender.ListAsapComms.Count(x => x.DateTimeSmsScheduled == _asapListSender.DtTextSendEnd);

            if (PrefC.DoRestrictAutoSendWindow && countTextToSendAtEndTime > 1)
            {
                labelAnticipated.Text += Lan.g(this, "In order to not send texts outside the automatic send window,") + " " + countTextToSendAtEndTime
                                         + " " + Lan.g(this, "texts will be sent at") + " " + _asapListSender.DtTextSendEnd.ToString() + ".\r\n";
            }
            if (countEmails > 0)
            {
                labelAnticipated.Text += countEmails + " " + Lan.g(this, "email" + (countEmails == 1 ? "" : "s") + " will be sent upon clicking Send.");
            }
            if (countTexts == 0 && countEmails == 0)
            {
                labelAnticipated.Text += Lan.g(this, "No patients selected are able to receive communication using this send method.");
            }
        }