///<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); }
public void ProcMultiVisitTests_CrownGroupComplete_ClaimDates() { string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(suffix); InsuranceInfo insInfo = InsuranceT.AddInsurance(pat, suffix); List <Procedure> listProcs = new List <Procedure>(); Procedure procBillable = ProcedureT.CreateProcedure(pat, "D2750", ProcStat.TP, "1", 100, new DateTime(2018, 5, 1));//PFM listProcs.Add(procBillable); Procedure procDelivery = ProcedureT.CreateProcedure(pat, "N4118", ProcStat.TP, "1", 0, new DateTime(2018, 8, 20)); //Seat - usually completed several months later. listProcs.Add(procDelivery); List <ClaimProc> listClaimProcs = ProcedureT.ComputeEstimates(pat, insInfo); ProcMultiVisits.CreateGroup(listProcs); Procedure procBillableOld = procBillable.Copy(); procBillable.ProcStatus = ProcStat.C; Procedures.Update(procBillable, procBillableOld); Procedure procDeliveryOld = procDelivery.Copy(); procDelivery.ProcStatus = ProcStat.C; Procedures.Update(procDelivery, procDeliveryOld); Assert.AreEqual(ProcMultiVisits.IsProcInProcess(procBillable.ProcNum), false); //Both procedures complete means the group is now complete (not In Process). Assert.AreEqual(ProcMultiVisits.IsProcInProcess(procDelivery.ProcNum), false); //Both procedures complete means the group is now complete (not In Process). Claim claim = new Claim(); claim.DateSent = DateTimeOD.Today; claim.DateSentOrig = DateTime.MinValue; claim.ClaimStatus = "W"; //Dates of service are calculated inside AccountModules.CreateClaim(). //The procDelivery cannot be attached to the claim in the UI, because $0 procs are blocked by UI. Therefore, we only attach the procBilled to the claim here. ODTuple <bool, Claim, string> clmResult = AccountModules.CreateClaim(claim, "P", insInfo.ListPatPlans, insInfo.ListInsPlans, listClaimProcs, listProcs, insInfo.ListInsSubs, pat, null, new List <Procedure> { procBillable }, "", insInfo.PriInsPlan, insInfo.PriInsSub, Relat.Self); Assert.AreEqual(clmResult.Item3, ""); //Ensure no validation errors creating the claim. This is to verify the integrity of the unit test design. Assert.AreEqual(clmResult.Item2.DateService, procDelivery.ProcDate); //Claim date of service must always be the greatest date in the multi visit group. listClaimProcs = ClaimProcs.RefreshForClaim(clmResult.Item2.ClaimNum); Assert.AreEqual(listClaimProcs[0].ProcDate, procDelivery.ProcDate); //Proc date of service must always be the greatest date in the multi visit group, even if performed on a different day. }
private void FillGrid() { CreditCalcType credCalc; if (_isSimpleView) { credCalc = CreditCalcType.ExcludeAll; groupBreakdown.Visible = false; groupCreditLogic.Visible = false; } else if (radioIncludeAllCredits.Checked) { credCalc = CreditCalcType.IncludeAll; } else if (radioOnlyAllocatedCredits.Checked) { credCalc = CreditCalcType.AllocatedOnly; } else { credCalc = CreditCalcType.ExcludeAll; } _listAccountCharges = AccountModules.GetListUnpaidAccountCharges(_listProcedures, _listAdjustments, _listPaySplits, _listClaimProcs, _listPayPlanCharges, _listInsPayAsTotal, credCalc, ListSplitsCur); gridMain.BeginUpdate(); gridMain.ListGridColumns.Clear(); GridColumn col = new GridColumn(Lan.g("TableProcSelect", "Date"), 70); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableProcSelect", "Prov"), 55); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableProcSelect", "Code"), 55); gridMain.ListGridColumns.Add(col); if (Clinics.IsMedicalPracticeOrClinic(Clinics.ClinicNum)) { col = new GridColumn(Lan.g("TableProcSelect", "Description"), 290); gridMain.ListGridColumns.Add(col); } else { col = new GridColumn(Lan.g("TableProcSelect", "Tooth"), 40); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableProcSelect", "Description"), 250); gridMain.ListGridColumns.Add(col); } if (credCalc == CreditCalcType.ExcludeAll) { col = new GridColumn(Lan.g("TableProcSelect", "Amt"), 0, HorizontalAlignment.Right); gridMain.ListGridColumns.Add(col); } else { col = new GridColumn(Lan.g("TableProcSelect", "Amt Orig"), 60, HorizontalAlignment.Right); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableProcSelect", "Amt Start"), 60, HorizontalAlignment.Right); gridMain.ListGridColumns.Add(col); col = new GridColumn(Lan.g("TableProcSelect", "Amt End"), 60, HorizontalAlignment.Right); gridMain.ListGridColumns.Add(col); } gridMain.ListGridRows.Clear(); GridRow row; foreach (AccountEntry entry in _listAccountCharges) { if ((entry.GetType() != typeof(ProcExtended) || Math.Round(entry.AmountEnd, 3) == 0) && credCalc != CreditCalcType.ExcludeAll) { continue; } Procedure procCur = ((ProcExtended)entry.Tag).Proc; ProcedureCode procCodeCur = ProcedureCodes.GetProcCode(procCur.CodeNum); row = new GridRow(); row.Cells.Add(procCur.ProcDate.ToShortDateString()); row.Cells.Add(Providers.GetAbbr(entry.ProvNum)); row.Cells.Add(procCodeCur.ProcCode); if (!Clinics.IsMedicalPracticeOrClinic(Clinics.ClinicNum)) { row.Cells.Add(procCur.ToothNum == "" ? Tooth.SurfTidyFromDbToDisplay(procCur.Surf, procCur.ToothNum) : Tooth.ToInternat(procCur.ToothNum)); } string descriptionText = ""; if (procCur.ProcStatus == ProcStat.TP) { descriptionText = "(TP) "; } descriptionText += procCodeCur.Descript; row.Cells.Add(descriptionText); row.Cells.Add(entry.AmountOriginal.ToString("f")); if (credCalc != CreditCalcType.ExcludeAll) { row.Cells.Add(entry.AmountStart.ToString("f")); row.Cells.Add(entry.AmountEnd.ToString("f")); } row.Tag = entry; gridMain.ListGridRows.Add(row); } gridMain.EndUpdate(); if (!_isSimpleView) { RefreshBreakdown(); } }
///<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); }