コード例 #1
0
ファイル: FormRxManage.cs プロジェクト: ChemBrain/OpenDental
 private void butNewRx_Click(object sender, EventArgs e)
 {
     //This code is a copy of ContrChart.Tool_Rx_Click().  Any changes to this code need to be changed there too.
     if (!Security.IsAuthorized(Permissions.RxCreate))
     {
         return;
     }
     if (Programs.UsingEcwTightOrFullMode() && Bridges.ECW.UserId != 0)
     {
         VBbridges.Ecw.LoadRxForm((int)Bridges.ECW.UserId, Bridges.ECW.EcwConfigPath, (int)Bridges.ECW.AptNum);
         //refresh the right panel:
         try {
             string strAppServer = VBbridges.Ecw.GetAppServer((int)Bridges.ECW.UserId, Bridges.ECW.EcwConfigPath);
             labelECWerror.Visible = false;
         }
         catch (Exception ex) {
             labelECWerror.Text    = "Error: " + ex.Message;
             labelECWerror.Visible = true;
         }
     }
     else
     {
         FormRxSelect FormRS = new FormRxSelect(_patCur);
         FormRS.ShowDialog();
         if (FormRS.DialogResult != DialogResult.OK)
         {
             return;
         }
         SecurityLogs.MakeLogEntry(Permissions.RxCreate, _patCur.PatNum, "Created prescription.");
     }
     FillGrid();
 }
コード例 #2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            Userod selectedUser = (Userod)listUser.SelectedItem;

            if (!Userods.CheckTypedPassword(textPassword.Text, selectedUser.Password))
            {
                MsgBox.Show(this, "Incorrect password");
                return;
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.Password == "" && textPassword.Text == "")
            {
                MsgBox.Show(this, "When using the web service, not allowed to log in with no password.  A password should be added for this user.");
                return;
            }
            Security.CurUser = selectedUser.Copy();
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                string password = textPassword.Text;
                if (Programs.UsingEcwTightOrFullMode())                 //ecw requires hash, but non-ecw requires actual password
                {
                    password = Userods.EncryptPassword(password, true);
                }
                Security.PasswordTyped = password;
            }
            if (PrefC.GetBool(PrefName.TasksCheckOnStartup))
            {
                int taskcount = Tasks.UserTasksCount(Security.CurUser.UserNum);
                if (taskcount > 0)
                {
                    MessageBox.Show(Lan.g(this, "There are ") + taskcount + Lan.g(this, " unread tasks on your tasklists."));
                }
            }
            Plugins.HookAddCode(this, "FormLogOn.butOK_Click_end");
            DialogResult = DialogResult.OK;
        }
コード例 #3
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (_isPasswordReset)
            {
                if (textPassword.Text != textCurrent.Text || string.IsNullOrWhiteSpace(textPassword.Text))
                {
                    MsgBox.Show(this, "Passwords must match and not be empty.");
                    return;
                }
            }
            else if (!IsInSecurityWindow &&
                     !Authentication.CheckPassword(Security.CurUser, textCurrent.Text))
            {
                MsgBox.Show(this, "Current password incorrect.");
                return;
            }
            string explanation = Userods.IsPasswordStrong(textPassword.Text);

            if (PrefC.GetBool(PrefName.PasswordsMustBeStrong))
            {
                if (explanation != "")
                {
                    MessageBox.Show(explanation);
                    return;
                }
            }
            //If the PasswordsMustBeStrong preference is off, still store whether or not the password is strong in case the preference is turned on later
            PasswordIsStrong = string.IsNullOrEmpty(explanation);
            if (Programs.UsingEcwTightOrFullMode())             //Same check as FormLogOn
            {
                LoginDetails = Authentication.GenerateLoginDetails(textPassword.Text, HashTypes.MD5_ECW);
            }
            else
            {
                LoginDetails = Authentication.GenerateLoginDetailsSHA512(textPassword.Text);
            }
            PasswordTyped = textPassword.Text;           //update the stored typed password for middle tier refresh
            DialogResult  = DialogResult.OK;
        }
