Exemple #1
0
        public static PatientRestrictOptions GetPatientRestrictOptions(AdvancedSettings settings)
        {
            PatientRestrictOptions options = null;

            try
            {
                settings.RefreshSettings();
                options = settings.GetAddInCustomData <PatientRestrictOptions>(Source, OptionsName);
                if (options == null)
                {
                    options = new PatientRestrictOptions();
                }
            }
            catch (Exception e)
            {
                if (options == null)
                {
                    options = new PatientRestrictOptions();
                }

                Logger.Global.SystemMessage(LogType.Error, e.Message);
            }

            return(options);
        }
        public void ShowDialog(IWin32Window Owner)
        {
            List <AeAccessKey> aeRoleListNew = Module.PatientRightsDataAccess.GetAllAeRoleRecords();

            _optionsDialog.aeRoleList = aeRoleListNew;

            PatientRestrictOptions options = Module.GetPatientRestrictOptions(_AdvancedSettings);

            _optionsDialog.PageSize = options.PageSize;
            _optionsDialog.PatientRestrictEnabled = options.PatientRestrictEnabled;
            _optionsDialog.ApplyOptionsMethod     = UpdateOptions;

            {
                if (_optionsDialog.ShowDialog(Owner) == DialogResult.OK)
                {
                    try
                    {
                        UpdateOptions(false);
                    }
                    catch (Exception e)
                    {
                        Logger.Global.SystemMessage(LogType.Error, e.Message);
                    }
                }
            }
        }
        public bool UpdateOptions(bool refresh)
        {
            PatientRestrictOptions options = new PatientRestrictOptions();

            options.PageSize = _optionsDialog.PageSize;
            options.PatientRestrictEnabled = _optionsDialog.PatientRestrictEnabled;

            List <AeAccessKey> aeRoleListNew = _optionsDialog.aeRoleList;

            // Save AdvancedSettings settings;
            _AdvancedSettings.RefreshSettings();
            _AdvancedSettings.SetAddInCustomData <PatientRestrictOptions>(Module.Source, Module.OptionsName, options);
            _AdvancedSettings.Save();

            // Save Database Settings
            List <AeAccessKey> aeRoleListOriginal = Module.PatientRightsDataAccess.GetAllAeRoleRecords();

            // We want to remove all items from each list that are IN BOTH LISTS
            // After this:
            //    aeRoleListOriginal will contain elements to be deleted
            //    aeRoleListNew      will contain elements to be added
            for (int i = aeRoleListNew.Count - 1; i >= 0; i--)
            {
                AeAccessKey value        = aeRoleListNew[i];
                int         countRemoved = aeRoleListOriginal.MyRemoveAll(value);

                if (countRemoved > 0)
                {
                    aeRoleListNew.RemoveAt(i);
                }
            }

            int deletedCount = aeRoleListOriginal.Count;
            int addedCount   = aeRoleListNew.Count;

            // aeRoleListOriginal now contains elements to be deleted
            foreach (AeAccessKey value in aeRoleListOriginal)
            {
                Module.PatientRightsDataAccess.DeleteAeRole(value.AeTitle, value.AccessKey);
            }

            // aeRoleListNew now contains elements to be added
            foreach (AeAccessKey value in aeRoleListNew)
            {
                Module.PatientRightsDataAccess.AddAeRole(value.AeTitle, value.AccessKey);
            }

            if ((addedCount != 0) || (deletedCount != 0))
            {
                string message = string.Format("Records Added: {0}\r\nRecords Deleted: {1}", addedCount, deletedCount);
                MessageBox.Show(message, "Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            if (refresh)
            {
                aeRoleListNew             = Module.PatientRightsDataAccess.GetAllAeRoleRecords();
                _optionsDialog.aeRoleList = aeRoleListNew;
            }

            return(true);
        }
Exemple #4
0
 public static void ConfigureAddin(AdvancedSettings settings)
 {
     _options = GetPatientRestrictOptions(settings);
 }