コード例 #1
0
 private void btnPrint_Click(object sender, RoutedEventArgs e)
 {
     if (datResults.SelectedItems.Count == 1)
     {
         ClaimTrackerCommon.PrintClaims(GetSelectedClaims());
     }
 }
コード例 #2
0
        public static 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);
            }
        }
コード例 #3
0
        /// <summary>
        /// Builds the SQL to be used on this form. If whereonly is true, will return only the where clause
        /// </summary>
        /// <param name="whereOnly"></param>
        /// <returns></returns>
        private string BuildSQL(bool whereOnly = false, bool includeCarrierFilter = true)
        {
            string toReturn;

            if (whereOnly)
            {
                toReturn = "WHERE 0=0 ";
            }
            else
            {
                toReturn = @"SELECT TOP 500 c.patient_last_name + ', ' + c.patient_first_name AS 'PatientName', c.id as 'ID', 
                CONVERT(varchar, c.patient_dob, 101) AS 'DOB', cmp.name AS 'Carrier', c.amount_of_claim / 100 AS 'Amount', 
                CONVERT(varchar, c.date_of_service , 101) AS 'DOS', c.date_of_service, c.patient_dob, 
                CASE c.claim_type  
                    WHEN 0 THEN 'PRIM'
                    WHEN 1 THEN 'SEC'
                    When 2 THEN 'PRE'
                    WHEN 3 THEN 'SECPRE'
                ELSE '?'
                END AS 'Type', CONVERT(varchar, c.revisit_date, 101) AS 'Revisit', c.revisit_date,
                c.doctor_provider_id AS 'Provider', c.doctor_provider_id as 'AlternateProvider', cs.name AS 'Status', 
                CONVERT(varchar, (SELECT MAX(csent.sent_date) FROM claim_sent_history csent WHERE csent.claim_id = c.id), 101) AS 'LastSent',
                (SELECT MAX(csent.sent_date) FROM claim_sent_history csent WHERE csent.claim_id = c.id) AS 'last_sent',
                (SELECT CONVERT(varchar, MAX(alog.action_taken_time), 101) FROM user_action_log alog WHERE alog.claim_id = c.id) AS 'LastEdit',
                (SELECT MAX(alog.action_taken_time) FROM user_action_log alog WHERE alog.claim_id = c.id) AS 'last_edit', override_address_provider,
                (SELECT TOP 1 username FROM user_action_log alog inner join users u on alog.user_id = u.id WHERE alog.claim_id = c.id ORDER BY action_taken_time desc) AS 'User',
                CONVERT(varchar, (SELECT MAX(pl_date) FROM procedures p WHERE p.claim_id = c.id), 101) AS 'LastDOS',
                (SELECT MAX(pl_date) FROM procedures p WHERE p.claim_id = c.id) AS 'last_dos'
                FROM claims c
                LEFT JOIN Companies cmp ON c.company_id = cmp.id
                LEFT JOIN users u ON c.owner_id = u.id
                LEFT JOIN claimstatus cs ON cs.id = c.status_id
                WHERE 0=0 ";
            }


            claim_change_log c = new claim_change_log();

            if (_whereClause == "")
            {
                if (_formSearchMode == FormSearchModes.Patient)
                {
                    // create custom search string for patient name
                    toReturn += BuildWherePatientName(txtPatientName.Text, 1);
                    if (chkPatientUnpaidClaimsOnly.IsChecked.GetValueOrDefault(true))
                    {
                        toReturn += BuildWhereSingle("c.[open]", "1", DataTypes.Numeric, DataObject.SearchTypes.Exact);
                    }

                    if (chkPatientExcludeWorkedClaims.IsChecked.GetValueOrDefault(true))
                    {
                        toReturn += BuildWhereSingle("c.revisit_date", CommonFunctions.ToSQLServerDateTime(DateTime.Now), DataTypes.Date, DataObject.SearchTypes.After);
                    }
                }
                else if (_formSearchMode == FormSearchModes.Insurance)
                {
                    // name, age, worked claims
                    toReturn += BuildWhereSingle("cmp.name", txtInsuranceName.Text.Trim(), DataTypes.Text, DataObject.SearchTypes.Contains);

                    // Do the "by date" filtering
                    string dateFilterString = string.Empty;

                    // Only add SQL if at least one is unchecked
                    if (!chkAge24.IsChecked.GetValueOrDefault(true) || !chkAge44.IsChecked.GetValueOrDefault(true) || !chkAge45.IsChecked.GetValueOrDefault(true))
                    {
                        if (chkAge24.IsChecked.GetValueOrDefault(true)) // 0-24
                        {
                            dateFilterString += " date_of_service > DATEADD(\"day\", -24, GETDATE())";
                        }

                        if (chkAge44.IsChecked.GetValueOrDefault(true)) // 25-44
                        {
                            if (dateFilterString != string.Empty)
                            {
                                dateFilterString += " OR ";
                            }
                            dateFilterString += " (date_of_service > DATEADD(\"day\", -24, GETDATE()) AND date_of_service < DATEADD(\"d\", -45, GETDATE()))";
                        }

                        if (chkAge45.IsChecked.GetValueOrDefault(true)) // 45+
                        {
                            if (dateFilterString != string.Empty)
                            {
                                dateFilterString += " OR ";
                            }
                            dateFilterString += " date_of_service < DATEADD(\"day\", -45, GETDATE())";
                        }
                    }


                    if (dateFilterString != string.Empty)
                    {
                        toReturn += string.Format(" AND ({0})", dateFilterString);
                    }

                    if (chkInsuranceExcludeWorked.IsChecked.GetValueOrDefault(true))
                    {
                        toReturn += BuildWhereSingle("c.[open]", "1", DataTypes.Numeric, DataObject.SearchTypes.Exact);
                    }
                }
            }
            else
            {
                toReturn += _whereClause;

                if (FilterByInsurance && cmbCarrierFilter.SelectedIndex > 0 && includeCarrierFilter)
                {
                    // Add a company criteria
                    // toReturn += " AND cmp.id = " + cmbCarrierFilter.SelectedValue;

                    InsuranceCompanyGroups icg = null;

                    if (carrierSource.Find(item => item.ToString() == ((InsuranceCompanyGroups)cmbCarrierFilter.SelectedItem).ToString()) != null)
                    {
                        icg = (InsuranceCompanyGroups)cmbCarrierFilter.SelectedItem;

                        if (icg.Group == null)
                        {
                            toReturn += BuildWhereSingle("cmp.id", icg.Companies[0].id.ToString(), DataTypes.Numeric, DataObject.SearchTypes.Exact);
                        }
                        else
                        {
                            toReturn += string.Format(" AND cmp.id IN({0})", ClaimTrackerCommon.CompaniesToInString(icg.Companies));
                        }
                    }
                }
            }

            if (!whereOnly)
            {
                if (_orderByClause == "")
                {
                    toReturn += " ORDER BY c.sent_date";
                }
                else
                {
                    toReturn += _orderByClause;
                }
            }


            return(toReturn);
        }