Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        public void AgingData_GetAgingData_PayPlanBillInAdvanceDays_WithPendingProc()
        {
            string   suffix            = MethodBase.GetCurrentMethod().Name;
            Patient  patient           = PatientT.CreatePatient(suffix);
            long     provNum           = ProviderT.CreateProvider(suffix);
            DateTime datePayPlan       = DateTime.Today.AddDays(5);
            DateTime datePayPlanCreate = DateTime.Today.AddMonths(-1);          //Payment Plan was created a month ago.
            DateTime dateProc          = DateTime.Today;
            DateTime dateStatement     = DateTime.Today.AddDays(-5);

            //Create a payment plan where the first charge date in the future.
            PayPlanT.CreatePayPlan(patient.PatNum, 1000, 500, datePayPlan, provNum);
            //Create a completed procedure that was completed today, before the first payplan charge date.
            ProcedureT.CreateProcedure(patient, "D1100", ProcStat.C, "", 5, dateProc);
            //Insert a statement that was sent during the "bill in advance days" for the payment plan charge above.
            StatementT.CreateStatement(patient.PatNum, mode_: StatementMode.Mail, isSent: true, dateSent: dateStatement);
            //Make sure that the preference PayPlansBillInAdvanceDays is set to a day range that encompasses the first payment plan charge date.
            PrefT.UpdateLong(PrefName.PayPlansBillInAdvanceDays, 10);
            //This scenario is exploiting the fact that the statement created 5 days ago was technically created for the payment plan (in advance).
            //Because of this fact, the patient shouldn't show up in the billing list until something new happens after the statement date.
            //The procedure that was completed today should cause the patient to show up in the billing list (something new happened).
            SerializableDictionary <long, PatAgingData> dictPatAgingData = AgingData.GetAgingData(false, true, false, false, false, new List <long>());

            //Assert that the patient has been returned due to the completed procedure.
            Assert.IsTrue(dictPatAgingData.ContainsKey(patient.PatNum), "No aging data was returned for the patient.");
            //Assert all pertinent PatAgingData for this unit test.
            Assert.IsNotNull(dictPatAgingData[patient.PatNum].ListPatAgingTransactions);
            PatAgingTransaction patAgingTransactionPP = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                        .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.PayPlanCharge);

            //Act like the payment plan was created a month ago.
            patAgingTransactionPP.SecDateTEntryTrans = datePayPlanCreate;
            PatAgingTransaction patAgingTransactionProc = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                          .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.Procedure);

            Assert.IsNotNull(patAgingTransactionPP);
            Assert.IsNotNull(patAgingTransactionProc);
            Assert.AreEqual(datePayPlan, patAgingTransactionPP.DateLastTrans);
            Assert.AreEqual(dateProc, patAgingTransactionProc.DateLastTrans);
            SerializableDictionary <long, List <PatAgingTransaction> > dictPatAgingTrans = new SerializableDictionary <long, List <PatAgingTransaction> >();

            foreach (KeyValuePair <long, PatAgingData> kvp in dictPatAgingData)
            {
                dictPatAgingTrans[kvp.Key] = kvp.Value.ListPatAgingTransactions;
            }
            //The last transaction date should be the procedure date and not the pay plan charge date (even though pay plan is later).
            Assert.AreEqual(dateProc, AgingData.GetDateLastTrans(dictPatAgingTrans[patient.PatNum], dateStatement).Date);
            List <PatAging> listPatAging = Patients.GetAgingList("", DateTime.Today.AddMonths(-1), new List <long>(), false, false, 0, false, false, new List <long>(),
                                                                 false, false, new List <long>(), new List <long>(), dictPatAgingTrans);

            //Assert that the patient has been flagged to get a new statement due to procedure that was completed above.
            Assert.IsTrue(listPatAging.Any(x => x.PatNum == patient.PatNum), "The expected patient was not present in the AgingList.");
        }
