コード例 #1
0
        ///<summary>Retrieves data and uses them to create new PayPlanExtended objects.
        ///Heavy lifting (db calls and double loops) done here once upon load.  This also gets called if the user clicks "Refresh Data".</summary>
        private bool LoadData()
        {
            List <PayPlan>       listPayPlans;
            List <PayPlanCharge> listPayPlanCharges;
            List <ClaimProc>     listPayPlanClaimProcs;
            List <Patient>       listPatients;
            List <InsPlan>       listInsPlans;

            listPayPlans = PayPlans.GetAllOpenInsPayPlans();
            if (listPayPlans.Count == 0)
            {
                MsgBox.Show(this, "There are no insurance payment plans past due.");
                return(false);
            }
            listPayPlanCharges    = PayPlanCharges.GetForPayPlans(listPayPlans.Select(x => x.PayPlanNum).ToList()).Where(x => x.ChargeType == PayPlanChargeType.Debit).ToList();
            listPayPlanClaimProcs = ClaimProcs.GetForPayPlans(listPayPlans.Select(x => x.PayPlanNum).ToList()
                                                              , new List <ClaimProcStatus>()
            {
                ClaimProcStatus.Received, ClaimProcStatus.Supplemental
            });
            listPatients         = Patients.GetLimForPats(listPayPlans.Select(x => x.PatNum).ToList());
            listInsPlans         = InsPlans.GetPlans(listPayPlans.Select(x => x.PlanNum).ToList());
            _listPayPlanExtended = new List <PayPlanExtended>();
            foreach (PayPlan plan in listPayPlans)
            {
                //for each payplan, create a PayPlanExtended object which contains all of the payment plan's information and it's charges.
                //pass in the plan, the list of associated charges, and the list of associated claimprocs (payments).
                _listPayPlanExtended.Add(new PayPlanExtended(plan,
                                                             listPatients.FirstOrDefault(x => x.PatNum == plan.PatNum),
                                                             listPayPlanCharges.Where(x => x.PayPlanNum == plan.PayPlanNum).ToList(),
                                                             listPayPlanClaimProcs.Where(x => x.PayPlanNum == plan.PayPlanNum).ToList(),
                                                             listInsPlans.FirstOrDefault(x => x.PlanNum == plan.PlanNum)));
            }
            return(true);
        }
コード例 #2
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDate.errorProvider1.GetError(textDate) != "" ||
         textPrincipal.errorProvider1.GetError(textPrincipal) != "" ||
         textInterest.errorProvider1.GetError(textInterest) != ""
         )
     {
         MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
         return;
     }
     if (textPrincipal.Text == "")
     {
         textPrincipal.Text = "0";
     }
     if (textInterest.Text == "")
     {
         textInterest.Text = "0";
     }
     //todo: test dates?  The day of the month should be the same as all others
     PayPlanChargeCur.ChargeDate = PIn.PDate(textDate.Text);
     PayPlanChargeCur.Principal  = PIn.PDouble(textPrincipal.Text);
     PayPlanChargeCur.Interest   = PIn.PDouble(textInterest.Text);
     PayPlanChargeCur.Note       = textNote.Text;
     try{
         PayPlanCharges.InsertOrUpdate(PayPlanChargeCur, IsNew);
     }
     catch (ApplicationException ex) {          //even though it doesn't currently throw any exceptions
         MessageBox.Show(ex.Message);
         return;
     }
     DialogResult = DialogResult.OK;
 }
コード例 #3
0
ファイル: FormCreditCardEdit.cs プロジェクト: nampn/ODental
 private void FormCreditCardEdit_Load(object sender, EventArgs e)
 {
     CreditCardOld = CreditCardCur.Clone();
     FillData();
     if (IsXCharge)             //Get recurring payment plan information if using X-Charge.
     {
         List <PayPlanCharge> chargeList = PayPlanCharges.Refresh(PatCur.PatNum);
         PayPlanList = PayPlans.GetValidPlansNoIns(PatCur.PatNum);
         comboPaymentPlans.Items.Add("None");
         comboPaymentPlans.SelectedIndex = 0;
         for (int i = 0; i < PayPlanList.Count; i++)
         {
             comboPaymentPlans.Items.Add(PayPlans.GetTotalPrinc(PayPlanList[i].PayPlanNum, chargeList).ToString("F")
                                         + "  " + Patients.GetPat(PayPlanList[i].PatNum).GetNameFL());
             if (PayPlanList[i].PayPlanNum == CreditCardCur.PayPlanNum)
             {
                 comboPaymentPlans.SelectedIndex = i + 1;
             }
         }
     }
     else              //This will hide the recurring section and change the window size.
     {
         groupRecurringCharges.Visible = false;
         this.ClientSize = new System.Drawing.Size(this.ClientSize.Width, this.ClientSize.Height - 215);
     }
 }
コード例 #4
0
ファイル: FormProcSelect.cs プロジェクト: royedwards/DRDNet
 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();
 }
