예제 #1
0
        /// <summary>Returns true if ClaimProcAllowCreditsGreaterThanProcFee preference allows the user to add credits greater than the proc fee. Otherwise returns false </summary>
        private bool isClaimProcGreaterThanProcFee()
        {
            ClaimProcCreditsGreaterThanProcFee creditsGreaterPref = (ClaimProcCreditsGreaterThanProcFee)PrefC.GetInt(PrefName.ClaimProcAllowCreditsGreaterThanProcFee);

            if (creditsGreaterPref == ClaimProcCreditsGreaterThanProcFee.Allow)
            {
                return(true);
            }
            List <Procedure>  listProcs                 = Procedures.GetManyProc(ClaimProcsToEdit.Select(x => x.ProcNum).ToList(), false);
            List <ClaimProc>  listClaimProcsForPat      = ClaimProcs.Refresh(PatCur.PatNum);
            List <PaySplit>   listPaySplitForSelectedCP = PaySplits.GetPaySplitsFromProcs(ClaimProcsToEdit.Select(x => x.ProcNum).ToList());
            List <Adjustment> listAdjForSelectedCP      = Adjustments.GetForProcs(ClaimProcsToEdit.Select(x => x.ProcNum).ToList());
            bool          isCreditGreater               = false;
            List <string> listProcDescripts             = new List <string>();

            for (int i = 0; i < ClaimProcsToEdit.Length; i++)
            {
                ClaimProc claimProcCur = ClaimProcsToEdit[i];
                int       insPayIdx    = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Ins Pay"));
                int       writeoffIdx  = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Writeoff"));
                int       feeAcctIdx   = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Fee"));
                decimal   insPayAmt    = (decimal)ClaimProcs.ProcInsPay(listClaimProcsForPat.FindAll(x => x.ClaimProcNum != claimProcCur.ClaimProcNum), claimProcCur.ProcNum)
                                         + PIn.Decimal(gridMain.ListGridRows[i].Cells[insPayIdx].Text);
                decimal writeOff = (decimal)ClaimProcs.ProcWriteoff(listClaimProcsForPat.FindAll(x => x.ClaimProcNum != claimProcCur.ClaimProcNum), claimProcCur.ProcNum)
                                   + PIn.Decimal(gridMain.ListGridRows[i].Cells[writeoffIdx].Text);
                decimal feeAcct   = PIn.Decimal(gridMain.ListGridRows[i].Cells[feeAcctIdx].Text);
                decimal adj       = listAdjForSelectedCP.Where(x => x.ProcNum == claimProcCur.ProcNum).Select(x => (decimal)x.AdjAmt).Sum();
                decimal patPayAmt = listPaySplitForSelectedCP.Where(x => x.ProcNum == claimProcCur.ProcNum).Select(x => (decimal)x.SplitAmt).Sum();
                //Any changes to this calculation should also consider FormClaimProc.IsClaimProcGreaterThanProcFee().
                decimal creditRem = feeAcct - patPayAmt - insPayAmt - writeOff + adj;
                isCreditGreater |= (creditRem.IsLessThanZero());
                if (creditRem.IsLessThanZero())
                {
                    Procedure proc = listProcs.FirstOrDefault(x => x.ProcNum == claimProcCur.ProcNum);
                    listProcDescripts.Add((proc == null ? "" : ProcedureCodes.GetProcCode(proc.CodeNum).ProcCode)
                                          + "\t" + Lan.g(this, "Fee") + ": " + feeAcct.ToString("F")
                                          + "\t" + Lan.g(this, "Credits") + ": " + (Math.Abs(-patPayAmt - insPayAmt - writeOff + adj)).ToString("F")
                                          + "\t" + Lan.g(this, "Remaining") + ": (" + Math.Abs(creditRem).ToString("F") + ")");
                }
            }
            if (!isCreditGreater)
            {
                return(true);
            }
            if (creditsGreaterPref == ClaimProcCreditsGreaterThanProcFee.Block)
            {
                MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(Lan.g(this, "Remaining amount is negative for the following procedures") + ":\r\n"
                                                             + string.Join("\r\n", listProcDescripts) + "\r\n" + Lan.g(this, "Not allowed to continue."));
                msgBox.Text = Lan.g(this, "Overpaid Procedure Warning");
                msgBox.ShowDialog();
                return(false);
            }
            if (creditsGreaterPref == ClaimProcCreditsGreaterThanProcFee.Warn)
            {
                return(MessageBox.Show(Lan.g(this, "Remaining amount is negative for the following procedures") + ":\r\n"
                                       + string.Join("\r\n", listProcDescripts.Take(10)) + "\r\n" + (listProcDescripts.Count > 10?"...\r\n":"") + Lan.g(this, "Continue?")
                                       , Lan.g(this, "Overpaid Procedure Warning"), MessageBoxButtons.OKCancel) == DialogResult.OK);
            }
            return(true);           //should never get to this line, only possible if another enum value is added to allow, warn, and block
        }
예제 #2
0
        private void FormProcEditAll_Load(object sender, EventArgs e)
        {
            ProcOldList = new List <Procedure>();
            for (int i = 0; i < ProcList.Count; i++)
            {
                ProcOldList.Add(ProcList[i].Copy());
            }
            AnyAreC = false;
            DateTime oldestDateEntryC = DateTime.Today;
            bool     datesAreSame     = true;

            for (int i = 0; i < ProcList.Count; i++)
            {
                if (ProcList[i].ProcStatus == ProcStat.C)
                {
                    AnyAreC = true;
                    if (ProcList[i].ProcDate < oldestDateEntryC)
                    {
                        oldestDateEntryC = ProcList[i].ProcDate;
                    }
                }
                if (ProcList[0].ProcDate != ProcList[i].ProcDate)
                {
                    datesAreSame = false;
                }
            }
            if (AnyAreC)
            {
                if (!Security.IsAuthorized(Permissions.ProcComplEdit, oldestDateEntryC))
                {
                    butOK.Enabled         = false;
                    butEditAnyway.Enabled = false;
                }
            }
            List <ClaimProc> ClaimProcList = ClaimProcs.Refresh(ProcList[0].PatNum);

            if (Procedures.IsAttachedToClaim(ProcList, ClaimProcList))
            {
                //StartedAttachedToClaim=true;
                //however, this doesn't stop someone from creating a claim while this window is open,
                //so this is checked at the end, too.
                textDate.Enabled      = false;
                butToday.Enabled      = false;
                butEditAnyway.Visible = true;
                labelClaim.Visible    = true;
            }
            if (datesAreSame)
            {
                textDate.Text = ProcList[0].ProcDate.ToShortDateString();
            }
        }
예제 #3
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textProcDate.errorProvider1.GetError(textProcDate) != "" ||
                textAmount.errorProvider1.GetError(textAmount) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (textProcDate.Text == "")
            {
                MsgBox.Show(this, "Please enter a date first.");
                return;
            }
            if (_procCur.ProcStatus == ProcStat.C && PIn.Date(textProcDate.Text).Date > DateTime.Today.Date && !PrefC.GetBool(PrefName.FutureTransDatesAllowed))
            {
                MsgBox.Show(this, "Completed procedures cannot be set for future dates.");
                return;
            }
            if (textAmount.Text == "")
            {
                MsgBox.Show(this, "Please enter an amount.");
                return;
            }
            if (comboProv.GetSelectedProvNum() != _procOld.ProvNum && PrefC.GetBool(PrefName.ProcProvChangesClaimProcWithClaim))
            {
                List <ClaimProc> listClaimProc = ClaimProcs.GetForProc(ClaimProcs.Refresh(_procOld.PatNum), _procOld.ProcNum);
                if (listClaimProc.Any(x => x.Status == ClaimProcStatus.Received ||
                                      x.Status == ClaimProcStatus.Supplemental ||
                                      x.Status == ClaimProcStatus.CapClaim))
                {
                    MsgBox.Show(this, "The provider cannot be changed when this procedure is attached to a claim.");
                    return;
                }
            }
            _procCur.ProcDate    = PIn.Date(textProcDate.Text);
            _procCur.ProcFee     = PIn.Double(textAmount.Text);
            _procCur.Note        = textChartNotes.Text;
            _procCur.BillingNote = textAccountNotes.Text;
            _procCur.ProvNum     = comboProv.GetSelectedProvNum();
            _procCur.ClinicNum   = comboClinic.SelectedClinicNum;
            Procedures.Update(_procCur, _procOld);
            ProcedureCode procedureCode = ProcedureCodes.GetProcCode(_procCur.CodeNum);
            string        logText       = procedureCode.ProcCode + " (" + _procCur.ProcStatus + "), " + Lan.g(this, "Fee") + ": " + _procCur.ProcFee.ToString("c") + ", " + procedureCode.Descript;

            SecurityLogs.MakeLogEntry(IsNew ? Permissions.ProcComplCreate : Permissions.ProcComplEdit, _procCur.PatNum, logText);
            DialogResult = DialogResult.OK;
        }
