public void PaymentEdit_ImplicitlyLinkPrepaymentsHelper() { Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); Patient patFam = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); Patient patFamOld = patFam.Copy(); patFam.Guarantor = pat.PatNum; Patients.Update(patFam, patFamOld); //create prepayment of $100 long provNum = ProviderT.CreateProvider("SG"); Clinic clinic1 = ClinicT.CreateClinic("Clinic1"); //create original prepayment. PaySplit prePay = PaySplitT.CreatePrepayment(pat.PatNum, 100, DateTime.Today.AddDays(-1), provNum, clinic1.ClinicNum); //complete a procedure Procedure proc1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 50, provNum: provNum); //Manually allocate prepayment without linking to the original prepayment. List <PaySplit> listPaySplits = PaySplitT.CreatePaySplitsForPrepayment(proc1, 50, prov: provNum, clinic: clinic1); ResetPrepayments(pat); long nonMatch = 100000; //test the PaymentEdit.AllocateUnearned() method. double unearnedAmt = (double)PaySplits.GetUnearnedForFam(Patients.GetFamily(pat.PatNum), _listFamPrePaySplits); //Logic check PatNum - match, ProvNum - match, ClinicNum - match double retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumMatch: true, isClinicNumMatch: true); Assert.AreEqual(50, retVal); //Logic check PatNum - match, ProvNum - match, ClinicNum - zero ResetPrepayments(pat); //update the clinicnum to 0 _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, provNum, 0, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumMatch: true, isClinicNumZero: true); Assert.AreEqual(50, retVal); //previous Test one should be $100 ResetPrepayments(pat); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumMatch: true, isClinicNumMatch: true); Assert.AreEqual(100, retVal); //Logic check PatNum - match, ProvNum - match, ClinicNum - non zero & non match ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, provNum, 100000, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumMatch: true, isClinicNonZeroNonMatch: true); Assert.AreEqual(50, retVal); //Logic check PatNum - match, ProvNum - zero, ClinicNum - match ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, 0, clinic1.ClinicNum, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumZero: true, isClinicNumMatch: true); Assert.AreEqual(50, retVal); //Logic check PatNum - match, ProvNum - zero, ClinicNum - zero ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, 0, 0, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumZero: true, isClinicNumZero: true); Assert.AreEqual(50, retVal); //Logic check PatNum - match, ProvNum - zero, ClinicNum - non zero & non match ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, 0, nonMatch, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumZero: true, isClinicNonZeroNonMatch: true); Assert.AreEqual(50, retVal); //Logic check PatNum - match, ProvNum - non zero & non match, ClinicNum - match ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, nonMatch, clinic1.ClinicNum, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNonZeroNonMatch: true, isClinicNumMatch: true); Assert.AreEqual(50, retVal); //Logic check PatNum - match, ProvNum - non zero & non match, ClinicNum - zero ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, nonMatch, 0, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNonZeroNonMatch: true, isClinicNumZero: true); Assert.AreEqual(50, retVal); //Logic check PatNum - match, ProvNum - non zero & non match, ClinicNum - non zero & non match ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, nonMatch, nonMatch, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNonZeroNonMatch: true, isClinicNonZeroNonMatch: true); Assert.AreEqual(50, retVal); //Logic check PatNum - other family members, ProvNum - match, ClinicNum - match ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, provNum, clinic1.ClinicNum, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumMatch: true, isClinicNumMatch: true); Assert.AreEqual(50, retVal); //Logic check PatNum - other family members, ProvNum - match, ClinicNum - zero ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, provNum, 0, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumMatch: true, isClinicNumZero: true); Assert.AreEqual(50, retVal); //Logic check PatNum - other family members, ProvNum - match, ClinicNum - non zero & non match ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, provNum, nonMatch, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumMatch: true, isClinicNonZeroNonMatch: true); Assert.AreEqual(50, retVal); //Logic check PatNum - other family members, ProvNum - zero, ClinicNum - match ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, 0, clinic1.ClinicNum, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumZero: true, isClinicNumMatch: true); Assert.AreEqual(50, retVal); //Logic check PatNum - other family members, ProvNum - zero, ClinicNum - zero ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, 0, 0, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumZero: true, isClinicNumZero: true); Assert.AreEqual(50, retVal); //Logic checkPatNum - other family members, ProvNum - zero, ClinicNum - non zero & non match ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, 0, nonMatch, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumZero: true, isClinicNonZeroNonMatch: true); Assert.AreEqual(50, retVal); //Old test from above ResetPrepayments(pat); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumMatch: true, isClinicNumMatch: true); Assert.AreEqual(100, retVal); //Logic checkPatNum - other family members, ProvNum - non zero & non match, ClinicNum - match ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, nonMatch, clinic1.ClinicNum, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNonZeroNonMatch: true, isClinicNumMatch: true); Assert.AreEqual(50, retVal); //Logic check PatNum - other family members, ProvNum - non zero & non match, ClinicNum - zero ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, nonMatch, 0, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNonZeroNonMatch: true, isClinicNumZero: true); Assert.AreEqual(50, retVal); //Logic check PatNum - other family members, ProvNum - non zero & non match, ClinicNum - non zero & non match ResetPrepayments(pat); _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, nonMatch, nonMatch, _listNegPrePay.First().PayNum)); retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNonZeroNonMatch: true, isClinicNonZeroNonMatch: true); Assert.AreEqual(50, retVal); }