public void FeeSchedTools_GlobalUpdateFees() { PrefT.UpdateBool(PrefName.MedicalFeeUsedForNewProcs, false); string suffix = MethodBase.GetCurrentMethod().Name; string procStr = "D0120"; string procStr2 = "D0145"; double procFee = 100; ProcedureCode procCode = ProcedureCodes.GetProcCode(procStr); ProcedureCode procCode2 = ProcedureCodes.GetProcCode(procStr2); //Set up clinic, prov, pat Clinic clinic = ClinicT.CreateClinic(suffix); long feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix, false); long provNum = ProviderT.CreateProvider(suffix, feeSchedNum: feeSchedNum); Fee fee = FeeT.GetNewFee(feeSchedNum, procCode.CodeNum, procFee, clinic.ClinicNum, provNum); Fee fee2 = FeeT.GetNewFee(feeSchedNum, procCode2.CodeNum, procFee, clinic.ClinicNum, provNum); Patient pat = PatientT.CreatePatient(suffix, provNum, clinic.ClinicNum); //Chart a procedure for this proccode/pat as well as a different proccode Procedure proc = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", fee.Amount); Procedure proc2 = ProcedureT.CreateProcedure(pat, procStr2, ProcStat.TP, "", fee2.Amount); //Update the fee amount for only the D0120 code fee.Amount = 50; Fees.Update(fee); //Now run global update fees Procedures.GlobalUpdateFees(Fees.GetByClinicNum(clinic.ClinicNum), clinic.ClinicNum, clinic.Abbr); //Make sure we have the same number of updated fees, and fee amounts for both procs proc = Procedures.GetOneProc(proc.ProcNum, false); proc2 = Procedures.GetOneProc(proc2.ProcNum, false); Assert.AreEqual(fee.Amount, proc.ProcFee); Assert.AreEqual(fee2.Amount, proc2.ProcFee); }
public void SecurityLogs_MakeLogEntry_DuplicateEntryParallelRandomKeys() { Patient patient = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); //First, turn on random primary keys PrefT.UpdateBool(PrefName.RandomPrimaryKeys, true); //There are lots of bug submissions with exception text like "Duplicate entry 'XXXXX' for key 'PRIMARY'". //OpenDentBusiness.SecurityLogs.MakeLogEntry() seems to be the common theme for most of the submissions. //Spawn parallel threads to insert 200 security logs trying to get a duplicate entry exception. List <Action> listActions = new List <Action>(); for (int i = 0; i < 200; i++) { listActions.Add(() => SecurityLogs.MakeLogEntry(Permissions.Accounting, patient.PatNum, "", 0, DateTime.Now.AddDays(-7))); } //Parallel threads do not support Middle Tier mode when unit testing due to how we have to fake being both the client and the server. RemotingRole remotingRoleOld = RemotingClient.RemotingRole; if (RemotingClient.RemotingRole != RemotingRole.ClientDirect) { RemotingClient.RemotingRole = RemotingRole.ClientDirect; } ODThread.RunParallel(listActions, onException: (ex) => { PrefT.UpdateBool(PrefName.RandomPrimaryKeys, false); RemotingClient.RemotingRole = remotingRoleOld; Assert.Fail(ex.Message); }); PrefT.UpdateBool(PrefName.RandomPrimaryKeys, false); RemotingClient.RemotingRole = remotingRoleOld; }
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 Fees_GetListFromObjects_ProviderPracticeDefault() { string suffix = MethodBase.GetCurrentMethod().Name; ProcedureCode procedureCode = ProcedureCodeT.CreateProcCode("D1110"); Fee fee = CreateSingleFee(suffix, (_defaultFeeAmt * _rand.NextDouble()), hasProv: true, codeNum: procedureCode.CodeNum); //Update our new provider so that they are associated to the new fee schedule that was just created. Provider prov = Providers.GetProv(fee.ProvNum); prov.FeeSched = fee.FeeSched; ProviderT.Update(prov); //Update the database so that the practice provider is the provider associated to our new fee. long practiceDefaultProvOld = PrefC.GetLong(PrefName.PracticeDefaultProv); PrefT.UpdateLong(PrefName.PracticeDefaultProv, fee.ProvNum); //Since our new fee is associated to the fee schedule of the practice default provider, it should be returned by GetListFromObjects(). List <Fee> listFees = Fees.GetListFromObjects(new List <ProcedureCode>() { procedureCode }, null, null, 0, 0, 0, null, null, null, null, 0); //Put the default provider back the way it was prior to asserting. PrefT.UpdateLong(PrefName.PracticeDefaultProv, practiceDefaultProvOld); Assert.IsTrue(listFees.Exists(x => x.FeeNum == fee.FeeNum)); }
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 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."); }
private void CheckAgingProcLifo(long patNum, double bal_0_30, double bal_31_60, double bal_61_90, double balOver90, double payPlanDue, YN prefVal) { int agingProcLifoPrev = PrefC.GetInt(PrefName.AgingProcLifo); try { PrefT.UpdateInt(PrefName.AgingProcLifo, (int)prefVal); Ledgers.ComputeAging(patNum, DateTime.Today); PatAssertBalances(patNum, bal_0_30, bal_31_60, bal_61_90, balOver90, payPlanDue); } finally { PrefT.UpdateInt(PrefName.AgingProcLifo, agingProcLifoPrev); } }
public void LedgersTests_ComputeAging_PayPlanDynamic() { List <Procedure> listProcs = new List <Procedure>(); List <Adjustment> listAdjs = new List <Adjustment>(); long provNum = ProviderT.CreateProvider("Aging_PayPlanDynamic"); string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(fName: "Aging_PayPlanDynamic", suffix: suffix); Family fam = Patients.GetFamily(pat.PatNum); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D0210", ProcStat.C, "", 45, DateTime.Today.AddDays(-61), provNum: provNum); Procedure proc2 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 55, DateTime.Today.AddDays(-32), provNum: provNum); Procedure proc3 = ProcedureT.CreateProcedure(pat, "D0270", ProcStat.C, "", 65, DateTime.Today.AddDays(-15), provNum: provNum); Adjustment adjProc2 = AdjustmentT.MakeAdjustment(pat.PatNum, 10, proc2.ProcDate, proc2.ProcDate, proc2.ProcNum, provNum); Adjustment adjProc3 = AdjustmentT.MakeAdjustment(pat.PatNum, 20, proc3.ProcDate, proc3.ProcDate, proc3.ProcNum, provNum); Adjustment adj = AdjustmentT.MakeAdjustment(pat.PatNum, 30, DateTime.Today.AddDays(-5), provNum: provNum); listProcs.AddRange(new List <Procedure> { proc1, proc2, proc3 }); listAdjs.AddRange(new List <Adjustment> { adj }); PayPlan payPlan = PayPlanT.CreateDynamicPaymentPlan(pat.PatNum, pat.PatNum, DateTime.Today.AddDays(-1), 0, 0, 40, listProcs, listAdjs); //PayPlan payplan=PayPlanT.CreatePayPlanWithCredits(pat.PatNum,40,DateTime.Today,provNum:provNum,listProcs,195,pat.PatNum); //make two non payplan productions to put on the account Procedure procUnattached = ProcedureT.CreateProcedure(pat, "D0210", ProcStat.C, "", 35, DateTime.Today.AddDays(-91), provNum: provNum); //Run pay plan logic to generate first set of charges List <PayPlanCharge> listChargesDb = PayPlanCharges.GetForPayPlan(payPlan.PayPlanNum); List <PayPlanLink> listEntries = PayPlanLinks.GetForPayPlans(new List <long> { payPlan.PayPlanNum }); PayPlanTerms terms = PayPlanT.GetTerms(payPlan, listEntries); List <PayPlanCharge> listChargesThisPeriod = PayPlanEdit.GetListExpectedCharges(listChargesDb, terms, fam, listEntries, payPlan, true); Assert.AreEqual(40, listChargesThisPeriod.Sum(x => x.Principal)); foreach (PayPlanCharge charge in listChargesThisPeriod) { PayPlanCharges.Insert(charge); } int payPlansVersionPrev = PrefC.GetInt(PrefName.PayPlansVersion); try { PrefT.UpdateInt(PrefName.PayPlansVersion, (int)PayPlanVersions.AgeCreditsAndDebits); CheckAgingProcLifo(pat.PatNum, 70, 0, 0, 5, 40, YN.Yes); //new CheckAgingProcLifo(pat.PatNum, 75, 0, 0, 0, 40, YN.No); //old CheckAgingProcLifo(pat.PatNum, 75, 0, 0, 0, 40, YN.Unknown); } finally { PrefT.UpdateInt(PrefName.PayPlansVersion, payPlansVersionPrev); } }
public void LedgersTests_ComputeAging_PayPlanDynamicCreditsWithClaimProcs() { List <Procedure> listProcs = new List <Procedure>(); List <Adjustment> listAdjs = new List <Adjustment>(); long provNum = ProviderT.CreateProvider("Aging_PayPlanDynamic"); string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(fName: "Aging_PayPlanDynamic", suffix: suffix); Family fam = Patients.GetFamily(pat.PatNum); Procedure proc45 = ProcedureT.CreateProcedure(pat, "D0210", ProcStat.C, "", 45, DateTime.Today.AddDays(-61), provNum: provNum); ClaimProc cp45 = new ClaimProc(); InsuranceInfo insInfo = InsuranceT.AddInsurance(pat, "DynPayPlan"); ClaimProcs.CreateEst(cp45, proc45, insInfo.PriInsPlan, insInfo.PriInsSub); cp45.Status = ClaimProcStatus.NotReceived; cp45.InsEstTotal = -1; cp45.InsPayEst = 15; cp45.WriteOffEst = 0; cp45.WriteOff = 0; ClaimProcs.Update(cp45); listProcs.AddRange(new List <Procedure> { proc45 }); PayPlan payPlan = PayPlanT.CreateDynamicPaymentPlan(pat.PatNum, pat.PatNum, DateTime.Today.AddDays(-1), 0, 0, 30, listProcs, listAdjs); //make two non payplan productions to put on the account Procedure procUnattached = ProcedureT.CreateProcedure(pat, "D0210", ProcStat.C, "", 35, DateTime.Today.AddDays(-91), provNum: provNum); //Run pay plan logic to generate first set of charges List <PayPlanCharge> listChargesDb = PayPlanCharges.GetForPayPlan(payPlan.PayPlanNum); List <PayPlanLink> listEntries = PayPlanLinks.GetForPayPlans(new List <long> { payPlan.PayPlanNum }); PayPlanTerms terms = PayPlanT.GetTerms(payPlan, listEntries); List <PayPlanCharge> listChargesThisPeriod = PayPlanEdit.GetListExpectedCharges(listChargesDb, terms, fam, listEntries, payPlan, true); Assert.AreEqual(30, listChargesThisPeriod.Sum(x => x.Principal)); foreach (PayPlanCharge charge in listChargesThisPeriod) { PayPlanCharges.Insert(charge); } int payPlansVersionPrev = PrefC.GetInt(PrefName.PayPlansVersion); try { PrefT.UpdateInt(PrefName.PayPlansVersion, (int)PayPlanVersions.AgeCreditsAndDebits); CheckAgingProcLifo(pat.PatNum, 30, 0, 15, 35, 30, YN.Yes); //new - pay plan credit of $30 gets applied to cooresponding procedure CheckAgingProcLifo(pat.PatNum, 30, 0, 45, 5, 30, YN.No); //old - pay plan credit gets applied to oldest production on the account CheckAgingProcLifo(pat.PatNum, 30, 0, 45, 5, 30, YN.Unknown); } finally { PrefT.UpdateInt(PrefName.PayPlansVersion, payPlansVersionPrev); } }
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."); }
///<summary>Creates patients with billing cycle day. Sets BillingUseBillingCycleDay preference to true. Creates an UpdateHistory ///entry for version 16.1.1.0. Deletes all current repeat charges.</summary> public Patient CreatePatForRepeatCharge(string suffix, int billingCycleDay) { Patient pat = PatientT.CreatePatient(suffix); Patient patOld = pat.Copy(); pat.BillingCycleDay = billingCycleDay; Patients.Update(pat, patOld); PrefT.UpdateBool(PrefName.BillingUseBillingCycleDay, true); UpdateHistoryT.CreateUpdateHistory("16.1.1.0"); Prefs.RefreshCache(); List <RepeatCharge> listRepeatingCharges = RepeatCharges.Refresh(0).ToList(); listRepeatingCharges.ForEach(x => RepeatCharges.Delete(x)); return(pat); }
public void SetupTest() { PrefT.UpdateBool(PrefName.EasyNoClinics, false); PrefT.UpdateInt(PrefName.TasksGlobalFilterType, (int)GlobalTaskFilterType.None); TaskListT.ClearTaskListTable(); TaskT.ClearTaskTable(); TaskSubscriptionT.ClearTaskSubscriptionTable(); _taskListMainNoFilter = TaskListT.CreateTaskList(descript: "No Filter", parent: 0, globalTaskFilterType: GlobalTaskFilterType.None); _taskListClinic = TaskListT.CreateTaskList(descript: "Clinic Filter", parent: _taskListMainNoFilter.TaskListNum, globalTaskFilterType: GlobalTaskFilterType.Clinic); _taskListRegion = TaskListT.CreateTaskList(descript: "Region Filter", parent: _taskListMainNoFilter.TaskListNum, globalTaskFilterType: GlobalTaskFilterType.Region); _taskListRepeating = TaskListT.CreateTaskList("Repeating", isRepeating: true); TaskSubscriptions.TrySubscList(_taskListMainNoFilter.TaskListNum, _userA.UserNum); TaskSubscriptions.TrySubscList(_taskListClinic.TaskListNum, _userA.UserNum); TaskSubscriptions.TrySubscList(_taskListRegion.TaskListNum, _userA.UserNum); TaskSubscriptions.TrySubscList(_taskListRegion.TaskListNum, _userNW.UserNum); }
public void LedgersTests_ComputeAgingProcLifo_InsWoEst_And_InsPayEst() { string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(fName: "Aging_InsEst", suffix: suffix); InsuranceInfo insInfo = InsuranceT.AddInsurance(pat, "AgingInsEst"); Procedure proc95 = ProcedureT.CreateProcedure(pat, "D0270", ProcStat.C, "", 1000, DateTime.Today.AddDays(-95)); ClaimProc cp95 = new ClaimProc(); ClaimProcs.CreateEst(cp95, proc95, insInfo.PriInsPlan, insInfo.PriInsSub); cp95.Status = ClaimProcStatus.NotReceived; cp95.InsEstTotal = 800; cp95.InsPayEst = 800; cp95.WriteOffEst = 200; cp95.WriteOff = 200; ClaimProcs.Update(cp95); Procedure proc85 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 100, DateTime.Today.AddDays(-85)); ClaimProc cp85 = new ClaimProc(); ClaimProcs.CreateEst(cp85, proc85, insInfo.PriInsPlan, insInfo.PriInsSub); cp85.Status = ClaimProcStatus.NotReceived; cp85.InsEstTotal = 60; cp85.InsPayEst = 60; cp85.WriteOffEst = 40; cp85.WriteOff = 40; ClaimProcs.Update(cp85); 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 }); Assert.AreEqual(PIn.Double(dictAging[pat.Guarantor]["InsPayEst"].ToString()), 860); Assert.AreEqual(PIn.Double(dictAging[pat.Guarantor]["InsWoEst"].ToString()), 240); PrefT.UpdateInt(PrefName.AgingProcLifo, (int)YN.Yes); dictAging = Ledgers.GetAgingGuarTransTable(DateTime.Today, new List <long> { pat.Guarantor }); Assert.AreEqual(PIn.Double(dictAging[pat.Guarantor]["InsPayEst"].ToString()), 860); Assert.AreEqual(PIn.Double(dictAging[pat.Guarantor]["InsWoEst"].ToString()), 240); } finally { PrefT.UpdateInt(PrefName.AgingProcLifo, agingProcLifoPrev); } }
public void PaymentEdit_Init_AdjustmentPreferWithPosAdjustment() { PrefT.UpdateInt(PrefName.AutoSplitLogic, (int)AutoSplitPreference.Adjustments); Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); long provNum = ProviderT.CreateProvider("prov1"); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 75, DateTime.Today.AddMonths(-1), provNum: provNum); Procedure proc2 = 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); Payment payCur = PaymentT.MakePaymentNoSplits(pat.PatNum, 20); 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 the logic chooses to pay off the adjustment first Assert.AreEqual(1, initData.AutoSplitData.ListAccountCharges.Count(x => x.Tag.GetType() == typeof(Adjustment) && x.AmountEnd == 0)); }
public void EmailMessages_FindAndReplacePostalAddressTag() { //Format disclaimer. PrefT.UpdateString(PrefName.EmailDisclaimerTemplate, "This email has been sent to you from:\r\n[PostalAddress].\r\n\r\nHow to unsubscribe:\r\nIf you no longer want to receive any email messages from us, simply reply to this email with the word \"unsubscribe\" in the subject line."); //Setup practice address. PrefT.UpdateString(PrefName.PracticeAddress, "Practice Address1 Here"); PrefT.UpdateString(PrefName.PracticeAddress2, "3275 Marietta St SE"); PrefT.UpdateString(PrefName.PracticeCity, "Salem"); PrefT.UpdateString(PrefName.PracticeST, "OR"); PrefT.UpdateString(PrefName.PracticeZip, "97317"); //Setup clinic address. Clinic clinic = ClinicT.CreateClinic(); clinic.Address = "Clinic Address1 Here"; Clinics.Update(clinic); Clinics.RefreshCache(); //Turn feature off. PrefT.UpdateBool(PrefName.EmailDisclaimerIsOn, false); string emailBody = "Hi, this is an email.\r\n\r\nRegards,\r\nEvery OD Engineer... ever."; string emailBodyWithDisclaimer = EmailMessages.FindAndReplacePostalAddressTag(emailBody, 0); //Feature is off so no disclaimer added. Assert.AreEqual(emailBody, emailBodyWithDisclaimer); //Turn feature on. PrefT.UpdateBool(PrefName.EmailDisclaimerIsOn, true); //Turn clinics off. PrefT.UpdateBool(PrefName.EasyNoClinics, true); emailBodyWithDisclaimer = EmailMessages.FindAndReplacePostalAddressTag(emailBody, 0); //Feature is on so disclaimer added (no clinic). Assert.AreNotEqual(emailBody, emailBodyWithDisclaimer); Assert.IsTrue(emailBodyWithDisclaimer.EndsWith("subject line.")); Assert.IsTrue(emailBodyWithDisclaimer.Contains("Practice Address")); Assert.IsFalse(emailBodyWithDisclaimer.Contains("Clinic Address")); //Turn clinics on. PrefT.UpdateBool(PrefName.EasyNoClinics, false); emailBodyWithDisclaimer = EmailMessages.FindAndReplacePostalAddressTag(emailBody, clinic.ClinicNum); //Feature is on so disclaimer added (with clinic). Assert.AreNotEqual(emailBody, emailBodyWithDisclaimer); Assert.IsTrue(emailBodyWithDisclaimer.EndsWith("subject line.")); Assert.IsTrue(emailBodyWithDisclaimer.Contains("Clinic Address")); Assert.IsFalse(emailBodyWithDisclaimer.Contains("Practice Address")); }
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); } }
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."); }
public void SecurityLogs_MakeLogEntry_DuplicateEntryRandomKeys() { Patient patient = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); //First, turn on random primary keys PrefT.UpdateBool(PrefName.RandomPrimaryKeys, true); //There are lots of bug submissions with exception text like "Duplicate entry 'XXXXX' for key 'PRIMARY'". //OpenDentBusiness.SecurityLogs.MakeLogEntry() seems to be the common theme for most of the submissions. //Loop as fast as we can and insert 200 security logs trying to get a duplicate entry exception. for (int i = 0; i < 200; i++) { try { SecurityLogs.MakeLogEntry(Permissions.Accounting, patient.PatNum, "", 0, DateTime.Now.AddDays(-7)); } catch (Exception ex) { PrefT.UpdateBool(PrefName.RandomPrimaryKeys, false); Assert.Fail(ex.Message); break; } } PrefT.UpdateBool(PrefName.RandomPrimaryKeys, false); }
public void LedgersTests_ComputeAging_PayPlanDynamicCredits() { //first need to create an unrelated pat that also has payment plan data to conflict with ours. This test is specifically to guard against a bug List <Procedure> listProcs = new List <Procedure>(); List <Adjustment> listAdjs = new List <Adjustment>(); long provNum = ProviderT.CreateProvider("Aging_PayPlanDynamicCredits"); Patient unrelatedPat = PatientT.CreatePatient("unrelatedPatPayPlanDyn"); Procedure procAttach = ProcedureT.CreateProcedure(unrelatedPat, "D0220", ProcStat.C, "", 200, provNum: provNum); listProcs.Add(procAttach); listAdjs.Add(AdjustmentT.MakeAdjustment(unrelatedPat.PatNum, 15, DateTime.Today.AddDays(-2), provNum: provNum)); listAdjs.Add(AdjustmentT.MakeAdjustment(unrelatedPat.PatNum, 5, DateTime.Today, DateTime.Today.AddDays(-2), procAttach.ProcNum, provNum)); PayPlanT.CreateDynamicPaymentPlan(unrelatedPat.PatNum, unrelatedPat.PatNum, DateTime.Today.AddDays(-2), 0, 0, 20, listProcs, listAdjs); string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(fName: "Aging_PayPlanDynamic", suffix: suffix); listProcs.Clear(); listAdjs.Clear(); Procedure proc = ProcedureT.CreateProcedure(pat, "D0270", ProcStat.C, "", 65, DateTime.Today.AddDays(-1), provNum: provNum); Adjustment adj = AdjustmentT.MakeAdjustment(pat.PatNum, 20, DateTime.Today.AddDays(-1), proc.ProcDate, proc.ProcNum, provNum); listProcs.Add(proc); listAdjs.Add(adj); PayPlan payPlan = PayPlanT.CreateDynamicPaymentPlan(pat.PatNum, pat.PatNum, DateTime.Today.AddDays(-1), 0, 0, 30, listProcs, listAdjs); int payPlansVersionPrev = PrefC.GetInt(PrefName.PayPlansVersion); try { PrefT.UpdateInt(PrefName.PayPlansVersion, (int)PayPlanVersions.AgeCreditsAndDebits); CheckAgingProcLifo(pat.PatNum, 0, 0, 0, 0, 0, YN.Yes); CheckAgingProcLifo(pat.PatNum, 0, 0, 0, 0, 0, YN.No); Assert.AreEqual(pat.BalTotal, 0); //everything on account should be credited } finally { PrefT.UpdateInt(PrefName.PayPlansVersion, payPlansVersionPrev); } }
public void Legacy_TestFiftyFour() { //When there are multiple repeat charges on one account and the repeat charge tool is run, and then a procedure from the account is deleted, //and then the repeat charges tool is run again, the same number of procedures that were deleted should be added. string suffix = "54"; Patient pat = PatientT.CreatePatient(suffix); Patient patOld = pat.Copy(); pat.BillingCycleDay = 11; Patients.Update(pat, patOld); PrefT.UpdateBool(PrefName.BillingUseBillingCycleDay, true); PrefT.UpdateBool(PrefName.FutureTransDatesAllowed, true); UpdateHistoryT.CreateUpdateHistory("16.1.1.0"); //Sets a timestamp that determines which logic we use to calculate repeate charge procedures Prefs.RefreshCache(); List <RepeatCharge> listRepeatingCharges = RepeatCharges.Refresh(0).ToList(); listRepeatingCharges.ForEach(x => RepeatCharges.Delete(x)); DateTime dateRun = new DateTime(DateTime.Today.AddMonths(2).Year, DateTime.Today.AddMonths(2).Month, 15);//The 15th of two months from now List <int> listFailedTests = new List <int>(); RepeatCharge rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 15); //The 15th of this month rc.Note = "Charge #1"; rc.CopyNoteToProc = true; rc.RepeatChargeNum = RepeatCharges.Insert(rc); rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 15); rc.Note = "Charge #2"; rc.CopyNoteToProc = true; rc.RepeatChargeNum = RepeatCharges.Insert(rc); rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 15); rc.Note = "Charge #3"; rc.CopyNoteToProc = true; rc.RepeatChargeNum = RepeatCharges.Insert(rc); //Subtest 1 =============================================================== //There are three procedures with the same amount, proc code, and start date. Run the repeat charge tool. Delete all procedures from //last month. Run the repeat charge tool again. Make sure that the correct repeat charges were added back. RepeatCharges.RunRepeatingCharges(dateRun); List <Procedure> procs = Procedures.Refresh(pat.PatNum); int lastMonth = dateRun.AddMonths(-1).Month; int thisMonth = dateRun.Month; //Delete all procedures from last month procs.FindAll(x => x.ProcDate.Month == lastMonth) .ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); //Make sure that the correct number of procedures were added using the correct repeating charges if (procs.Count != 6 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #1").Count != 1 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #2").Count != 1 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #3").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #1").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #2").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #3").Count != 1) { listFailedTests.Add(1); } //Subtest 2 =============================================================== //Run the repeat charge tool. Delete all procedures from this month. Run the repeat charge tool again. Make sure that the correct //repeat charges were added back. procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); //Delete all procedures from this month procs.FindAll(x => x.ProcDate.Month == thisMonth) .ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); //Make sure that the correct number of procedures were added using the correct repeating charges if (procs.Count != 6 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #1").Count != 1 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #2").Count != 1 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #3").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #1").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #2").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #3").Count != 1) { listFailedTests.Add(2); } //Subtest 3 =============================================================== //Run the repeat charge tool. Delete one procedure from this month. Run the repeat charge tool again. Make sure that the correct //repeat charges were added back. procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); //Delete one procedure from this month procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #1") .ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); //Make sure that the correct number of procedures were added using the correct repeating charges if (procs.Count != 6 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #1").Count != 1 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #2").Count != 1 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #3").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #1").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #2").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #3").Count != 1) { listFailedTests.Add(3); } //Subtest 4 =============================================================== //Run the repeat charge tool. Delete one procedure from last month. Run the repeat charge tool again. Make sure that the correct //repeat charges were added back. procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); //Delete one procedure from last month procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #1") .ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); //Make sure that the correct number of procedures were added using the correct repeating charges if (procs.Count != 6 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #1").Count != 1 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #2").Count != 1 || procs.FindAll(x => x.ProcDate.Month == lastMonth && x.BillingNote == "Charge #3").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #1").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #2").Count != 1 || procs.FindAll(x => x.ProcDate.Month == thisMonth && x.BillingNote == "Charge #3").Count != 1) { listFailedTests.Add(4); } Assert.AreEqual(0, listFailedTests.Count); }
public static void SetupClass(TestContext testContext) { //Make sure the SpellCheck preference is enabled. PrefT.UpdateBool(PrefName.SpellCheckIsEnabled, true); }
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); }
public void ResetTest() { PrefT.RevertPrefChanges(); }