예제 #4
0
        ///<summary>Returns true if InsPayNoWriteoffMoreThanProc preference is turned on and the sum of write off amount is greater than the proc fee.
        ///Otherwise returns false </summary>
        private bool IsWriteOffGreaterThanProcFee()
        {
            if (!PrefC.GetBool(PrefName.InsPayNoWriteoffMoreThanProc))
            {
                return(false);               //InsPayNoWriteoffMoreThanProc preference is off. No need to check.
            }
            List <ClaimProc>  listClaimProcsForPat  = ClaimProcs.Refresh(PatCur.PatNum);
            List <Adjustment> listAdjustmentsForPat = Adjustments.GetForProcs(ClaimProcsToEdit.Select(x => x.ProcNum).Where(x => x != 0).ToList());
            bool          isWriteoffGreater         = false;
            List <string> listProcDescripts         = new List <string>();

            for (int i = 0; i < ClaimProcsToEdit.Length; i++)
            {
                ClaimProc claimProcCur = ClaimProcsToEdit[i];
                //Fetch all adjustments for the given procedure.
                List <Adjustment> listClaimProcAdjustments = listAdjustmentsForPat.Where(x => x.ProcNum == claimProcCur.ProcNum).ToList();
                int     writeoffIdx = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Writeoff"));
                int     feeAcctIdx  = gridMain.ListGridColumns.GetIndex(Lan.g("TableClaimProc", "Fee"));
                decimal writeOff    = (decimal)ClaimProcs.ProcWriteoff(listClaimProcsForPat.FindAll(x => x.ClaimProcNum != claimProcCur.ClaimProcNum), claimProcCur.ProcNum)
                                      + PIn.Decimal(gridMain.ListGridRows[i].Cells[writeoffIdx].Text);
                decimal feeAcct = PIn.Decimal(gridMain.ListGridRows[i].Cells[feeAcctIdx].Text);
                decimal adjAcct = listClaimProcAdjustments.Sum(x => (decimal)x.AdjAmt);
                //Any changes to this calculation should also consider FormClaimProc.IsWriteOffGreaterThanProc().
                decimal writeoffRem = feeAcct - writeOff + adjAcct;
                isWriteoffGreater |= (writeoffRem.IsLessThanZero() && writeOff.IsGreaterThanZero());
                if (writeoffRem.IsLessThanZero() && writeOff.IsGreaterThanZero())
                {
                    Procedure proc = Procedures.GetProcFromList(ProcList, claimProcCur.ProcNum);                 //will return a new procedure if none found.
                    listProcDescripts.Add((proc == null ? "" : ProcedureCodes.GetProcCode(proc.CodeNum).ProcCode)
                                          + "\t" + Lan.g(this, "Fee") + ": " + feeAcct.ToString("F")
                                          + "\t" + Lan.g(this, "Adjustments") + ": " + adjAcct.ToString("F")
                                          + "\t" + Lan.g(this, "Write-off") + ": " + (Math.Abs(-writeOff)).ToString("F")
                                          + "\t" + Lan.g(this, "Remaining") + ": (" + Math.Abs(writeoffRem).ToString("F") + ")");
                }
            }
            if (isWriteoffGreater)
            {
                MsgBoxCopyPaste msgBox = new MsgBoxCopyPaste(Lan.g(this, "Write-off amount is greater than the adjusted procedure fee for the following "
                                                                   + "procedure(s)") + ":\r\n" + string.Join("\r\n", listProcDescripts) + "\r\n" + Lan.g(this, "Not allowed to continue."));
                msgBox.Text = Lan.g(this, "Excessive Write-off");
                msgBox.ShowDialog();
                return(true);
            }
            return(false);
        }
예제 #5
0
        ///<summary>Deletes the patplan with the specified patPlanNum.  Rearranges the other patplans for the patient to keep the ordinal sequence contiguous.  Then, recomputes all estimates for this patient because their coverage is now different.  Also sets patient.HasIns to the correct value.</summary>
        public static void Delete(int patPlanNum)
        {
            string    command = "SELECT PatNum FROM patplan WHERE PatPlanNum=" + POut.PInt(patPlanNum);
            DataTable table   = General.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return;
            }
            int patNum = PIn.PInt(table.Rows[0][0].ToString());

            PatPlan[] patPlans    = Refresh(patNum);
            bool      doDecrement = false;

            for (int i = 0; i < patPlans.Length; i++)
            {
                if (doDecrement)                //patPlan has already been deleted, so decrement the rest.
                {
                    command = "UPDATE patplan SET Ordinal=" + POut.PInt(patPlans[i].Ordinal - 1)
                              + " WHERE PatPlanNum=" + POut.PInt(patPlans[i].PatPlanNum);
                    General.NonQ(command);
                    continue;
                }
                if (patPlans[i].PatPlanNum == patPlanNum)
                {
                    command = "DELETE FROM patplan WHERE PatPlanNum=" + POut.PInt(patPlanNum);
                    General.NonQ(command);
                    command = "DELETE FROM benefit WHERE PatPlanNum=" + POut.PInt(patPlanNum);
                    General.NonQ(command);
                    doDecrement = true;
                }
            }
            Family  fam = Patients.GetFamily(patNum);
            Patient pat = fam.GetPatient(patNum);

            ClaimProc[] claimProcs = ClaimProcs.Refresh(patNum);
            Procedure[] procs      = Procedures.Refresh(patNum);
            patPlans = PatPlans.Refresh(patNum);
            InsPlan[] planList = InsPlans.Refresh(fam);
            Benefit[] benList  = Benefits.Refresh(patPlans);
            Procedures.ComputeEstimatesForAll(patNum, claimProcs, procs, planList, patPlans, benList);
            Patients.SetHasIns(patNum);
        }
예제 #6
0
        ///<summary>Used when closing the edit plan window to find all patients using this plan and to update all claimProcs for each patient.  This keeps estimates correct.</summary>
        public static void ComputeEstimatesForPlan(int planNum)
        {
            string    command = "SELECT PatNum FROM patplan WHERE PlanNum=" + POut.PInt(planNum);
            DataTable table   = General.GetTable(command);
            int       patNum  = 0;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                patNum = PIn.PInt(table.Rows[i][0].ToString());
                Family      fam         = Patients.GetFamily(patNum);
                Patient     pat         = fam.GetPatient(patNum);
                ClaimProc[] claimProcs  = ClaimProcs.Refresh(patNum);
                Procedure[] procs       = Procedures.Refresh(patNum);
                InsPlan[]   plans       = InsPlans.Refresh(fam);
                PatPlan[]   patPlans    = PatPlans.Refresh(patNum);
                Benefit[]   benefitList = Benefits.Refresh(patPlans);
                Procedures.ComputeEstimatesForAll(patNum, claimProcs, procs, plans, patPlans, benefitList);
                Patients.SetHasIns(patNum);
            }
        }