コード例 #5
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);
            }
        }
コード例 #6
0
ファイル: PayPlans.cs プロジェクト: luisurbinanet/apolloniax
        ///<summary>Refreshes the list for the specified guarantor, and then determines if there are any valid plans with that patient as the guarantor.  If more than one valid payment plan, displays list to select from.  If any valid plans, then it returns that plan, else returns null.</summary>
        public static PayPlan GetValidPlan(int guarNum, bool isIns)
        {
            PayPlan[] PlanListAll = Refresh(guarNum, 0);
            PayPlan[] PayPlanList = GetListOneType(PlanListAll, isIns);
            if (PayPlanList.Length == 0)
            {
                return(null);
            }
            if (PayPlanList.Length == 1)           //if there is only one valid payplan
            {
                return(PayPlanList[0].Copy());
            }
            PayPlanCharge[] ChargeList = PayPlanCharges.Refresh(guarNum);
            //enhancement needed to weed out payment plans that are all paid off
            //more than one valid PayPlan
            FormPayPlanSelect FormPPS = new FormPayPlanSelect(PayPlanList, ChargeList);

            FormPPS.ShowDialog();
            if (FormPPS.DialogResult == DialogResult.OK)
            {
                return(PayPlanList[FormPPS.IndexSelected].Copy());
            }
            else
            {
                return(null);
            }
        }
コード例 #7
0
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
     }
     else
     {
         PayPlanCharges.Delete(PayPlanChargeCur);
         DialogResult = DialogResult.OK;
     }
 }
コード例 #8
0
 private void FormPayPlanSelect_Load(object sender, System.EventArgs e)
 {
     if (_includeNone)
     {
         this.Text         = Lan.g(this, "Attach to payment plan?");
         labelExpl.Visible = true;
         butNone.Visible   = true;
     }
     _listPayPlanCharges = PayPlanCharges.GetForPayPlans(_listValidPayPlans.Select(x => x.PayPlanNum).ToList());
     FillGrid();
     gridMain.SetSelected(0, true);
 }
コード例 #9
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();
 }
コード例 #10
0
ファイル: FormAdjMulti.cs プロジェクト: royedwards/DRDNet
        ///<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);
        }
コード例 #11
0
 private void FormCreditCardEdit_Load(object sender, EventArgs e)
 {
     _creditCardOld = CreditCardCur.Clone();
     FillFrequencyCombos();
     FillData();
     checkExcludeProcSync.Checked = CreditCardCur.ExcludeProcSync;
     if ((_isXChargeEnabled || _isPayConnectEnabled || _isPaySimpleEnabled) &&
         (!CreditCardCur.IsXWeb() && !CreditCardCur.IsPayConnectPortal()))
     {            //Get recurring payment plan information if using X-Charge or PayConnect and the card is not from XWeb or PayConnectPortal.
         PayPlanList = PayPlans.GetValidPlansNoIns(PatCur.PatNum);
         List <PayPlanCharge> chargeList = PayPlanCharges.GetForPayPlans(PayPlanList.Select(x => x.PayPlanNum).ToList());
         comboPaymentPlans.Items.Add("None");
         comboPaymentPlans.SelectedIndex = 0;
         for (int i = 0; i < PayPlanList.Count; i++)
         {
             comboPaymentPlans.Items.Add(PayPlans.GetTotalPrinc(PayPlanList[i].PayPlanNum, chargeList).ToString("F")
                                         + "  " + Patients.GetPat(PayPlanList[i].PatNum).GetNameFL());
             if (PayPlanList[i].PayPlanNum == CreditCardCur.PayPlanNum)
             {
                 comboPaymentPlans.SelectedIndex = i + 1;
             }
         }
         if (PrefC.IsODHQ)
         {
             groupProcedures.Visible = true;
             FillProcs();
         }
         else
         {
             this.ClientSize = new System.Drawing.Size(this.ClientSize.Width, this.ClientSize.Height - 144);
         }
         UpdateFrequencyText();
         EnableFrequencyControls();
     }
     else              //This will hide the recurring section and change the window size.
     {
         groupRecurringCharges.Visible = false;
         groupChargeFrequency.Visible  = false;
         this.ClientSize = new System.Drawing.Size(this.ClientSize.Width, this.ClientSize.Height - 486);
     }
     if (_isPaySimpleEnabled && !CreditCardCur.IsNew)
     {
         labelAcctType.Visible   = true;
         textAccountType.Visible = true;
     }
     checkChrgWithNoBal.Checked = CreditCardCur.CanChargeWhenNoBal;
     //Only visible if preference is on.
     checkChrgWithNoBal.Visible = PrefC.GetBool(PrefName.RecurringChargesAllowedWhenNoPatBal);
     Plugins.HookAddCode(this, "FormCreditCardEdit.Load_end", PatCur);
 }
