예제 #1
0
        internal bool InCurrentApexResendBatch()
        {
            claim_batch cb = claim_batch.GetApexResendBatchForToday();

            DataTable dt = Search("SELECT * FROM batch_claim_list WHERE batch_id = " + cb.id +
                                  " AND claim_id = " + id);

            return(dt.Rows.Count > 0);
        }
        internal static claim_batch NewMercuryBatch()
        {
            claim_batch toReturn = new claim_batch();

            toReturn.batch_date  = DateTime.Now;
            toReturn.batch_info  = "Mercury Batch";
            toReturn.handling    = clsClaimEnums.SentMethods.Mercury;
            toReturn.source      = 0;
            toReturn.server_name = C_DentalClaimTracker.General.RegistryData.LocalComputerName;
            toReturn.Save();
            return(toReturn);
        }
예제 #3
0
        internal static claim_batch GetApexMostRecentBatch()
        {
            claim_batch toReturn = new claim_batch();
            DataTable   dt       = toReturn.Search("SELECT TOP 1 * FROM claim_batch WHERE handling = " +
                                                   (int)clsClaimEnums.SentMethods.ApexEDI + "ORDER BY batch_date desc");

            if (dt.Rows.Count > 0)
            {
                toReturn.Load(dt.Rows[0]);
            }
            else
            {
                toReturn = null;
            }

            return(toReturn);
        }
        internal static claim_batch FindApexBatchWithDate(DateTime fileDate)
        {
            claim_batch toReturn = new claim_batch();
            string      sql      = "SELECT * FROM claim_batch WHERE DateDiff(day, batch_date, '" + fileDate + "') = 0 ORDER BY batch_date desc";
            DataTable   dt       = toReturn.Search(sql);

            if (dt.Rows.Count > 0)
            {
                toReturn.Load(dt.Rows[0]);
            }
            else
            {
                toReturn = null;
            }

            return(toReturn);
        }
예제 #5
0
        internal List <claim_batch> LinkedBatches()
        {
            List <claim_batch> toReturn = new List <claim_batch>();
            claim_batch        workingBatch;

            DataTable results = Search("SELECT id FROM claim_batch cb INNER JOIN batch_claim_list bcl ON cb.id = bcl.batch_ID " +
                                       "WHERE bcl.claim_id = " + id + " AND bcl.still_in_batch = 1 ORDER BY batch_date desc");


            foreach (DataRow aRow in results.Rows)
            {
                workingBatch = new claim_batch();
                workingBatch.Load((int)aRow["id"]);

                toReturn.Add(workingBatch);
            }

            return(toReturn);
        }
