Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CareSiteAccessController csaController = new CareSiteAccessController();
        CareSiteController       csController  = new CareSiteController();

        //string codeWord = Request.QueryString["accessCode"];

        //try
        //{
        //    var careSiteId = csaController.GetCareSiteID(codeWord);
        //    string careSiteName = csController.GetCareSiteName(careSiteId);

        //    SiteNameLabel.Text = careSiteName;
        //}
        //catch (Exception ex)
        //{
        //    Server.Transfer("index.aspx?errorMSG=That code is not active, please check your meal or tray ticket", true);
        //}

        //TODO: Populate the Units DDL from the database
    }
Ejemplo n.º 2
0
    /*
     * CREATED:     C. Stanhope		Mar 3 2018
     * MODIFIED:   P. Chavez       MAR 27 2018
     *  - Added to method body, used Holly's code
     *
     * Page_Load()
     * Run on page load and is used to display today's and tomorrow's access codes if a care site is selected from the drop-down list.
     *
     * PARAMETERS:
     * object sender - references the object that raised the Page_Load event
     * EventArgs e - optional class that may be passed that inherits from EventArgs (usually empty)
     *
     * RETURNS:
     * void
     *
     * ODEV METHOD CALLS:
     * UserManager.FindById()
     * MessageUserControl.ShowErrorMessage()
     * CareSiteController.GetCareSiteByCareSiteID()
     * DisplayAccessCodes()
     */
    protected void Page_Load(object sender, EventArgs e)
    {
        if (CareSiteDDL.SelectedIndex == 0)
        {
            CodeCards.Visible = false;
        }

        if (User.IsInRole(AuthorizationLevelRoles.User))
        {
            UserManager        userManager        = new UserManager();
            ApplicationUser    account            = userManager.FindById(User.Identity.GetUserId());
            CareSiteController careSiteController = new CareSiteController();

            int accountCareSiteId = account.caresiteid == null ? 0 : (int)account.caresiteid;

            if (accountCareSiteId == 0)
            {
                MessageUserControl.ShowErrorMessage("Your account has no assigned care site. Please contact your administrator to be assigned a care site.");
            }
            else
            {
                try
                {
                    CareSiteDDL.DataSourceID         = null;
                    CareSiteDDL.AppendDataBoundItems = false;
                    List <CareSiteDTO> tempCareSiteList = new List <CareSiteDTO>();
                    tempCareSiteList.Add(careSiteController.GetCareSiteByCareSiteID(accountCareSiteId));
                    CareSiteDDL.DataSource = tempCareSiteList;
                    CareSiteDDL.DataBind();

                    DisplayAccessCodes(accountCareSiteId);
                }
                catch (Exception ex)
                {
                    MessageUserControl.ShowErrorMessage("Could not retrieve User's care site. Please try again. If error persists, please contact your administrator.", ex);
                }
            }
        }
    }