Beispiel #3
0
        public void AgingData_GetAgingData_PayPlanBillInAdvanceDays_WithNewPayPlan()
        {
            string   suffix            = MethodBase.GetCurrentMethod().Name;
            Patient  patient           = PatientT.CreatePatient(suffix);
            long     provNum           = ProviderT.CreateProvider(suffix);
            DateTime datePayPlanCharge = DateTime.Today.AddDays(5);
            DateTime datePayPlanCreate = DateTime.Today;          //The payment plan that we are about to create will automatically have this date as the SecTDateEntry
            DateTime dateProc          = DateTime.Today.AddDays(-1);
            DateTime dateStatement     = DateTime.Today.AddDays(-1);

            //Create a payment plan where the first charge date in the future.
            PayPlanT.CreatePayPlan(patient.PatNum, 1000, 500, datePayPlanCharge, provNum);
            //Create a completed procedure that was completed yesterday, before the first payplan charge date AND before the payment plan creation date.
            ProcedureT.CreateProcedure(patient, "D1100", ProcStat.C, "", 5, dateProc);
            //Insert a statement that was sent during the "bill in advance days" for the payment plan charge AND before the payment plan creation date.
            StatementT.CreateStatement(patient.PatNum, mode_: StatementMode.Mail, isSent: true, dateSent: dateStatement);
            //Make sure that the preference PayPlansBillInAdvanceDays is set to a day range that encompasses the first payment plan charge date.
            PrefT.UpdateLong(PrefName.PayPlansBillInAdvanceDays, 10);
            //This scenario is exploiting the fact that the statement created yesterday was NOT technically created for the payment plan (in advance).
            //Because of this fact, the patient should show up in the billing list because something new has happened after the statement date.
            //The new payment plan should not be associated to the previous statement due to the SecTDateEntry.
            SerializableDictionary <long, PatAgingData> dictPatAgingData = AgingData.GetAgingData(false, true, false, false, false, new List <long>());

            //Assert that the patient has been returned due to owing money on the payment plan that was created.
            Assert.IsTrue(dictPatAgingData.ContainsKey(patient.PatNum), "No aging data was returned for the patient.");
            Assert.IsNotNull(dictPatAgingData[patient.PatNum].ListPatAgingTransactions);
            PatAgingTransaction patAgingTransactionPP = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                        .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.PayPlanCharge);
            PatAgingTransaction patAgingTransactionProc = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                          .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.Procedure);

            Assert.IsNotNull(patAgingTransactionPP);
            Assert.IsNotNull(patAgingTransactionProc);
            Assert.AreEqual(datePayPlanCharge, patAgingTransactionPP.DateLastTrans);
            Assert.AreEqual(dateProc, patAgingTransactionProc.DateLastTrans);
            SerializableDictionary <long, List <PatAgingTransaction> > dictPatAgingTrans = new SerializableDictionary <long, List <PatAgingTransaction> >();

            foreach (KeyValuePair <long, PatAgingData> kvp in dictPatAgingData)
            {
                dictPatAgingTrans[kvp.Key] = kvp.Value.ListPatAgingTransactions;
            }
            //The last transaction date should be the charge date of the pay plan charge which indicates that the statement doesn't apply
            //to the payment plan because the payment plan was created AFTER the statement that just so happens to fall within the "bill in advance days".
            Assert.AreEqual(datePayPlanCharge, AgingData.GetDateLastTrans(dictPatAgingTrans[patient.PatNum], dateStatement).Date);
            List <PatAging> listPatAging = Patients.GetAgingList("", DateTime.Today.AddMonths(-1), new List <long>(), false, false, 0, false, false, new List <long>(),
                                                                 false, false, new List <long>(), new List <long>(), dictPatAgingTrans);

            Assert.IsTrue(listPatAging.Any(x => x.PatNum == patient.PatNum), "The expected patient was not present in the AgingList.");
        }
