Example #1
0
        private void butDuplicate_Click(object sender, EventArgs e)
        {
            if (gridCustom.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select an custom alert category from the list first.");
                return;
            }
            List <AlertCategory> listNewAlertCategories = _listInternalAlertCategory.Select(x => x.Copy()).ToList();
            AlertCategory        alertCat = _listCustomAlertCategory[gridCustom.GetSelectedIndex()].Copy();

            alertCat.Description += Lan.g(this, "(Copy)");
            listNewAlertCategories.Add(alertCat);
            //alertCat.AlertCategoryNum reflects the original pre-copied PK. After sync this will be a new PK for the new row.
            List <AlertCategoryLink> listAlertCategoryType = AlertCategoryLinks.GetForCategory(alertCat.AlertCategoryNum);

            if (AlertCategories.Sync(listNewAlertCategories, _listInternalAlertCategory))
            {
                //At this point alertCat has a new PK, so we need to update and insert our new copied alertCategoryLinks
                listAlertCategoryType.ForEach(x => {
                    x.AlertCategoryNum = alertCat.AlertCategoryNum;
                    AlertCategoryLinks.Insert(x);
                });
                DataValid.SetInvalid(InvalidType.AlertCategories, InvalidType.AlertCategoryLinks);
                FillGrids(selectedCustomKey: alertCat.AlertCategoryNum);
            }
        }
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Are you sure you would like to delete this?"))
     {
         return;
     }
     AlertCategoryLinks.DeleteForCategory(_categoryCur.AlertCategoryNum);
     AlertCategories.Delete(_categoryCur.AlertCategoryNum);
     DataValid.SetInvalid(InvalidType.AlertCategories, InvalidType.AlertCategories);
     DialogResult = DialogResult.OK;
 }
        private void InsertCopyAlertCategory(AlertCategory alertCat)
        {
            alertCat.IsHQCategory = false;
            alertCat.Description += Lan.g(this, "(Copy)");
            //alertCat.AlertCategoryNum reflects the original pre-copied PK. After Insert this will be a new PK for the new row.
            List <AlertCategoryLink> listAlertCategoryType = AlertCategoryLinks.GetForCategory(alertCat.AlertCategoryNum);

            alertCat.AlertCategoryNum = AlertCategories.Insert(alertCat);
            //At this point alertCat has a new PK, so we need to update and insert our new copied alertCategoryLinks
            listAlertCategoryType.ForEach(x => {
                x.AlertCategoryNum = alertCat.AlertCategoryNum;
                AlertCategoryLinks.Insert(x);
            });
            DataValid.SetInvalid(InvalidType.AlertCategories, InvalidType.AlertCategoryLinks);
            FillGrids();
        }
Example #4
0
 private void FillGrids(long selectedIneranlKey = 0, long selectedCustomKey = 0)
 {
     _listCustomAlertCategory.Clear();
     _listInternalAlertCategory.Clear();
     AlertCategories.GetDeepCopy().ForEach(x =>
     {
         if (x.IsHQCategory)
         {
             _listInternalAlertCategory.Add(x);
         }
         else
         {
             _listCustomAlertCategory.Add(x);
         }
     });
     _listInternalAlertCategory.OrderBy(x => x.InternalName);
     _listCustomAlertCategory.OrderBy(x => x.InternalName);
     FillInternalGrid(selectedIneranlKey);
     FillCustomGrid(selectedCustomKey);
 }
        private void butOK_Click(object sender, EventArgs e)
        {
            _categoryCur.Description = textDesc.Text;
            List <AlertType> listSelectedTypes = listBoxAlertTypes.SelectedIndices
                                                 .OfType <int>()
                                                 .Select(x => (AlertType)listShownAlertTypes[x])
                                                 .ToList();
            List <AlertCategoryLink> listNewAlertCategoryType = listOldAlertCategoryLinks.Select(x => x.Copy()).ToList();

            listNewAlertCategoryType.RemoveAll(x => !listSelectedTypes.Contains(x.AlertType));            //Remove unselected AlertTypes
            foreach (AlertType type in listSelectedTypes)
            {
                if (!listOldAlertCategoryLinks.Exists(x => x.AlertType == type))               //Add newly selected AlertTypes.
                {
                    listNewAlertCategoryType.Add(new AlertCategoryLink(_categoryCur.AlertCategoryNum, type));
                }
            }
            AlertCategoryLinks.Sync(listNewAlertCategoryType, listOldAlertCategoryLinks);
            AlertCategories.Update(_categoryCur);
            DataValid.SetInvalid(InvalidType.AlertCategoryLinks, InvalidType.AlertCategories);
            DialogResult = DialogResult.OK;
        }
