Example #1
0
        ///<summary>Returns true if this form needs to be shown to the user based on practice and patient settings.  False otherwise.</summary>
        public static void PromptIfNecessary(Patient pat, long clinicNum)
        {
            PatComm patComm = Patients.GetPatComms(pat.SingleItemToList()).FirstOrDefault();

            if (patComm is null)
            {
                return;
            }
            bool isClinicPrompting = ClinicPrefs.GetBool(PrefName.ShortCodeOptInOnApptComplete, clinicNum);

            if (!isClinicPrompting &&        //Auto prompt is disabled (practice pref if not found for clinic)
                patComm.IsPatientShortCodeEligible(clinicNum) &&                //The patient might be able to receive short code sms.
                pat.ShortCodeOptIn == YN.Unknown)                 //And the patient has not explicitly opted in or out yet.
            {
                //Provider has acknowledged they will have the Appt Text opt-in conversation with the patient in absence of this prompt, and that this will
                //cause "Unknown" patients to be automatically opted-in.  HQ has a preference to disable auto Unknown->Yes if necessary.
                TrySendToHq(pat.WirelessPhone, YN.Yes, pat.PatNum, clinicNum, isSilent: true);
                return;
            }
            bool isPromptNecessary = isClinicPrompting &&       //Auto prompt is enabled (practice pref if not found for clinic)
                                     patComm.IsPatientShortCodeEligible(clinicNum) &&
                                     pat.ShortCodeOptIn == YN.Unknown; //Patient has not opted in or out for short codes yet.

            if (!isPromptNecessary)
            {
                return;
            }
            new FormShortCodeOptIn(pat).ShowDialog();
        }