Ejemplo n.º 1
0
        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();
        }
 private void FillGridPriority()
 {
     gridPriorities.BeginUpdate();
     gridPriorities.ListGridColumns.Clear();
     gridPriorities.ListGridColumns.Add(new GridColumn("", 0));
     gridPriorities.ListGridRows.Clear();
     for (int i = 0; i < _sendOrder.Count; i++)
     {
         CommType typeCur = _sendOrder[i];
         if (typeCur == CommType.Preferred)
         {
             if (checkSendAll.Checked)
             {
                 //"Preferred" is irrelevant when SendAll is checked.
                 continue;
             }
             gridPriorities.AddRow(Lan.g(this, "Preferred Confirm Method"));
             continue;
         }
         if (typeCur == CommType.Text && !SmsPhones.IsIntegratedTextingEnabled())
         {
             gridPriorities.AddRow(Lan.g(this, typeCur.ToString()) + " (" + Lan.g(this, "Not Configured") + ")");
             gridPriorities.ListGridRows[gridPriorities.ListGridRows.Count - 1].ColorBackG = Color.LightGray;
         }
         else
         {
             gridPriorities.AddRow(Lan.g(this, typeCur.ToString()));
         }
     }
     gridPriorities.EndUpdate();
 }
Ejemplo n.º 3
0
        private void butSend_Click(object sender, EventArgs e)
        {
            if (!SmsPhones.IsIntegratedTextingEnabled())
            {
                MsgBox.Show(this, "Integrated Texting has not been enabled.");
                return;
            }
            if (textMessage.Text == "")
            {
                MsgBox.Show(this, "Please enter a message first.");
                return;
            }
            if (textMessage.Text.ToLower().Contains("[date]") || textMessage.Text.ToLower().Contains("[time]"))
            {
                MsgBox.Show(this, "Please replace or remove the [Date] and [Time] tags.");
                return;
            }
            if (PrefC.HasClinicsEnabled && !Clinics.IsTextingEnabled(_clinicNum))              //Checking for specific clinic.
            {
                if (_clinicNum != 0)
                {
                    MessageBox.Show(Lans.g(this, "Integrated Texting has not been enabled for the following clinic") + ":\r\n" + Clinics.GetClinic(_clinicNum).Description + ".");
                }
                else
                {
                    //Should never happen. This message is precautionary.
                    MsgBox.Show(this, "The default texting clinic has not been set.");
                }
                return;
            }
            Cursor = Cursors.WaitCursor;
            int numTextsSent = 0;

            foreach (PatComm patComm in _listPatComms)
            {
                try {
                    string textMsgText = textMessage.Text.Replace("[NameF]", patComm.FName);
                    if (SendText(patComm, _clinicNum, textMsgText))
                    {
                        numTextsSent++;
                    }
                }
                catch (Exception ex) {
                    ex.DoNothing();
                    Cursor = Cursors.Default;
                    string errorMsg = Lan.g(this, "There was an error sending to") + " " + patComm.WirelessPhone + ". "
                                      + Lan.g(this, "Do you want to continue sending messages?");
                    if (MessageBox.Show(errorMsg, "", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        break;
                    }
                    Cursor = Cursors.WaitCursor;
                }
            }
            Cursor = Cursors.Default;
            MessageBox.Show(numTextsSent + " " + Lan.g(this, "texts sent successfully."));
            DialogResult = DialogResult.OK;
        }
        private void WebSchedRecallAutoSendRadioButtons_CheckedChanged(object sender, EventArgs e)
        {
            //Only do validation when the Web Sched tab is selected and either Do Not Send is NOT checked.
            if (tabControl.SelectedTab != tabWebSched || (radioDoNotSend.Checked && radioDoNotSendText.Checked))
            {
                return;
            }
            //Validate the following recall setup preferences.  See task #880961 or #879613 for more details.
            //1. The Days Past field is not blank
            //2. The Initial Reminder field is greater than 0
            //3. The Second(or more) Reminder field is greater than 0
            //4. Integrated texting is enabled if Send Text is checked
            List <string> listSetupErrors    = new List <string>();
            bool          isEmailSendInvalid = false;
            bool          isTextSendInvalid  = false;

            if (PrefC.GetLong(PrefName.RecallDaysPast) == -1)           //Days Past field
            {
                listSetupErrors.Add("- " + Lan.g(this, "Days Past (e.g. 1095, blank, etc) field cannot be blank."));
                isEmailSendInvalid = true;
                isTextSendInvalid  = true;
            }
            if (PrefC.GetLong(PrefName.RecallShowIfDaysFirstReminder) < 1)           //Initial Reminder field
            {
                listSetupErrors.Add("- " + Lan.g(this, "Initial Reminder field has to be greater than 0."));
                isEmailSendInvalid = true;
                isTextSendInvalid  = true;
            }
            if (PrefC.GetLong(PrefName.RecallShowIfDaysSecondReminder) < 1)           //Second(or more) Reminder field
            {
                listSetupErrors.Add("- " + Lan.g(this, "Second (or more) Reminder field has to be greater than 0."));
                isEmailSendInvalid = true;
                isTextSendInvalid  = true;
            }
            if (radioSendText.Checked && !SmsPhones.IsIntegratedTextingEnabled())
            {
                listSetupErrors.Add("- " + Lan.g(this, "Integrated texting must be enabled."));
                isTextSendInvalid = true;
            }
            //Checking the "Do Not Send" radio button will automatically uncheck all the other radio buttons in the group box.
            if (isEmailSendInvalid)
            {
                radioDoNotSend.Checked = true;
            }
            if (isTextSendInvalid)
            {
                radioDoNotSendText.Checked = true;
            }
            if (listSetupErrors.Count > 0)
            {
                MessageBox.Show(Lan.g(this, "Recall Setup settings are not correctly set in order to Send Messages Automatically to patients:")
                                + "\r\n" + string.Join("\r\n", listSetupErrors)
                                , Lan.g(this, "Web Sched - Recall Setup Error"));
            }
        }
Ejemplo n.º 5
0
        private void FillGridSmsUsage()
        {
            List <Clinic> listClinics = Clinics.GetForUserod(Security.CurUser);

            if (!PrefC.HasClinicsEnabled)              //No clinics so just get the practice as a clinic.
            {
                listClinics.Clear();
                listClinics.Add(Clinics.GetPracticeAsClinicZero());
            }
            var items = SmsPhones.GetSmsUsageLocal(listClinics.Select(x => x.ClinicNum).ToList(), dateTimePickerSms.Value,
                                                   WebServiceMainHQProxy.EServiceSetup.SignupOut.SignupOutPhone.ToSmsPhones(_signupOut.Phones))
                        .Rows.Cast <DataRow>().Select(x => new {
                ClinicNum       = PIn.Long(x["ClinicNum"].ToString()),
                PhoneNumber     = x["PhoneNumber"].ToString(),
                CountryCode     = x["CountryCode"].ToString(),
                SentMonth       = PIn.Int(x["SentMonth"].ToString()),
                SentCharge      = PIn.Double(x["SentCharge"].ToString()),
                SentDiscount    = PIn.Double(x["SentDiscount"].ToString()),
                SentPreDiscount = PIn.Double(x["SentPreDiscount"].ToString()),
                RcvMonth        = PIn.Int(x["ReceivedMonth"].ToString()),
                RcvCharge       = PIn.Double(x["ReceivedCharge"].ToString())
            });
            bool doShowDiscount = items.Any(x => x.SentDiscount.IsGreaterThan(0));

            gridSmsSummary.BeginUpdate();
            gridSmsSummary.ListGridColumns.Clear();
            if (PrefC.HasClinicsEnabled)
            {
                gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Default"), 80)
                {
                    TextAlign = HorizontalAlignment.Center
                });
            }
            gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Location"), 170, HorizontalAlignment.Left));
            gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Subscribed"), 80, HorizontalAlignment.Center));
            gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Primary\r\nPhone Number"), 105, HorizontalAlignment.Center));
            gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Country\r\nCode"), 60, HorizontalAlignment.Center));
            gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Limit"), 80, HorizontalAlignment.Right));
            gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Sent\r\nFor Month"), 70, HorizontalAlignment.Right));
            if (doShowDiscount)
            {
                gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Sent\r\nPre-Discount"), 80, HorizontalAlignment.Right));
                gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Sent\r\nDiscount"), 70, HorizontalAlignment.Right));
            }
            gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Sent\r\nCharges"), 70, HorizontalAlignment.Right));
            gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Received\r\nFor Month"), 70, HorizontalAlignment.Right));
            gridSmsSummary.ListGridColumns.Add(new GridColumn(Lan.g(this, "Received\r\nCharges"), 70, HorizontalAlignment.Right));
            gridSmsSummary.ListGridRows.Clear();
            foreach (Clinic clinic in listClinics)
            {
                GridRow row = new GridRow();
                if (PrefC.HasClinicsEnabled)                  //Default texting clinic?
                {
                    row.Cells.Add(clinic.ClinicNum == PrefC.GetLong(PrefName.TextingDefaultClinicNum) ? "X" : "");
                }
                row.Cells.Add(clinic.Abbr);                 //Location.
                var dataRow = items.FirstOrDefault(x => x.ClinicNum == clinic.ClinicNum);
                if (dataRow == null)
                {
                    row.Cells.Add("No");                                         //subscribed
                    row.Cells.Add("");                                           //phone number
                    row.Cells.Add("");                                           //country code
                    row.Cells.Add((0f).ToString("c", new CultureInfo("en-US"))); //montly limit
                    row.Cells.Add("0");                                          //Sent Month
                    if (doShowDiscount)
                    {
                        row.Cells.Add((0f).ToString("c", new CultureInfo("en-US"))); //Sent Pre-Discount
                        row.Cells.Add((0f).ToString("c", new CultureInfo("en-US"))); //Sent Discount
                    }
                    row.Cells.Add((0f).ToString("c", new CultureInfo("en-US")));     //Sent Charge
                    row.Cells.Add("0");                                              //Rcvd Month
                    row.Cells.Add((0f).ToString("c", new CultureInfo("en-US")));     //Rcvd Charge
                }
                else
                {
                    row.Cells.Add(clinic.SmsContractDate.Year > 1800 ? Lan.g(this, "Yes") : Lan.g(this, "No"));
                    row.Cells.Add(dataRow.PhoneNumber);
                    row.Cells.Add(dataRow.CountryCode);
                    row.Cells.Add(clinic.SmsMonthlyLimit.ToString("c", new CultureInfo("en-US")));                   //Charge this month (Must always be in USD)
                    row.Cells.Add(dataRow.SentMonth.ToString());
                    if (doShowDiscount)
                    {
                        row.Cells.Add(dataRow.SentPreDiscount.ToString("c", new CultureInfo("en-US")));
                        row.Cells.Add(dataRow.SentDiscount.ToString("c", new CultureInfo("en-US")));
                    }
                    row.Cells.Add(dataRow.SentCharge.ToString("c", new CultureInfo("en-US")));
                    row.Cells.Add(dataRow.RcvMonth.ToString());
                    row.Cells.Add(dataRow.RcvCharge.ToString("c", new CultureInfo("en-US")));
                }
                row.Tag = clinic;
                gridSmsSummary.ListGridRows.Add(row);
            }
            if (listClinics.Count > 1)           //Total row if there is more than one clinic (Will not display for practice because practice will have no clinics.
            {
                GridRow row = new GridRow();
                row.Cells.Add("");
                row.Cells.Add("");
                row.Cells.Add("");
                row.Cells.Add("");
                row.Cells.Add(Lans.g(this, "Total"));
                row.Cells.Add(listClinics.Where(x => items.Any(y => y.ClinicNum == x.ClinicNum)).Sum(x => x.SmsMonthlyLimit).ToString("c", new CultureInfo("en-US")));
                row.Cells.Add(items.Sum(x => x.SentMonth).ToString());
                if (doShowDiscount)
                {
                    row.Cells.Add(items.Sum(x => x.SentPreDiscount).ToString("c", new CultureInfo("en-US")));
                    row.Cells.Add(items.Sum(x => x.SentDiscount).ToString("c", new CultureInfo("en-US")));
                }
                row.Cells.Add(items.Sum(x => x.SentCharge).ToString("c", new CultureInfo("en-US")));
                row.Cells.Add(items.Sum(x => x.RcvMonth).ToString());
                row.Cells.Add(items.Sum(x => x.RcvCharge).ToString("c", new CultureInfo("en-US")));
                row.ColorBackG = Color.LightYellow;
                gridSmsSummary.ListGridRows.Add(row);
            }
            gridSmsSummary.EndUpdate();
        }