예제 #6
0
        internal static claim_batch FindApexBatchWithDate(DateTime fileDate)
        {
            claim_batch toReturn = new claim_batch();
            string      sql      = "SELECT * FROM claim_batch WHERE TimeDiff(batch_date, '" + CommonFunctions.ToMySQLDateTime(fileDate) +
                                   "') = 0";
            DataTable dt = toReturn.Search(sql);

            if (dt.Rows.Count > 0)
            {
                toReturn.Load(dt.Rows[0]);

                if (dt.Rows.Count > 1)
                {
                    System.Diagnostics.Debug.WriteLine("Too many batches returned from the FindApexBatchWithDateFunction");
                }
            }
            else
            {
                toReturn = null;
            }

            return(toReturn);
        }
        private void sendEclaimsDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string XMLPATH = Application.StartupPath + "\\syncdata.xml";
            // start by getting the date everything was sent out from the xml file
            DateTime lastWrite    = new DateTime(1999, 12, 31);
            bool     okToContinue = true;

            if (File.Exists(XMLPATH))
            {
                XmlDocument toOpen = new XmlDocument();
                toOpen.Load(XMLPATH);

                try
                {
                    XmlElement ele = toOpen.DocumentElement;
                    lastWrite = System.Convert.ToDateTime(ele.InnerText);
                }
                catch
                {
                    // assume the data is corrupt and there was no last write date.
                    okToContinue = MessageBox.Show(this, "The file that specifies which batches have been sent to eclaims has been corrupted. Would you like to continue and " +
                                                   "send all batches to eclaims?", "Sync File Corrupt", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes;
                }
            }
            int count = 0;

            if (okToContinue)
            {
                // Get the claims to process
                List <claim_batch> cbList    = new List <claim_batch>();
                claim_batch        cb        = new claim_batch();
                string             searchSQL = "SELECT * FROM claim_batch WHERE batch_date > CAST('" + CommonFunctions.ToMySQLDateTime(lastWrite)
                                               + "' AS DATETIME) AND SOURCE = 0";
                DataTable dt = cb.Search(searchSQL);
                count = dt.Rows.Count;

                foreach (DataRow aBatch in dt.Rows)
                {
                    cb = new claim_batch();
                    cb.Load(aBatch);
                    cbList.Add(cb);
                }



                // Add the claims as claims in Dentrix
                // NHDG_CLAIM_BATCHES - CLAIMBATCHID, BATCH_DATE, HANDLING ("Paper", "Electronic (ApexEDI)"
                // NHDG_CLAIM_TRANSACTIONS - CLAIM_ID, CLAIM_DB, CLAIMBATCHID, RESUBMIT_FLAG (char?), BATCH_RESUBMITTED
                data_mapping_schema dms          = new data_mapping_schema(3);
                SqlConnection       dbConnection = new SqlConnection(dms.GetConnectionString(false));

                try
                {
                    dbConnection.Open();

                    foreach (claim_batch aBatch in cbList)
                    {
                        SqlCommand sc = new SqlCommand("INSERT INTO NHDG_CLAIM_BATCHES (batch_date, handling) VALUES ('" +
                                                       CommonFunctions.ToMySQLDateTime(aBatch.batch_date) + "', '" + ConvertHandlingToDentrix(aBatch.handlingAsString) +
                                                       "')", dbConnection);
                        sc.ExecuteNonQuery();

                        sc.CommandText = "SELECT IDENT_CURRENT('NHDG_CLAIM_BATCHES')";
                        SqlDataReader getID = sc.ExecuteReader();
                        getID.Read();
                        int lastID = System.Convert.ToInt32(getID[0]);
                        getID.Close();

                        // Insert all the claims in the batch into nhdg_claim_transactions
                        foreach (claim aClaim in aBatch.GetMatchingClaims())
                        {
                            sc.CommandText = "INSERT INTO NHDG_CLAIM_TRANSACTIONS (CLAIM_ID, CLAIM_DB, CLAIMBATCHID) " +
                                             " VALUES (" + aClaim.claimidnum + "," + aClaim.claimdb + "," + lastID + ")";
                            sc.ExecuteNonQuery();
                        }
                    }
                }
                catch
                {
                    okToContinue = false;
                    MessageBox.Show("There was an error getting the data into the Dentrix database. The process cannot continue.");
                }
            }
            if (okToContinue)
            {
                XmlDocument toSave = new XmlDocument();
                XmlNode     toChange;
                if (File.Exists(XMLPATH))
                {
                    toSave.Load(XMLPATH);
                    toChange = toSave.DocumentElement;
                }
                else
                {
                    toChange = toSave.AppendChild(toSave.CreateNode(XmlNodeType.Element, "SyncData", ""));
                    toChange = toSave.DocumentElement.AppendChild(toSave.CreateTextNode("LastUpdate"));
                }

                toChange.InnerText = DateTime.Now.ToString();
                toSave.Save(XMLPATH);

                MessageBox.Show(count + " batches synced successfully.");
            }


            else
            {
                MessageBox.Show("Please contact a system administrator to fix the problems you encountered while syncing.");
            }
        }
        private void mnuSyncWithEclaims_Click(object sender, EventArgs e)
        {
            data_mapping_schema dms;
            SqlConnection       dbConnection;

            try
            {
                dms = new data_mapping_schema();
                dms.Load(3);
                dbConnection = new SqlConnection(dms.GetConnectionString(false));
                dbConnection.Open();
            }
            catch
            {
                MessageBox.Show(this, "Could not open connection to Dentrix database.", "Could not connect");
                return;
            }

            try
            {
                // Remove all batches with a source of external, then pull them all back in
                claim_batch toDelete = new claim_batch();

                toDelete.ExecuteNonQuery("DELETE claim_batch, batch_claim_list FROM claim_batch " +
                                         " LEFT JOIN batch_claim_list ON claim_batch.id = batch_claim_list.batch_id WHERE source = 1");
                // Got rid of the existing external stuff, now pull in the stuff from the last few months
                // NHDG_CLAIM_BATCHES - CLAIMBATCHID, BATCH_DATE, HANDLING ("Paper", "Electronic (ApexEDI)"
                // NHDG_CLAIM_TRANSACTIONS - CLAIM_ID, CLAIM_DB, CLAIMBATCHID, RESUBMIT_FLAG (char?), BATCH_RESUBMITTED

                Dictionary <string, int> batchIDData = new Dictionary <string, int>(); // Update this as I iterate through claim batches, we'll grab all the items for valid
                // bacthes in a 2nd sql statement
                string batchIDList = "";

                SqlCommand command = new SqlCommand("SELECT * FROM NHDG_CLAIM_BATCHES cb " +
                                                    "WHERE DATEDIFF(\"dd\", cb.BATCH_DATE, GETDATE()) < 200", dbConnection);

                SqlDataReader reader = command.ExecuteReader();


                while (reader.Read())
                {
                    claim_batch cb = new claim_batch();

                    cb.batch_date = (DateTime)reader["batch_date"];
                    cb.handling   = ConvertHandlingFromDentrix(reader["handling"].ToString());
                    cb.batch_info = "Imported from Eclaims";
                    cb["source"]  = 1;
                    cb.Save();
                    batchIDData.Add(reader["claimbatchid"].ToString(), cb.id);
                }

                reader.Close();
                if (batchIDData.Count > 0)
                {
                    foreach (KeyValuePair <string, int> kvp in batchIDData)
                    {
                        batchIDList += kvp.Key + ",";
                    }
                    batchIDList = batchIDList.TrimEnd(",".ToCharArray());
                    //Clipboard.SetText(batchIDList);
                    //MessageBox.Show("Here's my batchid list (it's in the clipboard): " + batchIDList);

                    string searchSQL = "SELECT * FROM NHDG_CLAIM_TRANSACTIONS WHERE CLAIMBATCHID IN (" + batchIDList +
                                       ")";
                    command = new SqlCommand(searchSQL, dbConnection);

                    //Clipboard.SetText(searchSQL);
                    //MessageBox.Show("And here's the search sql: " + searchSQL);
                    reader = command.ExecuteReader();
                    string bigMessageBox = "";
                    int    foundCount    = 0;
                    while (reader.Read())
                    {
                        int claimID = FindClaim(reader["claim_id"].ToString(), reader["claim_db"].ToString());

                        bigMessageBox += reader["claim_id"].ToString() + " | ";

                        if (claimID > 0)
                        {
                            batch_claim_list bcl = new batch_claim_list();
                            claim_batch      cb  = new claim_batch(batchIDData[reader["claimbatchid"].ToString()]);
                            bcl.batch_id          = cb.id;
                            bcl.claim_id          = claimID;
                            bcl.still_in_batch    = reader["resubmit_flag"].ToString() != "Y";
                            bcl["last_send_date"] = cb.batch_date;
                            bcl.Save();

                            foundCount++;
                        }
                    }

                    //MessageBox.Show("Here are the claimIDs that were searched for. ( " + foundCount + " were found.)\n" + bigMessageBox);
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show(this, "An unexpected error occurred syncing data.\n\n" + ex.Message);
            }

            MessageBox.Show(this, "Sync successful!", "Sync with Eclaims", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        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();
        }
예제 #10
0
        private void LoadClaim(int Index)
        {
            if (RecordChangeOK())
            {
                _loading      = true;
                _editMode     = EditModes.Edit;
                _currentIndex = Index;
                claim toLoad = new claim(_claimsList[_currentIndex].id);
                _claimsList[_currentIndex] = toLoad;

                #region Field assignment

                // Services
                nmbClaimAmount.Value = toLoad.amount_of_claim;

                LoadProcedures(toLoad);

                // Insurance
                LoadInsurance(toLoad.LinkedCompany, toLoad.LinkedCompanyAddress);

                // Patient
                txtPatientName.Text = toLoad.PatientName;

                ctlPatientDOB.CurrentDate = toLoad.patient_dob;

                txtPatientSSN.Text      = toLoad.patient_ssn;
                txtPatientAddress.Text  = toLoad.patient_address;
                txtPatientAddress2.Text = toLoad.patient_address2;
                txtPatientCity.Text     = toLoad.patient_city;
                txtPatientState.Text    = toLoad.patient_state;
                txtPatientZIP.Text      = toLoad.patient_zip;

                // Doctor
                txtDoctorName.Text      = toLoad.DoctorName;
                txtDoctorTaxID.Text     = toLoad.doctor_tax_number;
                txtDoctorLicenseID.Text = toLoad.doctor_license_number;
                txtDoctorBC.Text        = toLoad.doctor_bcbs_number;
                txtDoctorPhone.Text     = toLoad.doctor_phone_number_object.FormattedPhone;
                txtDoctorFax.Text       = toLoad.doctor_fax_number_object.FormattedPhone;
                txtDoctorAddress.Text   = toLoad.doctor_address;
                txtDoctorAddress2.Text  = toLoad.doctor_address2;
                txtDoctorCity.Text      = toLoad.doctor_city;
                txtDoctorState.Text     = toLoad.doctor_state;
                txtDoctorZIP.Text       = toLoad.doctor_zip;

                // Subscriber
                txtSubscriberName.Text       = toLoad.SubscriberName;
                ctlSubscriberDOB.CurrentDate = toLoad.subscriber_dob;

                txtSubscriberID.Text        = toLoad.subscriber_number;
                txtSubscriberAltID.Text     = toLoad.subscriber_alternate_number;
                txtSubscriberSSN.Text       = toLoad.subscriber_ssn;
                txtSubscriberGroupName.Text = toLoad.subscriber_group_name;
                txtSubscriberGroupNum.Text  = toLoad.subscriber_group_number;
                txtSubscriberAddress.Text   = toLoad.subscriber_address;
                txtSubscriberAddress2.Text  = toLoad.subscriber_address2;
                txtSubscriberCity.Text      = toLoad.subscriber_city;
                txtSubscriberState.Text     = toLoad.subscriber_state;
                txtSubscriberZIP.Text       = toLoad.subscriber_zip;

                // General
                ctlSentDate.CurrentDate   = toLoad.sent_date;
                ctlResentDate.CurrentDate = toLoad.resent_date;
                ctlTracerDate.CurrentDate = toLoad.tracer_date;
                ctlOnHoldDate.CurrentDate = toLoad.on_hold_date;
                chkClosed.Checked         = !System.Convert.ToBoolean(toLoad.open);

                // Notes
                txtNotes.Text = toLoad.notes;


                #endregion

                #region Handling Specific


                claim_batch cb = toLoad.LinkedBatch();

                if (cb != null)
                {
                    cmbHandling.Enabled       = false;
                    chkInBatch.Checked        = true;
                    ctlBatchDate.DateValue    = cb.batch_date;
                    cmbHandling.SelectedIndex = cmbHandling.FindStringExact(cb.handling);
                }
                else
                {
                    cmbHandling.Enabled = true;
                    chkInBatch.Checked  = false;
                    ctlBatchDate.Clear();
                    cmbHandling.SelectedIndex = cmbHandling.FindStringExact(toLoad.handling);
                }

                #endregion

                if (toLoad.revisit_date.HasValue)
                {
                    ctlRevisitDate.CurrentDate = toLoad.revisit_date;
                }
                else
                {
                    ctlRevisitDate.CurrentDate = DateTime.Now.AddDays(System.Convert.ToDouble(nmbRevisitInterval.Value));
                }

                if (toLoad.LinkedChanges.Count > 0)
                {
                    lnkViewClaimChangeHistory.Visible = true;
                }

                Text = toLoad.claim_type.ToString() + " claim for " + toLoad.PatientName;
                callManager.LoadClaim(toLoad);

                _changed = false;
                _loading = false;
            }
        }