Beispiel #1
0
 private void FormProcSelect_Load(object sender, System.EventArgs e)
 {
     if (_isMultiSelect)
     {
         gridMain.SelectionMode = OpenDental.UI.GridSelectionMode.MultiExtended;
     }
     _listSelectedProcs = new List <Procedure>();
     _listProcedures    = Procedures.GetCompleteForPats(new List <long> {
         _patNumCur
     });
     _listAdjustments = Adjustments.GetAdjustForPats(new List <long> {
         _patNumCur
     });
     _listPayPlanCharges = PayPlanCharges.GetDueForPayPlans(PayPlans.GetForPats(null, _patNumCur), _patNumCur).ToList();        //Does not get charges for the future.
     _listPaySplits      = PaySplits.GetForPats(new List <long> {
         _patNumCur
     });                                                                            //Might contain payplan payments.
     _listInsPayAsTotal = ClaimProcs.GetByTotForPats(new List <long> {
         _patNumCur
     });
     _listClaimProcs          = ClaimProcs.GetForProcs(_listProcedures.Select(x => x.ProcNum).ToList());
     labelUnallocated.Visible = _doShowUnallocatedLabel;
     if (PrefC.GetInt(PrefName.RigorousAdjustments) == (int)RigorousAdjustments.DontEnforce)
     {
         radioIncludeAllCredits.Checked = true;
     }
     else
     {
         radioOnlyAllocatedCredits.Checked = true;
     }
     FillGrid();
 }
Beispiel #2
0
        private void FormPayPlanCredits_Load(object sender, EventArgs e)
        {
            _listPatNums = new List <long>();
            _listPatNums.Add(_patCur.PatNum);
            _listAdjustments = Adjustments.GetAdjustForPats(_listPatNums);
            _listProcs       = Procedures.GetCompAndTpForPats(_listPatNums);
            List <PayPlan> listPayPlans = PayPlans.GetForPats(_listPatNums, _patCur.PatNum);        //Used to figure out how much we need to pay off procs with, also contains insurance payplans.

            _listPayPlanCharges = new List <PayPlanCharge>();
            if (listPayPlans.Count > 0)
            {
                //get all current payplan charges for plans already on the patient, excluding the current one.
                _listPayPlanCharges = PayPlanCharges.GetDueForPayPlans(listPayPlans, _patCur.PatNum)                                               //Does not get charges for the future.
                                      .Where(x => !(x.PayPlanNum == _payPlanCur.PayPlanNum && x.ChargeType == PayPlanChargeType.Credit)).ToList(); //do not get credits for current payplan
            }
            List <PaySplit> tempListPaySplits = PaySplits.GetForPats(_listPatNums).Where(x => x.UnearnedType == 0).ToList();                       //Might contain payplan payments. Do not include unearned.

            _listPaySplits     = tempListPaySplits.FindAll(x => x.PayPlanNum == 0 || listPayPlans.Exists(y => y.PayPlanNum == x.PayPlanNum));
            _listPayments      = Payments.GetNonSplitForPats(_listPatNums);
            _listInsPayAsTotal = ClaimProcs.GetByTotForPats(_listPatNums);          //Claimprocs paid as total, might contain ins payplan payments.
            _listClaimProcs    = ClaimProcs.GetForProcs(_listProcs.Select(x => x.ProcNum).ToList());
            textCode.Text      = Lan.g(this, "None");
            FillGrid();
            if (!Security.IsAuthorized(Permissions.PayPlanEdit, true))
            {
                this.DisableForm(butCancel, checkHideUnattached, checkShowImplicit, butPrint, gridMain);
            }
        }
Beispiel #3
0
 private void FormProcSelect_Load(object sender, System.EventArgs e)
 {
     if (_isMultiSelect)
     {
         gridMain.SelectionMode = OpenDental.UI.GridSelectionMode.MultiExtended;
     }
     _listSelectedProcs = new List <Procedure>();
     _listProcedures    = Procedures.GetCompleteForPats(new List <long> {
         _patNumCur
     });
     if (ShowTpProcs)
     {
         _listProcedures.AddRange(Procedures.GetTpForPats(new List <long> {
             _patNumCur
         }));
     }
     _listAdjustments = Adjustments.GetAdjustForPats(new List <long> {
         _patNumCur
     });
     _listPayPlanCharges = PayPlanCharges.GetDueForPayPlans(PayPlans.GetForPats(null, _patNumCur), _patNumCur).ToList();        //Does not get charges for the future.
     _listPaySplits      = PaySplits.GetForPats(new List <long> {
         _patNumCur
     });                                                                            //Might contain payplan payments.
     foreach (PaySplit split in ListSplitsCur)
     {
         //If this is a new payment, its paysplits will not be in the database yet, so we need to add them manually. We might also need to set the
         //ProcNum on the pay split if it has changed and has not been saved to the database.
         PaySplit splitDb = _listPaySplits.FirstOrDefault(x => x.IsSame(split));
         if (splitDb == null)
         {
             _listPaySplits.Add(split);
         }
         else
         {
             splitDb.ProcNum = split.ProcNum;
         }
     }
     _listInsPayAsTotal = ClaimProcs.GetByTotForPats(new List <long> {
         _patNumCur
     });
     _listClaimProcs          = ClaimProcs.GetForProcs(_listProcedures.Select(x => x.ProcNum).ToList());
     labelUnallocated.Visible = _doShowUnallocatedLabel;
     if (PrefC.GetInt(PrefName.RigorousAdjustments) == (int)RigorousAdjustments.DontEnforce)
     {
         radioIncludeAllCredits.Checked = true;
     }
     else
     {
         radioOnlyAllocatedCredits.Checked = true;
     }
     FillGrid();
 }
