///<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 Legacy_TestFiftySix() { //Repeat charges should not be posted before the start date. string suffix = "56"; Patient pat = PatientT.CreatePatient(suffix); Patient patOld = pat.Copy(); pat.BillingCycleDay = 15; Patients.Update(pat, patOld); Prefs.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)); DateTime dateRun = new DateTime(2015, 12, 15); List <int> listFailedTests = new List <int>(); //Subtest 1 =============================================================== //The date start is the same as the date ran and the same as the billing day. Add a procedure that day. RepeatCharge rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(2015, 12, 15); rc.RepeatChargeNum = RepeatCharges.Insert(rc); RepeatCharges.RunRepeatingCharges(dateRun); List <Procedure> procs = Procedures.Refresh(pat.PatNum); if (procs.Count != 1 || procs.FindAll(x => x.ProcDate.ToShortDateString() == "12/15/2015" && x.ProcFee == 99).Count != 1) { listFailedTests.Add(1); } //Subtest 2 =============================================================== //The start date is the same as the date ran but the billing day is three days earlier. Don't add a procedure that day. procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.Delete(rc); patOld = pat.Copy(); pat.BillingCycleDay = 12; Patients.Update(pat, patOld); rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(2015, 12, 15); rc.RepeatChargeNum = RepeatCharges.Insert(rc); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); if (procs.Count != 0) { listFailedTests.Add(2); } //Subtest 3 =============================================================== //The start date is the same as the billing day but is three days after the date ran. Don't add a procedure that day. procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.Delete(rc); patOld = pat.Copy(); pat.BillingCycleDay = 15; Patients.Update(pat, patOld); rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(2015, 12, 18); rc.RepeatChargeNum = RepeatCharges.Insert(rc); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); if (procs.Count != 0) { listFailedTests.Add(3); } Assert.AreEqual(0, listFailedTests.Count); }
public void Legacy_TestFiftyThree() { //Repeat charges should be added after the stop date if the duration of the repeating charge if the number of charges added to the account is //less than the number of months the repeat charge was active (a partial month is counted as a full month). string suffix = "53"; Patient pat = PatientT.CreatePatient(suffix); Patient patOld = pat.Copy(); pat.BillingCycleDay = 11; Patients.Update(pat, patOld); Prefs.UpdateBool(PrefName.BillingUseBillingCycleDay, true); UpdateHistoryT.CreateUpdateHistory("16.1.1.0"); Prefs.RefreshCache(); //delete all existing repeating charges List <RepeatCharge> listRepeatingCharges = RepeatCharges.Refresh(0).ToList(); listRepeatingCharges.ForEach(x => RepeatCharges.Delete(x)); DateTime dateRun = new DateTime(2015, 12, 15); //Subtest 1 ===================================================== //The start day is before the stop day which is before the billing day. Add a charge after the stop date. RepeatCharge rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; //arbitrary code rc.IsEnabled = true; rc.DateStart = new DateTime(2015, 11, 8); rc.DateStop = new DateTime(2015, 12, 9); rc.RepeatChargeNum = RepeatCharges.Insert(rc); RepeatCharges.RunRepeatingCharges(dateRun); List <Procedure> procs = Procedures.Refresh(pat.PatNum); Assert.AreEqual(2, procs.Count); Assert.AreEqual(1, procs.Count(x => x.ProcDate == new DateTime(2015, 11, 11))); Assert.AreEqual(1, procs.Count(x => x.ProcDate == new DateTime(2015, 12, 11))); //Subtest 2 ===================================================== //The start day is after the billing day which is after the stop day. Add a charge after the stop date. procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.Delete(rc); rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(2015, 10, 25); rc.DateStop = new DateTime(2015, 12, 1); rc.RepeatChargeNum = RepeatCharges.Insert(rc); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); Assert.AreEqual(2, procs.Count); Assert.AreEqual(1, procs.Count(x => x.ProcDate == new DateTime(2015, 11, 11))); Assert.AreEqual(1, procs.Count(x => x.ProcDate == new DateTime(2015, 12, 11))); //Subtest 3 ===================================================== //The start day is the same as the stop day but before the billing day. Add a charge after the stop date. procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.Delete(rc); rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(2015, 11, 10); rc.DateStop = new DateTime(2015, 12, 10); RepeatCharges.Insert(rc); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); Assert.AreEqual(2, procs.Count); Assert.AreEqual(1, procs.Count(x => x.ProcDate == new DateTime(2015, 11, 11))); Assert.AreEqual(1, procs.Count(x => x.ProcDate == new DateTime(2015, 12, 11))); //Subtest 4 ===================================================== //The start day is the same as the stop day and the billing day. Don't add a charge after the stop date. procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.Delete(rc); dateRun = new DateTime(2015, 11, 15); rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(2015, 10, 11); rc.DateStop = new DateTime(2015, 11, 11); rc.RepeatChargeNum = RepeatCharges.Insert(rc); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); Assert.AreEqual(2, procs.Count); Assert.AreEqual(1, procs.Count(x => x.ProcDate == new DateTime(2015, 10, 11))); Assert.AreEqual(1, procs.Count(x => x.ProcDate == new DateTime(2015, 11, 11))); //Subtest 5 ===================================================== //The start day is after the stop day which is after the billing day. Don't add a charge after the stop date. procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.Delete(rc); rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(2015, 10, 15); rc.DateStop = new DateTime(2015, 11, 13); rc.RepeatChargeNum = RepeatCharges.Insert(rc); Procedure p = new Procedure(); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); Assert.AreEqual(1, procs.Count); Assert.AreEqual(1, procs.Count(x => x.ProcDate == new DateTime(2015, 11, 11))); //Subtest 6 ===================================================== //The start day is before billing day which is before the stop day. Don't add a charge after the stop date. procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.Delete(rc); rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(2015, 11, 05); rc.DateStop = new DateTime(2015, 11, 20); rc.RepeatChargeNum = RepeatCharges.Insert(rc); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); Assert.AreEqual(1, procs.Count); Assert.AreEqual(1, procs.Count(x => x.ProcDate == new DateTime(2015, 11, 11))); }
public void Legacy_TestFiftyFive() { //Changing the amount or start date on a repeat charge should not cause the repeat charge to be added again. string suffix = "55"; Patient pat = PatientT.CreatePatient(suffix); Patient patOld = pat.Copy(); pat.BillingCycleDay = 11; Patients.Update(pat, patOld); Prefs.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)); DateTime dateRun = new DateTime(2015, 12, 15); List <int> listFailedTests = new List <int>(); //Subtest 1 =============================================================== //Run the repeat charge tool. Change the charge amount on the repeat charge. Run the repeat charge tool again. Make sure that no //extra procedures are added. RepeatCharge rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(2015, 11, 1); rc.RepeatChargeNum = RepeatCharges.Insert(rc); RepeatCharges.RunRepeatingCharges(dateRun); rc.ChargeAmt = 80; RepeatCharges.Update(rc); RepeatCharges.RunRepeatingCharges(dateRun); List <Procedure> procs = Procedures.Refresh(pat.PatNum); if (procs.Count != 2 || procs.FindAll(x => x.ProcDate.ToShortDateString() == "11/11/2015" && x.ProcFee == 99).Count != 1 || procs.FindAll(x => x.ProcDate.ToShortDateString() == "12/11/2015" && x.ProcFee == 99).Count != 1) { listFailedTests.Add(1); } //Subtest 2 =============================================================== //Run the repeat charge tool. Change the start date on the repeat charge. Run the repeat charge tool again. Make sure that no //extra procedures are added. procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.Delete(rc); rc = new RepeatCharge(); rc.ChargeAmt = 99; rc.PatNum = pat.PatNum; rc.ProcCode = "D2750"; rc.IsEnabled = true; rc.DateStart = new DateTime(2015, 11, 1); rc.RepeatChargeNum = RepeatCharges.Insert(rc); RepeatCharges.RunRepeatingCharges(dateRun); rc.DateStart = new DateTime(2015, 11, 2); RepeatCharges.Update(rc); RepeatCharges.RunRepeatingCharges(dateRun); procs = Procedures.Refresh(pat.PatNum); if (procs.Count != 2 || procs.FindAll(x => x.ProcDate.ToShortDateString() == "11/11/2015" && x.ProcFee == 99).Count != 1 || procs.FindAll(x => x.ProcDate.ToShortDateString() == "12/11/2015" && x.ProcFee == 99).Count != 1) { listFailedTests.Add(2); } procs.ForEach(x => Procedures.Delete(x.ProcNum)); RepeatCharges.Delete(rc); Assert.AreEqual(0, listFailedTests.Count); }
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); }