Example #1
0
 private void FormPatientPortal_Load(object sender, EventArgs e)
 {
     _userWebCur = UserWebs.GetByFKeyAndType(_patCur.PatNum, UserWebFKeyType.PatientPortal);
     if (_userWebCur == null)
     {
         _isNew               = true;
         _userWebCur          = new UserWeb();
         _userWebCur.UserName = UserWebs.CreateUserNameFromPat(_patCur, UserWebFKeyType.PatientPortal);
         _userWebCur.FKey     = _patCur.PatNum;
         _userWebCur.FKeyType = UserWebFKeyType.PatientPortal;
         _userWebCur.RequireUserNameChange = true;
         _userWebCur.Password = "";
         UserWebs.Insert(_userWebCur);
     }
     _userWebOld             = _userWebCur.Copy();
     textOnlineUsername.Text = _userWebCur.UserName;
     textOnlinePassword.Text = "";
     if (_userWebCur.Password != "")           //if a password was already filled in
     {
         butGiveAccess.Text = "Remove Online Access";
         //We do not want to show the password hash that is stored in the database so we will fill the online password with asterisks.
         textOnlinePassword.Text     = "********";
         textOnlinePassword.ReadOnly = false;
         textOnlineUsername.ReadOnly = false;
     }
     textPatientPortalURL.Text = PrefC.GetString(PrefName.PatientPortalURL);
 }
Example #2
0
 private void butCancel_Click(object sender, EventArgs e)
 {
     if (_isNew)
     {
         UserWebs.Delete(_userWebCur.UserWebNum);
     }
     DialogResult = DialogResult.Cancel;
 }
Example #3
0
 private void butGiveAccess_Click(object sender, EventArgs e)
 {
     if (butGiveAccess.Text == "Provide Online Access")           //When form open opens with a blank password
     {
         if (PrefC.GetString(PrefName.PatientPortalURL) == "")
         {
             //User probably hasn't set up the patient portal yet.
             MsgBox.Show(this, "Patient Facing URL is required to be set before granting online access.  Click Setup to set the Patient Facing URL.");
             return;
         }
         string error;
         if (!UserWebs.ValidatePatientAccess(_patCur, out error))
         {
             MessageBox.Show(error);
             return;
         }
         Cursor = Cursors.WaitCursor;
         //1. Fill password.
         string passwordGenerated = UserWebs.GenerateRandomPassword(8);
         textOnlinePassword.Text = passwordGenerated;
         //2. Make the username and password editable in case they want to change it.
         textOnlineUsername.ReadOnly = false;
         textOnlinePassword.ReadOnly = false;
         //3. Save password to db.
         // We only save the hash of the generated password.
         string passwordHashed = Userods.HashPassword(passwordGenerated, false);
         _userWebCur.Password = passwordHashed;
         UserWebs.Update(_userWebCur, _userWebOld);
         _userWebOld.Password = passwordHashed;              //Update _userWebOld in case the user changes password manually.
         //4. Insert EhrMeasureEvent
         EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();
         newMeasureEvent.DateTEvent = DateTime.Now;
         newMeasureEvent.EventType  = EhrMeasureEventType.OnlineAccessProvided;
         newMeasureEvent.PatNum     = _userWebCur.FKey;
         newMeasureEvent.MoreInfo   = "";
         EhrMeasureEvents.Insert(newMeasureEvent);
         //5. Rename button
         butGiveAccess.Text = "Remove Online Access";
         Cursor             = Cursors.Default;
     }
     else              //remove access
     {
         Cursor = Cursors.WaitCursor;
         //1. Clear password
         textOnlinePassword.Text = "";
         //2. Make in uneditable
         textOnlinePassword.ReadOnly = true;
         //3. Save password to db
         _userWebCur.Password = textOnlinePassword.Text;
         UserWebs.Update(_userWebCur, _userWebOld);
         _userWebOld.Password = textOnlinePassword.Text;              //Update PatOld in case the user changes password manually.
         //4. Rename button
         butGiveAccess.Text = "Provide Online Access";
         Cursor             = Cursors.Default;
     }
 }
        private void butGenerate_Click(object sender, EventArgs e)
        {
            if (textOnlinePassword.ReadOnly)
            {
                MessageBox.Show("Please use the Provide Online Access button first.");
                return;
            }
            Cursor = Cursors.WaitCursor;
            string passwordGenerated = UserWebs.GenerateRandomPassword(8);

            textOnlinePassword.Text = passwordGenerated;
            // We only save the hash of the generated password.
            _userWebCur.LoginDetails = Authentication.GenerateLoginDetailsSHA512(passwordGenerated);
            UserWebs.Update(_userWebCur, _userWebOld);
            _userWebOld.LoginDetails = _userWebCur.LoginDetails;
            Cursor = Cursors.Default;
        }