Beispiel #4
0
        ///<summary>This method converts the AccountEntry objects we get back from AccountModules.GetListUnpaidAccountCharges() to MultiAdjEntry objects.
        ///These are used to fill the grid and do all relevant logic in this form. This method will return a fresh list of procedures and will not show
        ///any existing adjustments that may have been made in this form already. Called on load and when checkShowImplicit is clicked.
        ///When called from checkShowImplicit any existing adjustments made will not be shown.(Ask Andrew about this functionality)</summary>
        private List <MultiAdjEntry> FillListGridEntries(CreditCalcType calc)
        {
            List <MultiAdjEntry> retVal = new List <MultiAdjEntry>();

            #region Get required data
            List <Procedure> listProcedures = Procedures.GetCompleteForPats(new List <long> {
                _patCur.PatNum
            });
            //Does not get charges for the future.
            List <PaySplit> listPaySplits = PaySplits.GetForPats(new List <long> {
                _patCur.PatNum
            }).Where(x => x.UnearnedType == 0).ToList();
            List <Adjustment> listAdjustments = Adjustments.GetAdjustForPats(new List <long> {
                _patCur.PatNum
            });
            //Might contain payplan payments. Do not include unearned.
            List <PayPlanCharge> listPayPlanCharges = PayPlanCharges.GetDueForPayPlans(PayPlans.GetForPats(null, _patCur.PatNum), _patCur.PatNum).ToList();
            List <ClaimProc>     listInsPayAsTotal  = ClaimProcs.GetByTotForPats(new List <long> {
                _patCur.PatNum
            });
            List <ClaimProc> listClaimProcs = ClaimProcs.GetForProcs(listProcedures.Select(x => x.ProcNum).ToList());
            #endregion
            List <AccountEntry> listAccountCharges = AccountModules.GetListUnpaidAccountCharges(listProcedures, listAdjustments
                                                                                                , listPaySplits, listClaimProcs, listPayPlanCharges, listInsPayAsTotal, calc, new List <PaySplit>());
            List <AccountEntry> listAccountChargesIncludeAll = null;
            if (calc == CreditCalcType.ExcludeAll)
            {
                //We need to get all credits so that our AmtRemBefore can reflect what has truly been allocated to the procedure.
                listAccountChargesIncludeAll = AccountModules.GetListUnpaidAccountCharges(listProcedures, listAdjustments
                                                                                          , listPaySplits, listClaimProcs, listPayPlanCharges, listInsPayAsTotal, CreditCalcType.IncludeAll, new List <PaySplit>());
            }
            MultiAdjEntry multiEntry = null;
            foreach (AccountEntry entry in listAccountCharges)
            {
                //We only want AccountEntries that are completed procedures.
                if (entry.GetType() != typeof(ProcExtended))
                {
                    continue;
                }
                ProcExtended procEntry = (ProcExtended)entry.Tag;
                if ((_listSelectedProcs != null && _listSelectedProcs.Any(x => x.ProcNum == procEntry.Proc.ProcNum)) ||        //Allow selected procs to show if paid off
                    entry.AmountEnd != 0)                     //All unpaid procedures should always show up per Nathan
                {
                    double amtRemBefore = (double)(listAccountChargesIncludeAll?.FirstOrDefault(x => x.Tag.GetType() == typeof(ProcExtended) &&
                                                                                                ((ProcExtended)x.Tag).Proc.ProcNum == procEntry.Proc.ProcNum) ?? entry).AmountStart;
                    multiEntry = new MultiAdjEntry(procEntry.Proc, (double)entry.AmountStart, (double)entry.AmountEnd, amtRemBefore);
                    retVal.Add(multiEntry);
                }
            }
            OrderListGridEntries();
            return(retVal);
        }
Beispiel #5
0
        private void FormAdjustSelect_Load(object sender, EventArgs e)
        {
            List <Adjustment> listAdjusts = Adjustments.GetAdjustForPats(new List <long>()
            {
                PatNumCur
            }).FindAll(x => x.ProcNum == 0);                                                                                                 //Get all unallocated adjustments for current pat.

            foreach (Adjustment adjust in listAdjusts)
            {
                _listAdjusts.Add(new AccountEntry(adjust));
            }
            _listSplitsForAdjusts = PaySplits.GetForAdjustments(listAdjusts.Select(x => x.AdjNum).ToList());
            foreach (AccountEntry entry in _listAdjusts)
            {
                //Figure out how much each adjustment has left, not counting this payment.
                entry.AmountStart -= (decimal)Adjustments.GetAmtAllocated(entry.PriKey, PayNumCur, _listSplitsForAdjusts.FindAll(x => x.AdjNum == entry.PriKey));
                //Reduce adjustments based on current payment's splits as well (this is in-memory list, could be new, could be modified) but not the current split
                entry.AmountStart -= (decimal)Adjustments.GetAmtAllocated(entry.PriKey, 0, ListSplitsForPayment.FindAll(x => x.AdjNum == entry.PriKey && x != PaySplitCur));
            }
            FillGrid();
        }