Example #6
0
 public static string GetText(
     this AlertCategories category) =>
 AlertCategoriesTexts[
     (int)category,
     ((int)Settings.Default.UILocale) > 5 ? 5 : (int)Settings.Default.UILocale];
Example #7
0
        private void FormUserEdit_Load(object sender, System.EventArgs e)
        {
            checkIsHidden.Checked = UserCur.IsHidden;
            if (UserCur.UserNum != 0)
            {
                textUserNum.Text = UserCur.UserNum.ToString();
            }
            textUserName.Text   = UserCur.UserName;
            textDomainUser.Text = UserCur.DomainUser;
            if (!PrefC.GetBool(PrefName.DomainLoginEnabled))
            {
                labelDomainUser.Visible   = false;
                textDomainUser.Visible    = false;
                butPickDomainUser.Visible = false;
            }
            checkRequireReset.Checked = UserCur.IsPasswordResetRequired;
            _listUserGroups           = UserGroups.GetList();
            _isFillingList            = true;
            for (int i = 0; i < _listUserGroups.Count; i++)
            {
                listUserGroup.Items.Add(new ODBoxItem <UserGroup>(_listUserGroups[i].Description, _listUserGroups[i]));
                if (!_isFromAddUser && UserCur.IsInUserGroup(_listUserGroups[i].UserGroupNum))
                {
                    listUserGroup.SetSelected(i, true);
                }
                if (_isFromAddUser && _listUserGroups[i].UserGroupNum == PrefC.GetLong(PrefName.DefaultUserGroup))
                {
                    listUserGroup.SetSelected(i, true);
                }
            }
            if (listUserGroup.SelectedIndex == -1)          //never allowed to delete last group, so this won't fail
            {
                listUserGroup.SelectedIndex = 0;
            }
            _isFillingList = false;
            securityTreeUser.FillTreePermissionsInitial();
            RefreshUserTree();
            listEmployee.Items.Clear();
            listEmployee.Items.Add(Lan.g(this, "none"));
            listEmployee.SelectedIndex = 0;
            _listEmployees             = Employees.GetDeepCopy(true);
            for (int i = 0; i < _listEmployees.Count; i++)
            {
                listEmployee.Items.Add(Employees.GetNameFL(_listEmployees[i]));
                if (UserCur.EmployeeNum == _listEmployees[i].EmployeeNum)
                {
                    listEmployee.SelectedIndex = i + 1;
                }
            }
            listProv.Items.Clear();
            listProv.Items.Add(Lan.g(this, "none"));
            listProv.SelectedIndex = 0;
            _listProviders         = Providers.GetDeepCopy(true);
            for (int i = 0; i < _listProviders.Count; i++)
            {
                listProv.Items.Add(_listProviders[i].GetLongDesc());
                if (UserCur.ProvNum == _listProviders[i].ProvNum)
                {
                    listProv.SelectedIndex = i + 1;
                }
            }
            _listClinics           = Clinics.GetDeepCopy(true);
            _listUserAlertTypesOld = AlertSubs.GetAllForUser(UserCur.UserNum);
            List <long> listSubscribedClinics;
            bool        isAllClinicsSubscribed = false;

            if (_listUserAlertTypesOld.Select(x => x.ClinicNum).Contains(-1))             //User subscribed to all clinics
            {
                isAllClinicsSubscribed = true;
                listSubscribedClinics  = _listClinics.Select(x => x.ClinicNum).Distinct().ToList();
            }
            else
            {
                listSubscribedClinics = _listUserAlertTypesOld.Select(x => x.ClinicNum).Distinct().ToList();
            }
            List <long> listAlertCatNums = _listUserAlertTypesOld.Select(x => x.AlertCategoryNum).Distinct().ToList();

            listAlertSubMulti.Items.Clear();
            _listAlertCategories = AlertCategories.GetDeepCopy();
            List <long> listUserAlertCatNums = _listUserAlertTypesOld.Select(x => x.AlertCategoryNum).ToList();

            foreach (AlertCategory cat in _listAlertCategories)
            {
                int index = listAlertSubMulti.Items.Add(Lan.g(this, cat.Description));
                listAlertSubMulti.SetSelected(index, listUserAlertCatNums.Contains(cat.AlertCategoryNum));
            }
            if (!PrefC.HasClinicsEnabled)
            {
                tabClinics.Enabled = false;              //Disables all controls in the clinics tab.  Tab is still selectable.
                listAlertSubsClinicsMulti.Visible = false;
                labelAlertClinic.Visible          = false;
            }
            else
            {
                listClinic.Items.Clear();
                listClinic.Items.Add(Lan.g(this, "All"));
                listAlertSubsClinicsMulti.Items.Add(Lan.g(this, "All"));
                listAlertSubsClinicsMulti.Items.Add(Lan.g(this, "Headquarters"));
                if (UserCur.ClinicNum == 0)               //Unrestricted
                {
                    listClinic.SetSelected(0, true);
                    checkClinicIsRestricted.Enabled = false; //We don't really need this checkbox any more but it's probably better for users to keep it....
                }
                if (isAllClinicsSubscribed)                  //They are subscribed to all clinics
                {
                    listAlertSubsClinicsMulti.SetSelected(0, true);
                }
                else if (listSubscribedClinics.Contains(0))                 //They are subscribed to Headquarters
                {
                    listAlertSubsClinicsMulti.SetSelected(1, true);
                }
                List <UserClinic> listUserClinics = UserClinics.GetForUser(UserCur.UserNum);
                for (int i = 0; i < _listClinics.Count; i++)
                {
                    listClinic.Items.Add(_listClinics[i].Abbr);
                    listClinicMulti.Items.Add(_listClinics[i].Abbr);
                    listAlertSubsClinicsMulti.Items.Add(_listClinics[i].Abbr);
                    if (UserCur.ClinicNum == _listClinics[i].ClinicNum)
                    {
                        listClinic.SetSelected(i + 1, true);
                    }
                    if (UserCur.ClinicNum != 0 && listUserClinics.Exists(x => x.ClinicNum == _listClinics[i].ClinicNum))
                    {
                        listClinicMulti.SetSelected(i, true);                       //No "All" option, don't select i+1
                    }
                    if (!isAllClinicsSubscribed && _listUserAlertTypesOld.Exists(x => x.ClinicNum == _listClinics[i].ClinicNum))
                    {
                        listAlertSubsClinicsMulti.SetSelected(i + 2, true);                     //All+HQ
                    }
                }
                checkClinicIsRestricted.Checked = UserCur.ClinicIsRestricted;
            }
            if (string.IsNullOrEmpty(UserCur.PasswordHash))
            {
                butPassword.Text = Lan.g(this, "Create Password");
            }
            if (!PrefC.IsODHQ)
            {
                butJobRoles.Visible = false;
            }
            if (IsNew)
            {
                butUnlock.Visible = false;
            }
            _listDoseSpotUserPrefOld = UserOdPrefs.GetByUserAndFkeyAndFkeyType(UserCur.UserNum,
                                                                               Programs.GetCur(ProgramName.eRx).ProgramNum, UserOdFkeyType.Program,
                                                                               Clinics.GetForUserod(Security.CurUser, true).Select(x => x.ClinicNum)
                                                                               .Union(new List <long>()
            {
                0
            })                                                //Always include 0 clinic, this is the default, NOT a headquarters only value.
                                                                               .Distinct()
                                                                               .ToList());
            _listDoseSpotUserPrefNew = _listDoseSpotUserPrefOld.Select(x => x.Clone()).ToList();
            _doseSpotUserPrefDefault = _listDoseSpotUserPrefNew.Find(x => x.ClinicNum == 0);
            if (_doseSpotUserPrefDefault == null)
            {
                _doseSpotUserPrefDefault = DoseSpot.GetDoseSpotUserIdFromPref(UserCur.UserNum, 0);
                _listDoseSpotUserPrefNew.Add(_doseSpotUserPrefDefault);
            }
            textDoseSpotUserID.Text = _doseSpotUserPrefDefault.ValueString;
            if (_isFromAddUser && !Security.IsAuthorized(Permissions.SecurityAdmin, true))
            {
                butPassword.Visible       = false;
                checkRequireReset.Checked = true;
                checkRequireReset.Enabled = false;
                butUnlock.Visible         = false;
                butJobRoles.Visible       = false;
            }
            if (!PrefC.HasClinicsEnabled)
            {
                butDoseSpotAdditional.Visible = false;
            }
        }
        /// <summary>
        /// Process Records
        /// </summary>
        protected override void ProcessRecord()
        {
            var queries = new Dictionary <string, string>();

            if (MaxAlerts.HasValue)
            {
                queries.Add("maxAlerts", MaxAlerts.ToString());
            }

            if (AlertCategories != null && AlertCategories.Any())
            {
                List <string> alertCategories = AlertCategories.ToList().ConvertAll <string>(x => x.ToString().First().ToString().ToLower() + x.ToString().Substring(1));
                queries.Add("alertCategoryList", string.Join(",", alertCategories));
            }

            if (AlertStates != null && AlertStates.Any())
            {
                List <string> alertStates = AlertStates.ToList().ConvertAll <string>(x => x.ToString().First().ToString().ToLower() + x.ToString().Substring(1));
                queries.Add("alertStateList", string.Join(",", alertStates));
            }

            if (AlertSeverities != null && AlertSeverities.Any())
            {
                List <string> alertSeverities = AlertSeverities.ToList().ConvertAll <string>(x => x.ToString().First().ToString().ToLower() + x.ToString().Substring(1));
                queries.Add("alertSeverityList", string.Join(",", alertSeverities));
            }

            if (ResolutionIds != null && ResolutionIds.Any())
            {
                queries.Add("resolutionIdList", string.Join(",", ResolutionIds));
            }

            if (AlertIds != null && AlertIds.Any())
            {
                queries.Add("alertIdList", string.Join(",", AlertIds));
            }

            if (AlertTypes != null && AlertTypes.Any())
            {
                queries.Add("alertTypeList", string.Join(",", AlertTypes));
            }

            if (StartTime.HasValue)
            {
                queries.Add("startDateUsecs", StartTime.ToString());
            }

            if (EndTime.HasValue)
            {
                queries.Add("endDateUsecs", EndTime.ToString());
            }

            var queryString = string.Empty;

            if (queries.Any())
            {
                queryString = "?" + string.Join("&", queries.Select(q => $"{q.Key}={q.Value}"));
            }

            var preparedUrl = $"/public/alerts{queryString}";

            WriteDebug(preparedUrl);
            var result = Session.ApiClient.Get <IEnumerable <Model.Alert> >(preparedUrl);

            WriteObject(result, true);
        }