コード例 #4
0
ファイル: FormEcwDiag.cs プロジェクト: steev90/opendental
        private string verifyAsSIUMessage(int interfaceID, int messageID, out int errors, bool verbose)
        {
            string retVal = "";

            errors = 0;
            bool          validMessage      = true;
            List <string> segmentsContained = new List <string>();
            DataTable     hl7Segments       = MySqlHelper.ExecuteDataset(connString, "SELECT SegmentData FROM hl7segment_details WHERE InterfaceID=" + interfaceID + " AND Messageid=" + messageID + ";").Tables[0];

            //validate segments based on content
            foreach (DataRow segment in hl7Segments.Rows)
            {
                string[] segmentFields = segment["SegmentData"].ToString().Split('|');
                segmentsContained.Add(segmentFields[0]);                //used later to validate existance of segments.
                switch (segmentFields[0])
                {
                case "MSH":
                    //validation?
                    continue;

                case "SCH":
                    if (segmentFields[2] != "{ENCID}")                           //eCW's documentation is wrong. SCH.01 is not used as appointment num, instead SCH.02 is used for appointment num.
                    {
                        retVal += "SIU HL7 message is not sending visit number in field SCH.01\r\n";
                        errors++;
                        validMessage = false;
                    }
                    if (segmentFields[7] != "{ENCREASON}")
                    {
                        retVal += "SIU HL7 message is not sending visit reason in field SCH.07\r\n";
                        errors++;
                        validMessage = false;
                    }
                    if (segmentFields[8] != "{VISITTYPE}")
                    {
                        retVal += "SIU HL7 message is not sending visit type in field SCH.08\r\n";
                        errors++;
                        validMessage = false;
                    }
                    if (false)                             //segmentFields[9]!="{???}") { //Don't know what this should look like when properly configured. TODO
                    {
                        retVal += "SIU HL7 message is not sending appointment duration in minutes in field SCH.09\r\n";
                        errors++;
                        validMessage = false;
                    }
                    if (false)                             //segmentFields[10]!="{???}") { //Don't know what this should look like when properly configured. TODO
                    {
                        retVal += "SIU HL7 message is not sending appointment duration units in field SCH.10\r\n";
                        errors++;
                        validMessage = false;
                    }
                    string[] SCH11 = segmentFields[11].Split('^');
                    if (false)                             //SCH11[2]!="{???}") { //Don't
                    {
                        retVal += "SIU HL7 message is not sending appointment duration in field SCH.11.02\r\n";
                        errors++;
                        validMessage = false;
                    }
                    if (SCH11[3] != "{ENCSDATETIME}")
                    {
                        retVal += "SIU HL7 message is not sending appointment start time in field SCH.11.03\r\n";
                        errors++;
                        validMessage = false;
                    }
                    if (SCH11[4] != "{ENCEDATETIME}")
                    {
                        retVal += "SIU HL7 message is not sending appointment end time in field SCH.11.04\r\n";
                        errors++;
                        validMessage = false;
                    }
                    //if(segmentFields[25]!="{STATUS}") {//according to documentation, we need this, but actually we never try to reference it.
                    //  retVal+="SIU HL7 message is not sending visit status in field SCH.25\r\n";
                    //  errors++;
                    //  validMessage=false;
                    //}
                    continue;

                case "PID":
                    if (segmentFields[2] != "{PID}")
                    {
                        retVal += "SIU HL7 message is not sending eCW's internal patient number in field PID.02\r\n";
                        errors++;
                        validMessage = false;
                    }
                    if (segmentFields[4] != "{CONTNO}" && !Programs.UsingEcwTightOrFullMode())
                    {
                        retVal += "SIU HL7 message is not sending eCW's account number in field PID.04\r\n";
                        errors++;
                        validMessage = false;
                    }
                    if (segmentFields[5] != "{PLN}^{PFN}^{PMN}")
                    {
                        retVal += "SIU HL7 message is not sending patient's name correctly in field PID.05\r\n";
                        errors++;
                        validMessage = false;
                    }
                    if (segmentFields[7] != "{PDOB}")
                    {
                        retVal += "SIU HL7 message is not sending patient's date of birth in field PID.07\r\n";
                        errors++;
                        validMessage = false;
                    }
                    if (segmentFields[8] != "{PSEX}")
                    {
                        retVal += "SIU HL7 message is not sending patient's gender in field PID.08\r\n";
                        errors++;
                        validMessage = false;
                    }
                    //No checking of optional fields.
                    continue;

                case "PV1":
                    if (segmentFields[7] != "{ODDRID}^{ODLN}^{ODFN}")
                    {
                        retVal += "SIU HL7 message is not sending provider id in field PV1.07\r\n";
                        errors++;
                        validMessage = false;
                    }
                    continue;

                case "AIG":
                    if (segmentFields[3] != "{RSDRID}^{RSLN}^{RSFN}")
                    {
                        retVal += "SIU HL7 message is not sending provider/resource id in field AIG.03\r\n";
                        errors++;
                        validMessage = false;
                    }
                    continue;

                default:
                    continue;
                }
            }
            //Validate existance of segments
            if (!segmentsContained.Contains("SCH"))
            {
                retVal      += "No SCH segment found in SIU HL7 message.\r\n";
                errors      += 7;         //no segment plus 6 sub errors.
                validMessage = false;
            }
            if (!segmentsContained.Contains("PID"))
            {
                retVal += "No PID segment found in SIU HL7 message.\r\n";
                if (!Programs.UsingEcwTightOrFullMode())
                {
                    errors++;             //to account for not sending eCW's account number
                }
                errors      += 5;         //no segment plus 4 sub errors.
                validMessage = false;
            }
            if (!segmentsContained.Contains("AIG") && !segmentsContained.Contains("PV1"))
            {
                retVal      += "No AIG or PV1 segments found in SIU HL7 message. Appointments will use patient's default primary provider.\r\n";         //ecwSIU.cs sets this when in-processing SIU message.
                validMessage = false;
            }
            //If everything above checks out return a success message
            if (validMessage && verbose)
            {
                retVal += "Found properly formed SIU HL7 message definition.\r\n";
            }
            return(retVal);
        }