Beispiel #6
0
        ///<summary>This method converts the AccountEntry objects we get back from AccountModules.GetListUnpaidAccountCharges() to MultiAdjEntry objects.
        ///These are used to fill the grid and do all relevant logic in this form. This method will return a fresh list of procedures and will not show
        ///any existing adjustments that may have been made in this form already. Called on load and when checkShowImplicit is clicked.
        ///When called from checkShowImplicit any existing adjustments made will not be shown.(Ask Andrew about this functionality)</summary>
        private List <MultiAdjEntry> FillListGridEntries(CreditCalcType calc)
        {
            //CONSIDER ANY CHANGES MADE HERE MAY ALSO NEED TO BE ADDED TO FormProcSelect.
            List <MultiAdjEntry> retVal = new List <MultiAdjEntry>();

            #region Get required data
            List <Procedure> listProcedures = Procedures.GetCompleteForPats(new List <long> {
                _patCur.PatNum
            });
            //Does not get charges for the future.
            List <PaySplit> listPaySplits = PaySplits.GetForPats(new List <long> {
                _patCur.PatNum
            }).Where(x => x.UnearnedType == 0).ToList();
            List <Adjustment> listAdjustments = Adjustments.GetAdjustForPats(new List <long> {
                _patCur.PatNum
            });
            //Might contain payplan payments. Do not include unearned.
            List <PayPlanCharge> listPayPlanCharges = PayPlanCharges.GetDueForPayPlans(PayPlans.GetForPats(null, _patCur.PatNum), _patCur.PatNum).ToList();
            List <ClaimProc>     listInsPayAsTotal  = ClaimProcs.GetByTotForPats(new List <long> {
                _patCur.PatNum
            });
            List <ClaimProc> listClaimProcs = ClaimProcs.GetForProcs(listProcedures.Select(x => x.ProcNum).ToList());
            #endregion
            List <AccountEntry> listAccountCharges = AccountModules.GetListUnpaidAccountCharges(listProcedures, listAdjustments, listPaySplits, listClaimProcs
                                                                                                , listPayPlanCharges, listInsPayAsTotal, calc, new List <PaySplit>());
            List <AccountEntry> listAccountChargesIncludeAll = null;
            if (calc == CreditCalcType.ExcludeAll)
            {
                //We need to get all credits so that our AmtRemBefore can reflect what has truly been allocated to the procedure.
                listAccountChargesIncludeAll = AccountModules.GetListUnpaidAccountCharges(listProcedures, listAdjustments
                                                                                          , listPaySplits, listClaimProcs, listPayPlanCharges, listInsPayAsTotal, CreditCalcType.IncludeAll, new List <PaySplit>());
            }
            MultiAdjEntry multiEntry = null;
            foreach (AccountEntry entry in listAccountCharges)
            {
                //We only want AccountEntries that are completed procedures.
                if (entry.GetType() != typeof(ProcExtended))
                {
                    continue;
                }
                ProcExtended procEntry = (ProcExtended)entry.Tag;
                bool         isProcSelectedInAccount = false;
                if (_listSelectedProcs != null && _listSelectedProcs.Any(x => x.ProcNum == procEntry.Proc.ProcNum))
                {
                    isProcSelectedInAccount = true;
                }
                if (calc == CreditCalcType.ExcludeAll)               //show everything. Regardless of procs loading window or amount remaining.
                {
                    double amtRemBefore = (double)(listAccountChargesIncludeAll?.FirstOrDefault(x => x.Tag.GetType() == typeof(ProcExtended) &&
                                                                                                ((ProcExtended)x.Tag).Proc.ProcNum == procEntry.Proc.ProcNum) ?? entry).AmountStart;
                    multiEntry = new MultiAdjEntry(procEntry.Proc, (double)entry.AmountStart, (double)entry.AmountEnd, amtRemBefore);
                    retVal.Add(multiEntry);
                }
                else if (calc.In(CreditCalcType.IncludeAll, CreditCalcType.AllocatedOnly) && (entry.AmountEnd != 0 || isProcSelectedInAccount))
                {
                    //Unpaid procedures should always show per Nathan. If proc was specifically selected before entering window, show it anyways.
                    multiEntry = new MultiAdjEntry(procEntry.Proc, (double)entry.AmountStart, (double)entry.AmountEnd, (double)entry.AmountStart);
                    retVal.Add(multiEntry);
                }
            }
            OrderListGridEntries();
            return(retVal);
        }