예제 #7
0
        ///<summary>raised for each page to be printed.  One page per appointment.</summary>
        private void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            if (ApptNum != 0)           //just for one appointment
            {
                date = Appointments.DateSelected;
            }
            Graphics   g = ev.Graphics;
            float      y = 50;
            float      x = 0;
            string     str;
            float      sizeW;       //used when measuring text for placement
            Font       fontTitle   = new Font(FontFamily.GenericSansSerif, 11, FontStyle.Bold);
            Font       fontHeading = new Font(FontFamily.GenericSansSerif, 9, FontStyle.Bold);
            Font       font        = new Font(FontFamily.GenericSansSerif, 8);
            SolidBrush brush       = new SolidBrush(Color.Black);

            //Title----------------------------------------------------------------------------------------------------------
            str   = Lan.g(this, "Routing Slip");
            sizeW = g.MeasureString(str, fontTitle).Width;
            x     = 425 - sizeW / 2;
            g.DrawString(str, fontTitle, brush, x, y);
            y += 35;
            x  = 75;
            //Today's appointment, including procedures-----------------------------------------------------------------------
            Family  fam = Patients.GetFamily(Appts[pagesPrinted].PatNum);
            Patient pat = fam.GetPatient(Appts[pagesPrinted].PatNum);

            str = pat.GetNameFL();
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = Appts[pagesPrinted].AptDateTime.ToShortTimeString() + "  " + Appts[pagesPrinted].AptDateTime.ToShortDateString();
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = (Appts[pagesPrinted].Pattern.Length * 5).ToString() + " " + Lan.g(this, "minutes");
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Providers.GetAbbr(Appts[pagesPrinted].ProvNum);
            g.DrawString(str, font, brush, x, y);
            y += 15;
            if (Appts[pagesPrinted].ProvHyg != 0)
            {
                str = Providers.GetAbbr(Appts[pagesPrinted].ProvHyg);
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            str = Lan.g(this, "Procedures:");
            g.DrawString(str, font, brush, x, y);
            y += 15;
            Procedure[] procsAll = Procedures.Refresh(pat.PatNum);
            Procedure[] procsApt = Procedures.GetProcsOneApt(Appts[pagesPrinted].AptNum, procsAll);
            for (int i = 0; i < procsApt.Length; i++)
            {
                str = "   " + Procedures.GetDescription(procsApt[i]);
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            str = Lan.g(this, "Note:") + " " + Appts[pagesPrinted].Note;
            g.DrawString(str, font, brush, x, y);
            y += 25;
            //Patient/Family Info---------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Patient Info");
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = Lan.g(this, "PatNum:") + " " + pat.PatNum.ToString();
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Age:") + " ";
            if (pat.Age > 0)
            {
                str += pat.Age.ToString();
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Date of First Visit:") + " ";
            if (pat.DateFirstVisit.Year < 1880)
            {
                str += "?";
            }
            else if (pat.DateFirstVisit == Appts[pagesPrinted].AptDateTime.Date)
            {
                str += Lan.g(this, "New Patient");
            }
            else
            {
                str += pat.DateFirstVisit.ToShortDateString();
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Billing Type:") + " " + DefB.GetName(DefCat.BillingTypes, pat.BillingType);
            g.DrawString(str, font, brush, x, y);
            y += 15;
            Recall[] recallList = Recalls.GetList(new int[] { pat.PatNum });
            str = Lan.g(this, "Recall Due Date:") + " ";
            if (recallList.Length > 0)
            {
                str += recallList[0].DateDue.ToShortDateString();
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Medical notes:") + " " + pat.MedUrgNote;
            g.DrawString(str, font, brush, x, y);
            y += 25;
            //Other Family Members
            str = Lan.g(this, "Other Family Members");
            g.DrawString(str, fontHeading, brush, x, y);
            y += 18;
            for (int i = 0; i < fam.List.Length; i++)
            {
                if (fam.List[i].PatNum == pat.PatNum)
                {
                    continue;
                }
                str = fam.List[i].GetNameFL();
                if (fam.List[i].Age > 0)
                {
                    str += ",   " + fam.List[i].Age.ToString();
                }
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            y += 10;
            //Insurance Info--------------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Insurance");
            g.DrawString(str, fontHeading, brush, x, y);
            y += 18;
            PatPlan[]   patPlanList   = PatPlans.Refresh(pat.PatNum);
            InsPlan[]   plans         = InsPlans.Refresh(fam);
            ClaimProc[] claimProcList = ClaimProcs.Refresh(pat.PatNum);
            Benefit[]   benefits      = Benefits.Refresh(patPlanList);
            InsPlan     plan;
            Carrier     carrier;
            string      subscriber;
            double      max;
            double      deduct;

            if (patPlanList.Length == 0)
            {
                str = Lan.g(this, "none");
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            for (int i = 0; i < patPlanList.Length; i++)
            {
                plan    = InsPlans.GetPlan(patPlanList[i].PlanNum, plans);
                carrier = Carriers.GetCarrier(plan.CarrierNum);
                str     = carrier.CarrierName;
                g.DrawString(str, fontHeading, brush, x, y);
                y         += 18;
                subscriber = fam.GetNameInFamFL(plan.Subscriber);
                if (subscriber == "")               //subscriber from another family
                {
                    subscriber = Patients.GetLim(plan.Subscriber).GetNameLF();
                }
                str = Lan.g(this, "Subscriber:") + " " + subscriber;
                g.DrawString(str, font, brush, x, y);
                y += 15;
                bool isFamMax = Benefits.GetIsFamMax(benefits, plan.PlanNum);
                str = "";
                if (isFamMax)
                {
                    str += Lan.g(this, "Family ");
                }
                str += Lan.g(this, "Annual Max:") + " ";
                max  = Benefits.GetAnnualMax(benefits, plan.PlanNum, patPlanList[i].PatPlanNum);
                if (max != -1)
                {
                    str += max.ToString("n0") + " ";
                }
                str += "   ";
                bool isFamDed = Benefits.GetIsFamDed(benefits, plan.PlanNum);
                if (isFamDed)
                {
                    str += Lan.g(this, "Family ");
                }
                str   += Lan.g(this, "Deductible:") + " ";
                deduct = Benefits.GetDeductible(benefits, plan.PlanNum, patPlanList[i].PatPlanNum);
                if (deduct != -1)
                {
                    str += deduct.ToString("n0");
                }
                g.DrawString(str, font, brush, x, y);
                y  += 15;
                str = "";
                for (int j = 0; j < benefits.Length; j++)
                {
                    if (benefits[j].PlanNum != plan.PlanNum)
                    {
                        continue;
                    }
                    if (benefits[j].BenefitType != InsBenefitType.Percentage)
                    {
                        continue;
                    }
                    if (str != "")
                    {
                        str += ",  ";
                    }
                    str += CovCats.GetDesc(benefits[j].CovCatNum) + " " + benefits[j].Percent.ToString() + "%";
                }
                if (str != "")
                {
                    g.DrawString(str, font, brush, x, y);
                    y += 15;
                }
                double pend = 0;
                double used = 0;
                if (isFamMax || isFamDed)
                {
                    ClaimProc[] claimProcsFam = ClaimProcs.RefreshFam(plan.PlanNum);
                    used = InsPlans.GetInsUsed(claimProcsFam, date, plan.PlanNum, patPlanList[i].PatPlanNum, -1, plans, benefits);
                    pend = InsPlans.GetPending(claimProcsFam, date, plan, patPlanList[i].PatPlanNum, -1, benefits);
                }
                else
                {
                    used = InsPlans.GetInsUsed(claimProcList, date, plan.PlanNum, patPlanList[i].PatPlanNum, -1, plans, benefits);
                    pend = InsPlans.GetPending(claimProcList, date, plan, patPlanList[i].PatPlanNum, -1, benefits);
                }
                str = Lan.g(this, "Ins Used:") + " " + used.ToString("n");
                g.DrawString(str, font, brush, x, y);
                y  += 15;
                str = Lan.g(this, "Ins Pending:") + " " + pend.ToString("n");
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            y += 10;
            //Account Info---------------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Account Info");
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = Lan.g(this, "Guarantor:") + " " + fam.List[0].GetNameFL();
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Balance:") + (fam.List[0].BalTotal - fam.List[0].InsEst).ToString("c");
            if (fam.List[0].InsEst > .01)
            {
                str += "  (" + fam.List[0].BalTotal.ToString("c") + " - "
                       + fam.List[0].InsEst.ToString("c") + " " + Lan.g(this, "InsEst") + ")";
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Aging:")
                  + "  0-30:" + fam.List[0].Bal_0_30.ToString("c")
                  + "  31-60:" + fam.List[0].Bal_31_60.ToString("c")
                  + "  61-90:" + fam.List[0].Bal_61_90.ToString("c")
                  + "  90+:" + fam.List[0].BalOver90.ToString("c");
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Fam Urgent Fin Note:")
                  + fam.List[0].FamFinUrgNote;
            g.DrawString(str, font, brush, x, y);
            y += 15;
            y += 10;
            //Treatment Plan--------------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Treatment Plan");
            g.DrawString(str, fontHeading, brush, x, y);
            y += 18;
            for (int i = 0; i < procsAll.Length; i++)
            {
                if (procsAll[i].ProcStatus != ProcStat.TP)
                {
                    continue;
                }
                str = Procedures.GetDescription(procsAll[i]);
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            pagesPrinted++;
            if (pagesPrinted == Appts.Length)
            {
                ev.HasMorePages = false;
                pagesPrinted    = 0;
            }
            else
            {
                ev.HasMorePages = true;
            }
        }
예제 #8
0
        private void butNewClaims_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)           //No selections made.
            {
                MsgBox.Show(this, "Please select at least one procedure.");
                return;
            }
            if (!ContrAccount.CheckClearinghouseDefaults())
            {
                return;
            }
            //Generate List and Table----------------------------------------------------------------------------------------------------------------------
            //List of all procedures being shown.
            //Pulls procedures based off of the PatNum, if the row was selected in gridMain and if it has been attached to a claim.
            List <ProcNotBilled> listNotBilledProcs = new List <ProcNotBilled>();
            List <long>          listPatNums        = new List <long>();
            Patient          patOld            = new Patient();
            List <Claim>     listPatClaims     = new List <Claim>();
            List <ClaimProc> listPatClaimProcs = new List <ClaimProc>();
            List <ClaimProc> listCurClaimProcs = new List <ClaimProc>();
            //Table rows need to be 1:1 with gridMain rows due to logic in ContrAccount.toolBarButIns_Click(...).
            DataTable table = new DataTable();

            //Required columns as mentioned by ContrAccount.toolBarButIns_Click().
            table.Columns.Add("ProcNum");
            table.Columns.Add("chargesDouble");
            table.Columns.Add("ProcNumLab");
            for (int i = 0; i < gridMain.Rows.Count; i++)                         //Loop through gridMain to construct listNotBilledProcs.
            {
                long      procNumCur = PIn.Long(gridMain.Rows[i].Tag.ToString()); //Tag is set to procNum in fillGrid().
                Procedure procCur    = Procedures.GetOneProc(procNumCur, false);
                long      patNumCur  = procCur.PatNum;
                if (patOld.PatNum != patNumCur)               //Procedures in gridMain are ordered by patient, so when the patient changes, we know previous patient is complete.
                {
                    listPatClaims     = Claims.Refresh(patNumCur);
                    listPatClaimProcs = ClaimProcs.Refresh(patNumCur);
                    patOld            = Patients.GetPat(procCur.PatNum);
                }
                listCurClaimProcs = ClaimProcs.GetForProc(listPatClaimProcs, procNumCur);
                bool hasPriClaim = false;
                bool hasSecClaim = false;
                for (int j = 0; j < listCurClaimProcs.Count; j++)
                {
                    ClaimProc claimProcCur = listCurClaimProcs[j];
                    if (claimProcCur.ClaimNum > 0 && claimProcCur.Status != ClaimProcStatus.Preauth && claimProcCur.Status != ClaimProcStatus.Estimate)
                    {
                        Claim claimCur = Claims.GetFromList(listPatClaims, claimProcCur.ClaimNum);
                        switch (claimCur.ClaimType)
                        {
                        case "P":
                            hasPriClaim = true;
                            break;

                        case "S":
                            hasSecClaim = true;
                            break;
                        }
                    }
                }
                bool isSelected = gridMain.SelectedIndices.Contains(i);
                listNotBilledProcs.Add(new ProcNotBilled(patOld, procNumCur, i, isSelected, hasPriClaim, hasSecClaim, procCur.ClinicNum, procCur.PlaceService));
                DataRow row = table.NewRow();
                row["ProcNum"] = procNumCur;
                #region Calculate chargesDouble
                //Logic copied from AccountModules.GetAccount(...) line 857.
                double qty = (procCur.UnitQty + procCur.BaseUnits);
                if (qty == 0)
                {
                    qty = 1;
                }
                double writeOffCapSum = listPatClaimProcs.Where(x => x.Status == ClaimProcStatus.CapComplete).Select(y => y.WriteOff).ToList().Sum();
                row["chargesDouble"] = (procCur.ProcFee * qty) - writeOffCapSum;
                row["ProcNumLab"]    = procCur.ProcNumLab;
                #endregion Calculate chargesDouble
                table.Rows.Add(row);
                if (listPatNums.Contains(patNumCur))
                {
                    continue;
                }
                listPatNums.Add(patNumCur);
            }
            List <List <ProcNotBilled> > listGroupedProcs = new List <List <ProcNotBilled> >();
            Patient          patCur           = null;
            List <PatPlan>   listPatPlans     = null;
            List <InsSub>    listInsSubs      = null;
            List <InsPlan>   listInsPlans     = null;
            List <Procedure> listPatientProcs = null;
            ProcNotBilled    procNotBilled    = new ProcNotBilled();    //When automatically grouping,  this is used as the procedure to group by.
            long             patNumOld        = 0;
            int claimCreatedCount             = 0;
            int patIndex = 0;
            //The procedures show in the grid ordered by patient.  Also listPatNums contains unique patnums which are in the same order as the grid.
            while (patIndex < listPatNums.Count)
            {
                List <ProcNotBilled> listProcs = listNotBilledProcs.Where(x => x.Patient.PatNum == listPatNums[patIndex] && x.IsRowSelected && !x.IsAttached).ToList();
                if (listProcs.Count == 0)
                {
                    patNumOld = listPatNums[patIndex];
                    patIndex++;                    //No procedures were selected for this patient.
                    continue;
                }
                else
                {
                    //Maintain the same patient, in order to create one or more additional claims for the remaining procedures.
                    //Currently will only happen for specific instances;
                    //--Canadian customers who are attempting to create a claim with over 7 procedures.
                    //--When checkAutoGroupProcs is checked and when there are multiple procedure groupings by GroupKey status, ClinicNum, and placeService.
                }
                if (patNumOld != listPatNums[patIndex])               //The patient could repeat if we had to group the procedures for the patinet into multiple claims.
                {
                    patCur           = Patients.GetPat(listPatNums[patIndex]);
                    listPatPlans     = PatPlans.Refresh(patCur.PatNum);
                    listInsSubs      = InsSubs.RefreshForFam(Patients.GetFamily(patCur.PatNum));
                    listInsPlans     = InsPlans.RefreshForSubList(listInsSubs);
                    listPatientProcs = Procedures.Refresh(patCur.PatNum);
                }
                if (checkAutoGroupProcs.Checked)                 //Automatically Group Procedures.
                {
                    procNotBilled = listProcs[0];
                    //Update listProcs to reflect those that match the procNotBilled values.
                    listProcs = listProcs.FindAll(x => x.HasPriClaim == procNotBilled.HasPriClaim && x.HasSecClaim == procNotBilled.HasSecClaim);
                    if (PrefC.HasClinicsEnabled)                     //Group by clinic only if clinics enabled.
                    {
                        listProcs = listProcs.FindAll(x => x.ClinicNum == procNotBilled.ClinicNum);
                    }
                    else if (!PrefC.GetBool(PrefName.EasyHidePublicHealth))                     //Group by Place of Service only if Public Health feature is enabled.
                    {
                        listProcs = listProcs.FindAll(x => x.PlaceService == procNotBilled.PlaceService);
                    }
                }
                GetUniqueDiagnosticCodes(listProcs, listPatientProcs, listPatPlans, listInsSubs, listInsPlans);
                if (listProcs.Count > 7 && CultureInfo.CurrentCulture.Name.EndsWith("CA")) //Canadian. en-CA or fr-CA
                {
                    listProcs = listProcs.Take(7).ToList();                                //Returns first 7 items of the list.
                }
                listProcs.ForEach(x => x.IsAttached = true);                               //This way we can not attach procedures to multiple claims thanks to the logic above.
                if (listProcs.Any(x => listProcs[0].PlaceService != x.PlaceService) || listProcs.Any(x => listProcs[0].ClinicNum != x.ClinicNum))
                {
                    //Regardless if we are automatically grouping or not,
                    //if all procs in our list at this point do not share the same PlaceService or ClinicNum then claims will not be made.
                }
                else                  //Basic validation passed.
                {
                    if (!listProcs[0].HasPriClaim &&                 //Medical claim.
                        PatPlans.GetOrdinal(PriSecMed.Medical, listPatPlans, listInsPlans, listInsSubs) > 0 &&                    //Has medical ins.
                        PatPlans.GetOrdinal(PriSecMed.Primary, listPatPlans, listInsPlans, listInsSubs) == 0 &&                    //Does not have primary dental ins.
                        PatPlans.GetOrdinal(PriSecMed.Secondary, listPatPlans, listInsPlans, listInsSubs) == 0)                       //Does not have secondary dental ins.
                    {
                        claimCreatedCount++;
                    }
                    else                                                                                                                      //Not a medical claim.
                    {
                        if (!listProcs[0].HasPriClaim && PatPlans.GetOrdinal(PriSecMed.Primary, listPatPlans, listInsPlans, listInsSubs) > 0) //Primary claim.
                        {
                            claimCreatedCount++;
                        }
                        if (!listProcs[0].HasSecClaim && PatPlans.GetOrdinal(PriSecMed.Secondary, listPatPlans, listInsPlans, listInsSubs) > 0)                  //Secondary claim.
                        {
                            claimCreatedCount++;
                        }
                    }
                }
                listGroupedProcs.Add(listProcs);
            }
            if (!MsgBox.Show(this, true, "Clicking continue will create up to " + POut.Int(claimCreatedCount) + " claims and cannot be undone, except by manually going to each account.  "
                             + "Some claims may not be created if there are validation issues.  Would you like to proceed?"))
            {
                return;
            }
            //Create Claims--------------------------------------------------------------------------------------------------------------------------------
            claimCreatedCount = 0;
            string claimErrors = "";
            foreach (List <ProcNotBilled> listProcs in listGroupedProcs)
            {
                patCur = listProcs[0].Patient;
                gridMain.SetSelected(false);                //Need to deslect all rows each time so that ContrAccount.toolBarButIns_Click(...) only uses pertinent rows.
                for (int j = 0; j < listProcs.Count; j++)
                {
                    gridMain.SetSelected(listProcs[j].RowIndex, true);                   //Select the pertinent rows so that they will be attached to the claim below.
                }
                ContrAccount.toolBarButIns_Click(false, patCur, Patients.GetFamily(patCur.PatNum), gridMain, table,
                                                 procNotBilled.HasPriClaim, procNotBilled.HasSecClaim);
                string errorTitle = patCur.PatNum + " " + patCur.GetNameLFnoPref() + " - ";
                if (patNumOld == patCur.PatNum && !string.IsNullOrEmpty(ContrAccount.ClaimErrorsCur))
                {
                    claimErrors += "\t\t" + ContrAccount.ClaimErrorsCur + "\r\n";
                }
                else if (!string.IsNullOrEmpty(ContrAccount.ClaimErrorsCur))
                {
                    claimErrors += errorTitle + ContrAccount.ClaimErrorsCur + "\r\n";
                }
                claimCreatedCount += ContrAccount.ClaimCreatedCount;
                patNumOld          = patCur.PatNum;
            }
            FillGrid();
            if (!string.IsNullOrEmpty(claimErrors))
            {
                MsgBoxCopyPaste form = new MsgBoxCopyPaste(claimErrors);
                form.ShowDialog();
            }
            MessageBox.Show(Lan.g(this, "Number of claims created") + ": " + claimCreatedCount);
        }
예제 #9
0
        private void FillProcedure()
        {
            if (_adjustmentCur.ProcNum == 0)
            {
                textProcDate2.Text       = "";
                textProcProv.Text        = "";
                textProcTooth.Text       = "";
                textProcDescription.Text = "";
                textProcFee.Text         = "";
                textProcWriteoff.Text    = "";
                textProcInsPaid.Text     = "";
                textProcInsEst.Text      = "";
                textProcAdj.Text         = "";
                textProcPatPaid.Text     = "";
                textProcAdjCur.Text      = "";
                labelProcRemain.Text     = "";
                _adjRemAmt = 0;
                return;
            }
            Procedure         procCur         = Procedures.GetOneProc(_adjustmentCur.ProcNum, false);
            List <ClaimProc>  listClaimProcs  = ClaimProcs.Refresh(procCur.PatNum);
            List <Adjustment> listAdjustments = Adjustments.Refresh(procCur.PatNum)
                                                .Where(x => x.ProcNum == procCur.ProcNum && x.AdjNum != _adjustmentCur.AdjNum).ToList();

            textProcDate.Text        = procCur.ProcDate.ToShortDateString();
            textProcDate2.Text       = procCur.ProcDate.ToShortDateString();
            textProcProv.Text        = Providers.GetAbbr(procCur.ProvNum);
            textProcTooth.Text       = Tooth.ToInternat(procCur.ToothNum);
            textProcDescription.Text = ProcedureCodes.GetProcCode(procCur.CodeNum).Descript;
            double procWO      = -ClaimProcs.ProcWriteoff(listClaimProcs, procCur.ProcNum);
            double procInsPaid = -ClaimProcs.ProcInsPay(listClaimProcs, procCur.ProcNum);
            double procInsEst  = -ClaimProcs.ProcEstNotReceived(listClaimProcs, procCur.ProcNum);
            double procAdj     = listAdjustments.Sum(x => x.AdjAmt);
            double procPatPaid = -PaySplits.GetTotForProc(procCur);

            textProcFee.Text      = procCur.ProcFeeTotal.ToString("F");
            textProcWriteoff.Text = procWO == 0?"":procWO.ToString("F");
            textProcInsPaid.Text  = procInsPaid == 0?"":procInsPaid.ToString("F");
            textProcInsEst.Text   = procInsEst == 0?"":procInsEst.ToString("F");
            textProcAdj.Text      = procAdj == 0?"":procAdj.ToString("F");
            textProcPatPaid.Text  = procPatPaid == 0?"":procPatPaid.ToString("F");
            //Intelligently sum the values above based on statuses instead of blindly adding all of the values together.
            //The remaining amount is typically called the "patient portion" so utilze the centralized method that gets the patient portion.
            decimal patPort    = ClaimProcs.GetPatPortion(procCur, listClaimProcs, listAdjustments);
            double  procAdjCur = 0;

            if (textAmount.errorProvider1.GetError(textAmount) == "")
            {
                if (listTypePos.SelectedIndex > -1)              //pos
                {
                    procAdjCur = PIn.Double(textAmount.Text);
                }
                else if (listTypeNeg.SelectedIndex > -1 || Defs.GetValue(DefCat.AdjTypes, _adjustmentCur.AdjType) == "dp")           //neg or discount plan
                {
                    procAdjCur = -PIn.Double(textAmount.Text);
                }
            }
            textProcAdjCur.Text = procAdjCur == 0?"":procAdjCur.ToString("F");
            //Add the current adjustment amount to the patient portion which will give the newly calculated remaining amount.
            _adjRemAmt           = (decimal)procAdjCur + (decimal)procPatPaid + patPort;
            labelProcRemain.Text = _adjRemAmt.ToString("c");
        }
예제 #10
0
        ///<summary>Updates all claimproc estimates and also updates claim totals to db. Must supply procList which includes all procedures that this claim is linked to.  Will also need to refresh afterwards to see the results</summary>
        public static void CalculateAndUpdate(List <Procedure> procList, List <InsPlan> planList, Claim claimCur, List <PatPlan> patPlans, List <Benefit> benefitList, int patientAge, List <InsSub> subList)
        {
            //we need more than just the claimprocs for this claim.
            //in order to run Procedures.ComputeEstimates, we need all claimprocs for all procedures attached to this claim
            List <ClaimProc> ClaimProcsAll      = ClaimProcs.Refresh(claimCur.PatNum);
            List <ClaimProc> ClaimProcsForClaim = ClaimProcs.RefreshForClaim(claimCur.ClaimNum);         //will be ordered by line number.
            double           claimFee           = 0;
            double           dedApplied         = 0;
            double           insPayEst          = 0;
            double           insPayAmt          = 0;
            double           writeoff           = 0;
            InsPlan          plan = InsPlans.GetPlan(claimCur.PlanNum, planList);

            if (plan == null)
            {
                return;
            }
            long patPlanNum = PatPlans.GetPatPlanNum(claimCur.InsSubNum, patPlans);

            //first loop handles totals for received items.
            for (int i = 0; i < ClaimProcsForClaim.Count; i++)
            {
                if (ClaimProcsForClaim[i].Status != ClaimProcStatus.Received)
                {
                    continue;                    //disregard any status except Receieved.
                }
                claimFee   += ClaimProcsForClaim[i].FeeBilled;
                dedApplied += ClaimProcsForClaim[i].DedApplied;
                insPayEst  += ClaimProcsForClaim[i].InsPayEst;
                insPayAmt  += ClaimProcsForClaim[i].InsPayAmt;
                writeoff   += ClaimProcsForClaim[i].WriteOff;
            }
            //loop again only for procs not received.
            //And for preauth.
            Procedure ProcCur;
            //InsPlan plan=InsPlans.GetPlan(claimCur.PlanNum,planList);
            List <ClaimProcHist> histList         = ClaimProcs.GetHistList(claimCur.PatNum, benefitList, patPlans, planList, claimCur.ClaimNum, claimCur.DateService, subList);
            List <ClaimProc>     claimProcListOld = new List <ClaimProc>();    //make a copy

            for (int i = 0; i < ClaimProcsAll.Count; i++)
            {
                claimProcListOld.Add(ClaimProcsAll[i].Copy());
            }
            List <ClaimProcHist> loopList = new List <ClaimProcHist>();

            for (int i = 0; i < ClaimProcsForClaim.Count; i++)       //loop through each proc
            {
                ProcCur = Procedures.GetProcFromList(procList, ClaimProcsForClaim[i].ProcNum);
                //in order for ComputeEstimates to give accurate Writeoff when creating a claim, InsPayEst must be filled for the claimproc with status of NotReceived.
                //So, we must set it here.  We need to set it in the claimProcsAll list.  Find the matching one.
                for (int j = 0; j < ClaimProcsAll.Count; j++)
                {
                    if (ClaimProcsAll[j].ClaimProcNum == ClaimProcsForClaim[i].ClaimProcNum)                  //same claimproc in a different list
                    {
                        if (ClaimProcsForClaim[i].Status == ClaimProcStatus.NotReceived &&
                            ProcCur != null)                             //ignores payments, etc
                        {
                            ClaimProcsAll[j].InsPayEst = ClaimProcs.GetInsEstTotal(ClaimProcsAll[j]);
                        }
                    }
                }
                //When this is the secondary claim, HistList includes the primary estimates, which is something we don't want because the primary calculations gets confused.
                //So, we must remove those bad entries from histList.
                for (int h = histList.Count - 1; h >= 0; h--)         //loop through the histList backwards
                {
                    if (histList[h].ProcNum != ProcCur.ProcNum)
                    {
                        continue;                        //Makes sure we will only be excluding histList entries for procs on this claim.
                    }
                    //we already excluded this claimNum when getting the histList.
                    if (histList[h].Status != ClaimProcStatus.NotReceived)
                    {
                        continue;                        //The only ones that are a problem are the ones on the primary claim not received yet.
                    }
                    histList.RemoveAt(h);
                }
                Procedures.ComputeEstimates(ProcCur, claimCur.PatNum, ref ClaimProcsAll, false, planList, patPlans, benefitList, histList, loopList, false, patientAge, subList);
                //then, add this information to loopList so that the next procedure is aware of it.
                loopList.AddRange(ClaimProcs.GetHistForProc(ClaimProcsAll, ProcCur.ProcNum, ProcCur.CodeNum));
            }
            //save changes in the list to the database
            ClaimProcs.Synch(ref ClaimProcsAll, claimProcListOld);
            ClaimProcsForClaim = ClaimProcs.RefreshForClaim(claimCur.ClaimNum);
            //But ClaimProcsAll has not been refreshed.
            for (int i = 0; i < ClaimProcsForClaim.Count; i++)
            {
                if (ClaimProcsForClaim[i].Status != ClaimProcStatus.NotReceived &&
                    ClaimProcsForClaim[i].Status != ClaimProcStatus.Preauth &&
                    ClaimProcsForClaim[i].Status != ClaimProcStatus.CapClaim)
                {
                    continue;
                }
                ProcCur = Procedures.GetProcFromList(procList, ClaimProcsForClaim[i].ProcNum);
                if (ProcCur.ProcNum == 0)
                {
                    continue;                    //ignores payments, etc
                }
                //fee:
                int qty = ProcCur.UnitQty + ProcCur.BaseUnits;
                if (qty == 0)
                {
                    qty = 1;
                }
                if (plan.ClaimsUseUCR)                 //use UCR for the provider of the procedure
                {
                    long provNum = ProcCur.ProvNum;
                    if (provNum == 0)                   //if no prov set, then use practice default.
                    {
                        provNum = PrefC.GetLong(PrefName.PracticeDefaultProv);
                    }
                    //get the fee based on code and prov fee sched
                    double feebilled = Fees.GetAmount0(ProcCur.CodeNum, ProviderC.ListLong[Providers.GetIndexLong(provNum)].FeeSched);
                    if (feebilled > ProcCur.ProcFee)
                    {
                        ClaimProcsForClaim[i].FeeBilled = qty * feebilled;
                    }
                    else
                    {
                        ClaimProcsForClaim[i].FeeBilled = qty * ProcCur.ProcFee;
                    }
                }
                //else if(claimCur.ClaimType=="Cap") {//Even for capitation, use the proc fee.
                //	ClaimProcsForClaim[i].FeeBilled=0;
                //}
                else                  //don't use ucr.  Use the procedure fee instead.
                {
                    ClaimProcsForClaim[i].FeeBilled = qty * ProcCur.ProcFee;
                }
                claimFee += ClaimProcsForClaim[i].FeeBilled;
                if (claimCur.ClaimType == "PreAuth" || claimCur.ClaimType == "Other" || claimCur.ClaimType == "Cap")
                {
                    //only the fee gets calculated, the rest does not
                    ClaimProcs.Update(ClaimProcsForClaim[i]);
                    continue;
                }
                //ClaimProcs.ComputeBaseEst(ClaimProcsForClaim[i],ProcCur.ProcFee,ProcCur.ToothNum,ProcCur.CodeNum,plan,patPlanNum,benefitList,histList,loopList);
                ClaimProcsForClaim[i].InsPayEst  = ClaimProcs.GetInsEstTotal(ClaimProcsForClaim[i]); //Yes, this is duplicated from further up.
                ClaimProcsForClaim[i].DedApplied = ClaimProcs.GetDedEst(ClaimProcsForClaim[i]);
                if (ClaimProcsForClaim[i].Status == ClaimProcStatus.NotReceived)                     //(vs preauth)
                {
                    ClaimProcsForClaim[i].WriteOff = ClaimProcs.GetWriteOffEstimate(ClaimProcsForClaim[i]);
                    writeoff += ClaimProcsForClaim[i].WriteOff;

                    /*
                     * ClaimProcsForClaim[i].WriteOff=0;
                     * if(claimCur.ClaimType=="P" && plan.PlanType=="p") {//Primary && PPO
                     *      double insplanAllowed=Fees.GetAmount(ProcCur.CodeNum,plan.FeeSched);
                     *      if(insplanAllowed!=-1) {
                     *              ClaimProcsForClaim[i].WriteOff=ProcCur.ProcFee-insplanAllowed;
                     *      }
                     *      //else, if -1 fee not found, then do not show a writeoff. User can change writeoff if they disagree.
                     * }
                     * writeoff+=ClaimProcsForClaim[i].WriteOff;*/
                }
                dedApplied += ClaimProcsForClaim[i].DedApplied;
                insPayEst  += ClaimProcsForClaim[i].InsPayEst;
                ClaimProcsForClaim[i].ProcDate = ProcCur.ProcDate.Date;              //this solves a rare bug. Keeps dates synched.
                //It's rare enough that I'm not goint to add it to the db maint tool.
                ClaimProcs.Update(ClaimProcsForClaim[i]);
                //but notice that the ClaimProcs lists are not refreshed until the loop is finished.
            }            //for claimprocs.forclaim
            claimCur.ClaimFee   = claimFee;
            claimCur.DedApplied = dedApplied;
            claimCur.InsPayEst  = insPayEst;
            claimCur.InsPayAmt  = insPayAmt;
            claimCur.WriteOff   = writeoff;
            //Cur=ClaimCur;
            Claims.Update(claimCur);
        }
예제 #11
0
        private void FillProcedure()
        {
            if (PaySplitCur.ProcNum == 0)
            {
                textProcDate2.Text       = "";
                textProcProv.Text        = "";
                textProcTooth.Text       = "";
                textProcDescription.Text = "";
                ProcFee               = 0;
                textProcFee.Text      = "";
                ProcInsPaid           = 0;
                textProcInsPaid.Text  = "";
                ProcInsEst            = 0;
                textProcInsEst.Text   = "";
                ProcAdj               = 0;
                textProcAdj.Text      = "";
                ProcPrevPaid          = 0;
                textProcPrevPaid.Text = "";
                ProcPaidHere          = 0;
                textProcPaidHere.Text = "";
                labelProcRemain.Text  = "";
                //butAttach.Enabled=true;
                //butDetach.Enabled=false;
                //ComputeProcTotals();
                return;
            }
            Procedure ProcCur = Procedures.GetOneProc(PaySplitCur.ProcNum, false);

            ClaimProc[]  ClaimProcList  = ClaimProcs.Refresh(ProcCur.PatNum);
            Adjustment[] AdjustmentList = Adjustments.Refresh(ProcCur.PatNum);
            PaySplit[]   PaySplitList   = PaySplits.Refresh(ProcCur.PatNum);
            textProcDate.Text        = ProcCur.ProcDate.ToShortDateString();
            textProcDate2.Text       = ProcCur.ProcDate.ToShortDateString();
            textProcProv.Text        = Providers.GetAbbr(ProcCur.ProvNum);
            textProcTooth.Text       = Tooth.ToInternat(ProcCur.ToothNum);
            textProcDescription.Text = ProcedureCodes.GetProcCode(ProcCur.ADACode).Descript;
            ProcFee     = ProcCur.ProcFee;
            ProcInsPaid = -ClaimProcs.ProcInsPay(ClaimProcList, ProcCur.ProcNum);
            ProcInsEst  = -ClaimProcs.ProcEstNotReceived(ClaimProcList, ProcCur.ProcNum);
            ProcAdj     = Adjustments.GetTotForProc(ProcCur.ProcNum, AdjustmentList);
            //next line will still work even if IsNew
            ProcPrevPaid     = -PaySplits.GetTotForProc(ProcCur.ProcNum, PaySplitList, PaySplitCur.SplitNum);
            textProcFee.Text = ProcFee.ToString("F");
            if (ProcInsPaid == 0)
            {
                textProcInsPaid.Text = "";
            }
            else
            {
                textProcInsPaid.Text = ProcInsPaid.ToString("F");
            }
            if (ProcInsEst == 0)
            {
                textProcInsEst.Text = "";
            }
            else
            {
                textProcInsEst.Text = ProcInsEst.ToString("F");
            }
            if (ProcAdj == 0)
            {
                textProcAdj.Text = "";
            }
            else
            {
                textProcAdj.Text = ProcAdj.ToString("F");
            }
            if (ProcPrevPaid == 0)
            {
                textProcPrevPaid.Text = "";
            }
            else
            {
                textProcPrevPaid.Text = ProcPrevPaid.ToString("F");
            }
            ComputeProcTotals();
            //butAttach.Enabled=false;
            //butDetach.Enabled=true;
        }
예제 #12
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            RepeatCharge[] chargeList  = RepeatCharges.Refresh(0);         //Gets all repeating charges for all patients, they may be disabled
            int            countAdded  = 0;
            int            claimsAdded = 0;
            DateTime       startDate;
            Procedure      proc;

            for (int i = 0; i < chargeList.Length; i++)
            {
                if (!chargeList[i].IsEnabled)                 //first make sure it is not disabled
                {
                    continue;
                }
                if (chargeList[i].DateStart > DateTime.Today)              //not started yet
                {
                    continue;
                }
                //if(chargeList[i].DateStop.Year>1880//not blank
                //	&& chargeList[i].DateStop<DateTime.Today)//but already ended
                //{
                //	continue;
                //}
                //get a list dates of all completed procedures with this Code and patNum
                ArrayList ALdates = RepeatCharges.GetDates(ProcedureCodes.GetCodeNum(chargeList[i].ProcCode), chargeList[i].PatNum);
                startDate = chargeList[i].DateStart;
                //This is the repeating date using the old methodology.  It is necessary for checking if the repeating procedure was already added using the old methodology.
                DateTime possibleDateOld = startDate;
                //This is a more accurate repeating date which will allow procedures to be added on the 28th and later.
                DateTime possibleDateNew = startDate;
                int      countMonths     = 0;
                //start looping through possible dates, beginning with the start date of the repeating charge
                while (possibleDateNew <= DateTime.Today)
                {
                    //Only allow back dating up to one month and 20 days.
                    if (possibleDateNew < DateTime.Today.AddDays(-50))
                    {
                        possibleDateOld = possibleDateOld.AddMonths(1);
                        countMonths++;
                        possibleDateNew = startDate.AddMonths(countMonths);
                        continue;                        //don't go back more than one month and 20 days
                    }
                    //check to see if the possible date is present in the list
                    if (ALdates.Contains(possibleDateNew) ||
                        ALdates.Contains(possibleDateOld))
                    {
                        possibleDateOld = possibleDateOld.AddMonths(1);
                        countMonths++;
                        possibleDateNew = startDate.AddMonths(countMonths);
                        continue;
                    }
                    if (chargeList[i].DateStop.Year > 1880 &&              //not blank
                        chargeList[i].DateStop < possibleDateNew)                           //but already ended
                    {
                        break;
                    }
                    //otherwise, insert a procedure to db
                    proc                = new Procedure();
                    proc.CodeNum        = ProcedureCodes.GetCodeNum(chargeList[i].ProcCode);
                    proc.DateEntryC     = DateTimeOD.Today;
                    proc.PatNum         = chargeList[i].PatNum;
                    proc.ProcDate       = possibleDateNew;
                    proc.DateTP         = possibleDateNew;
                    proc.ProcFee        = chargeList[i].ChargeAmt;
                    proc.ProcStatus     = ProcStat.C;
                    proc.ProvNum        = PrefC.GetLong(PrefName.PracticeDefaultProv);
                    proc.MedicalCode    = ProcedureCodes.GetProcCode(proc.CodeNum).MedicalCode;
                    proc.BaseUnits      = ProcedureCodes.GetProcCode(proc.CodeNum).BaseUnits;
                    proc.DiagnosticCode = PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
                    //Check if the repeating charge has been flagged to copy it's note into the billing note of the procedure.
                    if (chargeList[i].CopyNoteToProc)
                    {
                        proc.BillingNote = chargeList[i].Note;
                    }
                    Procedures.Insert(proc);                    //no recall synch needed because dental offices don't use this feature
                    countAdded++;
                    possibleDateOld = possibleDateOld.AddMonths(1);
                    countMonths++;
                    possibleDateNew = startDate.AddMonths(countMonths);
                    if (chargeList[i].CreatesClaim && !ProcedureCodes.GetProcCode(chargeList[i].ProcCode).NoBillIns)
                    {
                        List <PatPlan>   patPlanList = PatPlans.Refresh(chargeList[i].PatNum);
                        List <InsSub>    subList     = InsSubs.RefreshForFam(Patients.GetFamily(chargeList[i].PatNum));
                        List <InsPlan>   insPlanList = InsPlans.RefreshForSubList(subList);;
                        List <Benefit>   benefitList = Benefits.Refresh(patPlanList, subList);
                        Claim            claimCur;
                        List <Procedure> procCurList = new List <Procedure>();
                        procCurList.Add(proc);
                        if (patPlanList.Count == 0)                       //no current insurance, do not create a claim
                        {
                            continue;
                        }
                        //create the claimprocs
                        Procedures.ComputeEstimates(proc, proc.PatNum, new List <ClaimProc>(), true, insPlanList, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList);
                        //get claimprocs for this proc, may be more than one
                        List <ClaimProc> claimProcList = ClaimProcs.GetForProc(ClaimProcs.Refresh(proc.PatNum), proc.ProcNum);
                        string           claimType     = "P";
                        if (patPlanList.Count == 1 && PatPlans.GetOrdinal(PriSecMed.Medical, patPlanList, insPlanList, subList) > 0)                  //if there's exactly one medical plan
                        {
                            claimType = "Med";
                        }
                        claimCur      = CreateClaim(claimType, patPlanList, insPlanList, claimProcList, proc, subList);
                        claimProcList = ClaimProcs.Refresh(proc.PatNum);
                        if (claimCur.ClaimNum == 0)
                        {
                            continue;
                        }
                        claimsAdded++;
                        ClaimL.CalculateAndUpdate(procCurList, insPlanList, claimCur, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList);
                        if (PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, insPlanList, subList) > 0 &&                //if there exists a secondary plan
                            !CultureInfo.CurrentCulture.Name.EndsWith("CA"))                               //and not canada (don't create secondary claim for canada)
                        {
                            claimCur = CreateClaim("S", patPlanList, insPlanList, claimProcList, proc, subList);
                            if (claimCur.ClaimNum == 0)
                            {
                                continue;
                            }
                            claimsAdded++;
                            claimProcList        = ClaimProcs.Refresh(proc.PatNum);
                            claimCur.ClaimStatus = "H";
                            ClaimL.CalculateAndUpdate(procCurList, insPlanList, claimCur, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList);
                        }
                    }
                }
            }
            //MessageBox.Show(countAdded.ToString()+" "+Lan.g(this,"procedures added."));
            MessageBox.Show(countAdded.ToString() + " " + Lan.g(this, "procedures added.") + "\r\n" + claimsAdded.ToString() + " " + Lan.g(this, "claims added."));
            DialogResult = DialogResult.OK;
        }
예제 #13
0
        private void FormProcEditAll_Load(object sender, EventArgs e)
        {
            ProcOldList = new List <Procedure>();
            for (int i = 0; i < ProcList.Count; i++)
            {
                ProcOldList.Add(ProcList[i].Copy());
            }
            _hasCompletedProc = false;
            _hasExistingProc  = false;
            DateTime oldestProcDate = DateTime.Today;
            bool     datesAreSame   = true;
            bool     areAllBypass   = true;

            for (int i = 0; i < ProcList.Count; i++)
            {
                if (ProcList[i].ProcStatus == ProcStat.C)
                {
                    _hasCompletedProc = true;
                    if (ProcList[i].ProcDate < oldestProcDate)
                    {
                        oldestProcDate = ProcList[i].ProcDate;
                    }
                }
                else if (ProcList[i].ProcStatus.In(ProcStat.EO, ProcStat.EC))
                {
                    _hasExistingProc = true;
                    if (ProcList[i].ProcDate < oldestProcDate)
                    {
                        oldestProcDate = ProcList[i].ProcDate;
                    }
                }
                if (ProcList[0].ProcDate != ProcList[i].ProcDate)
                {
                    datesAreSame = false;
                }
                if (!ProcedureCodes.CanBypassLockDate(ProcList[i].CodeNum, ProcList[i].ProcFee))
                {
                    areAllBypass = false;
                }
            }
            if (_hasCompletedProc || _hasExistingProc)
            {
                if (areAllBypass)
                {
                    if ((_hasCompletedProc && !Security.IsAuthorized(Permissions.ProcComplEdit, oldestProcDate, ProcList[0].CodeNum, 0)) ||
                        (_hasExistingProc && !Security.IsAuthorized(Permissions.ProcExistingEdit, oldestProcDate, ProcList[0].CodeNum, 0)))
                    {
                        butOK.Enabled         = false;
                        butEditAnyway.Enabled = false;
                    }
                }
                else if ((_hasCompletedProc && !Security.IsAuthorized(Permissions.ProcComplEdit, oldestProcDate)) ||
                         (_hasExistingProc && !Security.IsAuthorized(Permissions.ProcExistingEdit, oldestProcDate)))
                {
                    butOK.Enabled         = false;
                    butEditAnyway.Enabled = false;
                }
            }
            List <ClaimProc> ClaimProcList = ClaimProcs.Refresh(ProcList[0].PatNum);

            if (Procedures.IsAttachedToClaim(ProcList, ClaimProcList))
            {
                //StartedAttachedToClaim=true;
                //however, this doesn't stop someone from creating a claim while this window is open,
                //so this is checked at the end, too.
                textDate.Enabled      = false;
                butToday.Enabled      = false;
                butEditAnyway.Visible = true;
                labelClaim.Visible    = true;
            }
            if (datesAreSame)
            {
                textDate.Text = ProcList[0].ProcDate.ToShortDateString();
            }
        }
예제 #14
0
        private void FormProcEditAll_Load(object sender, EventArgs e)
        {
            _procOldList = new List <Procedure>();
            for (int i = 0; i < ProcList.Count; i++)
            {
                _procOldList.Add(ProcList[i].Copy());
            }
            _hasCompletedProc = false;
            _hasExistingProc  = false;
            _canAllBypass     = true;
            DateTime oldestProcDate      = DateTime.Today;
            bool     dateLoadedWithValue = true;

            foreach (Procedure proc in ProcList)
            {
                if (proc.ProcStatus == ProcStat.C)
                {
                    _hasCompletedProc = true;
                    if (proc.ProcDate < oldestProcDate)
                    {
                        oldestProcDate = proc.ProcDate;
                    }
                }
                else if (proc.ProcStatus.In(ProcStat.EO, ProcStat.EC))
                {
                    _hasExistingProc = true;
                    if (proc.ProcDate < oldestProcDate)
                    {
                        oldestProcDate = proc.ProcDate;
                    }
                }
                if (ProcList[0].ProcDate != proc.ProcDate)
                {
                    dateLoadedWithValue = false;
                }
                if (!ProcedureCodes.CanBypassLockDate(proc.CodeNum, proc.ProcFee))
                {
                    _canAllBypass = false;
                }
            }
            if (!IsUserAuthorizedForProcDate(oldestProcDate))
            {
                butOK.Enabled         = false;
                butEditAnyway.Enabled = false;
            }
            List <ClaimProc> ClaimProcList = ClaimProcs.Refresh(ProcList[0].PatNum);

            if (Procedures.IsAttachedToClaim(ProcList, ClaimProcList))
            {
                //StartedAttachedToClaim=true;
                //however, this doesn't stop someone from creating a claim while this window is open,
                //so this is checked at the end, too.
                textDate.Enabled      = false;
                butToday.Enabled      = false;
                butEditAnyway.Visible = true;
                labelClaim.Visible    = true;
            }
            if (dateLoadedWithValue)
            {
                textDate.Text = ProcList[0].ProcDate.ToShortDateString();
            }
            if (PrefC.HasClinicsEnabled)
            {
                labelClinic.Visible = true;
                comboClinic.Visible = true;
                FillComboClinic();                //Must be called before FillProviderCombo().
            }
            FillComboProv();
        }