Ejemplo n.º 6
0
 /// <summary>May be called from other parts of the program without showing this form. You must still create an instance of this form though.
 /// Checks CallFire bridge, if it is OK to send a text, etc. (Buttons to load this form are usually disabled if it is not OK,
 /// but this is needed for Confirmations, Recalls, etc.). CanIncreaseLimit will prompt the user to increase the spending limit if sending the
 /// text would exceed that limit. Should only be true when this method is called from this form. </summary>
 public bool SendText(long patNum, string wirelessPhone, string message, YN txtMsgOk, long clinicNum, SmsMessageSource smsMessageSource, bool canIncreaseLimit = false)
 {
     if (Plugins.HookMethod(this, "FormTxtMsgEdit.SendText_Start", patNum, wirelessPhone, message, txtMsgOk))
     {
         return(false);
     }
     if (Plugins.HookMethod(this, "FormTxtMsgEdit.SendText_Start2", patNum, wirelessPhone, message, txtMsgOk))
     {
         return(true);
     }
     if (wirelessPhone == "")
     {
         MsgBox.Show(this, "Please enter a phone number.");
         return(false);
     }
     if (SmsPhones.IsIntegratedTextingEnabled())
     {
         if (!PrefC.HasClinicsEnabled && PrefC.GetDateT(PrefName.SmsContractDate).Year < 1880)                //Checking for practice (clinics turned off).
         {
             MsgBox.Show(this, "Integrated Texting has not been enabled.");
             return(false);
         }
         else if (PrefC.HasClinicsEnabled && !Clinics.IsTextingEnabled(clinicNum))                  //Checking for specific clinic.
         //This is likely to happen a few times per office until they setup texting properly.
         {
             if (clinicNum != 0)
             {
                 MessageBox.Show(Lans.g(this, "Integrated Texting has not been enabled for the following clinic") + ":\r\n" + Clinics.GetClinic(clinicNum).Description + ".");
             }
             else
             {
                 //Should never happen. This message is precautionary.
                 MsgBox.Show(this, "The default texting clinic has not been set.");
             }
             return(false);
         }
     }
     else if (!Programs.IsEnabled(ProgramName.CallFire))
     {
         MsgBox.Show(this, "CallFire Program Link must be enabled.");
         return(false);
     }
     if (patNum != 0 && txtMsgOk == YN.Unknown && PrefC.GetBool(PrefName.TextMsgOkStatusTreatAsNo))
     {
         MsgBox.Show(this, "It is not OK to text this patient.");
         return(false);
     }
     if (patNum != 0 && txtMsgOk == YN.No)
     {
         MsgBox.Show(this, "It is not OK to text this patient.");
         return(false);
     }
     if (SmsPhones.IsIntegratedTextingEnabled())
     {
         try {
             SmsToMobiles.SendSmsSingle(patNum, wirelessPhone, message, clinicNum, smsMessageSource, user: Security.CurUser);                //Can pass in 0 as PatNum if no patient selected.
             return(true);
         }
         catch (Exception ex) {
             //ProcessSendSmsException handles the spending limit has been reached error, or returns false if the exception is different.
             if (!canIncreaseLimit || !FormEServicesSetup.ProcessSendSmsException(ex))
             {
                 MsgBox.Show(this, ex.Message);
             }
             return(false);
         }
     }
     else
     {
         if (message.Length > 160)           //only a limitation for CallFire
         {
             MsgBox.Show(this, "Text length must be less than 160 characters.");
             return(false);
         }
         return(SendCallFire(patNum, wirelessPhone, message));               //Can pass in 0 as PatNum if no patient selected.
     }
 }