コード例 #5
0
ファイル: FormPractice.cs プロジェクト: royedwards/DRDNet
 private void FormPractice_Load(object sender, System.EventArgs e)
 {
     checkIsMedicalOnly.Checked = PrefC.GetBool(PrefName.PracticeIsMedicalOnly);
     if (Programs.UsingEcwTightOrFullMode())
     {
         checkIsMedicalOnly.Visible = false;
     }
     textPracticeTitle.Text = PrefC.GetString(PrefName.PracticeTitle);
     textAddress.Text       = PrefC.GetString(PrefName.PracticeAddress);
     textAddress2.Text      = PrefC.GetString(PrefName.PracticeAddress2);
     textCity.Text          = PrefC.GetString(PrefName.PracticeCity);
     textST.Text            = PrefC.GetString(PrefName.PracticeST);
     textZip.Text           = PrefC.GetString(PrefName.PracticeZip);
     textPhone.Text         = TelephoneNumbers.ReFormat(PrefC.GetString(PrefName.PracticePhone));
     textFax.Text           = TelephoneNumbers.ReFormat(PrefC.GetString(PrefName.PracticeFax));
     checkUseBillingAddressOnClaims.Checked = PrefC.GetBool(PrefName.UseBillingAddressOnClaims);
     textBillingAddress.Text  = PrefC.GetString(PrefName.PracticeBillingAddress);
     textBillingAddress2.Text = PrefC.GetString(PrefName.PracticeBillingAddress2);
     textBillingCity.Text     = PrefC.GetString(PrefName.PracticeBillingCity);
     textBillingST.Text       = PrefC.GetString(PrefName.PracticeBillingST);
     textBillingZip.Text      = PrefC.GetString(PrefName.PracticeBillingZip);
     textPayToAddress.Text    = PrefC.GetString(PrefName.PracticePayToAddress);
     textPayToAddress2.Text   = PrefC.GetString(PrefName.PracticePayToAddress2);
     textPayToCity.Text       = PrefC.GetString(PrefName.PracticePayToCity);
     textPayToST.Text         = PrefC.GetString(PrefName.PracticePayToST);
     textPayToZip.Text        = PrefC.GetString(PrefName.PracticePayToZip);
     textBankNumber.Text      = PrefC.GetString(PrefName.PracticeBankNumber);
     if (CultureInfo.CurrentCulture.Name.EndsWith("CH"))             //CH is for switzerland. eg de-CH
     {
         textBankRouting.Text = PrefC.GetString(PrefName.BankRouting);
         textBankAddress.Text = PrefC.GetString(PrefName.BankAddress);
     }
     else
     {
         groupSwiss.Visible = false;
     }
     listProvider.Items.Clear();
     _listProviders = Providers.GetDeepCopy(true);
     for (int i = 0; i < _listProviders.Count; i++)
     {
         listProvider.Items.Add(_listProviders[i].GetLongDesc());
         if (_listProviders[i].ProvNum == PrefC.GetLong(PrefName.PracticeDefaultProv))
         {
             listProvider.SelectedIndex = i;
         }
     }
     listBillType.Items.Clear();
     _listBillingTypeDefs = Defs.GetDefsForCategory(DefCat.BillingTypes, true);
     for (int i = 0; i < _listBillingTypeDefs.Count; i++)
     {
         listBillType.Items.Add(_listBillingTypeDefs[i].ItemName);
         if (_listBillingTypeDefs[i].DefNum == PrefC.GetLong(PrefName.PracticeDefaultBillType))
         {
             listBillType.SelectedIndex = i;
         }
     }
     if (PrefC.GetBool(PrefName.EasyHidePublicHealth))
     {
         labelPlaceService.Visible = false;
         listPlaceService.Visible  = false;
     }
     listPlaceService.Items.Clear();
     for (int i = 0; i < Enum.GetNames(typeof(PlaceOfService)).Length; i++)
     {
         listPlaceService.Items.Add(Lan.g("enumPlaceOfService", Enum.GetNames(typeof(PlaceOfService))[i]));
     }
     listPlaceService.SelectedIndex = PrefC.GetInt(PrefName.DefaultProcedurePlaceService);
     _selectedBillingProvNum        = PrefC.GetLong(PrefName.InsBillingProv);
     _insBillingProvNum             = _selectedBillingProvNum;
     FillComboInsBillingProv();
 }
コード例 #6
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            bool   usingEcw     = Programs.UsingEcwTightOrFullMode();
            Userod selectedUser = null;

            if (PrefC.GetBool(PrefName.UserNameManualEntry))
            {
                for (int i = 0; i < listUser.Items.Count; i++)
                {
                    //Check the user name typed in using ToLower and Trim because Open Dental is case insensitive and does not allow white-space in regards to user names.
                    if (textUser.Text.Trim().ToLower() == listUser.Items[i].ToString().Trim().ToLower())
                    {
                        selectedUser = (Userod)listUser.Items[i];                      //Found the typed username
                        break;
                    }
                }
                if (selectedUser == null)
                {
                    MsgBox.Show(this, "Login failed");
                    return;
                }
            }
            else
            {
                selectedUser = (Userod)listUser.SelectedItem;
            }
            string password = textPassword.Text;

            if (usingEcw)             //ecw requires hash, but non-ecw requires actual password
            {
                password = Userods.HashPassword(password, true);
            }
            if (selectedUser.UserName == "Stay Open" && IsSimpleSwitch && PrefC.IsODHQ)
            {
                // No need to check password when changing task users at HQ to user "Stay Open".
            }
            else
            {
                try {
                    Userods.CheckUserAndPassword(selectedUser.UserName, password, usingEcw);
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.Password == "" && textPassword.Text == "")
            {
                MsgBox.Show(this, "When using the web service, not allowed to log in with no password.  A password should be added for this user.");
                return;
            }
            //successful login.
            if (!IsSimpleSwitch)
            {
                Security.CurUser        = selectedUser.Copy();
                Security.IsUserLoggedIn = true;
                //Jason approved always storing the cleartext password that the user typed in
                //since this is necessary for Reporting Servers over middle tier and was already happening when a user logged in over middle tier.
                Security.PasswordTyped = password;
                if (PrefC.GetBool(PrefName.PasswordsMustBeStrong) && PrefC.GetBool(PrefName.PasswordsWeakChangeToStrong))
                {
                    if (Userods.IsPasswordStrong(textPassword.Text) != "")                   //Password is not strong
                    {
                        MsgBox.Show(this, "You must change your password to a strong password due to the current Security settings.");
                        FormOpenDental FormOD = Application.OpenForms.OfType <FormOpenDental>().ToList()[0]; //There always should be exactly 1.
                        if (!FormOD.ChangePassword(true))                                                    //Failed password update.
                        {
                            return;
                        }
                    }
                }
            }
            else
            {
                CurUserSimpleSwitch = selectedUser.Copy();
            }
            if (!IsSimpleSwitch)
            {
                SecurityLogs.MakeLogEntry(Permissions.UserLogOnOff, 0, "User: "******" has logged on.");
            }
            Plugins.HookAddCode(this, "FormLogOn.butOK_Click_end");
            DialogResult = DialogResult.OK;
        }