Ejemplo n.º 3
0
    /*
     * CREATED:      H. L'Heureux         MAR 16 2018
     * MODIFIED:     H. Conant            MAR 29 2018
     *  - Added !IsPostBack check
     *  - Removed get respondent types
     * MODIFIED:     H. L'Heureux            APR 12 2018
     *  - Added error handling
     *
     * Page_Load()
     * This method contains information to show the initial set up of the take survey page to the user. It will show the Care Site Name with a valid access code word for the day, or it will redirect the user back to the landing page (index.aspx) with an error message to inform the user to check their meal/chit ticket.
     *
     * PARAMETERS:
     * object sender - object on the page that is being targeted
     * EventArgs e - event that has triggered the method
     *
     * RETURNS:
     * void
     *
     * ODEV METHOD CALLS:
     * CareSiteController.GetCareSiteID()
     * CareSiteController.GetCareSitename()
     * UnitController.GetActiveCareSiteUnits()
     */
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetNoStore();
        Response.Cache.AppendCacheExtension("no-cache");
        Response.Expires = 0;

        if (!IsPostBack) // added this to stop information from disapearing if there was an error
        {
            FirstNameLbl.Visible   = false;
            FirstName.Visible      = false;
            RoomNumber.Visible     = false;
            RoomNumberLbl.Visible  = false;
            BedNumber.Visible      = false;
            BedNumberLbl.Visible   = false;
            PhoneNumberLbl.Visible = false;
            PhoneNumber.Visible    = false;
        }
        CareSiteAccessController csaController = new CareSiteAccessController();
        CareSiteController       csController  = new CareSiteController();

        string codeword     = Request.QueryString["accesscode"];
        string caresitename = "";

        try
        {
            //get the care site ID from the database for the codeword given by the user
            var caresiteid = csaController.GetCareSiteID(codeword);
            //get the care site name for the care site ID
            caresitename = csController.GetCareSiteName(caresiteid);

            // check if new caresite
            if (SiteNameLabel.Text != caresitename)
            {
                //display the caresite name in the label for the user to see
                SiteNameLabel.Text = caresitename;

                UnitListDDL.Items.Clear();
                UnitListDDL.Items.Insert(0, new ListItem("Please select your unit", "-1"));

                //populate the unit list for the user to choose their unit
                List <UnitDTO> tempUnitList = unitCont.GetActiveCareSiteUnits(caresiteid);
                UnitListDDL.DataSource = tempUnitList;
                UnitListDDL.DataBind();
            }
        }
        catch (Exception ex)
        {
            //redirect to the index page with an appropriate error message
            if (codeword == "")
            {
                Response.Redirect("index.aspx?errormsg=You must enter the access code on your meal or tray ticket");
            }
            else if (caresitename == "" || string.IsNullOrWhiteSpace(caresitename))
            {
                Response.Redirect("index.aspx?errormsg=That code is not active, please check your meal or tray ticket. If problem persists this care site may be no longer supplying survey service.");
            }
            else
            {
                ErrorMSG.Text = "Login not available. If error persists, please contact covenant health. Error Message: " + ex.Message;
            }
        }
    }
Ejemplo n.º 4
0
    /*
     * CREATED:     H. Conant		MAR 4 2018
     * MODIFIED:   H. Conant       MAR 20 2018
     *  - Added method body
     *
     * Page_Load()
     * This method runs any code it contains when the page loads.
     *
     * PARAMETERS:
     * object sender - object on the page that is being targeted
     * EventArgs e - event that has triggered the method
     *
     * RETURNS:
     * void
     *
     * ODEV METHOD CALLS:
     * UserManager.FindById()
     * MessageUserControl.ShowErrorMessage()
     * CareSiteController.GetCareSiteByCareSiteID()
     * UnitController.GetCareSiteUnits()
     * UnitController.GetAllUnits()
     */
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (User.IsInRole(AuthorizationLevelRoles.User))
            {
                UserManager userManager = new UserManager();

                ApplicationUser account = new ApplicationUser();

                try
                {
                    account = userManager.FindById(User.Identity.GetUserId());
                }
                catch (Exception ex)
                {
                    MessageUserControl.ShowErrorMessage("Your account has no assigned care site. Please contact your administrator to be assigned a care site.", ex);
                }

                CareSiteController careSiteController = new CareSiteController();

                int accountCareSiteId = account.caresiteid == null ? 0 : (int)account.caresiteid;

                if (accountCareSiteId == 0)
                {
                    MessageUserControl.ShowErrorMessage("Your account has no assigned care site. Please contact your administrator to be assigned a care site.");
                }
                else
                {
                    try
                    {
                        CareSiteDDL.DataSourceID         = null;
                        CareSiteDDL.AppendDataBoundItems = false;
                        List <CareSiteDTO> tempCareSiteList = new List <CareSiteDTO>();
                        tempCareSiteList.Add(careSiteController.GetCareSiteByCareSiteID(accountCareSiteId));
                        CareSiteDDL.DataSource = tempCareSiteList;
                        CareSiteDDL.DataBind();

                        List <UnitDTO> tempUnitList = unitController.GetCareSiteUnits(accountCareSiteId);
                        UnitRepeater.DataSource = tempUnitList;
                        UnitRepeater.DataBind();
                        unitsdiv.Attributes.Remove("style");
                    }
                    catch (Exception ex)
                    {
                        MessageUserControl.ShowErrorMessage("Retrieving user care site and/or units from the database failed. Please try again. If error persists, please contact your administrator.", ex);
                    }
                }
            }
            else
            {
                if (CareSiteDDL.SelectedValue == "0")
                {
                    try
                    {
                        int tempCareSiteId;
                        int.TryParse(CareSiteDDL.SelectedValue, out tempCareSiteId);
                        List <UnitDTO> tempUnitList = unitController.GetAllUnits();
                        UnitRepeater.DataSource = tempUnitList;
                        UnitRepeater.DataBind();
                        unitsdiv.Attributes.Add("style", "display:none");
                    }
                    catch (Exception ex)
                    {
                        MessageUserControl.ShowErrorMessage("Retrieving units from the database failed. Please try again. If error persists, please contact your administrator.", ex);
                    }
                }
                else
                {
                    try
                    {
                        int tempCareSiteId;
                        int.TryParse(CareSiteDDL.SelectedValue, out tempCareSiteId);
                        List <UnitDTO> tempUnitList = unitController.GetCareSiteUnits(tempCareSiteId);
                        UnitRepeater.DataSource = tempUnitList;
                        UnitRepeater.DataBind();
                        unitsdiv.Attributes.Remove("style");
                    }
                    catch (Exception ex)
                    {
                        MessageUserControl.ShowErrorMessage("Retrieving units from the database failed. Please try again. If error persists, please contact your administrator.", ex);
                    }
                }
            }
        }
    }