Example #5
0
        private void butGenerate_Click(object sender, EventArgs e)
        {
            if (textOnlinePassword.ReadOnly)
            {
                MessageBox.Show("Please use the Provide Online Access button first.");
                return;
            }
            Cursor = Cursors.WaitCursor;
            string passwordGenerated = UserWebs.GenerateRandomPassword(8);

            textOnlinePassword.Text = passwordGenerated;
            // We only save the hash of the generated password.
            string passwordHashed = Userods.HashPassword(passwordGenerated, false);

            _userWebCur.Password = passwordHashed;
            UserWebs.Update(_userWebCur, _userWebOld);
            _userWebOld.Password = passwordHashed;          //Update PatOld in case the user changes password manually.
            Cursor = Cursors.Default;
        }
Example #6
0
        public static UserWeb CreateUserWeb(long fKey, UserWebFKeyType fKeyType, string userName = "", string password = "", bool requireUserNameChange = false,
                                            bool requirePasswordChange = false, string passwordResetCode = "", DateTime dateTimeLastLogin = default(DateTime))
        {
            UserWeb userWeb = new UserWeb()
            {
                IsNew    = true,
                FKey     = fKey,
                FKeyType = fKeyType,
                UserName = userName,
                Password = password,
                RequireUserNameChange = requireUserNameChange,
                RequirePasswordChange = requirePasswordChange,
                PasswordResetCode     = passwordResetCode,
                DateTimeLastLogin     = dateTimeLastLogin,
            };

            UserWebs.Insert(userWeb);
            return(userWeb);
        }
Example #7
0
        private void butOK_Click(object sender, EventArgs e)
        {
            bool shouldUpdateUserWeb = false;
            bool shouldPrint         = false;

            if (textOnlineUsername.ReadOnly == false)
            {
                if (textOnlineUsername.Text == "")
                {
                    MsgBox.Show(this, "Online Username cannot be blank.");
                    return;
                }
                else if (_userWebCur.UserName != textOnlineUsername.Text)
                {
                    if (UserWebs.UserNameExists(textOnlineUsername.Text, UserWebFKeyType.PatientPortal))
                    {
                        MsgBox.Show(this, "The Online Username already exists.");
                        return;
                    }
                    _userWebCur.UserName = textOnlineUsername.Text;
                    shouldUpdateUserWeb  = true;
                    if (!_wasPrinted)
                    {
                        shouldPrint = true;
                    }
                }
            }
            if (textOnlinePassword.Text != "" && textOnlinePassword.Text != "********")
            {
                string error = Patients.IsPortalPasswordValid(textOnlinePassword.Text);
                if (error != "")               //Non-empty string means it was invalid.
                {
                    MessageBox.Show(this, error);
                    return;
                }
                if (!_wasPrinted)
                {
                    shouldPrint = true;
                }
                shouldUpdateUserWeb  = true;
                _userWebCur.Password = Userods.HashPassword(textOnlinePassword.Text, false);
            }
            if (shouldPrint)
            {
                DialogResult result = MessageBox.Show(Lan.g(this, "Online Username or Password changed but was not printed, would you like to print?")
                                                      , Lan.g(this, "Print Patient Info")
                                                      , MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Yes)
                {
                    //Print the showing information.
                    PrintPatientInfo();
                }
                else if (result == DialogResult.No)
                {
                    //User does not want to print.  Do nothing.
                }
                else if (result == DialogResult.Cancel)
                {
                    return;
                }
            }
            if (shouldUpdateUserWeb)
            {
                UserWebs.Update(_userWebCur, _userWebOld);
            }
            DialogResult = DialogResult.OK;
        }