Example #9
0
        public void AlertItems_GetUniqueAlerts_Addclinic()
        {
            //This test will check the funcionality of alert items which are marked to show in all clinics(AlertItem.ClinicNum==-1).
            //Expected behaviour is that a user subscribed to all alert categories, and all clinics(AlertSub.ClinicNum==-1),
            //will see the alert no matter which clinic they are in.
            //In addition, when a new clinic is added, the user will be able to see alerts in that new clinic without the need to reenter
            //FormUserEdit and select "All" again under clinics for alert subscriptions.
            //Clear AlertSub table.
            AlertSubT.ClearAlertSubTable();
            //Create Users
            Userod userAdmin  = UserodT.CreateUser();
            Userod userNormal = UserodT.CreateUser();
            //Create Clinics
            List <Clinic> listClinics = new List <Clinic>();

            for (int i = 0; i < 2; i++)
            {
                listClinics.Add(ClinicT.CreateClinic());
            }
            //Create AlertItems
            //First alert Item is an alert item for all clinics(ClinicNum==-1).
            CreateAlertItem(true);
            //Second AlertItem is an AlertItem for HQ(ClinicNum==0).
            CreateAlertItem(false);
            List <AlertCategory> listAlertCats   = AlertCategories.GetDeepCopy();
            List <AlertSub>      listAlertSubOld = new List <AlertSub>();
            List <AlertSub>      listAlertSubNew = new List <AlertSub>();

            foreach (AlertCategory alertCat in listAlertCats)
            {
                AlertSub alSub = new AlertSub(userAdmin.UserNum, -1, alertCat.AlertCategoryNum);
                listAlertSubNew.Add(alSub);
            }
            AlertSubs.Sync(listAlertSubNew, listAlertSubOld);
            //Check number of alerts which will display in headquarters clinic.
            //Call CheckUniqueAlerts for user subscribed to all alert categories
            List <List <AlertItem> > listUniqueAlertsAll = AlertItems.GetUniqueAlerts(userAdmin.UserNum, 0);
            List <List <AlertItem> > listUniqueAlertsOne = AlertItems.GetUniqueAlerts(userNormal.UserNum, 0);

            //Assert lists are correct
            //UserAdmin should see two alerts, one for the generic headquarters alert and one for the eConnector all clinics alert.
            Assert.AreEqual(2, listUniqueAlertsAll.Count());
            //UserNormal is not subscribed to any clinics or alert categories and should not see any alerts.
            Assert.AreEqual(0, listUniqueAlertsOne.Count());
            //Add clinic
            listClinics.Add(ClinicT.CreateClinic());
            //Check that alert for all clinics is included for userAdmin(subscribed to all clinics)
            listUniqueAlertsAll = AlertItems.GetUniqueAlerts(userAdmin.UserNum, listClinics.LastOrDefault().ClinicNum);
            Assert.AreEqual(1, listUniqueAlertsAll.Count());
            //Check new clinic for user who is not subscribed to all alerts.
            listUniqueAlertsOne = AlertItems.GetUniqueAlerts(userNormal.UserNum, listClinics.LastOrDefault().ClinicNum);
            Assert.AreEqual(0, listUniqueAlertsOne.Count());
            //Add new alert for new clinic only.
            CreateAlertItem(false, listClinics.LastOrDefault().ClinicNum);
            //Check that userAdmin sees new alert item in new clinic. Should have 2, one all clinic econnector alert and the new clinic specific alert.
            listUniqueAlertsAll = AlertItems.GetUniqueAlerts(userAdmin.UserNum, listClinics.LastOrDefault().ClinicNum);
            Assert.AreEqual(2, listUniqueAlertsAll.Count());
            //Check that userNormal sees no alerts in new clinic, as they are not subscribed to any alert categories, nor clinics.
            listUniqueAlertsOne = AlertItems.GetUniqueAlerts(userNormal.UserNum, listClinics.LastOrDefault().ClinicNum);
            Assert.AreEqual(0, listUniqueAlertsOne.Count());
        }