Ejemplo n.º 5
0
    /*
     * CREATED:     H. Conant		MAR 17 2018
     *
     * Page_Load()
     * This method runs any code it contains when the page loads.
     * Will obtain survey details, questions and answers to the questions.
     *
     * PARAMETERS:
     * object sender - object on the page that is being targeted
     * EventArgs e - event that has triggered the method
     *
     * RETURNS:
     * void
     *
     * ODEV METHOD CALLS:
     * SurveyController.GetSurveyDetails()
     * MessageUserControl.ShowErrorMessage()
     * UserManager.FindById()
     * UnitController.GetUnit()
     * SurveyAnswerController.GetSurveyAnswers()
     * SurveyQuestionController.GetSurveyQuestions()
     * MessageUserControl.ShowInfoMessage()
     */
    protected void Page_Load(object sender, EventArgs e)
    {
        int surveyId = 0;

        int.TryParse(Request.QueryString["id"], out surveyId);

        if (surveyId == 0)
        {
            Response.Redirect("/Management/contact_requests.aspx");
        }
        else
        {
            ExtendedSurveyDTO survey = new ExtendedSurveyDTO();

            try
            {
                survey = surveyController.GetSurveyDetails(surveyId);
            } catch (Exception ex)
            {
                if (survey.surveyid != -1)
                {
                    MessageUserControl.ShowErrorMessage("Could not retrieve survey. Please try again. If error persists, please contact your administrator.", ex);
                }
            }

            if (survey.surveyid == 0 || string.IsNullOrEmpty(survey.surveyid.ToString()) || survey.surveyid == -1)
            {
                Response.Redirect("/Management/contact_requests.aspx");
            }
            else
            {
                if (User.IsInRole(AuthorizationLevelRoles.User))
                {
                    UserManager     userManager = new MSS.System.BLL.Security.UserManager();
                    ApplicationUser account     = new ApplicationUser();

                    try
                    {
                        account = userManager.FindById(User.Identity.GetUserId());
                    }
                    catch (Exception ex)
                    {
                        MessageUserControl.ShowErrorMessage("Could not retrieve user accounts. Please try again. If error persists, please contact your administrator.", ex);
                    }

                    CareSiteController careSiteController = new CareSiteController();

                    int accountCareSiteId = account.caresiteid == null ? 0 : (int)account.caresiteid;

                    if (accountCareSiteId == 0)
                    {
                        Response.Redirect("/Management/contact_requests.aspx");
                    }
                    else
                    {
                        UnitDTO surveyUnit = new UnitDTO();

                        try
                        {
                            surveyUnit = unitController.GetUnit(survey.unitid);
                        }
                        catch (Exception ex)
                        {
                            MessageUserControl.ShowErrorMessage("Could not retrieve care site. Please try again. If error persists, please contact your administrator.", ex);
                            survey = new ExtendedSurveyDTO();
                        }

                        if (surveyUnit.caresiteid != accountCareSiteId)
                        {
                            Response.Redirect("/Management/contact_requests.aspx");
                        }
                    }
                }

                SurveyIDLabel.Text = survey.surveyid.ToString();

                DateLabel.Text = survey.date.ToString("MMM dd, yyyy");

                UnitLabel.Text = survey.unitname;

                CareSiteLabel.Text = survey.caresitename;

                RespondentTypeLabel.Text = survey.respondenttypename;

                AgeLabel.Text = survey.agegroupname;


                GenderLabel.Text = survey.gendername;



                if (string.IsNullOrEmpty(survey.firstname))
                {
                    Name.Text = "Name not provided";
                }
                else
                {
                    Name.Text = survey.firstname;
                }

                BedNumber.Text = String.IsNullOrEmpty(survey.bednaumber) ? "Not Provided" : survey.bednaumber;

                PhoneNumber.Text = String.IsNullOrEmpty(survey.phonenumber) ? "Not Provided" : survey.phonenumber;

                if (survey.preferredcontact == null || survey.preferredcontact == "I don't want to be contacted")
                {
                    BedNumberLabel.Visible       = false;
                    BedNumber.Visible            = false;
                    PhoneNumberLabel.Visible     = false;
                    PhoneNumber.Visible          = false;
                    ProcessedStatusLabel.Visible = false;
                    ProcessedStatus.Visible      = false;
                    ProcessRequestButton.Enabled = false;
                    ProcessRequestButton.Visible = false;
                    PreferredContactLabel.Text   = String.IsNullOrEmpty(survey.preferredcontact) ? "I don't want to be contacted" : survey.preferredcontact;
                }
                else
                {
                    PreferredContactLabel.Text = survey.preferredcontact;

                    if (BedNumber.Text == "Not Provided")
                    {
                        BedNumberLabel.Visible = false;
                        BedNumber.Visible      = false;
                    }
                    else
                    {
                        BedNumberLabel.Visible = true;
                        BedNumber.Visible      = true;
                    }

                    if (PhoneNumber.Text == "Not Provided")
                    {
                        PhoneNumberLabel.Visible = false;
                        PhoneNumber.Visible      = false;
                    }
                    else
                    {
                        PhoneNumberLabel.Visible = true;
                        PhoneNumber.Visible      = true;
                    }

                    if (survey.contactedyn == true)
                    {
                        ProcessedStatus.Text         = "Processed";
                        ProcessedStatus.ForeColor    = System.Drawing.Color.Green;
                        ProcessRequestButton.Enabled = false;
                        ProcessRequestButton.Visible = false;
                    }
                    else if (survey.contactedyn == false)
                    {
                        ProcessedStatus.Text         = "Not Processed";
                        ProcessedStatus.ForeColor    = System.Drawing.Color.Red;
                        ProcessRequestButton.Enabled = true;
                        ProcessRequestButton.Visible = true;
                    }
                    else
                    {
                        ProcessedStatus.Text         = "Contact not requested";
                        ProcessedStatus.ForeColor    = System.Drawing.Color.Black;
                        ProcessRequestButton.Enabled = false;
                        ProcessRequestButton.Visible = false;
                    }
                }

                List <surveyanswer>   surveyAnswers   = new List <surveyanswer>();
                List <surveyquestion> surveyQuestions = new List <surveyquestion>();

                try
                {
                    surveyAnswers   = surveyAnswerController.GetSurveyAnswers(survey.surveyid);
                    surveyQuestions = surveyQuestionController.GetSurveyQuestions();
                } catch (Exception ex)
                {
                    MessageUserControl.ShowErrorMessage("Could not retrieve survey answers or questions. Please try again. If error persists, please contact your administrator.", ex);
                }


                if (surveyQuestions.Count > 0)
                {
                    foreach (surveyquestion question in surveyQuestions)
                    {
                        switch (question.surveyquestionid)
                        {
                        case 1:
                            Question1aLabel.Text = question.question;
                            break;

                        case 2:
                            Question1bLabel.Text = question.question;
                            break;

                        case 3:
                            Question1cLabel.Text = question.question;
                            break;

                        case 4:
                            Question1dLabel.Text = question.question;
                            break;

                        case 5:
                            Question1eLabel.Text = question.question;
                            break;

                        case 6:
                            Question2Label.Text = question.question;
                            break;

                        case 7:
                            Question3Label.Text = question.question;
                            break;

                        case 8:
                            Question4Label.Text = question.question;
                            break;

                        case 9:
                            Question5Label.Text = question.question;
                            break;

                        default:
                            MessageUserControl.ShowInfoMessage("New questions have been added to the survey. Please contact your administrator to update this webpage.");
                            break;
                        }
                    }

                    if (surveyAnswers.Count > 0)
                    {
                        foreach (surveyanswer answer in surveyAnswers)
                        {
                            switch (answer.possibleanswer.surveyquestionid)
                            {
                            case 1:
                                Question1aLabel.Text = (answer.historicalquestion == null) ? Question1aLabel.Text : answer.historicalquestion;
                                Answer1.Text         = (answer.answer == null) ? "- No response -" : answer.answer;
                                break;

                            case 2:
                                Question1bLabel.Text = (answer.historicalquestion == null) ? Question1bLabel.Text : answer.historicalquestion;
                                Answer2.Text         = (answer.answer == null) ? "- No response -" : answer.answer;
                                break;

                            case 3:
                                Question1cLabel.Text = (answer.historicalquestion == null) ? Question1cLabel.Text : answer.historicalquestion;
                                Answer3.Text         = (answer.answer == null) ? "- No response -" : answer.answer;
                                break;

                            case 4:
                                Question1dLabel.Text = (answer.historicalquestion == null) ? Question1dLabel.Text : answer.historicalquestion;
                                Answer4.Text         = (answer.answer == null) ? "- No response -" : answer.answer;
                                break;

                            case 5:
                                Question1eLabel.Text = (answer.historicalquestion == null) ? Question1eLabel.Text : answer.historicalquestion;
                                Answer5.Text         = (answer.answer == null) ? "- No response -" : answer.answer;
                                break;

                            case 6:
                                Question2Label.Text = (answer.historicalquestion == null) ? Question2Label.Text : answer.historicalquestion;
                                Answer6.Text        = (answer.answer == null) ? "- No response -" : answer.answer;
                                break;

                            case 7:
                                Question3Label.Text = (answer.historicalquestion == null) ? Question3Label.Text : answer.historicalquestion;
                                Answer7.Text        = (answer.answer == null) ? "- No response -" : answer.answer;
                                break;

                            case 8:
                                Question4Label.Text = (answer.historicalquestion == null) ? Question4Label.Text : answer.historicalquestion;
                                Answer8.Text        = (answer.answer == null) ? "- No response -" : answer.answer;
                                break;

                            case 9:
                                Question5Label.Text = (answer.historicalquestion == null) ? Question5Label.Text : answer.historicalquestion;
                                Answer9.Text        = (answer.answer == null) ? "- No response -" : answer.answer;
                                break;

                            default:
                                MessageUserControl.ShowInfoMessage("New questions have been added to the survey. Please contact your administrator to update this webpage.");
                                break;
                            }
                        }
                    }
                    else
                    {
                        MessageUserControl.ShowInfoMessage("Survey has no answers.");
                    }
                }
                else
                {
                    MessageUserControl.ShowInfoMessage("There are not questions in the database.");
                }
            }
        }
    }