Beispiel #4
0
        public void LedgersTests_ComputeAgingProcLifo_PayPlan3()
        {
            string        suffix              = MethodBase.GetCurrentMethod().Name;
            Patient       pat                 = PatientT.CreatePatient(fName: "Aging_PayPlan3", suffix: suffix);
            Procedure     proc95              = ProcedureT.CreateProcedure(pat, "D0270", ProcStat.C, "", 200, DateTime.Today.AddDays(-95));
            Procedure     proc35              = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 100, DateTime.Today.AddDays(-35));
            PayPlan       payPlan             = PayPlanT.CreatePayPlan(pat.PatNum, 100, 50, DateTime.Today.AddDays(-35), proc35.ProvNum);
            Adjustment    adj5                = AdjustmentT.MakeAdjustment(pat.PatNum, -5.50, DateTime.Today.AddDays(-5), proc35.ProcDate, proc35.ProcNum);
            PayPlanCharge ppc5                = PayPlanChargeT.CreateOne(payPlan.PayPlanNum, pat.Guarantor, pat.PatNum, DateTime.Today.AddDays(-5), 100, 0, chargeType: PayPlanChargeType.Credit, procNum: proc35.ProcNum);
            int           payPlansVersionPrev = PrefC.GetInt(PrefName.PayPlansVersion);

            try {
                PrefT.UpdateInt(PrefName.PayPlansVersion, (int)PayPlanVersions.AgeCreditsAndDebits);
                CheckAgingProcLifo(pat.PatNum, 50, 44.50, 0, 200, 100, YN.Yes);
                CheckAgingProcLifo(pat.PatNum, 50, 150, 0, 94.50, 100, YN.No);
                CheckAgingProcLifo(pat.PatNum, 50, 150, 0, 94.50, 100, YN.Unknown);          //Unset will behave the same as Off for now, until we change default behavior in future.
            }
            finally {
                PrefT.UpdateInt(PrefName.PayPlansVersion, payPlansVersionPrev);
            }
        }
Beispiel #5
0
        public void AgingData_GetAgingData_PayPlanBillInAdvanceDays_WithStatement()
        {
            string  suffix  = MethodBase.GetCurrentMethod().Name;
            Patient patient = PatientT.CreatePatient(suffix);
            long    provNum = ProviderT.CreateProvider(suffix);
            //Create a payment plan where the first charge date is in the future.
            DateTime dateTimePayPlanCharge = DateTime.Today.AddDays(5);
            DateTime dateStatement         = DateTime.Today;

            PayPlanT.CreatePayPlan(patient.PatNum, 1000, 500, dateTimePayPlanCharge, provNum);
            //Make sure that the preference PayPlansBillInAdvanceDays is set to a day range that encompasses the first payment plan charge date.
            PrefT.UpdateLong(PrefName.PayPlansBillInAdvanceDays, 10);
            SerializableDictionary <long, PatAgingData> dictPatAgingData = AgingData.GetAgingData(false, true, false, false, false, new List <long>());

            //Assert that the patient has been returned due to owing money on a payment plan that falls within the "bill in advance days" preference.
            Assert.IsTrue(dictPatAgingData.ContainsKey(patient.PatNum), "No aging data was returned for the patient.");
            //Assert all pertinent PatAgingData for this unit test.
            Assert.IsNotNull(dictPatAgingData[patient.PatNum].ListPatAgingTransactions);
            PatAgingTransaction patAgingTransaction = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                      .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.PayPlanCharge);

            Assert.IsNotNull(patAgingTransaction);
            Assert.AreEqual(dateTimePayPlanCharge, patAgingTransaction.DateLastTrans);
            //Insert a statement that was sent today.  This should cause the patient to be excluded from the PatAging list returned.
            StatementT.CreateStatement(patient.PatNum, mode_: StatementMode.Mail, isSent: true, dateSent: dateStatement);
            SerializableDictionary <long, List <PatAgingTransaction> > dictPatAgingTrans = new SerializableDictionary <long, List <PatAgingTransaction> >();

            foreach (KeyValuePair <long, PatAgingData> kvp in dictPatAgingData)
            {
                dictPatAgingTrans[kvp.Key] = kvp.Value.ListPatAgingTransactions;
            }
            //Assert that GetDateLastTrans() returns the date we are expecting.
            Assert.AreEqual(DateTime.MinValue, AgingData.GetDateLastTrans(dictPatAgingTrans[patient.PatNum], dateStatement).Date);
            List <PatAging> listPatAging = Patients.GetAgingList("", DateTime.Today.AddMonths(-1), new List <long>(), false, false, 0, false, false, new List <long>(), false, false,
                                                                 new List <long>(), new List <long>(), dictPatAgingTrans);

            //Assert that the patient will not get a new statement due to the statement that was created above.
            Assert.IsFalse(listPatAging.Any(x => x.PatNum == patient.PatNum), "The patient was not supposed to be present in the AgingList.");
        }
Beispiel #6
0
        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);
        }