示例#1
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;
     }
 }
示例#2
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.
            _userWebCur.LoginDetails = Authentication.GenerateLoginDetailsSHA512(passwordGenerated);
            UserWebs.Update(_userWebCur, _userWebOld);
            _userWebOld.LoginDetails = _userWebCur.LoginDetails;
            Cursor = Cursors.Default;
        }
示例#3
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;
        }
示例#4
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;
        }