Ejemplo n.º 6
0
    /*
     * CREATED:     C. Stanhope		MAR 23 2018
     * MODIFIED:   C. Stanhope     MAR 24 2018
     *  - moved error list method to its own class and call it
     *  - changed validation to account for care site name length
     * MODIFIED:   C. Stanhope     APR 5 2018
     *  - trim whitespace on inputs
     * MODIFIED:   C. Stanhope     APR 6 2018
     *  - added try-catch for database access
     * MODIFIED:   C. Stanhope     APR 17 2018
     *  - fixed city regex to limit at 30 characters
     *  - fixed care site regex to limit at 80 characters
     *
     * AddCareSiteButton_Click()
     * Used to add a care site to the database. Validates all input fields.
     *
     * PARAMETERS:
     * object sender - references the object that raised the Page_Load event
     * EventArgs e - optional class that may be passed that inherits from EventArgs (usually empty)
     *
     * RETURNS:
     * void
     *
     * ODEV METHOD CALLS:
     * CareSiteController.AddCareSite()
     * MessageUserControl.ShowSuccessMessage()
     * MessageUserControl.ShowInfoMessage()
     * ErrorMessagesAndValidation.ErrorList()
     */
    protected void AddCareSiteButton_Click(object sender, EventArgs e)
    {
        bool          isValid   = true;
        List <string> errorList = new List <string>();

        #region regexes for validation
        Regex careSiteRegex = new Regex(@"^[A-z]{1}[A-z 0-9 .-]{4,79}$");
        Regex addressRegex  = new Regex(@"^[A-z 0-9 .#-]{1,40}$");
        Regex cityRegex     = new Regex(@"^[A-z]{1}[A-z .-]{0,29}$");
        #endregion

        #region get values from page and validate
        string careSiteName = CareSiteNameTextBox.Text.Trim();
        if (!careSiteRegex.IsMatch(careSiteName))
        {
            errorList.Add("Care site must be a minimum of 5 characters and a maximum of 80 characters long. It must start with a letter and can contain letters, numbers, and the following symbols: . -");
            isValid = false;
        }

        string address = AddressTextBox.Text.Trim();
        if (!addressRegex.IsMatch(address))
        {
            errorList.Add("Address must be a minimum of 1 letter and a maximum of 40 characters long. It can contain letters, numbers, and the following symbols: # . -");
            isValid = false;
        }

        string city = CityTextBox.Text.Trim();
        if (!cityRegex.IsMatch(city))
        {
            errorList.Add("City must be a minimum of 1 letter and a maximum of 30 characters long. It must start with a letter and can contain letters and the following symbols: . -");
            isValid = false;
        }

        string province = ProvinceDDL.SelectedValue;
        if (ProvinceDDL.SelectedIndex == 0)
        {
            errorList.Add("A province must be selected from the drop-down list");
            isValid = false;
        }

        #endregion

        if (isValid)
        {
            #region put valid data into DTO, add to database, show success message, clear page
            CareSiteDTO newCareSite = new CareSiteDTO();

            newCareSite.caresitename = careSiteName;
            newCareSite.address      = address;
            newCareSite.city         = city;
            newCareSite.province     = province;

            CareSiteController careSiteController = new CareSiteController();
            try
            {
                careSiteController.AddCareSite(newCareSite);

                // show message, clear page
                MessageUserControl.ShowSuccessMessage("New care site " + careSiteName + " was successfully added. Please navigate to the Manage Units page to add units to the new care site.");

                CareSiteNameTextBox.Text  = "";
                AddressTextBox.Text       = "";
                CityTextBox.Text          = "";
                ProvinceDDL.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageUserControl.ShowErrorMessage("Adding care site failed. Please try again. If error persists, please contact your administrator.", ex);
            }
            #endregion
        }
        else
        {
            MessageUserControl.ShowInfoList("The following errors caused adding a care site to fail: ", errorList);
        }
    }