///<summary>Makes a web call to WebServiceMainHQ to get the corresponding EServiceSetupFull information and then attempts to fill each tab.
        ///If anything goes wrong within this method a message box will show to the user and then the window will auto close via Abort.</summary>
        private void FillForm()
        {
            Action actionCloseProgress = ODProgressOld.ShowProgressStatus("EServicesSetupProgress", this, "Validating eServices...");

            try {
                if (MiscUtils.TryUpdateIeEmulation())
                {
                    throw new Exception("Browser emulation version updated.\r\nYou must restart this application before accessing the Signup Portal.");
                }
                //Send light version of clinics to HQ to be used by signup portal below. Get back all args needed from HQ in order to perform the operations of this window.
                SignupPortalPermission perm = SignupPortalPermission.ReadOnly;
                if (Security.IsAuthorized(Permissions.SecurityAdmin, true))
                {
                    perm = SignupPortalPermission.FullPermission;
                }
                else if (Security.IsAuthorized(Permissions.EServicesSetup, true))
                {
                    perm = SignupPortalPermission.ReadOnly;
                }
                else
                {
                    perm = SignupPortalPermission.Denied;
                }
                _signupOut = WebServiceMainHQProxy.GetEServiceSetupFull(perm);
                //Show user any prompts that were generated by GetEServiceSetupFull().
                if (_signupOut.Prompts.Count > 0)
                {
                    MessageBox.Show(string.Join("\r\n", _signupOut.Prompts.Select(x => Lans.g(this, x))));
                }
                #region Fill
                EServicesEvent.Fire(new ODEventArgs("EServicesSetupProgress", Lan.g(this, "Loading tab - Signup")));
                FillTabSignup();
                EServicesEvent.Fire(new ODEventArgs("EServicesSetupProgress", Lan.g(this, "Loading tab - eConnector Service")));
                FillTabEConnector();
                EServicesEvent.Fire(new ODEventArgs("EServicesSetupProgress", Lan.g(this, "Loading tab - Mobile Synch (old-style)")));
                FillTabMobileSynch();
                EServicesEvent.Fire(new ODEventArgs("EServicesSetupProgress", Lan.g(this, "Loading tab - Mobile Web")));
                FillTabMobileWeb();
                EServicesEvent.Fire(new ODEventArgs("EServicesSetupProgress", Lan.g(this, "Loading tab - Patient Portal")));
                FillTabPatientPortal();
                EServicesEvent.Fire(new ODEventArgs("EServicesSetupProgress", Lan.g(this, "Loading tab - Web Sched Recall")));
                FillTabWebSchedRecall();
                EServicesEvent.Fire(new ODEventArgs("EServicesSetupProgress", Lan.g(this, "Loading tab - Web Sched New Pat Appt")));
                FillTabWebSchedNewPat();
                EServicesEvent.Fire(new ODEventArgs("EServicesSetupProgress", Lan.g(this, "Loading tab - Web Sched Verify")));
                FillTabWebSchedVerify();
                EServicesEvent.Fire(new ODEventArgs("EServicesSetupProgress", Lan.g(this, "Loading tab - Texting Services")));
                FillTabTexting();
                EServicesEvent.Fire(new ODEventArgs("EServicesSetupProgress", Lan.g(this, "Loading tab - eReminders & eConfirmations")));
                FillTabECR();
                EServicesEvent.Fire(new ODEventArgs("EServicesSetupProgress", Lan.g(this, "Loading tab - Miscellaneous")));
                FillTabMisc();
                #endregion
                #region Authorize editing
                //Disable certain buttons but let them continue to view.
                bool allowEdit = Security.IsAuthorized(Permissions.EServicesSetup, true);
                AuthorizeTabSignup(allowEdit);
                AuthorizeTabEConnector(allowEdit);
                AuthorizeTabMobileSynch(allowEdit);
                AuthorizeTabPatientPortal(allowEdit);
                AuthorizeTabWebSchedRecall(allowEdit);
                AuthorizeTabWebSchedNewPat(allowEdit);
                AuthorizeTabTexting(allowEdit);
                AuthorizeTabECR(allowEdit);
                AuthorizeTabMisc(allowEdit);
                ((Control)tabMobileSynch).Enabled = allowEdit;
                #endregion
            }
            catch (WebException we) {
                actionCloseProgress?.Invoke();
                FriendlyException.Show(Lan.g(this, "Could not reach HQ.  Please make sure you have an internet connection and try again or call support."), we);
                //Set the dialog result to Abort so that FormClosing knows to not try and save any changes.
                DialogResult = DialogResult.Abort;
                Close();
            }
            catch (Exception e) {
                actionCloseProgress?.Invoke();
                FriendlyException.Show(Lan.g(this, "There was a problem loading the eServices Setup window.  Please try again or call support."), e);
                //Set the dialog result to Abort so that FormClosing knows to not try and save any changes.
                DialogResult = DialogResult.Abort;
                Close();
            }
            actionCloseProgress?.Invoke();
        }
        ///<summary>Makes a web call to WebServiceMainHQ to get the corresponding EServiceSetupFull information and then attempts to fill each tab.
        ///If anything goes wrong within this method a message box will show to the user and then the window will auto close via Abort.</summary>
        private void FillForm()
        {
            Action actionCloseProgress = ODProgress.Show(ODEventType.EServices, typeof(EServicesEvent), "Validating eServices...");

            try {
                if (!ODBuild.IsWeb() && MiscUtils.TryUpdateIeEmulation())
                {
                    throw new Exception("Browser emulation version updated.\r\nYou must restart this application before accessing the Signup Portal.");
                }
                //Send light version of clinics to HQ to be used by signup portal below. Get back all args needed from HQ in order to perform the operations of this window.
                SignupPortalPermission perm = GetUserSignupPortalPermissions();
                SecurityLogs.MakeLogEntry(Permissions.Setup, 0, $"User {Security.CurUser.UserName} entered EService Setup with SignupPortalPermission {perm}");
                if (_signupOut == null)                //the first time this loads _signupOut will be null, so we won't have a previous state to compare
                {
                    _signupOut = WebServiceMainHQProxy.GetEServiceSetupFull(perm);
                }
                else                   //If we are switching from the signup tab to another this will get called again and we don't want to lose the "diff"
                {
                    _signupOut = WebServiceMainHQProxy.GetEServiceSetupFull(perm, oldSignupOut: _signupOut);
                }
                //Show user any prompts that were generated by GetEServiceSetupFull().
                if (_signupOut.Prompts.Count > 0)
                {
                    MessageBox.Show(string.Join("\r\n", _signupOut.Prompts.Select(x => Lans.g(this, x))));
                }
                if (ODBuild.IsWeb())
                {
                    bool isSignupSelected = tabControl.SelectedTab == tabSignup;
                    tabControl.TabPages.Remove(tabSignup);
                    if (isSignupSelected)
                    {
                        actionCloseProgress?.Invoke();
                        this.ForceBringToFront();
                        Process.Start(_signupOut.SignupPortalUrl);
                        DialogResult = DialogResult.Abort;
                        return;
                    }
                }
                #region Fill
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - Signup"));
                FillTabSignup();
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - eConnector Service"));
                FillTabEConnector();
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - Mobile Synch (old-style)"));
                FillTabMobileSynch();
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - Mobile Web"));
                FillTabMobileWeb();
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - Patient Portal"));
                FillTabPatientPortal();
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - Web Sched Recall"));
                FillTabWebSchedRecall();
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - Web Sched New Pat Appt"));
                FillTabWebSchedNewPat();
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - Web Sched Verify"));
                FillTabWebSchedVerify();
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - Texting Services"));
                FillTabTexting();
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - eReminders & eConfirmations"));
                FillTabECR();
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - eClipboard"));
                FillTabEClipboard();
                EServicesEvent.Fire(ODEventType.EServices, Lan.g(this, "Loading tab - Miscellaneous"));
                FillTabMisc();
                #endregion
                #region Authorize editing
                //Disable certain buttons but let them continue to view.
                bool allowEdit = Security.IsAuthorized(Permissions.EServicesSetup, true);
                AuthorizeTabSignup(allowEdit);
                AuthorizeTabEConnector(allowEdit);
                AuthorizeTabMobileSynch(allowEdit);
                AuthorizeTabPatientPortal(allowEdit);
                AuthorizeTabWebSchedRecall(allowEdit);
                AuthorizeTabWebSchedNewPat(allowEdit);
                AuthorizeTabTexting(allowEdit);
                AuthorizeTabECR(allowEdit);
                AuthorizeTabEClipboard(allowEdit);
                AuthorizeTabMisc(allowEdit);
                ((Control)tabMobileSynch).Enabled = allowEdit;
                #endregion
            }
            catch (WebException we) {
                actionCloseProgress?.Invoke();
                this.ForceBringToFront();
                FriendlyException.Show(Lan.g(this, "Could not reach HQ.  Please make sure you have an internet connection and try again or call support."), we);
                //Set the dialog result to Abort so that FormClosing knows to not try and save any changes.
                DialogResult = DialogResult.Abort;
                Close();
            }
            catch (Exception e) {
                actionCloseProgress?.Invoke();
                this.ForceBringToFront();
                FriendlyException.Show(Lan.g(this, "There was a problem loading the eServices Setup window.  Please try again or call support."), e);
                //Set the dialog result to Abort so that FormClosing knows to not try and save any changes.
                DialogResult = DialogResult.Abort;
                Close();
            }
            actionCloseProgress?.Invoke();
            this.ForceBringToFront();
        }