internal List <claim> GetMatchingClaims() { List <claim> toReturn = new List <claim>(); try { DataTable dt = Search("SELECT c.* FROM batch_claim_list b " + "INNER JOIN claims c on b.claim_id = c.id WHERE b.batch_id = " + id + " AND b.still_in_batch = true ORDER BY c.open desc, c.patient_last_name, c.patient_first_name"); foreach (DataRow aClaim in dt.Rows) { claim newClaim = new claim(); newClaim.Load(aClaim); toReturn.Add(newClaim); } } catch (Exception err) { LoggingHelper.Log("Error in Retrieving matching claims", LogSeverity.Error, err, false); MessageBox.Show("There was an error retrieving the matching claims.\n\n" + err.Message); } return(toReturn); }
private company_contact_info FindContactInfo(string addressField, int companyId, string phoneNum) { try { company_contact_info toReturn = new company_contact_info(); string trimmedAddress = CommonFunctions.TrimSpaces(addressField); toReturn.address = trimmedAddress; toReturn.phone = phoneNum; DataTable results = toReturn.Search("SELECT * FROM company_contact_info WHERE company_id = " + companyId + " AND address = '" + trimmedAddress + "' AND phone = '" + phoneNum + "'"); if (results.Rows.Count > 0) { toReturn.Load(results.Rows[0]); } toReturn.address = trimmedAddress; return(toReturn); } catch (Exception err) { // Somewhat dangerous, but it ensures that the import won't crash LoggingHelper.Log("Error in frmImportData.FindContactInfo", LogSeverity.Critical, err, true); return(null); } }
private company FindCompany(string CompanyName) { try { company toReturn = new company(); string trimmedCompanyName = CommonFunctions.TrimSpaces(CompanyName); toReturn.name = trimmedCompanyName; toReturn.SearchType = DataObject.SearchTypes.Exact; DataTable results = toReturn.Search("SELECT * FROM companies WHERE name = '" + trimmedCompanyName + "'"); if (results.Rows.Count > 0) { toReturn.Load(results.Rows[0]); } toReturn.created_on = DateTime.Now; toReturn.name = trimmedCompanyName; toReturn.Save(); return(toReturn); } catch (Exception err) { // Somewhat dangerous, but it ensures that the import won't crash LoggingHelper.Log("Error in frmImportData.FindCompany", LogSeverity.Critical, err, true); return(null); } }
private void CreateStatusHistory(bool as_is_flag) { try { claim_status currentStatus; if (cmbStatus.SelectedIndex >= 0) { currentStatus = (claim_status)cmbStatus.SelectedItem; } else { currentStatus = null; } if (chkSetRevisitDate.Checked) { _formClaim.CreateStatusHistory(currentStatus, ctlRevisitDate.DateValue, as_is_flag); } else { _formClaim.CreateStatusHistory(currentStatus, _formClaim.revisit_date, as_is_flag); } } catch (Exception err) { LoggingHelper.Log("Error in frmClaimStatus.CreateStatusHistory\n" + err.Message, LogSeverity.Error); MessageBox.Show(this, "An error occurred creating the status history for this change. Your save should continue as " + "normal, but please notify a system administrator of this error:\n\n" + err.Message, "Error saving note", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void UpdateStatusHistory(claim aClaim) { return; // Unknown error occurring here on import (property value empty or invalid - int i id) // TODO: Figure this out! try { claim_status_history csh = new claim_status_history(); csh.claim_id = aClaim.id; csh.order_id = csh.GetNextOrderID(); csh.user_id = C_DentalClaimTracker.Properties.Settings.Default.SystemUserID; csh.date_of_change = DateTime.Now; csh.old_status_id = aClaim.status_id; csh.new_status_id = C_DentalClaimTracker.Properties.Settings.Default.PaymentStatusID; csh.old_revisit_date = aClaim.revisit_date; csh.new_revisit_date = csh.old_revisit_date; csh.as_is_flag = false; csh.Save(); } catch (Exception err) { LoggingHelper.Log("Error in update status history\n" + err.Message, LogSeverity.Critical); throw new Exception("An error occurred creating the status history for this change. Your save should continue as " + "normal, but please notify a system administrator of this error:\n\n" + err.Message); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ApplicationExit += new EventHandler(Application_ApplicationExit); // Set things up. // Globals.Settings = (EClaimsSettings)Utilities.DeserializeFromFile(typeof(EClaimsSettings), SettingsManager.Instance.Settings["EClaims"].ConfigurationFile); // log4net.Config.DOMConfigurator.ConfigureAndWatch(new System.IO.FileInfo(SettingsManager.Instance.Settings["EClaims"].LogConfigurationFile)); // Run the application. try { Application.Run(frmStartScreenWPFContainer.Instance()); } catch (Exception ex) { LoggingHelper.Log("Unhandled exception occurred somewhere in the application.", LogSeverity.Error, ex, false); MessageBox.Show("There was an unhandled problem in the application. Please report the following error to an administrator. You may need to restart Claim Tracker\n\n" + ex.Message, "Unexpected error", MessageBoxButtons.OK, MessageBoxIcon.Error); try { if (ActiveUser.UserObject != null) { ActiveUser.LogAction(ActiveUser.ActionTypes.Logout); ActiveUser.UserObject.Logout(); ActiveUser.UserObject = null; } } catch { } } }
internal static bool FromYesNo(string p) { bool toReturn = false; try { toReturn = Convert.ToBoolean(p); } catch (Exception err) { if ((p.ToUpper() == "YES") || (p.ToUpper() == "Y")) { toReturn = true; } else if ((p.ToUpper() == "NO") || (p.ToUpper() == "N")) { toReturn = false; } else { LoggingHelper.Log("Error converting yes/no to boolean in CommonFunctions.FromYesNo", LogSeverity.Error, err, false); throw new Exception("Error converting Yes/No value to boolean.", err); } } return(toReturn); }
private void ctlStatusHandler_AllChoicesMade(object sender, EventArgs e) { ShowNewCallControls(false, false); mainQuestionViewer.AddCategory(ctlStatusHandler.Category); if (ctlStatusHandler.Category.default_revisit_date > 0) { ctlRevisitDate.CurrentDate = DateTime.Now.AddDays(ctlStatusHandler.Category.default_revisit_date); } if (ctlStatusHandler.Category.linked_status > 0) { try { cmbStatus.SelectedIndex = new claim_status(ctlStatusHandler.Category.linked_status).orderid; } catch (Exception err) { LoggingHelper.Log("Error in ctlMultiCallClaimDisplay", LogSeverity.Error, err, false); #if DEBUG MessageBox.Show("DEBUG: Error displaying status.\n" + err.Message); #endif } } }
internal void SetApexResendStatus() { if (system_options.ApexResendStatus > 0) { try { SetStatusAndRevisitDate(new claim_status(system_options.ApexResendStatus), null); } catch (Exception e) { LoggingHelper.Log("Error in SetApexStatus\n" + e.Message, LogSeverity.Critical, e, false); } } }
public void Remove(int index) { if (index > Count - 1 || index < 0) { LoggingHelper.Log("Programmer Error in ConnectionHolderCollection.Remove - Index not valid.", LogSeverity.Error); throw new Exception("Index not valid!"); } else { List.RemoveAt(index); } }
internal static void SetLastImportDate(DateTime lastDate) { try { user u = new user(); u.ExecuteNonQuery("UPDATE system_options SET last_import_date = '" + CommonFunctions.ToMySQLDateTime(lastDate) + "'"); } catch (Exception err) { LoggingHelper.Log("Error in system_options.SetLastImportDate", LogSeverity.Error, err, true); } }
private void LoadCurrentQuestion() { txtQuestionText.Text = _currentQuestion.popup_question_text; txtTreeText.Text = _currentQuestion.text; radFork.Checked = _currentQuestion.is_fork; radCallClassification.Checked = _currentQuestion.is_classification; if ((!radFork.Checked) && (!radCallClassification.Checked)) { radStandard.Checked = true; } cmbQuestionType.SelectedIndex = (int)_currentQuestion.type - 1; InitialRequiredAnswer(_currentQuestion); try { nmbDefaultRevisitDate.Value = Convert.ToInt32(_currentQuestion.default_revisit_date); if (_currentQuestion.linked_status > 0) { try { cmbStatusDropdown.SelectedIndex = new claim_status(_currentQuestion.linked_status).orderid + 1; } catch { LoggingHelper.Log("An invalid status was assigned to a question in frmEditQuestionTree.LoadCurrentQuestion().", LogSeverity.Error); } } else { cmbStatusDropdown.SelectedIndex = 0; } if ((int)_currentQuestion.set_revisit_date >= 0) { cmbRevisitDateOptions.SelectedIndex = (int)_currentQuestion.set_revisit_date; } else { cmbRevisitDateOptions.SelectedIndex = cmbRevisitDateOptions.Items.Count - 1; } } catch (Exception err) { LoggingHelper.Log("Error loading classification data in frmEditQuestionTree.LoadCurrentQuestion.", LogSeverity.Error, err, false); MessageBox.Show(this, "An error occurred loading classification specific data."); } QuestionChanged(false); }
private void InitializeQuickNote(int index, Button btnToUse) { try { btnToUse.Text = system_options.GetQuickNote(index, false); btnToUse.Tag = system_options.GetQuickNote(index, true); ttipMain.SetToolTip(btnToUse, btnToUse.Tag.ToString()); btnToUse.Visible = btnToUse.Tag.ToString() != ""; } catch (Exception e) { LoggingHelper.Log(e, false); // Not expecting any errors here } }
private static bool SetEnvironmentVariableEx(string environmentVariable, string variableValue) { try { // Get the write permission to set the environment variable. EnvironmentPermission environmentPermission = new EnvironmentPermission(EnvironmentPermissionAccess.Write, environmentVariable); environmentPermission.Demand(); return(SetEnvironmentVariable(environmentVariable, variableValue)); } catch (SecurityException e) { LoggingHelper.Log("Error SettingEnvironmentVariable in EnvironmentVars.SetEnvironmentVariables", LogSeverity.Error, e, false); Console.WriteLine("Exception:" + e.Message); } return(false); }
private void InitializeRequiredAnswerDropDown(question toInitialize) { cmbRequiredAnswer.Items.Add("No answer required"); if (toInitialize.ParentQuestion.type == question.QuestionTypes.MultipleChoice) { foreach (multiple_choice_answer mca in toInitialize.GetMultipleChoiceAnswers()) { cmbRequiredAnswer.Items.Add(mca); } cmbRequiredAnswer.SelectedIndex = cmbRequiredAnswer.FindStringExact(toInitialize.required_answer); } else if (toInitialize.ParentQuestion.type == question.QuestionTypes.YesNo) { cmbRequiredAnswer.Items.Add("Yes"); cmbRequiredAnswer.Items.Add("No"); try { // Temporary structure to deal with the fact that sometime required answer is saved as "true" and other times as "yes" cmbRequiredAnswer.SelectedIndex = cmbRequiredAnswer.FindStringExact( CommonFunctions.ToYesNo(System.Convert.ToBoolean(toInitialize.required_answer))); } catch { cmbRequiredAnswer.SelectedIndex = cmbRequiredAnswer.FindStringExact(toInitialize.required_answer); if (cmbRequiredAnswer.SelectedIndex < 0) { cmbRequiredAnswer.SelectedIndex = 0; } } } else { LoggingHelper.Log("Uninitialized question type on a parent that is marked as a fork.", LogSeverity.Critical, new Exception("Uninitialized question type on a parent that is marked as a fork."), true); } if (cmbRequiredAnswer.SelectedIndex == -1) { cmbRequiredAnswer.SelectedIndex = 0; } }
public static bool ClaimExists(claim toCheck) { bool exists; // Attempt to create a connection object to look at the production db try { SqlConnection dbConnection = new SqlConnection(new data_mapping_schema(3).GetConnectionString(false)); dbConnection.Open(); System.Data.SqlClient.SqlTransaction trans; string _errorClaims = string.Empty; try { trans = dbConnection.BeginTransaction(); } catch { throw new Exception("Could not connect to Dentrix to print claim."); } NHDG.NHDGCommon.Claims.Claim aClaim; try { aClaim = new NHDG.NHDGCommon.Claims.Claim(toCheck, trans, false, true); exists = true; } catch (Exception err) { // Could not find claim exists = false; LoggingHelper.Log(string.Format("Claim with id {0} and db {1} does not exist in Dentrix.", toCheck.claimidnum, toCheck.claimdb), LogSeverity.Information, err); } dbConnection.Close(); } catch { throw new Exception("Could not open connection to Dentrix database."); } return(exists); }
private void cmdSave_Click(object sender, EventArgs e) { if (txtName.Text == "") { MessageBox.Show(this, "Please give the rule a unique name."); } else if (txtRuleText.Text == "") { MessageBox.Show(this, "Please specify the text you'd like to use in this rule."); } else { try { _formARR.DeleteAllLinkedData(); _formARR.name = txtName.Text; _formARR.apply_predeterm = chkPredeterm.Checked; _formARR.apply_primary = chkPrimary.Checked; _formARR.apply_secondary = chkSecondary.Checked; _formARR.rule_text = txtRuleText.Text; if (_formARR.priority == 10000) // If this doesn't have a set priority yet { _formARR.priority = _formARR.GetLastPriority(); } _formARR.Save(); _formARR.AddProcedureCodes(lstProcFilterList.Items); _formARR.AddInsuranceCompanyFilter(lstInsuranceFilters.Items); Close(); } catch (Exception err) { LoggingHelper.Log("Could not save rule in frmApexRulesEdit.Save", LogSeverity.Error, err, false); MessageBox.Show(this, "An unexpected error occurred saving this rule. Your rule did not save properly. Please report the " + "following message to an administrator.\n\n" + err.Message); } } }
public static void OpenDirectory(string dirName) { if (Directory.Exists(dirName)) { try { System.Diagnostics.Process.Start(dirName); } catch (Exception err) { LoggingHelper.Log("Error opening folder in CommonFunctions.OpenDirectory", LogSeverity.Error, err, false); #if DEBUG MessageBox.Show("The program encountered an error trying to open the file. Possible problems " + "include an unrecognized file type.\n\n" + err.Message); #endif } } else { throw new FileNotFoundException(); } }
public void AddConnection(ConnectionAlias alias, bool persistent) { OdbcConnection newConnection; for (int i = 0; i < ConnectionPool.Count; i++) { if (alias.CompareToConnection(ConnectionPool[i].Connection)) { // This connection already exists if (ConnectionPool[i].Status == ConnectionHolderStatus.Active) { // This connection is currently in use by another object // So create an identical connection instead } } } newConnection = new OdbcConnection(alias.GetConnectionString()); try { newConnection.Open(); if (!persistent) { newConnection.Close(); } } catch (Exception err) { LoggingHelper.Log("Error in ConnectionHandler.AddConnection", LogSeverity.Error, err, false); throw new Exception("The connection test for the newly added connection failed.", err); } // Connection test succeeded ConnectionHolder newConnHold = new ConnectionHolder(newConnection, null); newConnHold.PersistentConnection = persistent; ConnectionPool.Add(newConnHold); }
internal void SetApexStatus() { if (system_options.ApexSendStatus > 0 || system_options.ApexRevisitDateEnabled) { try { claim_status cs = null; DateTime? newRevisit = null; if (system_options.ApexSendStatus > 0) { cs = new claim_status(system_options.ApexSendStatus); } if (system_options.ApexRevisitDateEnabled) { newRevisit = DateTime.Today.AddDays(system_options.ApexRevisitDate); } SetStatusAndRevisitDate(cs, newRevisit); } catch (Exception e) { LoggingHelper.Log("Error in SetApexStatus\n" + e.Message, LogSeverity.Critical, e, false); } } }
public ConnectionHolder AddConnection(ConnectionAlias alias) { OdbcConnection newConnection; /* * for (int i = 0;i < ConnectionPool.Count;i++) * { * if (alias.CompareToConnection(ConnectionPool[i].Connection)) * { * // This connection already exists * if (ConnectionPool[i].Status == ConnectionHolderStatus.Active) * { * // This connection is currently in use by another object * // So create an identical connection instead * } * } * } */ newConnection = new OdbcConnection(alias.GetConnectionString()); try { newConnection.Open(); } catch (Exception err) { LoggingHelper.Log("Error in ConnectionHandler.AddConnection", LogSeverity.Error, err, false); throw new Exception("The connection test for the newly added connection failed.", err); } // Connection test succeeded ConnectionHolder newConnHold = new ConnectionHolder(newConnection, null); ConnectionPool.Add(newConnHold); return(newConnHold); }
internal void AddClaim(string id1, string id2) { try { DataTable dtClaims = Search(string.Format("SELECT * FROM claims WHERE claimidnum = '{0}' AND claimdb = '{2}'", id1, id2)); if (dtClaims.Rows.Count > 0) { claim c = new claim(); c.Load(dtClaims.Rows[0]); batch_claim_list bcl = new batch_claim_list(); DataTable dt = Search("SELECT * FROM batch_claim_list bcl WHERE bcl.claim_id = " + c.id + " AND bcl.batch_id = " + id); if (dt.Rows.Count > 0) { // Claim is already in batch bcl.Load(dt.Rows[0]); } else { // Adding claim to batch normally bcl.batch_id = id; bcl.claim_id = c.id; } bcl.still_in_batch = true; bcl["last_send_date"] = batch_date; bcl.Save(); } } catch (Exception err) { LoggingHelper.Log(err, false); } }
private void cmdLogin_Click(object sender, EventArgs e) { try { if (system_options.ImportFlag) { if (MessageBox.Show(this, "The system is currently locked by an administrator. It is recommended that you " + "wait until this update is complete before logging in to the system.\n\nWould you like to wait until " + "this update is complete?", "Update in progress", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { return; } } user currentUser = ValidateLogin(); if (currentUser != null) { ActiveUser.UserObject = currentUser; if (chkOpenExclusive.Checked) { if (currentUser.is_admin) { if (ActiveUser.UserObject.LoggedInUsers.Count > 0) { string userList = string.Empty; foreach (user aUser in ActiveUser.UserObject.LoggedInUsers) { if (aUser.id != ActiveUser.UserObject.id) { userList += aUser.username + "\n"; } } if (MessageBox.Show(this, "The following users are currently logged in to the system.\n\n" + userList + "\nIf you continue, they might " + "have problems with any claims they currently have open. Would you like to continue anyway?", "Continue with import?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } } system_options.SetImportFlag(true); } else { MessageBox.Show(this, "You cannot open the program exclusively if you are not an administrator."); } } DialogResult = DialogResult.OK; ActiveUser.UserObject.Login(); if (chkOpenExclusive.Checked) { ActiveUser.LogAction(ActiveUser.ActionTypes.Login, "Exclusive"); } else { ActiveUser.LogAction(ActiveUser.ActionTypes.Login); } C_DentalClaimTracker.Properties.Settings.Default.LastUserName = ActiveUser.UserObject.username; C_DentalClaimTracker.Properties.Settings.Default.Save(); Close(); mdiMain.Instance().HideAdminMenu(); } else { LoggingHelper.Log("An invalid login was detected. User name: " + txtUserName.Text, LogSeverity.Information); MessageBox.Show(this, "Incorrect login.", "Incorrect login"); } } catch (Exception err) { LoggingHelper.Log(err); string errorInfo = err.Message; Exception inner = err.InnerException; while (inner != null) { errorInfo += "\n\n" + inner.Message; inner = inner.InnerException; } if (MessageBox.Show(this, "There was an error connecting to the server to validate login information. Would you like to edit " + "the current server settings?\n\nError:" + errorInfo, "No database connection", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { frmSettings toShow = new frmSettings(true); toShow.ShowDialog(this); } } }
/// <summary> /// Prints a set of claims using a given database connection /// </summary> /// <param name="toPrint"></param> /// <param name="dbConnection"></param> public static void PrintClaims(List <claim> toPrint, SqlConnection dbConnection) { NHDG.NHDGCommon.Claims.ClaimBatch cb = new NHDG.NHDGCommon.Claims.ClaimBatch(); System.Data.SqlClient.SqlTransaction trans; string _errorClaims = string.Empty; try { trans = dbConnection.BeginTransaction(); } catch { MessageBox.Show("Could not connect to Dentrix to print claim."); return; } try { string _xmlPath = GetFileName(".xml", Application.StartupPath + "\\Processed XML\\Temp\\"); string _pdfPath = GetFileName(".pdf", Application.StartupPath + "\\Claims\\"); foreach (claim c in toPrint) { NHDG.NHDGCommon.Claims.Claim aClaim; try { if (C_DentalClaimTracker.Properties.Settings.Default.ShowPaymentLineOnSecondary) { aClaim = new NHDG.NHDGCommon.Claims.Claim(c, trans, false, true); } else { aClaim = new NHDG.NHDGCommon.Claims.Claim(c, trans, true, true); } CheckForEligibilityRestrictions(c, aClaim); // Special code for teeth aClaim.PutToothStringInTooth(); aClaim.CleanAddresses(); cb.Claims.Add(aClaim); } catch (Exception err) { string errDisplay = err.Message; Exception e = err.InnerException; while (e != null) { errDisplay += "\n)" + e.Message; e = e.InnerException; } _errorClaims = "\n" + c.created_on.Value.ToShortDateString() + ", " + c.PatientLastNameCommaFirst + "; " + c.LinkedCompany.name + "\nSystem error:" + errDisplay; } } if (cb.Claims.Count > 0) { NHDG.NHDGCommon.Utilities.SerializeToFile(cb, typeof(NHDG.NHDGCommon.Claims.ClaimBatch), _xmlPath); try { NHDG.ProphySplitter.ProphySplitter ps = new NHDG.ProphySplitter.ProphySplitter(); ps.PerformSplit(_xmlPath); } catch (Exception err) { MessageBox.Show("An error occurred splitting the procedures (for example, splitting D1110 into " + "multiple procedures. Please report the following error to a system administrator: \n\n" + err.Message, "Error Splitting"); } try { ProcedureCombiner pc = new ProcedureCombiner(); pc.Combine(_xmlPath); } catch (Exception err) { MessageBox.Show("An error occurred combining the procedures." + " Please report the following error to a system administrator: \n\n" + err.Message, "Error Combining"); } string workingDir = Application.StartupPath + "\\ada-form\\"; string fileToStart = "ruby"; string arguments = "ada_report.rb \"" + _xmlPath + "\" \"" + _pdfPath + "\""; Clipboard.SetText(fileToStart + " " + arguments); System.Diagnostics.ProcessStartInfo pi = new System.Diagnostics.ProcessStartInfo(fileToStart, arguments); pi.WorkingDirectory = workingDir; pi.UseShellExecute = true; System.Diagnostics.Process p = System.Diagnostics.Process.Start(pi); p.WaitForExit(45000); if (File.Exists(_pdfPath)) { System.Diagnostics.Process.Start(_pdfPath); } else { while (MessageBox.Show("The .pdf document appears to be taking a while to generate. Would you like to continue waiting?\n\nThis question appears every 45 seconds.", "PDF not generated", MessageBoxButtons.YesNo) == DialogResult.Yes) { p.WaitForExit(45000); if (File.Exists(_pdfPath)) { System.Diagnostics.Process.Start(_pdfPath); break; } } } } } catch (Exception err) { string innerText = ""; innerText += err.Message; Exception e = err; while (e.InnerException != null) { innerText += "\n\n" + e.InnerException.Message; e = e.InnerException; if (innerText.Length > 5000) // Just in case it's getting too long, break out { break; } } LoggingHelper.Log("Error printing claim in ClaimTrackerCommon.PrintClaims\n" + innerText, LogSeverity.Error); MessageBox.Show("An unexpected error occurred trying to print the claim.\n\n" + innerText, "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (_errorClaims != string.Empty) { LoggingHelper.Log("Errors occurred printing claim in ClaimTrackerCommon.PrintClaims\n" + _errorClaims, LogSeverity.Error); MessageBox.Show("Some of the claims could not be printed.\n\n" + _errorClaims); } }
private void cmdSave_Click(object sender, EventArgs e) { if (_isDBOnly) { try { } catch (Exception err) { LoggingHelper.Log("Error saving application settings.", LogSeverity.Error, err); MessageBox.Show(this, "An error occurred saving application settings.\n\n" + err.Message, "Unknown error."); } } else { try { system_options.ApexEDISaveFolder = txtEclaimsSaveFolder.Text; if (chkResendRevisit.Checked) { system_options.ResendRevisit = Convert.ToInt32(nmbResendRevisit.Value); } else { system_options.ResendRevisit = -1; } if (chkResendStatus.Checked) { if (cmbResendStatus.SelectedIndex >= 0) { system_options.ResendStatus = ((claim_status)cmbResendStatus.SelectedItem).id; } else { system_options.ResendStatus = -1; } } else { system_options.ResendStatus = -1; } if (chkStatusOnApex.Checked) { if (cmbStatusOnApex.SelectedIndex >= 0) { system_options.ApexSendStatus = ((claim_status)cmbStatusOnApex.SelectedItem).id; } else { system_options.ApexSendStatus = -1; } } else { system_options.ApexSendStatus = -1; } if (chkStatusOnApexResend.Checked) { if (cmbStatusOnApexResend.SelectedIndex >= 0) { system_options.ApexResendStatus = ((claim_status)cmbStatusOnApexResend.SelectedItem).id; } else { system_options.ApexResendStatus = -1; } } else { system_options.ApexResendStatus = -1; } system_options.ApexRevisitDateEnabled = chkApexRevisitDate.Checked; system_options.ApexRevisitDate = Convert.ToInt32(nmbApexRevisitDate.Value); system_options.EclaimsSecondaryShowExtraInfo = chkEclaimsShowSecondaryAmounts.Checked; system_options.MaxClaimsInBatch = Convert.ToInt32(nmbMaxClaimsInBatch.Value); system_options.LimitPredetermsOnSearch = chkLimitPredetermOnSearch.Checked; system_options.PredetermSearchDateMinimum = dtpPredetermLimitDate.Value; // Quick Notes system_options.SaveQuickNote(1, txtQNB1.Text, txtQNF1.Text); system_options.SaveQuickNote(2, txtQNB2.Text, txtQNF2.Text); system_options.SaveQuickNote(3, txtQNB3.Text, txtQNF3.Text); system_options.SaveQuickNote(4, txtQNB4.Text, txtQNF4.Text); system_options.OverrideStateNewProviderID = cmbOverrideStateNewProviderID.Text; system_options.OverrideStateState = txtOverrideStateState.Text; if (cmbOverrideStateInsurance.SelectedIndex >= 0) { system_options.OverrideStateInsurance = ((insurance_company_group)cmbOverrideStateInsurance.SelectedItem).id; } else { system_options.OverrideStateInsurance = 0; } system_options.OverrideStateEnabled = chkOverrideProviderByState.Checked; if (cmbOverrideStateProviderID.SelectedIndex < 0 || cmbOverrideStateProviderID.SelectedIndex == 0) // No selection { system_options.OverrideStateProviderID = ""; } else { system_options.OverrideStateProviderID = cmbOverrideStateProviderID.Text; } } catch { } C_DentalClaimTracker.Properties.Settings.Default.Save(); // Completely superfluous _saved = true; if (txtServerName.Text != oldServerName || txtDatabaseName.Text != oldDBName) { MessageBox.Show(this, "Changes to the server name require an application restart. Exiting application...", "Restart required."); Application.Exit(); } Close(); } }
private void ImportThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { Cursor = Cursors.Default; if (e.Cancelled) { CancelImport(); } else { pbarProgress.Value = pbarProgress.Maximum; lblStatus.Text = "Operation complete!"; // if (!chkSecondaryPredetermsOnly.Checked) system_options.SetLastImportDate(DateTime.Now); ShowLastImportDate(); AddStatus("The import completed successfully! " + totalRows + " rows were imported."); AddReportMessage(string.Format("The import completed successfully!\nPrimary: {0}\nSecondary: {1}\n" + "Predeterm: {2}\nSecondary Predeterm: {3}\nTotal Open Claims: {4}", primaryClaimCount, secondaryClaimCount, predetermClaimCount, secondaryPredetermClaimCount, primaryClaimCount + secondaryClaimCount + predetermClaimCount + secondaryPredetermClaimCount)); try { string importFileName = Application.StartupPath + "\\Imports\\" + DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss") + " import.rtf"; Directory.CreateDirectory(Path.GetDirectoryName(importFileName)); rtxtReport.SaveFile(importFileName); CreateLogFile("Import Successfully."); Updateimporterror(false); } catch (Exception ex) { CreateLogFile(ex.ToString()); Updateimporterror(true); LoggingHelper.Log("Error creating import report file.", LogSeverity.Error, ex, false); } cmdImport.Enabled = false; } }
private void ImportThread_DoWork(object sender, DoWorkEventArgs e) { claim workingClaim = new claim(); DataTable importData = new DataTable(); DataTable importDataSecondaries = new DataTable(); DataTable importDataPredeterms = new DataTable(); DataTable importDataSecondaryPredeterms = new DataTable(); system_options.SetImportFlag(true); primaryClaimCount = 0; secondaryClaimCount = 0; predetermClaimCount = 0; secondaryPredetermClaimCount = 0; closedClaimCount = 0; OleDbConnection oConnect; UpdateProgressBar(50, "Initiating Remote Connection..."); #region Initiate Connection, Get Data try { oConnect = new OleDbConnection(dms.GetConnectionString(true)); } catch (Exception err) { CreateLogFile(err.ToString()); Updateimporterror(true); LoggingHelper.Log("An error occurred getting the connection string for a new connection in frmImportData.Import", LogSeverity.Error, err, false); e.Cancel = true; return; } OleDbDataAdapter oAdapter; // Use Connection object for the DataAdapter to retrieve all tables from selected Database try { oConnect.Open(); } catch (Exception err) { CreateLogFile(err.ToString()); Updateimporterror(true); LoggingHelper.Log("Could not connect to the database in frmImportdata.Import", LogSeverity.Error, err, false); e.Cancel = true; return; } try { UpdateProgressBar(50, "Querying remote database (Standard)..."); // ************* Standard Claims oAdapter = new OleDbDataAdapter(PrepareSQL(dms.sqlstatement, changesOnly), oConnect); oAdapter.SelectCommand.CommandTimeout = System.Convert.ToInt32(nmbTimeout.Value); oAdapter.Fill(importData); UpdateProgressBar(10, "Querying remote database (Secondary)..."); // ************** Secondaries if (dms.sqlstatementsecondaries != "") { oAdapter = new OleDbDataAdapter(PrepareSQL(dms.sqlstatementsecondaries, changesOnly), oConnect); oAdapter.SelectCommand.CommandTimeout = System.Convert.ToInt32(nmbTimeout.Value); oAdapter.Fill(importDataSecondaries); } UpdateProgressBar(10, "Querying remote database (Predeterms)..."); // *************** Predeterms if (dms.sqlstatementpredeterms != "") { oAdapter = new OleDbDataAdapter(PrepareSQL(dms.sqlstatementpredeterms, changesOnly), oConnect); oAdapter.SelectCommand.CommandTimeout = System.Convert.ToInt32(nmbTimeout.Value); oAdapter.Fill(importDataPredeterms); } UpdateProgressBar(10, "Querying remote database (Secondary Predeterms)..."); // *************** Predeterms if (dms.sqlstatementsecondarypredeterms != "") { oAdapter = new OleDbDataAdapter(PrepareSQL(dms.sqlstatementsecondarypredeterms, changesOnly), oConnect); oAdapter.SelectCommand.CommandTimeout = System.Convert.ToInt32(nmbTimeout.Value); oAdapter.Fill(importDataSecondaryPredeterms); } } catch (Exception err) { CreateLogFile(err.ToString()); Updateimporterror(true); LoggingHelper.Log("Error with SQL statement or connection in frmImportData.Import", LogSeverity.Error, err); MessageBox.Show(this, "There was an error with your SQL statement or with your connection.\n\n" + err.Message, "Error retrieving data"); CancelImport(); return; } #endregion data_mapping_schema_data dmsd = new data_mapping_schema_data(); dmsd.schema_id = dms.id; DataTable dataForSchema = dmsd.Search(); // Generate our list of objects one time, and then use them for each iteration of rows List <data_mapping_schema_data> allMappedSchemaData = new List <data_mapping_schema_data>(); foreach (DataRow aMapping in dataForSchema.Rows) { // For every row, need to get the data for every field dmsd = new data_mapping_schema_data(); dmsd.Load(aMapping); allMappedSchemaData.Add(dmsd); } UpdateProgressBar(100, "Importing data..."); if (okToZap) { company cmp = new company(); cmp.Zap(); workingClaim.Zap(); call aCall = new call(); aCall.Zap(); company_contact_info info = new company_contact_info(); info.Zap(); procedure p = new procedure(); p.Zap(); choice c = new choice(); c.Zap(); notes n = new notes(); n.Zap(); claim_batch cb = new claim_batch(); cb.Zap(); batch_claim_list bcl = new batch_claim_list(); bcl.Zap(); } else { if (!changesOnly) { workingClaim.MarkAllImportsUpdated(false); } } // Apply incremental updates to progress bar int currentRow = 0; totalRows = importData.Rows.Count + importDataSecondaries.Rows.Count + importDataPredeterms.Rows.Count + importDataSecondaryPredeterms.Rows.Count; decimal exactIncrementAmount; if (totalRows > 0) { exactIncrementAmount = 500m / totalRows; } else { exactIncrementAmount = 500m; } decimal incrementCounter = 0; int increment; if (exactIncrementAmount < 1) { increment = 1; } else { increment = Convert.ToInt32(Math.Truncate(exactIncrementAmount)); } string lastClaimID = ""; claim aClaim = new claim(); company aCompany = new company(); company_contact_info anInfo = new company_contact_info(); procedure aProcedure = new procedure(); for (int p = 0; p < 4; p++) { claim.ClaimTypes ct; DataTable thisImport; switch (p) { case 0: thisImport = importData; ct = claim.ClaimTypes.Primary; UpdateLabels(0); break; case 1: thisImport = importDataSecondaries; ct = claim.ClaimTypes.Secondary; UpdateLabels(1); break; case 2: thisImport = importDataPredeterms; ct = claim.ClaimTypes.Predeterm; UpdateLabels(2); break; default: thisImport = importDataSecondaryPredeterms; UpdateLabels(3); ct = claim.ClaimTypes.SecondaryPredeterm; break; } // Have data at this point, need to tie them to the internal mapping schema data foreach (DataRow anImportRow in thisImport.Rows) { string newID = anImportRow[dms.claim_id_column].ToString(); string newDB = anImportRow[dms.claim_db_column].ToString(); bool isOnlyProcedureData; if (newID == lastClaimID) { // We're only dealing with the import of "some" data isOnlyProcedureData = true; } else { if (ct == claim.ClaimTypes.Primary) { primaryClaimCount++; } else if (ct == claim.ClaimTypes.Secondary) { secondaryClaimCount++; } else if (ct == claim.ClaimTypes.Predeterm) { predetermClaimCount++; } else { secondaryPredetermClaimCount++; } UpdateTypeCount(); aClaim = FindClaim(anImportRow, ct); aCompany = FindCompany(anImportRow[dms.company_namecolumn].ToString()); anInfo = FindContactInfo(anImportRow["Ins_Co_Street1"].ToString(), aCompany.id, anImportRow["Ins_Co_Phone"].ToString()); lastClaimID = newID; aClaim.ClearClaimProcedures(); isOnlyProcedureData = false; // Check for "X" in provider field try { if (aClaim.doctor_provider_id.StartsWith("X")) { AddStatus(string.Format("The claim for patient {0} on {1} uses an X provider ({2})", aClaim.PatientName, aClaim.DatesOfServiceString(), aClaim.doctor_provider_id), true, true); } } catch (Exception err) { CreateLogFile(err.ToString()); Updateimporterror(true); LoggingHelper.Log(err, false); } } aProcedure = FindProcedure(anImportRow["PROC_LOGID"].ToString()); if (CommonFunctions.DBNullToString(anImportRow["DATERECEIVED"]) == "") { aClaim.open = 1; } else if (((DateTime)anImportRow["DATERECEIVED"]).Year == 1753) { aClaim.open = 1; } else { aClaim.open = 0; UpdateStatusHistory(aClaim); } foreach (data_mapping_schema_data aMappedData in allMappedSchemaData) { // We do a check for is only procedure data to speed up processing // It makes the code a little messier. if (isOnlyProcedureData) { // If we're only importing the procedure data, none of the other information is important if ((aMappedData.LinkedField.table_name == "claims") || (aMappedData.LinkedField.table_name == "companies") || (aMappedData.LinkedField.table_name == "company_contact_info")) { // Ignore } else if (aMappedData.LinkedField.table_name == "procedures") { if (aMappedData.LinkedField.field_name == "surf_string") { aProcedure[aMappedData.LinkedField.field_name] = CommonFunctions.RemoveNonPrintableCharacters(anImportRow[aMappedData.mapped_to_text].ToString()); } else if (aMappedData.LinkedField.field_name == "claim_id") { aProcedure["claim_id"] = lastClaimID; } else { aProcedure[aMappedData.LinkedField.field_name] = anImportRow[aMappedData.mapped_to_text]; } } else { LoggingHelper.Log("Uninitialized table name in frmImportData.Import", LogSeverity.Critical, new Exception("Uninitialized table name in import procedure."), true); } } else { // This is a new claim - we need to get the data for every field if (aMappedData.LinkedField.table_name == "claims") { aClaim[aMappedData.LinkedField.field_name] = anImportRow[aMappedData.mapped_to_text]; } else if (aMappedData.LinkedField.table_name == "companies") { if (aMappedData.mapped_to_text != dms.company_namecolumn) { aCompany[aMappedData.LinkedField.field_name] = anImportRow[aMappedData.mapped_to_text]; } } else if (aMappedData.LinkedField.table_name == "company_contact_info") { anInfo[aMappedData.LinkedField.field_name] = anImportRow[aMappedData.mapped_to_text]; } else if (aMappedData.LinkedField.table_name == "procedures") { if (aMappedData.LinkedField.field_name == "surf_string") { aProcedure[aMappedData.LinkedField.field_name] = CommonFunctions.RemoveNonPrintableCharacters(anImportRow[aMappedData.mapped_to_text].ToString()); } else { aProcedure[aMappedData.LinkedField.field_name] = anImportRow[aMappedData.mapped_to_text]; } } else { LoggingHelper.Log("Uninitialized table name in frmImport.Import", LogSeverity.Critical); throw new Exception("Uninitialized table name in import procedure."); } } } aCompany.Save(); anInfo.company_id = aCompany.id; if (CommonFunctions.DBNullToZero(anInfo["order_id"]) == 0) { anInfo.order_id = anInfo.GetNextOrderID(); } anInfo.Save(); aClaim.company_id = aCompany.id; aClaim.company_address_id = anInfo.order_id; aClaim["import_update_flag"] = true; aClaim.Save(); if (p == 0 || p == 2 || p == 3) // Only update the id if this is the primary claim or a predeterm { aProcedure.claim_id = aClaim.id; } aProcedure.Save(); currentRow++; if (Math.Truncate(incrementCounter + exactIncrementAmount) != Math.Truncate(incrementCounter)) { UpdateProgressBar(increment, string.Format("{0} / {1} procedures completed...", currentRow, totalRows), false); } incrementCounter += exactIncrementAmount; } } if (changesOnly) { // Grab all the deleted claims and mark them as closed here // Add a note that they have been deleted, I guess string deletedClaimsSQL = "SELECT CLAIMID, CLAIMDB " + "FROM AUDIT_DDB_CLAIM " + "WHERE N_CLAIMID is null " + "AND CLAIMID is not null AND CLAIMDB is not null " + "AND date_changed >= '" + lastWrite.ToString("G") + "'"; DataTable deletedClaims = new DataTable(); OleDbCommand cmd = new OleDbCommand(deletedClaimsSQL, oConnect); cmd.CommandTimeout = 90; oAdapter = new OleDbDataAdapter(cmd); oAdapter.Fill(deletedClaims); UpdateProgressBar(5, "Updating Local Status for Deleted Claims..."); foreach (DataRow aDeletedClaim in deletedClaims.Rows) { // Close the claims DataTable matches = aClaim.Search("SELECT * FROM claims WHERE claimidnum = '" + aDeletedClaim["claimid"] + "' and claimdb = '" + aDeletedClaim["claimdb"] + "'"); if (matches.Rows.Count > 0) { // This should honestly not load every claim aClaim = new claim(); aClaim.Load(matches.Rows[0]); aClaim.open = 0; aClaim.Save(); UpdateStatusHistory(aClaim); closedClaimCount++; } } } else { closedClaimCount = workingClaim.CloseClaimsWithoutUpdate(); } UpdateLabels(4); workingClaim.FixRevisitDateAfterImport(); }
private claim FindClaim(DataRow anImportRow, claim.ClaimTypes claimType) { string importID = anImportRow[dms.claim_id_column].ToString(); string importDB = anImportRow[dms.claim_db_column].ToString(); try { claim c = new claim(); c.claimidnum = importID; c.claimdb = importDB; DataTable matches = c.Search(); if (matches.Rows.Count != 0) { c.Load(matches.Rows[0]); } else { // ****** Finding recreated claims ************* // Above, we checked for the common ID/DB match // Here we try to find if a claim that is not in Tracker has been recreated // We match by all fields minus 1 - if two primary fields have been changed // Tracker can't track it // If we find a possible match, we check to see that the current claim isn't in Dentrix // to avoid false positives bool possibleMatchFound = false; bool claimInDentrix = true; claim workingClaim = new claim(); DateTime?dateOfService = null; try { dateOfService = Convert.ToDateTime(anImportRow["PLDATE"]); } catch { } string lastName = anImportRow["PatLastName"].ToString(); string firstName = anImportRow["PatFirstName"].ToString(); decimal amount = Convert.ToDecimal(anImportRow["TOTAL"]); // stored as cents string doctorFirstName = anImportRow["DoctorFirstName"].ToString(); string doctorLastName = anImportRow["DoctorLastName"].ToString(); string subscriberInsuranceID = anImportRow["ID_NUM_ON_CLAIM"].ToString(); string matchingClaimInfo = matchingClaimInfo = string.Format("Patient: {0}, Doctor: {1}, Total: {2}, DOS: {3}, Ins ID: {4}, ID: {5}, Type: {6}", firstName + " " + lastName, doctorFirstName + " " + doctorLastName, amount, dateOfService, subscriberInsuranceID, importID + " | " + importDB, claimType.ToString()); int?newClaimID = null; // Search for a patient match first. If the patient doesn't match try to match on the other two fields workingClaim.patient_first_name = firstName; workingClaim.patient_last_name = lastName; workingClaim.open = 1; DataTable patientMatches = workingClaim.Search(); if (patientMatches.Rows.Count > 0) { // Iterate through all rows where the patient data matches foreach (DataRow aRow in patientMatches.Rows) { int numMatchesForclaim = 0; workingClaim.Load(aRow); if (workingClaim.amount_of_claim * 100 == amount) { numMatchesForclaim++; } if (workingClaim.doctor_first_name == doctorFirstName && workingClaim.doctor_last_name == doctorLastName) { numMatchesForclaim++; } if (workingClaim.date_of_service == dateOfService) { numMatchesForclaim++; } if (workingClaim.subscriber_alternate_number == subscriberInsuranceID) { numMatchesForclaim++; } if (workingClaim.claim_type == claimType) { numMatchesForclaim++; } if (numMatchesForclaim >= 4) { // Found a claim that appears to match newClaimID = workingClaim.id; possibleMatchFound = true; break; } } } else { // Look for a match on date of service, amount, provider, insurance id, and type workingClaim = new claim(); workingClaim.open = 1; workingClaim.amount_of_claim = amount / 100; workingClaim.doctor_first_name = doctorFirstName; workingClaim.doctor_last_name = doctorLastName; workingClaim.subscriber_alternate_number = subscriberInsuranceID; workingClaim.claim_type = claimType; string searchSQL = workingClaim.SearchSQL + string.Format(" AND DATEDIFF(d, [date_of_service], '{0}') = 0", dateOfService.GetValueOrDefault().ToShortDateString()); DataTable otherMatches = workingClaim.Search(searchSQL); if (otherMatches.Rows.Count > 0) { newClaimID = (int)otherMatches.Rows[0]["id"]; possibleMatchFound = true; } } if (possibleMatchFound) { // Check Dentrix to verify that the current ID/DB can't be found if (newClaimID.HasValue && ClaimTrackerCommon.ClaimExists(new claim(newClaimID.Value))) // No match found { // Log this temporarily for recordkeeping claimInDentrix = true; AddReportMessage("Found a possible claim to merge, but the claim exists in Dentrix. Did not merge claim..." + matchingClaimInfo, true); LoggingHelper.Log("Tried to merge a claim, but it was found in Dentrix. Claim info:\n" + matchingClaimInfo, LogSeverity.Information); } else { claimInDentrix = false; } } if (!claimInDentrix && possibleMatchFound) { // Already loaded claim, should have "correct" data c.Load(newClaimID.GetValueOrDefault(0)); AddReportMessage(string.Format("Merged a claim in Dentrix with an existing claim tracker claim. The claim's old ID/DB is {0}/{1}. The matching claim information is {2}", c.claimidnum, c.claimdb, matchingClaimInfo), true); c.claimidnum = importID; c.claimdb = importDB; LoggingHelper.Log("Successfully merged a claim. \n" + matchingClaimInfo, LogSeverity.Information); } else { AddReportMessage("New claim imported - " + matchingClaimInfo); c.created_by = "Automatic Database Importer"; c.updated_on = null; } } return(c); } catch (Exception err) { // Somewhat dangerous, but it ensures that the import won't crash LoggingHelper.Log("Error in frmImportData.FindClaim", LogSeverity.Critical, err, false); claim c = new claim(); c.claimidnum = importID; c.claimdb = importDB; return(c); } }