Ejemplo n.º 7
0
 private void butSend_Click(object sender, EventArgs e)
 {
     if (textMessage.Text == "")
     {
         MsgBox.Show(this, "Please enter a message first.");
         return;
     }
     if (radioOther.Checked)               //No patient selected
     {
         if (textWirelessPhone.Text == "")
         {
             MsgBox.Show(this, "Please enter a phone number first.");
             return;
         }
         if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "You do not have a patient selected.  If you are sending a message to an existing "
                          + "patient you should choose the Patient option and use the find button.  If you proceed no commlog entry "
                          + "will be created and any replies to this message will not be automatically associated with any patient.  Continue?"))
         {
             return;
         }
         long clinicNum = Clinics.ClinicNum;
         if (clinicNum == 0)
         {
             clinicNum = PrefC.GetLong(PrefName.TextingDefaultClinicNum);
         }
         if (!SendText(0, textWirelessPhone.Text, textMessage.Text, YN.Unknown, clinicNum, SmsMessageSource.DirectSms, true)) //0 as PatNum to denote no pat specified
         {
             return;                                                                                                          //Allow the user to try again.  A message was already shown to the user inside SendText().
         }
     }
     else                //Patient selected
     {
         if (PatNum == 0)
         {
             MsgBox.Show(this, "You must first select a patient with the find button, or use the Another Person option.");
             return;
         }
         if (textWirelessPhone.Text == "")
         {
             MsgBox.Show(this, "This patient has no wireless phone entered.  You must add a wireless phone number to their patient account first before "
                         + "you can send a text message.");
             return;
         }
         if (!SendText(PatNum, textWirelessPhone.Text, textMessage.Text, TxtMsgOk, SmsPhones.GetClinicNumForTexting(PatNum), SmsMessageSource.DirectSms, true))
         {
             return;                    //Allow the user to try again.  A message was already shown to the user inside SendText().
         }
     }
     DialogResult = DialogResult.OK;
 }