コード例 #7
0
 ///<summary>This reduces the number of places where Programs.UsingEcwTight() is called.  This helps with organization.  All calls within this class must pass through here. </summary>
 private static bool UsingEcwTightOrFull()
 {
     return(Programs.UsingEcwTightOrFullMode());
 }
コード例 #8
0
        private void butMerge_Click(object sender, EventArgs e)
        {
            if (_patTo.PatNum == _patFrom.PatNum)
            {
                MsgBox.Show(this, "Cannot merge a patient account into itself. Please select a different patient to merge from.");
                return;
            }
            string msgText = "";

            if (_patFrom.FName.Trim().ToLower() != _patTo.FName.Trim().ToLower() ||
                _patFrom.LName.Trim().ToLower() != _patTo.LName.Trim().ToLower() ||
                _patFrom.Birthdate != _patTo.Birthdate)
            {            //mismatch
                msgText = Lan.g(this, "The two patients do not have the same first name, last name, and birthdate.");
                if (Programs.UsingEcwTightOrFullMode())
                {
                    msgText += "\r\n" + Lan.g(this, "The patients must first be merged from within eCW, then immediately merged in the same order in Open Dental.  "
                                              + "If the patients are not merged in this manner, some information may not properly bridge between eCW and Open Dental.");
                }
                msgText += "\r\n\r\n"
                           + Lan.g(this, "Into patient name") + ": " + Patients.GetNameFLnoPref(_patTo.LName, _patTo.FName, "") + ", "     //using Patients.GetNameFLnoPref to omit MiddleI
                           + Lan.g(this, "Into patient birthdate") + ": " + _patTo.Birthdate.ToShortDateString() + "\r\n"
                           + Lan.g(this, "From patient name") + ": " + Patients.GetNameFLnoPref(_patFrom.LName, _patFrom.FName, "") + ", " //using Patients.GetNameFLnoPref to omit MiddleI
                           + Lan.g(this, "From patient birthdate") + ": " + _patFrom.Birthdate.ToShortDateString() + "\r\n\r\n"
                           + Lan.g(this, "Merge the patient on the bottom into the patient shown on the top?");
                if (MessageBox.Show(msgText, "", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;                    //The user chose not to merge
                }
            }
            else              //name and bd match
            {
                if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Merge the patient at the bottom into the patient shown at the top?"))
                {
                    return;                    //The user chose not to merge.
                }
            }
            if (_patFrom.PatNum == _patFrom.Guarantor)
            {
                Family fam = Patients.GetFamily(_patFrom.PatNum);
                if (fam.ListPats.Length > 1)
                {
                    msgText = Lan.g(this, "The patient you have chosen to merge from is a guarantor.  Merging this patient into another account will cause all "
                                    + "family members of the patient being merged from to be moved into the same family as the patient account being merged into.") + "\r\n"
                              + Lan.g(this, "Do you wish to continue with the merge?");
                    if (MessageBox.Show(msgText, "", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;                        //The user chose not to merge.
                    }
                }
            }
            Cursor = Cursors.WaitCursor;
            if (Patients.MergeTwoPatients(_patTo.PatNum, _patFrom.PatNum))
            {
                //The patient has been successfully merged.
                //Now copy the physical images from the old patient to the new if they are using an AtoZ image share.
                //This has to happen in the UI because the middle tier server might not have access to the image share.
                //If the users are storing images within the database, those images have already been taken care of in the merge method above.
                int fileCopyFailures = 0;
                if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
                {
                    #region Copy AtoZ Documents
                    //Move the patient documents within the 'patFrom' A to Z folder to the 'patTo' A to Z folder.
                    //We have to be careful here of documents with the same name. We have to rename such documents
                    //so that no documents are overwritten/lost.
                    string   atoZpath  = ImageStore.GetPreferredAtoZpath();
                    string   atozFrom  = ImageStore.GetPatientFolder(_patFrom, atoZpath);
                    string   atozTo    = ImageStore.GetPatientFolder(_patTo, atoZpath);
                    string[] fromFiles = Directory.GetFiles(atozFrom);
                    foreach (string fileCur in fromFiles)
                    {
                        string fileName     = Path.GetFileName(fileCur);
                        string destFileName = fileName;
                        string destFilePath = ODFileUtils.CombinePaths(atozTo, fileName);
                        if (File.Exists(destFilePath))
                        {
                            //The file being copied has the same name as a possibly different file within the destination a to z folder.
                            //We need to copy the file under a unique file name and then make sure to update the document table to reflect
                            //the change.
                            destFileName = _patFrom.PatNum.ToString() + "_" + fileName;
                            destFilePath = ODFileUtils.CombinePaths(atozTo, destFileName);
                            while (File.Exists(destFilePath))
                            {
                                destFileName = _patFrom.PatNum.ToString() + "_" + fileName + "_" + DateTime.Now.ToString("yyyyMMddhhmmss");
                                destFilePath = ODFileUtils.CombinePaths(atozTo, destFileName);
                            }
                        }
                        try {
                            File.Copy(fileCur, destFilePath);                            //Will throw exception if file already exists.
                        }
                        catch (Exception ex) {
                            ex.DoNothing();
                            fileCopyFailures++;
                            continue;                            //copy failed, increment counter and move onto the next file
                        }
                        //If the copy did not fail, try to delete the old file.
                        //We can now safely update the document FileName and PatNum to the "to" patient.
                        Documents.MergePatientDocument(_patFrom.PatNum, _patTo.PatNum, fileName, destFileName);
                        try {
                            File.Delete(fileCur);
                        }
                        catch (Exception ex) {
                            ex.DoNothing();
                            //If we were unable to delete the file then it is probably because someone has the document open currently.
                            //Just skip deleting the file. This means that occasionally there will be an extra file in their backup
                            //which is just clutter but at least the merge is guaranteed this way.
                        }
                    }
                    #endregion Copy AtoZ Documents
                }                //end if AtoZFolderUsed
                else if (CloudStorage.IsCloudStorage)
                {
                    string       atozFrom = ImageStore.GetPatientFolder(_patFrom, "");
                    string       atozTo   = ImageStore.GetPatientFolder(_patTo, "");
                    FormProgress FormP    = new FormProgress();
                    FormP.DisplayText          = "Moving Documents...";
                    FormP.NumberFormat         = "F";
                    FormP.NumberMultiplication = 1;
                    FormP.MaxVal = 100;                  //Doesn't matter what this value is as long as it is greater than 0
                    FormP.TickMS = 1000;
                    OpenDentalCloud.Core.TaskStateMove state = CloudStorage.MoveAsync(atozFrom
                                                                                      , atozTo
                                                                                      , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                    if (FormP.ShowDialog() == DialogResult.Cancel)
                    {
                        state.DoCancel   = true;
                        fileCopyFailures = state.CountTotal - state.CountSuccess;
                    }
                    else
                    {
                        fileCopyFailures = state.CountFailed;
                    }
                }
                Cursor = Cursors.Default;
                if (fileCopyFailures > 0)
                {
                    MessageBox.Show(Lan.g(this, "Some files belonging to the from patient were not copied.") + "\r\n"
                                    + Lan.g(this, "Number of files not copied") + ": " + fileCopyFailures);
                }
                textPatientIDFrom.Text    = "";
                textPatientNameFrom.Text  = "";
                textPatFromBirthdate.Text = "";
                CheckUIState();
                //Make log entry here not in parent form because we can merge multiple patients at a time.
                SecurityLogs.MakeLogEntry(Permissions.PatientMerge, _patTo.PatNum,
                                          "Patient: " + _patFrom.GetNameFL() + "\r\nPatNum From: " + _patFrom.PatNum + "\r\nPatNum To: " + _patTo.PatNum);
                MsgBox.Show(this, "Patients merged successfully.");
            }            //end MergeTwoPatients
            Cursor = Cursors.Default;
        }
コード例 #9
0
ファイル: FormLogOn.cs プロジェクト: ChemBrain/OpenDental
        private void butOK_Click(object sender, EventArgs e)
        {
            bool   isEcw    = Programs.UsingEcwTightOrFullMode();
            string userName = "";

            if (PrefC.GetBool(PrefName.UserNameManualEntry))
            {
                //Check the user name using ToLower and Trim because Open Dental is case insensitive and does not allow white-space in regards to user names.
                userName = listUser.Items.Cast <string>().FirstOrDefault(x => x.Trim().ToLower() == textUser.Text.Trim().ToLower());
            }
            else
            {
                userName = listUser.SelectedItem?.ToString();
            }
            if (string.IsNullOrEmpty(userName))
            {
                MsgBox.Show(this, "Login failed");
                return;
            }
            string passwordTyped = textPassword.Text;

            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && string.IsNullOrEmpty(passwordTyped))
            {
                MsgBox.Show(this, "When using the web service, not allowed to log in with no password.  A password should be added for this user.");
                return;
            }
            Userod userCur = null;

            if (isEcw)             //ecw requires hash, but non-ecw requires actual password
            {
                passwordTyped = Authentication.HashPasswordMD5(passwordTyped, true);
            }
            if (userName == "Stay Open" && _isSimpleSwitch && PrefC.IsODHQ)
            {
                // No need to check password when changing task users at HQ to user "Stay Open".
                userCur = Userods.GetUserByNameNoCache(userName);
            }
            else              //Not HQ (most common scenario)
                              //Middle Tier sessions should not fire the CheckUserAndPasswordFailed exception code in FormLogOn.
                              //That event would cause a second login window to pop with strange behavior.
                              //Invoke the overload for CheckUserAndPassword that does not throw exceptions and give the user a generic error message if necessary.
            {
                if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
                {
                    userCur = Userods.CheckUserAndPassword(userName, passwordTyped, isEcw, false);
                    if (userCur == null)
                    {
                        MsgBox.Show("Userods", "Invalid username, password, or the account has been locked due to failed log in attempts.");
                        return;
                    }
                }
                else                  //Directly connected to the database.  This code will give a more accurate error message to the user when failing to log in.
                {
                    try {
                        userCur = Userods.CheckUserAndPassword(userName, passwordTyped, isEcw);
                    }
                    catch (Exception ex) {
                        MessageBox.Show(ex.Message);
                        return;
                    }
                }
            }
            //successful login.
            if (_isSimpleSwitch)
            {
                CurUserSimpleSwitch = userCur;
            }
            else                            //Not a temporary login.
            {
                Security.CurUser = userCur; //Need to set for SecurityL.ChangePassword and calls.
                if (PrefC.GetBool(PrefName.PasswordsMustBeStrong) && PrefC.GetBool(PrefName.PasswordsWeakChangeToStrong))
                {
                    if (Userods.IsPasswordStrong(passwordTyped) != "")                   //Password is not strong
                    {
                        MsgBox.Show(this, "You must change your password to a strong password due to the current Security settings.");
                        if (!SecurityL.ChangePassword(true, _doRefreshSecurityCache))
                        {
                            return;                            //Failed password update.
                        }
                        _refreshSecurityCache = true;          //Indicate to calling method that they should manually refresh the Security cache.
                    }
                }
                Security.IsUserLoggedIn = true;
                //Jason approved always storing the cleartext password that the user typed in
                //since this is necessary for Reporting Servers over middle tier and was already happening when a user logged in over middle tier.
                Security.PasswordTyped = passwordTyped;
                SecurityLogs.MakeLogEntry(Permissions.UserLogOnOff, 0, Lan.g(this, "User:"******" " + Security.CurUser.UserName + " " + Lan.g(this, "has logged on."));
                UserOdPrefs.SetThemeForUserIfNeeded();
            }
            Plugins.HookAddCode(this, "FormLogOn.butOK_Click_end");
            DialogResult = DialogResult.OK;
        }
コード例 #10
0
        private void butMerge_Click(object sender, EventArgs e)
        {
            long patTo   = Convert.ToInt64(this.textPatientIDInto.Text.Trim());
            long patFrom = Convert.ToInt64(this.textPatientIDFrom.Text.Trim());

            if (patTo == patFrom)
            {
                MsgBox.Show(this, "Cannot merge a patient account into itself. Please select a different patient to merge from.");
                return;
            }
            Patient patientFrom = Patients.GetPat(patFrom);
            Patient patientTo   = Patients.GetPat(patTo);

            if (patientFrom.FName.Trim().ToLower() != patientTo.FName.Trim().ToLower() ||
                patientFrom.LName.Trim().ToLower() != patientTo.LName.Trim().ToLower() ||
                patientFrom.Birthdate != patientTo.Birthdate)
            {            //mismatch
                if (Programs.UsingEcwTightOrFullMode())
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.YesNo, @"The two selected patients do not have the same first name, last name, and date of birth.  The patients must first be merged from within eCW, then immediately merged in the same order in Open Dental.  If the patients are not merged in this manner, some information may not properly bridge between eCW and Open Dental.
Into patient name: " + patientTo.FName + " " + patientTo.LName + ", Into patient birthdate: " + patientTo.Birthdate.ToShortDateString() + @".
From patient name: " + patientFrom.FName + " " + patientFrom.LName + ", From paient birthdate: " + patientFrom.Birthdate.ToShortDateString() + @".
Merge the patient at the bottom into the patient shown at the top?"))
                    {
                        return;                        //The user chose not to merge
                    }
                }
                else                  //not eCW
                {
                    MsgBox.Show(this, "The two selected patients do not have the same first name, last name, and date of birth.  You must set all of those the same before merge is allowed.");
                    return;                    //Do not merge.
                }
            }
            else              //name and bd match
            {
                if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Merge the patient at the bottom into the patient shown at the top?"))
                {
                    return;                    //The user chose not to merge.
                }
            }
            this.Cursor = Cursors.WaitCursor;
            if (patientFrom.PatNum == patientFrom.Guarantor)
            {
                Family fam = Patients.GetFamily(patFrom);
                if (fam.ListPats.Length > 1)
                {
                    this.Cursor = Cursors.Default;
                    if (!MsgBox.Show(this, MsgBoxButtons.YesNo,
                                     "The patient you have chosen to merge from is a guarantor. Merging this patient into another account will "
                                     + "cause all familiy members of the patient being merged from to be moved into the same family as the "
                                     + "patient account being merged into. Do you wish to continue with the merge?"))
                    {
                        return;                        //The user chose not to merge.
                    }
                    this.Cursor = Cursors.WaitCursor;
                }
            }
            if (Patients.MergeTwoPatients(patTo, patFrom, ImageStore.GetPreferredAtoZpath()))
            {
                this.textPatientIDFrom.Text    = "";
                this.textPatientNameFrom.Text  = "";
                this.textPatFromBirthdate.Text = "";
                CheckUIState();
                MsgBox.Show(this, "Patients merged successfully.");
            }
            this.Cursor = Cursors.Default;
        }
コード例 #11
0
        private void butLogin_Click(object sender, EventArgs e)
        {
            Userod userEntered;
            string password;

            try {
                bool useEcwAlgorithm = Programs.UsingEcwTightOrFullMode();
                //ecw requires hash, but non-ecw requires actual password
                password = textPassword.Text;
                if (useEcwAlgorithm)
                {
                    //Userods.HashPassword explicitly goes over to middle tier in order to use it's MD5 algorithm.
                    //It doesn't matter what Security.CurUser is when it is null because we are technically trying to set it for the first time.
                    //It cannot be null before invoking HashPassword because middle needs it to NOT be null when creating the credentials for DtoGetString.
                    if (Security.CurUser == null)
                    {
                        Security.CurUser = new Userod();
                    }
                    password = Userods.HashPassword(password, true);
                }
                string username = textUser.Text;
                                #if DEBUG
                if (username == "")
                {
                    username = "******";
                    password = "******";
                }
                                #endif
                userEntered = Userods.CheckUserAndPassword(username, password, useEcwAlgorithm);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            //successful login.
            Security.CurUser              = userEntered;
            Security.PasswordTyped        = password;
            Security.IsUserLoggedIn       = true;
            RemotingClient.HasLoginFailed = false;
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb &&
                string.IsNullOrEmpty(userEntered.Password) &&
                string.IsNullOrEmpty(textPassword.Text))
            {
                MsgBox.Show(this, "When using the web service, not allowed to log in with no password.  A password should be added for this user.");
                FormOpenDental FormOD = Application.OpenForms.OfType <FormOpenDental>().ToList()[0]; //There always should be exactly 1.
                if (!FormOD.ChangePassword(true))                                                    //Failed password update.
                {
                    return;
                }
            }
            if (PrefC.GetBool(PrefName.PasswordsMustBeStrong) &&
                PrefC.GetBool(PrefName.PasswordsWeakChangeToStrong) &&
                Userods.IsPasswordStrong(textPassword.Text) != "")                  //Password is not strong
            {
                MsgBox.Show(this, "You must change your password to a strong password due to the current Security settings.");
                FormOpenDental FormOD = Application.OpenForms.OfType <FormOpenDental>().ToList()[0]; //There always should be exactly 1.
                if (!FormOD.ChangePassword(true))                                                    //Failed password update.
                {
                    return;
                }
            }
            SecurityLogs.MakeLogEntry(Permissions.UserLogOnOff, 0, "User: "******" has logged on.");
            DialogResult = DialogResult.OK;
        }
コード例 #12
0
        private void butMerge_Click(object sender, EventArgs e)
        {
            if (_patTo.PatNum == _patFrom.PatNum)
            {
                MsgBox.Show(this, "Cannot merge a patient account into itself. Please select a different patient to merge from.");
                return;
            }
            string msgText = "";

            if (_patFrom.FName.Trim().ToLower() != _patTo.FName.Trim().ToLower() ||
                _patFrom.LName.Trim().ToLower() != _patTo.LName.Trim().ToLower() ||
                _patFrom.Birthdate != _patTo.Birthdate)
            {            //mismatch
                msgText = Lan.g(this, "The two patients do not have the same first name, last name, and birthdate.");
                if (Programs.UsingEcwTightOrFullMode())
                {
                    msgText += "\r\n" + Lan.g(this, "The patients must first be merged from within eCW, then immediately merged in the same order in Open Dental.  "
                                              + "If the patients are not merged in this manner, some information may not properly bridge between eCW and Open Dental.");
                }
                msgText += "\r\n\r\n"
                           + Lan.g(this, "Into patient name") + ": " + Patients.GetNameFLnoPref(_patTo.LName, _patTo.FName, "") + ", "     //using Patients.GetNameFLnoPref to omit MiddleI
                           + Lan.g(this, "Into patient birthdate") + ": " + _patTo.Birthdate.ToShortDateString() + "\r\n"
                           + Lan.g(this, "From patient name") + ": " + Patients.GetNameFLnoPref(_patFrom.LName, _patFrom.FName, "") + ", " //using Patients.GetNameFLnoPref to omit MiddleI
                           + Lan.g(this, "From patient birthdate") + ": " + _patFrom.Birthdate.ToShortDateString() + "\r\n\r\n"
                           + Lan.g(this, "Merge the patient on the bottom into the patient shown on the top?");
                if (MessageBox.Show(msgText, "", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;                    //The user chose not to merge
                }
            }
            else              //name and bd match
            {
                if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Merge the patient at the bottom into the patient shown at the top?"))
                {
                    return;                    //The user chose not to merge.
                }
            }
            if (_patFrom.PatNum == _patFrom.Guarantor)
            {
                Family fam = Patients.GetFamily(_patFrom.PatNum);
                if (fam.ListPats.Length > 1)
                {
                    msgText = Lan.g(this, "The patient you have chosen to merge from is a guarantor.  Merging this patient into another account will cause all "
                                    + "family members of the patient being merged from to be moved into the same family as the patient account being merged into.") + "\r\n"
                              + Lan.g(this, "Do you wish to continue with the merge?");
                    if (MessageBox.Show(msgText, "", MessageBoxButtons.YesNo) != DialogResult.Yes)
                    {
                        return;                        //The user chose not to merge.
                    }
                }
            }
            Cursor = Cursors.WaitCursor;
            List <Task> listPatientTasks  = Tasks.RefreshPatientTickets(_patFrom.PatNum);        //Get this before the merge, because the merge updates Task.KeyNum.
            bool        isSuccessfulMerge = false;

            try {
                isSuccessfulMerge = Patients.MergeTwoPatients(_patTo.PatNum, _patFrom.PatNum);
            }
            catch (Exception ex) {
                SecurityLogs.MakeLogEntry(Permissions.PatientMerge, _patTo.PatNum,
                                          "Error occurred while merging Patient: " + _patFrom.GetNameFL() + "\r\nPatNum From: " + _patFrom.PatNum + "\r\nPatNum To: " + _patTo.PatNum);
                Cursor = Cursors.Default;
                FriendlyException.Show(Lan.g(this, "Unable to fully merge patients.  Contact support."), ex);
            }
            if (isSuccessfulMerge)
            {
                //The patient has been successfully merged.
                #region Refresh Patient's Tasks
                List <Signalod> listSignals = new List <Signalod>();
                foreach (Task task in listPatientTasks)
                {
                    Signalod signal = new Signalod();
                    signal.IType       = InvalidType.Task;
                    signal.FKeyType    = KeyType.Task;
                    signal.FKey        = task.TaskNum;
                    signal.DateViewing = DateTime.MinValue;                  //Mimics Signalods.SetInvalid()
                    listSignals.Add(signal);
                }
                Signalods.SetInvalid(InvalidType.TaskPatient, KeyType.Undefined, _patTo.PatNum); //Ensure anyone viewing Patient tab of new pat gets refreshed.
                Signalods.Insert(listSignals.ToArray());                                         //Refreshes existing tasks in all other tabs.
                //Causes Task area and open Task Edit windows to refresh immediately.  No popups, alright to pass empty lists for listRefreshedTaskNotes and
                //listBlockedTaskLists.
                FormOpenDental.S_HandleRefreshedTasks(listSignals, listPatientTasks.Select(x => x.TaskNum).ToList(), listPatientTasks, new List <TaskNote>()
                                                      , new List <UserOdPref>());
                #endregion
                //Now copy the physical images from the old patient to the new if they are using an AtoZ image share.
                //This has to happen in the UI because the middle tier server might not have access to the image share.
                //If the users are storing images within the database, those images have already been taken care of in the merge method above.
                int fileCopyFailures = 0;
                if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
                {
                    #region Copy AtoZ Documents
                    //Move the patient documents within the 'patFrom' A to Z folder to the 'patTo' A to Z folder.
                    //We have to be careful here of documents with the same name. We have to rename such documents
                    //so that no documents are overwritten/lost.
                    string   atoZpath  = ImageStore.GetPreferredAtoZpath();
                    string   atozFrom  = ImageStore.GetPatientFolder(_patFrom, atoZpath);
                    string   atozTo    = ImageStore.GetPatientFolder(_patTo, atoZpath);
                    string[] fromFiles = Directory.GetFiles(atozFrom);
                    if (atozFrom == atozTo)
                    {
                        //Very rarely, two patients have the same image folder.  PatFrom and PatTo both have Documents that point to the same file.  Since we
                        //are about to copy the image file for PatFrom to PatTo's directory and delete the file from PatFrom's directory, we would break the
                        //file reference for PatTo's Document.  In this case, skip deleting the original file, since PatTo's Document still references it.
                        Documents.MergePatientDocuments(_patFrom.PatNum, _patTo.PatNum);
                    }
                    else
                    {
                        foreach (string fileCur in fromFiles)
                        {
                            string fileName     = Path.GetFileName(fileCur);
                            string destFileName = fileName;
                            string destFilePath = ODFileUtils.CombinePaths(atozTo, fileName);
                            if (File.Exists(destFilePath))
                            {
                                //The file being copied has the same name as a possibly different file within the destination a to z folder.
                                //We need to copy the file under a unique file name and then make sure to update the document table to reflect
                                //the change.
                                destFileName = _patFrom.PatNum.ToString() + "_" + fileName;
                                destFilePath = ODFileUtils.CombinePaths(atozTo, destFileName);
                                while (File.Exists(destFilePath))
                                {
                                    destFileName = _patFrom.PatNum.ToString() + "_" + fileName + "_" + DateTime.Now.ToString("yyyyMMddhhmmss");
                                    destFilePath = ODFileUtils.CombinePaths(atozTo, destFileName);
                                }
                            }
                            try {
                                File.Copy(fileCur, destFilePath);                                //Will throw exception if file already exists.
                            }
                            catch (Exception ex) {
                                ex.DoNothing();
                                fileCopyFailures++;
                                continue;                                //copy failed, increment counter and move onto the next file
                            }
                            //If the copy did not fail, try to delete the old file.
                            //We can now safely update the document FileName and PatNum to the "to" patient.
                            Documents.MergePatientDocument(_patFrom.PatNum, _patTo.PatNum, fileName, destFileName);
                            try {
                                File.Delete(fileCur);
                            }
                            catch (Exception ex) {
                                ex.DoNothing();
                                //If we were unable to delete the file then it is probably because someone has the document open currently.
                                //Just skip deleting the file. This means that occasionally there will be an extra file in their backup
                                //which is just clutter but at least the merge is guaranteed this way.
                            }
                        }
                    }
                    #endregion Copy AtoZ Documents
                }                //end if AtoZFolderUsed
                else if (CloudStorage.IsCloudStorage)
                {
                    string atozFrom = ImageStore.GetPatientFolder(_patFrom, "");
                    string atozTo   = ImageStore.GetPatientFolder(_patTo, "");
                    if (atozFrom == atozTo)
                    {
                        //Very rarely, two patients have the same image folder.  PatFrom and PatTo both have Documents that point to the same file.  Since we
                        //are about to copy the image file for PatFrom to PatTo's directory and delete the file from PatFrom's directory, we would break the
                        //file reference for PatTo's Document.  In this case, skip deleting the original file, since PatTo's Document still references it.
                        Documents.MergePatientDocuments(_patFrom.PatNum, _patTo.PatNum);
                    }
                    else
                    {
                        FormProgress FormP = new FormProgress();
                        FormP.DisplayText          = "Moving Documents...";
                        FormP.NumberFormat         = "F";
                        FormP.NumberMultiplication = 1;
                        FormP.MaxVal = 100;                      //Doesn't matter what this value is as long as it is greater than 0
                        FormP.TickMS = 1000;
                        OpenDentalCloud.Core.TaskStateMove state = CloudStorage.MoveAsync(atozFrom
                                                                                          , atozTo
                                                                                          , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                        if (FormP.ShowDialog() == DialogResult.Cancel)
                        {
                            state.DoCancel   = true;
                            fileCopyFailures = state.CountTotal - state.CountSuccess;
                        }
                        else
                        {
                            fileCopyFailures = state.CountFailed;
                        }
                    }
                }
                Cursor = Cursors.Default;
                if (fileCopyFailures > 0)
                {
                    MessageBox.Show(Lan.g(this, "Some files belonging to the from patient were not copied.") + "\r\n"
                                    + Lan.g(this, "Number of files not copied") + ": " + fileCopyFailures);
                }
                //Make log entry here not in parent form because we can merge multiple patients at a time.
                SecurityLogs.MakeLogEntry(Permissions.PatientMerge, _patTo.PatNum,
                                          "Patient: " + _patFrom.GetNameFL() + "\r\nPatNum From: " + _patFrom.PatNum + "\r\nPatNum To: " + _patTo.PatNum);
                textPatientIDFrom.Text    = "";
                textPatientNameFrom.Text  = "";
                textPatFromBirthdate.Text = "";
                //This will cause CheckUIState() to disabled the merge button until the user selects a new _patFrom.
                _patFrom = null;
                CheckUIState();
                MsgBox.Show(this, "Patients merged successfully.");
            }            //end MergeTwoPatients
            Cursor = Cursors.Default;
        }