public void LedgersTests_ComputeAgingProcLifo_PayPlan2() { Patient pat = PatientT.CreatePatient(fName: "Visit Based", lName: "UDP Ortho"); Def defPay = DefT.CreateDefinition(DefCat.PaymentTypes, "Check"); Procedure proc6 = ProcedureT.CreateProcedure(pat, "D8090", ProcStat.C, "", 1200, DateTime.Today.AddMonths(-6).AddDays(-1)); PayPlan payPlan = PayPlanT.CreatePayPlan(pat.PatNum, 4000, 166.67, DateTime.Today.AddMonths(-6).AddDays(-1), proc6.ProvNum); Payment pay6 = PaymentT.MakePayment(pat.PatNum, 166.67, DateTime.Today.AddMonths(-6).AddDays(-1), payPlanNum: payPlan.PayPlanNum, provNum: proc6.ProvNum, procNum: proc6.ProcNum, payType: defPay.DefNum); PayPlanCharge ppc6 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-6).AddDays(-1), 1200, 0, "D8090: CompOrthoAdlt", proc6.ProvNum, 0, PayPlanChargeType.Credit, proc6.ProcNum); Procedure proc5 = ProcedureT.CreateProcedure(pat, "D8670", ProcStat.C, "", 121.74, DateTime.Today.AddMonths(-5).AddDays(-1)); Payment pay5 = PaymentT.MakePayment(pat.PatNum, 166.67, DateTime.Today.AddMonths(-5).AddDays(-1), payPlanNum: payPlan.PayPlanNum, provNum: proc5.ProvNum, procNum: proc5.ProcNum, payType: defPay.DefNum); PayPlanCharge ppc5 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-5).AddDays(-1), 121.74, 0, "D8670: OrthoAdj", proc5.ProvNum, 0, PayPlanChargeType.Credit, proc5.ProcNum); Procedure proc4 = ProcedureT.CreateProcedure(pat, "D8670", ProcStat.C, "", 121.74, DateTime.Today.AddMonths(-4).AddDays(-1)); PayPlanCharge ppc4 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-4).AddDays(-1), 121.74, 0, "D8670: OrthoAdj", proc4.ProvNum, 0, PayPlanChargeType.Credit, proc4.ProcNum); Procedure proc3 = ProcedureT.CreateProcedure(pat, "D8670", ProcStat.C, "", 121.74, DateTime.Today.AddMonths(-3).AddDays(-1)); PayPlanCharge ppc3 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-3).AddDays(-1), 121.74, 0, "D8670: OrthoAdj", proc3.ProvNum, 0, PayPlanChargeType.Credit, proc3.ProcNum); Procedure proc2 = ProcedureT.CreateProcedure(pat, "D8670", ProcStat.C, "", 121.74, DateTime.Today.AddMonths(-2).AddDays(-1)); PayPlanCharge ppc2 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-2).AddDays(-1), 121.74, 0, "D8670: OrthoAdj", proc2.ProvNum, 0, PayPlanChargeType.Credit, proc2.ProcNum); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D8670", ProcStat.C, "", 121.74, DateTime.Today.AddMonths(-1).AddDays(-1)); PayPlanCharge ppc1 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-1).AddDays(-1), 121.74, 0, "D8670: OrthoAdj", proc1.ProvNum, 0, PayPlanChargeType.Credit, proc1.ProcNum); int payPlansVersionPrev = PrefC.GetInt(PrefName.PayPlansVersion); try { PrefT.UpdateInt(PrefName.PayPlansVersion, (int)PayPlanVersions.AgeCreditsAndDebits); CheckAgingProcLifo(pat.PatNum, 166.67, 166.67, 166.67, 333.34, 833.35, YN.Yes); CheckAgingProcLifo(pat.PatNum, 166.67, 288.41, 288.41, 89.86, 833.35, YN.No); CheckAgingProcLifo(pat.PatNum, 166.67, 288.41, 288.41, 89.86, 833.35, YN.Unknown); //Unset will behave the same as Off for now, until we change default behavior in future. } finally { PrefT.UpdateInt(PrefName.PayPlansVersion, payPlansVersionPrev); } }
public void PaymentEdit_ConstructAndLinkChargeCredits_ChargesWithAttachedPayPlanCreditsWithPreviousPayments() { //new payplan Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D1120", ProcStat.C, "", 135, DateTime.Today.AddMonths(-4)); Procedure proc2 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 60, DateTime.Today.AddMonths(-4)); PayPlan payplan = PayPlanT.CreatePayPlanWithCredits(pat.PatNum, 30, DateTime.Today.AddMonths(-3), 0, new List <Procedure>() { proc1, proc2 }); //Procedures's amount start should now be 0 from being attached. Make initial payments. PaymentT.MakePayment(pat.PatNum, 30, DateTime.Today.AddMonths(-2), payplan.PayPlanNum, procNum: proc1.ProcNum); PaymentT.MakePayment(pat.PatNum, 30, DateTime.Today.AddMonths(-1), payplan.PayPlanNum, procNum: proc1.ProcNum); //2 pay plan charges should have been removed from being paid. Make a new payment. Payment pay = PaymentT.MakePaymentNoSplits(pat.PatNum, 30, DateTime.Today, isNew: true, payType: 1); PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, pay, new List <long> { pat.PatNum }, true, false); PaymentEdit.InitData initData = PaymentEdit.Init(loadData.ListAssociatedPatients, Patients.GetFamily(pat.PatNum), new Family { }, pay , loadData.ListSplits, new List <Procedure>(), pat.PatNum, loadData: loadData); //should only see 2 pay plan charges that have not been paid, along with 2 pay plan charges that have been paid. Assert.AreEqual(2, initData.AutoSplitData.ListAccountCharges.FindAll(x => x.AmountStart > 0).Count); Assert.AreEqual(4, initData.AutoSplitData.ListAccountCharges.Count(x => x.Tag.GetType() == typeof(PayPlanCharge))); }
public void LedgersTests_ComputeAgingProcLifo_DateLastPay() { string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(fName: "Aging_DateLastPay", suffix: suffix); Procedure proc95 = ProcedureT.CreateProcedure(pat, "D0270", ProcStat.C, "", 1000, DateTime.Today.AddDays(-95)); Procedure proc85 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 100, DateTime.Today.AddDays(-85)); Payment pay50 = PaymentT.MakePayment(pat.PatNum, 50, DateTime.Today.AddDays(-50)); Adjustment adj40_1 = AdjustmentT.MakeAdjustment(pat.PatNum, 4, DateTime.Today.AddDays(-40), proc85.ProcDate, proc85.ProcNum); Adjustment adj40_2 = AdjustmentT.MakeAdjustment(pat.PatNum, 6, DateTime.Today.AddDays(-40), proc85.ProcDate, proc85.ProcNum); Payment pay2 = PaymentT.MakePayment(pat.PatNum, 50, DateTime.Today.AddDays(-2)); int agingProcLifoPrev = PrefC.GetInt(PrefName.AgingProcLifo); try { PrefT.UpdateInt(PrefName.AgingProcLifo, (int)YN.No); Dictionary <long, DataRow> dictAging = Ledgers.GetAgingGuarTransTable(DateTime.Today, new List <long> { pat.Guarantor }, hasDateLastPay: true); Assert.AreEqual(PIn.Date(dictAging[pat.Guarantor]["DateLastPay"].ToString()), pay2.PayDate); PrefT.UpdateInt(PrefName.AgingProcLifo, (int)YN.Yes); dictAging = Ledgers.GetAgingGuarTransTable(DateTime.Today, new List <long> { pat.Guarantor }, hasDateLastPay: true); Assert.AreEqual(PIn.Date(dictAging[pat.Guarantor]["DateLastPay"].ToString()), pay2.PayDate); } finally { PrefT.UpdateInt(PrefName.AgingProcLifo, agingProcLifoPrev); } }
public void PaymentEdit_AutoSplitForPayment_NoNegativeAutoSplits() { long provNumA = ProviderT.CreateProvider("provA"); Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 70); Procedure proc2 = ProcedureT.CreateProcedure(pat, "D0150", ProcStat.C, "", 20); //make an overpayment for one of the procedures so it spills over. DateTime payDate = DateTime.Today; Payment pay = PaymentT.MakePayment(pat.PatNum, 71, payDate, procNum: proc1.ProcNum); //pre-existing payment //attempt to make another payment. Auto splits should not suggest a negative split. Payment newPayment = PaymentT.MakePaymentNoSplits(pat.PatNum, 2, payDate, isNew: true, payType: Defs.GetDefsForCategory(DefCat.PaymentTypes, true)[0].DefNum);//current payment we're trying to make PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, newPayment, new List <long>() { pat.PatNum }, true, false); PaymentEdit.ConstructChargesData chargeData = PaymentEdit.GetConstructChargesData(new List <long> { pat.PatNum }, pat.PatNum, PaySplits.GetForPayment(pay.PayNum), pay.PayNum, false); PaymentEdit.ConstructResults constructResults = PaymentEdit.ConstructAndLinkChargeCredits(new List <long> { pat.PatNum }, pat.PatNum , chargeData.ListPaySplits, newPayment, new List <Procedure> ()); PaymentEdit.AutoSplit autoSplits = PaymentEdit.AutoSplitForPayment(constructResults); Assert.AreEqual(0, autoSplits.ListAutoSplits.FindAll(x => x.SplitAmt < 0).Count); //assert no negative auto splits were made. Assert.AreEqual(0, autoSplits.ListSplitsCur.FindAll(x => x.SplitAmt < 0).Count); //auto splits not catching everything }
public void PaymentEdit_Init_ChargesWithUnattachedPayPlanCreditsWithPreviousPayments() { //new payplan Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); long prov = ProviderT.CreateProvider("ProvA"); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D1120", ProcStat.C, "", 135, DateTime.Today.AddMonths(-4), provNum: prov); Procedure proc2 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 60, DateTime.Today.AddMonths(-4).AddDays(1), provNum: prov); PayPlan payplan = PayPlanT.CreatePayPlanWithCredits(pat.PatNum, 30, DateTime.Today.AddMonths(-3), prov, totalAmt: 195); //totalAmt since unattached credits //Make initial payments. PaymentT.MakePayment(pat.PatNum, 30, DateTime.Today.AddMonths(-2), payplan.PayPlanNum, prov, 0, 1); PaymentT.MakePayment(pat.PatNum, 30, DateTime.Today.AddMonths(-1), payplan.PayPlanNum, prov, 0, 1); //Go to make another payment. 2 pay plan charges should have been "removed" (amtStart to 0) from being paid. Payment pay = PaymentT.MakePaymentNoSplits(pat.PatNum, 30, DateTime.Today); PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, pay, new List <long> { pat.PatNum }, true, false); PaymentEdit.InitData initData = PaymentEdit.Init(loadData.ListAssociatedPatients, Patients.GetFamily(pat.PatNum), new Family { }, pay , loadData.ListSplits, new List <Procedure>(), pat.PatNum, loadData: loadData); //2 procs and 2 pp charges Assert.AreEqual(4, initData.AutoSplitData.ListAccountCharges.FindAll(x => x.AmountStart > 0).Count); Assert.AreEqual(2, initData.AutoSplitData.ListAccountCharges.Count(x => x.Tag.GetType() == typeof(Procedure))); Assert.AreEqual(4, initData.AutoSplitData.ListAccountCharges.Count(x => x.Tag.GetType() == typeof(PayPlanCharge))); }
public void PaymentEdit_Init_AutoSplitOverAllocation() //Legacy_TestFortyThree { string suffix = "43"; Patient pat = PatientT.CreatePatient(suffix); long patNum = pat.PatNum; Procedure procedure1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 40, DateTime.Now.AddDays(-1)); Procedure procedure2 = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 60, DateTime.Now.AddDays(-2)); Procedure procedure3 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 80, DateTime.Now.AddDays(-3)); Payment payment1 = PaymentT.MakePayment(patNum, 200, DateTime.Now.AddDays(-2)); Payment payment2 = PaymentT.MakePaymentNoSplits(patNum, 50, DateTime.Today); Family famForPat = Patients.GetFamily(patNum); List <Patient> listFamForPat = famForPat.ListPats.ToList(); PaymentEdit.InitData init = PaymentEdit.Init(listFamForPat, famForPat, new Family { }, payment2, new List <PaySplit>(), new List <Procedure>(), patNum); //Auto Splits will be in opposite order from least recent to most recent. //ListSplitsCur should contain one paysplit worth 50 and not attached to any procedures. Assert.AreEqual(1, init.AutoSplitData.ListSplitsCur.Count); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[0].SplitAmt != 50 || init.AutoSplitData.ListSplitsCur[0].ProcNum != 0); }
public void PaymentEdit_Init_UnattachedPaymentsAndAttachedAdjustments() { Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); long provNum = ProviderT.CreateProvider("prov1"); Procedure proc = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 135, DateTime.Today.AddMonths(-1).AddDays(1), provNum: provNum); Adjustment adjustment = AdjustmentT.MakeAdjustment(pat.PatNum, 20, DateTime.Today.AddDays(-15), provNum: provNum, procNum: proc.ProcNum); Payment existingPayment1 = PaymentT.MakePayment(pat.PatNum, 35, DateTime.Today.AddDays(-1)); //no prov or proc because it's unattached. Payment existingPayment2 = PaymentT.MakePayment(pat.PatNum, 20, DateTime.Today.AddDays(-1)); Payment payCur = PaymentT.MakePaymentNoSplits(pat.PatNum, 100); PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, payCur, new List <long> { pat.PatNum }, true, false); PaymentEdit.InitData initData = PaymentEdit.Init(loadData.ListAssociatedPatients, Patients.GetFamily(pat.PatNum), new Family { }, payCur , loadData.ListSplits, new List <Procedure>(), pat.PatNum, loadData: loadData); //Verify there is only one charge (the procedure's charge + the adjustment for the amount original) Assert.AreEqual(1, initData.AutoSplitData.ListAccountCharges.Count); Assert.AreEqual(typeof(Procedure), initData.AutoSplitData.ListAccountCharges[0].Tag.GetType()); Assert.AreEqual(0, initData.AutoSplitData.ListAccountCharges[0].AmountEnd); }
public void PaymentEdit_Init_AutoSplitWithAdjustmentAndExistingPayment() //Legacy_TestFortyFive { string suffix = "45"; Patient pat = PatientT.CreatePatient(suffix); long patNum = pat.PatNum; Procedure procedure1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 40, DateTime.Now.AddDays(-1)); Procedure procedure2 = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 60, DateTime.Now.AddDays(-2)); Procedure procedure3 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 80, DateTime.Now.AddDays(-3)); Adjustment adjustment = AdjustmentT.MakeAdjustment(patNum, -40, procDate: DateTime.Now.AddDays(-2)); Payment payment = PaymentT.MakePayment(patNum, 100, DateTime.Now.AddDays(-2), procNum: procedure3.ProcNum); Payment payment2 = PaymentT.MakePaymentNoSplits(patNum, 50, DateTime.Today); Family famForPat = Patients.GetFamily(patNum); List <Patient> listFamForPat = famForPat.ListPats.ToList(); PaymentEdit.InitData init = PaymentEdit.Init(listFamForPat, famForPat, new Family { }, payment2, new List <PaySplit>(), new List <Procedure>(), patNum); //Auto Splits will be in opposite order from least recent to most recent. //ListSplitsCur should contain two paysplits, 40 attached to the D1110 and another for the remainder of 10, not attached to any procedure. Assert.AreEqual(2, init.AutoSplitData.ListSplitsCur.Count); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[0].SplitAmt != 40 || init.AutoSplitData.ListSplitsCur[0].ProcNum != procedure1.ProcNum); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[1].SplitAmt != 10 || init.AutoSplitData.ListSplitsCur[1].ProcNum != 0); }
public void PaymentEdit_Init_CorrectlyOrderedAutoSplitsWithExistingPayment() //Legacy_TestFortyTwo { string suffix = "42"; Patient pat = PatientT.CreatePatient(suffix); long patNum = pat.PatNum; Procedure procedure1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 40, DateTime.Now.AddDays(-1)); Procedure procedure2 = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 60, DateTime.Now.AddDays(-2)); Procedure procedure3 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 80, DateTime.Now.AddDays(-3)); Payment payment1 = PaymentT.MakePayment(patNum, 110, DateTime.Now.AddDays(-2)); Payment payment2 = PaymentT.MakePaymentNoSplits(patNum, 80, DateTime.Today); Family famForPat = Patients.GetFamily(patNum); List <Patient> listFamForPat = famForPat.ListPats.ToList(); PaymentEdit.InitData init = PaymentEdit.Init(listFamForPat, famForPat, new Family { }, payment2, new List <PaySplit>(), new List <Procedure>(), patNum); //Auto Splits will be in opposite order from least recent to most recent. //ListSplitsCur should contain three paysplits, one for procedure1 for 40, and one for procedure2 for 30, //and an unallocated split for 10 with the remainder on the payment (40+30+10=80). Assert.AreEqual(3, init.AutoSplitData.ListSplitsCur.Count); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[0].SplitAmt != 30 || init.AutoSplitData.ListSplitsCur[0].ProcNum != procedure2.ProcNum); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[1].SplitAmt != 40 || init.AutoSplitData.ListSplitsCur[1].ProcNum != procedure1.ProcNum); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[2].SplitAmt != 10 || init.AutoSplitData.ListSplitsCur[2].ProcNum != 0); }
public void PaymentEdit_Init_IncomeTransferWhenIncomeIncorrectlyAllocatedToOneProvider() { Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); long provNum1 = ProviderT.CreateProvider("prov1"); long provNum2 = ProviderT.CreateProvider("prov2"); Procedure procByProv1 = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 100, DateTime.Today.AddMonths(-1), provNum: provNum1); Procedure procByProv2 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 50, DateTime.Today.AddMonths(-1), provNum: provNum2); Payment payAllForOneProv = PaymentT.MakePayment(pat.PatNum, 150, DateTime.Today.AddDays(-1), provNum: provNum1, payType: 1); //make entire payment to prov1 //make an income transfer and see if it catches the over and underallocations Payment incomeTransfer = PaymentT.MakePaymentNoSplits(pat.PatNum, 0, isNew: true); PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, incomeTransfer, new List <long> { pat.PatNum }, true); PaymentEdit.InitData initData = PaymentEdit.Init(loadData.ListAssociatedPatients, Patients.GetFamily(pat.PatNum), new Family { }, incomeTransfer , loadData.ListSplits, new List <Procedure>(), pat.PatNum, isIncomeTxfr: true, loadData: loadData); //Assert there the appropriate amounts going to the correct providers. Assert.AreEqual(2, initData.AutoSplitData.ListAccountCharges.FindAll(x => x.Tag.GetType() == typeof(Procedure)).Count); Assert.AreEqual(1, initData.AutoSplitData.ListAccountCharges.FindAll(x => x.Tag.GetType() == typeof(PaySplit)).Count); //FormPayment.FillGridCharges will sum up the charges depending on what grouping is selected. Here we are just going to validate the output of //PaymentEdit.Init is as it should be. Assert.AreEqual(1, initData.AutoSplitData.ListAccountCharges.FindAll(x => x.AmountStart == -150 && x.ProvNum == provNum1).Count); }
public void LedgersTests_ComputeAgingProcLifo_LargeDb() { Def defNeg = DefT.CreateDefinition(DefCat.AdjTypes, "Ortho Revenue", "-"); Def defPos = DefT.CreateDefinition(DefCat.AdjTypes, "Ortho Revenue", "+"); Def defPay = DefT.CreateDefinition(DefCat.PaymentTypes, "Check"); List <Patient> listPats = new List <Patient>(); for (int i = 0; i < 1000; i++) { Patient pat = PatientT.CreatePatient(fName: "Schedule Based", lName: "UDP Ortho LargeDb"); Procedure proc = ProcedureT.CreateProcedure(pat, "D8090", ProcStat.C, "", 4000, DateTime.Today.AddMonths(-6).AddDays(-1)); PayPlan payPlan = PayPlanT.CreatePayPlan(pat.PatNum, 4000, 166.67, DateTime.Today.AddMonths(-6).AddDays(-1), proc.ProvNum); Adjustment adj6 = AdjustmentT.MakeAdjustment(pat.PatNum, -2800, DateTime.Today.AddMonths(-6).AddDays(-1), proc.ProcDate, proc.ProcNum, provNum: proc.ProvNum, adjType: defNeg.DefNum); Payment pay6 = PaymentT.MakePayment(pat.PatNum, 166.67, DateTime.Today.AddMonths(-6).AddDays(-1), payPlanNum: payPlan.PayPlanNum, provNum: proc.ProvNum, procNum: proc.ProcNum, payType: defPay.DefNum); PayPlanCharge ppc6 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-6).AddDays(-1), 1200, 0, "D8090: CompOrthoAdlt", proc.ProvNum, 0, PayPlanChargeType.Credit, proc.ProcNum); Adjustment adj5 = AdjustmentT.MakeAdjustment(pat.PatNum, 121.74, DateTime.Today.AddMonths(-5).AddDays(-1), proc.ProcDate, proc.ProcNum, provNum: proc.ProvNum, adjType: defPos.DefNum); Payment pay5 = PaymentT.MakePayment(pat.PatNum, 166.67, DateTime.Today.AddMonths(-5).AddDays(-1), payPlanNum: payPlan.PayPlanNum, provNum: proc.ProvNum, procNum: proc.ProcNum, payType: defPay.DefNum); PayPlanCharge ppc5 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-5).AddDays(-1), 121.74, 0, "D8090: CompOrthoAdlt", proc.ProvNum, 0, PayPlanChargeType.Credit, proc.ProcNum); Adjustment adj4 = AdjustmentT.MakeAdjustment(pat.PatNum, 121.74, DateTime.Today.AddMonths(-4).AddDays(-1), proc.ProcDate, proc.ProcNum, provNum: proc.ProvNum, adjType: defPos.DefNum); PayPlanCharge ppc4 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-4).AddDays(-1), 121.74, 0, "D8090: CompOrthoAdlt", proc.ProvNum, 0, PayPlanChargeType.Credit, proc.ProcNum); Adjustment adj3 = AdjustmentT.MakeAdjustment(pat.PatNum, 121.74, DateTime.Today.AddMonths(-3).AddDays(-1), proc.ProcDate, proc.ProcNum, provNum: proc.ProvNum, adjType: defPos.DefNum); PayPlanCharge ppc3 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-3).AddDays(-1), 121.74, 0, "D8090: CompOrthoAdlt", proc.ProvNum, 0, PayPlanChargeType.Credit, proc.ProcNum); Adjustment adj2 = AdjustmentT.MakeAdjustment(pat.PatNum, 121.74, DateTime.Today.AddMonths(-2).AddDays(-1), proc.ProcDate, proc.ProcNum, provNum: proc.ProvNum, adjType: defPos.DefNum); PayPlanCharge ppc2 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-2).AddDays(-1), 121.74, 0, "D8090: CompOrthoAdlt", proc.ProvNum, 0, PayPlanChargeType.Credit, proc.ProcNum); Adjustment adj1 = AdjustmentT.MakeAdjustment(pat.PatNum, 121.74, DateTime.Today.AddMonths(-1).AddDays(-1), proc.ProcDate, proc.ProcNum, provNum: proc.ProvNum, adjType: defPos.DefNum); PayPlanCharge ppc1 = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddMonths(-1).AddDays(-1), 121.74, 0, "D8090: CompOrthoAdlt", proc.ProvNum, 0, PayPlanChargeType.Credit, proc.ProcNum); listPats.Add(pat); } int payPlansVersionPrev = PrefC.GetInt(PrefName.PayPlansVersion); int agingProcLifoPrev = PrefC.GetInt(PrefName.AgingProcLifo); Stopwatch swOn = new Stopwatch(); Stopwatch swOff = new Stopwatch(); Stopwatch swUnset = new Stopwatch(); try { PrefT.UpdateInt(PrefName.PayPlansVersion, (int)PayPlanVersions.AgeCreditsAndDebits); swOn.Start(); PrefT.UpdateInt(PrefName.AgingProcLifo, (int)YN.Yes); Ledgers.ComputeAging(0, DateTime.Today); //Compute aging for all patients. foreach (Patient pat in listPats) { PatAssertBalances(pat.PatNum, 166.67, 166.67, 166.67, 333.34, 833.35); } swOn.Stop(); swOff.Start(); PrefT.UpdateInt(PrefName.AgingProcLifo, (int)YN.No); Ledgers.ComputeAging(0, DateTime.Today); //Compute aging for all patients. foreach (Patient pat in listPats) { PatAssertBalances(pat.PatNum, 166.67, 288.41, 288.41, 89.86, 833.35); } swOff.Stop(); swUnset.Start(); PrefT.UpdateInt(PrefName.AgingProcLifo, (int)YN.Unknown); Ledgers.ComputeAging(0, DateTime.Today); //Compute aging for all patients. foreach (Patient pat in listPats) { PatAssertBalances(pat.PatNum, 166.67, 288.41, 288.41, 89.86, 833.35); } swUnset.Stop(); } finally { PrefT.UpdateInt(PrefName.PayPlansVersion, payPlansVersionPrev); PrefT.UpdateInt(PrefName.AgingProcLifo, agingProcLifoPrev); } //Fails if swOn run time is at least 10 times as large as the average of the runtimes for swUnset and swOff. Assert.IsTrue(swOn.Elapsed.TotalMilliseconds < (swUnset.Elapsed.TotalMilliseconds + swOff.Elapsed.TotalMilliseconds) * 5, "Pref On: " + swOn.Elapsed + "\r\n" + "Pref Off: " + swOff.Elapsed + "\r\n" + "Pref Unset: " + swUnset.Elapsed); }