コード例 #12
0
 private void FormCreditCardEdit_Load(object sender, EventArgs e)
 {
     _creditCardOld = CreditCardCur.Clone();
     FillData();
     checkExcludeProcSync.Checked = CreditCardCur.ExcludeProcSync;
     if ((_isXChargeEnabled || _isPayConnectEnabled || _isPaySimpleEnabled) &&
         !CreditCardCur.IsXWeb())
     {            //Get recurring payment plan information if using X-Charge or PayConnect and the card is not from XWeb.
         PayPlanList = PayPlans.GetValidPlansNoIns(PatCur.PatNum);
         List <PayPlanCharge> chargeList = PayPlanCharges.GetForPayPlans(PayPlanList.Select(x => x.PayPlanNum).ToList());
         comboPaymentPlans.Items.Add("None");
         comboPaymentPlans.SelectedIndex = 0;
         for (int i = 0; i < PayPlanList.Count; i++)
         {
             comboPaymentPlans.Items.Add(PayPlans.GetTotalPrinc(PayPlanList[i].PayPlanNum, chargeList).ToString("F")
                                         + "  " + Patients.GetPat(PayPlanList[i].PatNum).GetNameFL());
             if (PayPlanList[i].PayPlanNum == CreditCardCur.PayPlanNum)
             {
                 comboPaymentPlans.SelectedIndex = i + 1;
             }
         }
         if (PrefC.IsODHQ)
         {
             groupProcedures.Visible = true;
             FillProcs();
         }
         else
         {
             this.ClientSize = new System.Drawing.Size(this.ClientSize.Width, this.ClientSize.Height - 144);
         }
     }
     else              //This will hide the recurring section and change the window size.
     {
         groupRecurringCharges.Visible = false;
         this.ClientSize = new System.Drawing.Size(this.ClientSize.Width, this.ClientSize.Height - 356);
     }
     if (_isPaySimpleEnabled && !CreditCardCur.IsNew)
     {
         textCardNumber.ReadOnly = true;
     }
     Plugins.HookAddCode(this, "FormCreditCardEdit.Load_end", PatCur);
 }
コード例 #13
0
 private void checkPayPlan_Click(object sender, System.EventArgs e)
 {
     if (checkPayPlan.Checked)
     {
         if (checkPatOtherFam.Checked)                //prevents a bug.
         {
             checkPayPlan.Checked = false;
             return;
         }
         PayPlan[] planListAll = PayPlans.Refresh(FamCur.List[listPatient.SelectedIndex].PatNum, 0);
         PayPlan[] payPlanList = PayPlans.GetListOneType(planListAll, false);
         if (payPlanList.Length == 0)              //no valid plans
         {
             MsgBox.Show(this, "The selected patient is not the guarantor for any payment plans.");
             checkPayPlan.Checked = false;
             return;
         }
         if (payPlanList.Length == 1)               //if there is only one valid payplan
         {
             PaySplitCur.PayPlanNum = payPlanList[0].PayPlanNum;
             return;
         }
         //more than one valid PayPlan
         PayPlanCharge[]   chargeList = PayPlanCharges.Refresh(FamCur.List[listPatient.SelectedIndex].PatNum);
         FormPayPlanSelect FormPPS    = new FormPayPlanSelect(payPlanList, chargeList);
         //FormPPS.ValidPlans=payPlanList;
         FormPPS.ShowDialog();
         if (FormPPS.DialogResult == DialogResult.Cancel)
         {
             checkPayPlan.Checked = false;
             return;
         }
         PaySplitCur.PayPlanNum = payPlanList[FormPPS.IndexSelected].PayPlanNum;
     }
     else             //payPlan unchecked
     {
         PaySplitCur.PayPlanNum = 0;
     }
 }
コード例 #14
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDate.errorProvider1.GetError(textDate) != "" ||
         textPrincipal.errorProvider1.GetError(textPrincipal) != "" ||
         textInterest.errorProvider1.GetError(textInterest) != ""
         )
     {
         MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
         return;
     }
     //if(comboProvNum.SelectedIndex==-1){
     //	MsgBox.Show(this,"Please select a provider first.");
     //	return;
     //}
     if (textPrincipal.Text == "")
     {
         textPrincipal.Text = "0";
     }
     if (textInterest.Text == "")
     {
         textInterest.Text = "0";
     }
     //todo: test dates?  The day of the month should be the same as all others
     PayPlanChargeCur.ChargeDate = PIn.Date(textDate.Text);
     PayPlanChargeCur.Principal  = PIn.Double(textPrincipal.Text);
     PayPlanChargeCur.Interest   = PIn.Double(textInterest.Text);
     PayPlanChargeCur.Note       = textNote.Text;
     //not allowed to change provnum or clinicNum here.
     if (IsNew)
     {
         PayPlanCharges.Insert(PayPlanChargeCur);
     }
     else
     {
         PayPlanCharges.Update(PayPlanChargeCur);
     }
     DialogResult = DialogResult.OK;
 }
コード例 #15
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);
        }