public void ProcedureCodes_GetSubstituteCodeNum_Posterior() { //First, setup the test scenario. string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(suffix); Carrier carrier = CarrierT.CreateCarrier(MethodBase.GetCurrentMethod().Name); InsPlan plan = new InsPlan(); plan.CarrierNum = carrier.CarrierNum; plan.PlanType = ""; plan.CobRule = EnumCobRule.Basic; plan.PlanNum = InsPlans.Insert(plan); //Add a substitution code on the procedure level. ProcedureCode originalProcCode = ProcedureCodes.GetProcCode("D2740"); ProcedureCode downgradeProcCode = ProcedureCodes.GetProcCode("D2750"); originalProcCode.SubstitutionCode = "D2750"; originalProcCode.SubstOnlyIf = SubstitutionCondition.Posterior; ProcedureCodeT.Update(originalProcCode); //Posterior Procedure= ToothNum 4 Procedure proc = ProcedureT.CreateProcedure(pat, originalProcCode.ProcCode, ProcStat.C, "4", 100);//Tooth 4 long subCodeNum = ProcedureCodes.GetSubstituteCodeNum(originalProcCode.ProcCode, proc.ToothNum, plan.PlanNum); //Finally, use one or more asserts to verify the results. Assert.AreEqual(downgradeProcCode.CodeNum, subCodeNum); }
public void ProcedureCodes_GetSubstituteCodeNum_InsPlanOverrideAlways() { //First, setup the test scenario. string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(suffix); Carrier carrier = CarrierT.CreateCarrier(MethodBase.GetCurrentMethod().Name); InsPlan plan = new InsPlan(); plan.CarrierNum = carrier.CarrierNum; plan.PlanType = ""; plan.CobRule = EnumCobRule.Basic; plan.PlanNum = InsPlans.Insert(plan); //Add a substitution code on the procedure level. ProcedureCode originalProcCode = ProcedureCodes.GetProcCode("D2330"); ProcedureCode downgradeProcCode = ProcedureCodes.GetProcCode("D2140"); originalProcCode.SubstitutionCode = "D2140"; originalProcCode.SubstOnlyIf = SubstitutionCondition.Always; ProcedureCodeT.Update(originalProcCode); //Add an override for the inplan above for the originalProcCode ProcedureCode downgradeProcCodeForIns = ProcedureCodes.GetProcCode("D2150"); SubstitutionLinkT.CreateSubstitutionLink(originalProcCode.CodeNum, downgradeProcCodeForIns.ProcCode, SubstitutionCondition.Always, plan.PlanNum); //Next, perform the thing you're trying to test. Procedure proc = ProcedureT.CreateProcedure(pat, originalProcCode.ProcCode, ProcStat.C, "9", 100);//Tooth 9 long subCodeNum = ProcedureCodes.GetSubstituteCodeNum(originalProcCode.ProcCode, proc.ToothNum, plan.PlanNum); //Finally, use one or more asserts to verify the results. Assert.AreEqual(downgradeProcCodeForIns.CodeNum, subCodeNum); }
public void ProcedureCodes_GetSubstituteCodeNum_InsPlanOverrideNever() { //First, setup the test scenario. string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(suffix); Carrier carrier = CarrierT.CreateCarrier(MethodBase.GetCurrentMethod().Name); InsPlan plan = new InsPlan(); plan.CarrierNum = carrier.CarrierNum; plan.PlanType = ""; plan.CobRule = EnumCobRule.Basic; plan.PlanNum = InsPlans.Insert(plan); //Add a substitution code on the procedure level that has SubstitutionCondition.Never. ProcedureCode originalProcCode = ProcedureCodes.GetProcCode("D2330"); //clear out any substitution codes on this procedure originalProcCode.SubstitutionCode = ""; ProcedureCodeT.Update(originalProcCode); //Add an override for the inplan above for the originalProcCode to never substitute ProcedureCode downgradeProcCodeForIns = ProcedureCodes.GetProcCode("D2150"); SubstitutionLinkT.CreateSubstitutionLink(originalProcCode.CodeNum, downgradeProcCodeForIns.ProcCode, SubstitutionCondition.Never, plan.PlanNum); //Next, perform the thing you're trying to test. Procedure proc = ProcedureT.CreateProcedure(pat, originalProcCode.ProcCode, ProcStat.C, "9", 100);//Tooth 9 long subCodeNum = ProcedureCodes.GetSubstituteCodeNum(originalProcCode.ProcCode, proc.ToothNum, plan.PlanNum); //The procedure level and ins override is set SubstitutionCondition.Never so it should use originalProcCode.CodeNum Assert.AreEqual(originalProcCode.CodeNum, subCodeNum); }
public void ProcedureCodes_GetSubstituteCodeNum_InsPlanOverridePosterior() { //First, setup the test scenario. string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(suffix); Carrier carrier = CarrierT.CreateCarrier(MethodBase.GetCurrentMethod().Name); InsPlan plan = new InsPlan(); plan.CarrierNum = carrier.CarrierNum; plan.PlanType = ""; plan.CobRule = EnumCobRule.Basic; plan.PlanNum = InsPlans.Insert(plan); //Procedure code does not have a substitution code ProcedureCode originalProcCode = ProcedureCodes.GetProcCode("D2740"); //clear out any substitution codes on this procedure originalProcCode.SubstitutionCode = ""; ProcedureCodeT.Update(originalProcCode); //Add an override for the inplan above for the originalProcCode to substitute if posterior ProcedureCode downgradeProcCodeForIns = ProcedureCodes.GetProcCode("D2750"); SubstitutionLinkT.CreateSubstitutionLink(originalProcCode.CodeNum, downgradeProcCodeForIns.ProcCode, SubstitutionCondition.Posterior, plan.PlanNum); //Posterior procedure Procedure proc = ProcedureT.CreateProcedure(pat, originalProcCode.ProcCode, ProcStat.C, "4", 100);//Tooth 4 long subCodeNum = ProcedureCodes.GetSubstituteCodeNum(originalProcCode.ProcCode, proc.ToothNum, plan.PlanNum); //The ins override is set to substitute only if posterior. Assert.AreEqual(downgradeProcCodeForIns.CodeNum, subCodeNum); }
public void PaymentEdit_AutoSplitForPayment_NoNegativeAutoSplits() { long provNumA = ProviderT.CreateProvider("provA"); Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 70); Procedure proc2 = ProcedureT.CreateProcedure(pat, "D0150", ProcStat.C, "", 20); //make an overpayment for one of the procedures so it spills over. DateTime payDate = DateTime.Today; Payment pay = PaymentT.MakePayment(pat.PatNum, 71, payDate, procNum: proc1.ProcNum); //pre-existing payment //attempt to make another payment. Auto splits should not suggest a negative split. Payment newPayment = PaymentT.MakePaymentNoSplits(pat.PatNum, 2, payDate, isNew: true, payType: Defs.GetDefsForCategory(DefCat.PaymentTypes, true)[0].DefNum);//current payment we're trying to make PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, newPayment, new List <long>() { pat.PatNum }, true, false); PaymentEdit.ConstructChargesData chargeData = PaymentEdit.GetConstructChargesData(new List <long> { pat.PatNum }, pat.PatNum, PaySplits.GetForPayment(pay.PayNum), pay.PayNum, false); PaymentEdit.ConstructResults constructResults = PaymentEdit.ConstructAndLinkChargeCredits(new List <long> { pat.PatNum }, pat.PatNum , chargeData.ListPaySplits, newPayment, new List <Procedure> ()); PaymentEdit.AutoSplit autoSplits = PaymentEdit.AutoSplitForPayment(constructResults); Assert.AreEqual(0, autoSplits.ListAutoSplits.FindAll(x => x.SplitAmt < 0).Count); //assert no negative auto splits were made. Assert.AreEqual(0, autoSplits.ListSplitsCur.FindAll(x => x.SplitAmt < 0).Count); //auto splits not catching everything }
///<summary>This method generates three patients and returns them as out variables. The patients have overlapping names, birthdates, emails, ///and phones.</summary> private void GenerateThreePatients(out Patient patA, out Patient patB, out Patient patA2) { patA = PatientT.CreatePatient(fName: "Billy", lName: "Bob"); Patient oldPat = patA.Copy(); patA.Birthdate = new DateTime(1971, 6, 28); patA.WirelessPhone = "5413635432"; patA.Email = "*****@*****.**"; patA.ClinicNum = 1; Patients.Update(patA, oldPat); patB = PatientT.CreatePatient(fName: "Joe", lName: "Schmoe"); oldPat = patB.Copy(); patB.Birthdate = new DateTime(2000, 6, 28); patB.HmPhone = "5413631111"; patB.Email = "*****@*****.**"; patB.Guarantor = patA.PatNum; patB.ClinicNum = 1; Patients.Update(patB, oldPat); patA2 = PatientT.CreatePatient(fName: "Billy", lName: "Bob"); oldPat = patA2.Copy(); patA2.Birthdate = new DateTime(1971, 6, 28); patA2.WirelessPhone = "5478982525"; patA2.Email = patA.Email; patA2.ClinicNum = 0; Patients.Update(patA2, oldPat); }
public void InsPlan_PpoNoSubWriteoffsNoSub() { string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(suffix); long ucrFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "UCR Fees" + suffix); long ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix); InsuranceInfo ins = InsuranceT.AddInsurance(pat, suffix, planType: "p", feeSchedNum: ppoFeeSchedNum); ins.PriInsPlan.HasPpoSubstWriteoffs = false; InsPlans.Update(ins.PriInsPlan); BenefitT.CreateCategoryPercent(ins.PriInsPlan.PlanNum, EbenefitCategory.Restorative, 50); ProcedureCode originalProcCode = ProcedureCodes.GetProcCode("D2330"); ProcedureCode downgradeProcCode = ProcedureCodes.GetProcCode("D2140"); originalProcCode.SubstitutionCode = ""; //NOT substituting originalProcCode.SubstOnlyIf = SubstitutionCondition.Always; ProcedureCodeT.Update(originalProcCode); FeeT.CreateFee(ucrFeeSchedNum, originalProcCode.CodeNum, 100); FeeT.CreateFee(ucrFeeSchedNum, downgradeProcCode.CodeNum, 80); FeeT.CreateFee(ppoFeeSchedNum, originalProcCode.CodeNum, 60); FeeT.CreateFee(ppoFeeSchedNum, downgradeProcCode.CodeNum, 50); Procedure proc = ProcedureT.CreateProcedure(pat, "D2330", ProcStat.C, "9", 100);//Tooth 9 List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum); List <Procedure> listProcs = Procedures.Refresh(pat.PatNum); ins.RefreshBenefits(); Claim claim = ClaimT.CreateClaim("P", ins.ListPatPlans, ins.ListInsPlans, listClaimProcs, listProcs, pat, listProcs, ins.ListBenefits, ins.ListInsSubs); ClaimProc clProc = ClaimProcs.Refresh(pat.PatNum)[0]; //Should only be one Assert.AreEqual(50, clProc.Percentage); Assert.AreEqual(30, clProc.BaseEst); Assert.AreEqual(30, clProc.InsPayEst); Assert.AreEqual(40, clProc.WriteOffEst); }
public void PaymentEdit_Init_ChargesWithUnattachedPayPlanCreditsWithPreviousPayments() { //new payplan Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); long prov = ProviderT.CreateProvider("ProvA"); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D1120", ProcStat.C, "", 135, DateTime.Today.AddMonths(-4), provNum: prov); Procedure proc2 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 60, DateTime.Today.AddMonths(-4).AddDays(1), provNum: prov); PayPlan payplan = PayPlanT.CreatePayPlanWithCredits(pat.PatNum, 30, DateTime.Today.AddMonths(-3), prov, totalAmt: 195); //totalAmt since unattached credits //Make initial payments. PaymentT.MakePayment(pat.PatNum, 30, DateTime.Today.AddMonths(-2), payplan.PayPlanNum, prov, 0, 1); PaymentT.MakePayment(pat.PatNum, 30, DateTime.Today.AddMonths(-1), payplan.PayPlanNum, prov, 0, 1); //Go to make another payment. 2 pay plan charges should have been "removed" (amtStart to 0) from being paid. Payment pay = PaymentT.MakePaymentNoSplits(pat.PatNum, 30, DateTime.Today); PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, pay, new List <long> { pat.PatNum }, true, false); PaymentEdit.InitData initData = PaymentEdit.Init(loadData.ListAssociatedPatients, Patients.GetFamily(pat.PatNum), new Family { }, pay , loadData.ListSplits, new List <Procedure>(), pat.PatNum, loadData: loadData); //2 procs and 2 pp charges Assert.AreEqual(4, initData.AutoSplitData.ListAccountCharges.FindAll(x => x.AmountStart > 0).Count); Assert.AreEqual(2, initData.AutoSplitData.ListAccountCharges.Count(x => x.Tag.GetType() == typeof(Procedure))); Assert.AreEqual(4, initData.AutoSplitData.ListAccountCharges.Count(x => x.Tag.GetType() == typeof(PayPlanCharge))); }
public void RpProcNotBilledIns_GetProcsNotBilled_MedicalInsOnly() { string suffix = MethodBase.GetCurrentMethod().Name; Patient patient = PatientT.CreatePatient(suffix); Carrier carrier = CarrierT.CreateCarrier(suffix); ProcedureCode procedureCode = ProcedureCodeT.CreateProcCode("T7782"); //Create a primary medical insurance plan InsuranceInfo insuranceInfo = InsuranceT.AddInsurance(patient, carrier.CarrierName, ordinal: 1, isMedical: true); insuranceInfo.AddBenefit(BenefitT.CreatePercentForProc(insuranceInfo.MedInsPlan.PlanNum, procedureCode.CodeNum, 80)); Procedure procedure = ProcedureT.CreateProcedure(patient, procedureCode.ProcCode, ProcStat.TP, "", 55, procDate: DateTime.Now.AddDays(-3)); ProcedureT.ComputeEstimates(patient, insuranceInfo); ProcedureT.SetComplete(procedure, patient, insuranceInfo); //Run the procs not billed report with "includeMedProcs" set to false. //The patient should not be returned due to not having any dental insurance estimates. DataTable table = RpProcNotBilledIns.GetProcsNotBilled(new List <long>(), false, DateTime.Now.AddDays(-10), DateTime.Now, false, false); Assert.IsNotNull(table); Assert.IsFalse(table.Select().Select(x => PIn.Long(x["PatNum"].ToString())).Contains(patient.PatNum)); //Run the procs not billed report with "includeMedProcs" set to true. //The patient should be returned due to the medical insurance estimates. table = RpProcNotBilledIns.GetProcsNotBilled(new List <long>(), true, DateTime.Now.AddDays(-10), DateTime.Now, false, false); Assert.IsNotNull(table); Assert.IsTrue(table.Rows.Count > 0); Assert.IsTrue(table.Select().Select(x => PIn.Long(x["PatNum"].ToString())).Contains(patient.PatNum)); }
public void InsPlans_ComputeEstimatesForSubscriber_CanadianLabFees() { string suffix = MethodBase.GetCurrentMethod().Name; CultureInfo curCulture = CultureInfo.CurrentCulture; Thread.CurrentThread.CurrentCulture = new CultureInfo("en-CA"); //Canada try { //Create a patient and treatment plan a procedure with a lab fee. Patient pat = PatientT.CreatePatient(); ProcedureCodeT.AddIfNotPresent("14611"); ProcedureCodeT.AddIfNotPresent("99111", isCanadianLab: true); Procedure proc = ProcedureT.CreateProcedure(pat, "14611", ProcStat.TP, "", 250); Procedure procLab = ProcedureT.CreateProcedure(pat, "99111", ProcStat.TP, "", 149, procNumLab: proc.ProcNum); //Create a new primary insurance plan for this patient. //It is important that we add the insurance plan after the procedure has already been created for this particular scenario. Carrier carrier = CarrierT.CreateCarrier(suffix); InsPlan plan = InsPlanT.CreateInsPlan(carrier.CarrierNum); InsSub sub = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum); PatPlan patPlan = PatPlanT.CreatePatPlan(1, pat.PatNum, sub.InsSubNum); //Invoking ComputeEstimatesForAll() will simulate the logic of adding a new insurance plan from the Family module. //The bug that this unit test is preventing is that a duplicate claimproc was being created for the lab fee. //This was causing a faux line to show up when a claim was created for the procedure in question. //It ironically doesn't matter if the procedures above are even covered by insurance because they'll get claimprocs created regardless. InsPlans.ComputeEstimatesForSubscriber(sub.Subscriber); //Check to see how many claimproc enteries there are for the current patient. There should only be two. List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum); Assert.AreEqual(2, listClaimProcs.Count); } finally { Thread.CurrentThread.CurrentCulture = curCulture; } }
public void OrthoCases_UpdateDatesByLinkedProc_UpdateBandingAndDebondDates() { Prefs.UpdateString(PrefName.OrthoDebondCodes, "D8070"); Userod user = UserodT.CreateUser(); Security.CurUser = user; Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); Procedure bandingProc = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.C, "", 0); Procedure debondProc = ProcedureT.CreateProcedure(pat, "D8070", ProcStat.C, "", 0, procDate: DateTime.Today.AddDays(2)); long orthoCaseNum = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, bandingProc); OrthoProcLinks.LinkProcForActiveOrthoCase(debondProc); OrthoProcLink bandingProcLink = OrthoProcLinks.GetByType(orthoCaseNum, OrthoProcType.Banding); OrthoProcLink debondProcLink = OrthoProcLinks.GetByType(orthoCaseNum, OrthoProcType.Debond); OrthoCase orthoCase = OrthoCases.GetOne(orthoCaseNum); Assert.AreEqual(orthoCase.BandingDate, DateTime.Today); bandingProc.ProcDate = DateTime.Today.AddDays(1); OrthoCases.UpdateDatesByLinkedProc(bandingProcLink, bandingProc); orthoCase = OrthoCases.GetOne(orthoCaseNum); Assert.AreEqual(orthoCase.BandingDate, DateTime.Today.AddDays(1)); Assert.AreEqual(orthoCase.DebondDate, DateTime.Today.AddDays(2)); debondProc.ProcDate = DateTime.Today.AddDays(3); OrthoCases.UpdateDatesByLinkedProc(debondProcLink, debondProc); orthoCase = OrthoCases.GetOne(orthoCaseNum); Assert.AreEqual(orthoCase.BandingDate, DateTime.Today.AddDays(1)); Assert.AreEqual(orthoCase.DebondDate, DateTime.Today.AddDays(3)); }
public void OrthoCases_Delete_DeleteOrthoCaseAndAssociatedObjects() { Prefs.UpdateString(PrefName.OrthoBandingCodes, "D8080"); Prefs.UpdateString(PrefName.OrthoDebondCodes, "D8070"); Prefs.UpdateString(PrefName.OrthoVisitCodes, "D8060"); Userod user = UserodT.CreateUser(); Security.CurUser = user; Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); Procedure bandingProc = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.C, "", 0); Procedure visitProc = ProcedureT.CreateProcedure(pat, "D8060", ProcStat.C, "", 0); Procedure debondProc = ProcedureT.CreateProcedure(pat, "D8070", ProcStat.C, "", 0); long orthoCaseNum = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, bandingProc); OrthoProcLinks.LinkProcForActiveOrthoCase(visitProc); OrthoProcLinks.LinkProcForActiveOrthoCase(debondProc); OrthoCase orthoCase = OrthoCases.GetOne(orthoCaseNum); OrthoPlanLink schedulePlanLink = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum, OrthoPlanLinkType.OrthoSchedule); long orthoscheduleNum = schedulePlanLink.FKey; OrthoSchedule orthoSchedule = OrthoSchedules.GetOne(schedulePlanLink.FKey); List <OrthoProcLink> listAllProcLinks = OrthoProcLinks.GetManyByOrthoCase(orthoCaseNum); OrthoCases.Delete(orthoCase.OrthoCaseNum, orthoSchedule, schedulePlanLink, listAllProcLinks); orthoCase = OrthoCases.GetOne(orthoCaseNum); schedulePlanLink = OrthoPlanLinks.GetOneForOrthoCaseByType(orthoCaseNum, OrthoPlanLinkType.OrthoSchedule); orthoSchedule = OrthoSchedules.GetOne(orthoscheduleNum); listAllProcLinks = OrthoProcLinks.GetManyByOrthoCase(orthoCaseNum); Assert.AreEqual(orthoCase, null); Assert.AreEqual(schedulePlanLink, null); Assert.AreEqual(orthoSchedule, null); Assert.AreEqual(listAllProcLinks.Count, 0); }
public void OrthoProcLinks_LinkProcForActiveOrthoCase_LinkCompletedProcsToOrthoCase() { Prefs.UpdateString(PrefName.OrthoBandingCodes, "D8080"); Prefs.UpdateString(PrefName.OrthoDebondCodes, "D8070"); Prefs.UpdateString(PrefName.OrthoVisitCodes, "D8060"); Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); Procedure bandingProc = ProcedureT.CreateProcedure(pat, "D8080", ProcStat.C, "", 0); Procedure visitProc = ProcedureT.CreateProcedure(pat, "D8060", ProcStat.C, "", 0); Procedure debondProc = ProcedureT.CreateProcedure(pat, "D8070", ProcStat.C, "", 0); long orthoCaseNum = OrthoCaseT.InsertForFormOrthoCase(pat.PatNum, 2000, 1200, 0, 800, DateTime.Today, false, DateTime.Today.AddMonths(12), 1000, 400, 60, bandingProc); OrthoProcLinks.LinkProcForActiveOrthoCase(visitProc); OrthoProcLinks.LinkProcForActiveOrthoCase(debondProc); OrthoCase orthoCase = OrthoCases.GetOne(orthoCaseNum); List <OrthoProcLink> listAllProcLinks = OrthoProcLinks.GetManyByOrthoCase(orthoCaseNum); List <OrthoProcLink> listVisitProcLinks = OrthoProcLinks.GetVisitLinksForOrthoCase(orthoCaseNum); OrthoProcLink debondProcLink = OrthoProcLinks.GetByType(orthoCaseNum, OrthoProcType.Debond); Assert.AreEqual(orthoCase.IsActive, false); Assert.AreEqual(listAllProcLinks.Count, 3); Assert.AreEqual(debondProcLink.ProcNum, debondProc.ProcNum); Assert.AreEqual(debondProcLink.SecUserNumEntry, Security.CurUser.UserNum); Assert.AreEqual(listVisitProcLinks.Count, 1); Assert.AreEqual(listVisitProcLinks[0].ProcNum, visitProc.ProcNum); Assert.AreEqual(listVisitProcLinks[0].SecUserNumEntry, Security.CurUser.UserNum); }
public void SecurityLogs_MakeLogEntry_DuplicateEntryParallel() { Patient patient = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); //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) => { RemotingClient.RemotingRole = remotingRoleOld; Assert.Fail(ex.Message); }); RemotingClient.RemotingRole = remotingRoleOld; }
public void InsPlan_GetInsUsedDisplay_LimitationsOverride() { string suffix = "6"; Patient pat = PatientT.CreatePatient(suffix); long patNum = pat.PatNum; Carrier carrier = CarrierT.CreateCarrier(suffix); InsPlan plan = InsPlanT.CreateInsPlan(carrier.CarrierNum); long planNum = plan.PlanNum; InsSub sub = InsSubT.CreateInsSub(pat.PatNum, planNum); //guarantor is subscriber long subNum = sub.InsSubNum; long patPlanNum = PatPlanT.CreatePatPlan(1, pat.PatNum, subNum).PatPlanNum; BenefitT.CreateAnnualMax(planNum, 1000); BenefitT.CreateLimitation(planNum, EbenefitCategory.Diagnostic, 1000); Procedure proc = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 50); //An exam long procNum = proc.ProcNum; Procedure proc2 = ProcedureT.CreateProcedure(pat, "D2750", ProcStat.C, "8", 830); //create a crown ClaimProcT.AddInsPaid(patNum, planNum, procNum, 50, subNum, 0, 0); ClaimProcT.AddInsPaid(patNum, planNum, proc2.ProcNum, 400, subNum, 0, 0); //Lists Family fam = Patients.GetFamily(patNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <PatPlan> patPlans = PatPlans.Refresh(patNum); List <Benefit> benefitList = Benefits.Refresh(patPlans, subList); List <ClaimProcHist> histList = ClaimProcs.GetHistList(patNum, benefitList, patPlans, planList, DateTime.Today, subList); //Validate double insUsed = InsPlans.GetInsUsedDisplay(histList, DateTime.Today, planNum, patPlanNum, -1, planList, benefitList, patNum, subNum); Assert.AreEqual(400, insUsed); }
public void PaymentEdit_Init_AutoSplitWithClaimPayments() //Legacy_TestFortyEight { string suffix = "48"; Patient pat = PatientT.CreatePatient(suffix); long patNum = pat.PatNum; InsPlan insPlan = InsPlanT.CreateInsPlan(CarrierT.CreateCarrier(suffix).CarrierNum); InsSub insSub = InsSubT.CreateInsSub(patNum, insPlan.PlanNum); PatPlan patPlan = PatPlanT.CreatePatPlan(1, patNum, insSub.InsSubNum); Procedure procedure1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 50, DateTime.Now.AddDays(-1)); Procedure procedure2 = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 40, DateTime.Now.AddDays(-2)); Procedure procedure3 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 60, DateTime.Now.AddDays(-3)); ClaimProcT.AddInsPaid(patNum, insPlan.PlanNum, procedure1.ProcNum, 20, insSub.InsSubNum, 0, 0); ClaimProcT.AddInsPaid(patNum, insPlan.PlanNum, procedure2.ProcNum, 5, insSub.InsSubNum, 5, 0); ClaimProcT.AddInsPaid(patNum, insPlan.PlanNum, procedure3.ProcNum, 20, insSub.InsSubNum, 0, 10); Payment payment = PaymentT.MakePaymentNoSplits(patNum, 150, DateTime.Today); Family famForPat = Patients.GetFamily(patNum); List <Patient> listFamForPat = famForPat.ListPats.ToList(); PaymentEdit.InitData init = PaymentEdit.Init(listFamForPat, famForPat, new Family { }, payment, new List <PaySplit>(), new List <Procedure>(), patNum); //Auto Splits will be in opposite order from least recent to most recent. //ListSplitsCur should contain four splits, 30, 35, and 30, then one unallocated for the remainder of the payment 55. Assert.AreEqual(4, init.AutoSplitData.ListSplitsCur.Count); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[0].SplitAmt != 40 || init.AutoSplitData.ListSplitsCur[0].ProcNum != procedure3.ProcNum || init.AutoSplitData.ListSplitsCur[0].PatNum != patNum); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[1].SplitAmt != 35 || init.AutoSplitData.ListSplitsCur[1].ProcNum != procedure2.ProcNum || init.AutoSplitData.ListSplitsCur[1].PatNum != patNum); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[2].SplitAmt != 30 || init.AutoSplitData.ListSplitsCur[2].ProcNum != procedure1.ProcNum || init.AutoSplitData.ListSplitsCur[2].PatNum != patNum); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[3].SplitAmt != 45 || init.AutoSplitData.ListSplitsCur[3].ProcNum != 0); }
public void InsPlan_GetInsUsedDisplay_OrthoProcsNotAffectInsUsed() { string suffix = "13"; Patient pat = PatientT.CreatePatient(suffix); Carrier carrier = CarrierT.CreateCarrier(suffix); InsPlan plan = InsPlanT.CreateInsPlan(carrier.CarrierNum); InsSub sub = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum); long subNum = sub.InsSubNum; PatPlan patPlan = PatPlanT.CreatePatPlan(1, pat.PatNum, subNum); BenefitT.CreateAnnualMax(plan.PlanNum, 100); BenefitT.CreateOrthoMax(plan.PlanNum, 500); BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Diagnostic, 100); BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Orthodontics, 100); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D0140", ProcStat.C, "", 59); //limEx Procedure proc2 = ProcedureT.CreateProcedure(pat, "D8090", ProcStat.C, "", 348); //Comprehensive ortho ClaimProcT.AddInsPaid(pat.PatNum, plan.PlanNum, proc1.ProcNum, 59, subNum, 0, 0); ClaimProcT.AddInsPaid(pat.PatNum, plan.PlanNum, proc2.ProcNum, 348, subNum, 0, 0); //Lists Family fam = Patients.GetFamily(pat.PatNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <PatPlan> patPlans = PatPlans.Refresh(pat.PatNum); List <Benefit> benefitList = Benefits.Refresh(patPlans, subList); List <ClaimProcHist> histList = ClaimProcs.GetHistList(pat.PatNum, benefitList, patPlans, planList, DateTime.Today, subList); //Validate double insUsed = InsPlans.GetInsUsedDisplay(histList, DateTime.Today, plan.PlanNum, patPlan.PatPlanNum, -1, planList, benefitList, pat.PatNum, subNum); Assert.AreEqual(59, insUsed); }
public void PaymentEdit_ConstructAndLinkChargeCredits_ChargesWithAttachedPayPlanCreditsWithPreviousPayments() { //new payplan Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); Procedure proc1 = ProcedureT.CreateProcedure(pat, "D1120", ProcStat.C, "", 135, DateTime.Today.AddMonths(-4)); Procedure proc2 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 60, DateTime.Today.AddMonths(-4)); PayPlan payplan = PayPlanT.CreatePayPlanWithCredits(pat.PatNum, 30, DateTime.Today.AddMonths(-3), 0, new List <Procedure>() { proc1, proc2 }); //Procedures's amount start should now be 0 from being attached. Make initial payments. PaymentT.MakePayment(pat.PatNum, 30, DateTime.Today.AddMonths(-2), payplan.PayPlanNum, procNum: proc1.ProcNum); PaymentT.MakePayment(pat.PatNum, 30, DateTime.Today.AddMonths(-1), payplan.PayPlanNum, procNum: proc1.ProcNum); //2 pay plan charges should have been removed from being paid. Make a new payment. Payment pay = PaymentT.MakePaymentNoSplits(pat.PatNum, 30, DateTime.Today, isNew: true, payType: 1); PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, pay, new List <long> { pat.PatNum }, true, false); PaymentEdit.InitData initData = PaymentEdit.Init(loadData.ListAssociatedPatients, Patients.GetFamily(pat.PatNum), new Family { }, pay , loadData.ListSplits, new List <Procedure>(), pat.PatNum, loadData: loadData); //should only see 2 pay plan charges that have not been paid, along with 2 pay plan charges that have been paid. Assert.AreEqual(2, initData.AutoSplitData.ListAccountCharges.FindAll(x => x.AmountStart > 0).Count); Assert.AreEqual(4, initData.AutoSplitData.ListAccountCharges.Count(x => x.Tag.GetType() == typeof(PayPlanCharge))); }
public void InsPlan_GetPendingDisplay_LimitationsOverrideGeneralLimitations() { string suffix = "31"; Patient pat = PatientT.CreatePatient(suffix); long patNum = pat.PatNum; Carrier carrier = CarrierT.CreateCarrier(suffix); InsPlan plan = InsPlanT.CreateInsPlan(carrier.CarrierNum); long planNum = plan.PlanNum; InsSub sub = InsSubT.CreateInsSub(pat.PatNum, planNum); //guarantor is subscriber long subNum = sub.InsSubNum; long patPlanNum = PatPlanT.CreatePatPlan(1, pat.PatNum, subNum).PatPlanNum; BenefitT.CreateAnnualMax(planNum, 1000); BenefitT.CreateCategoryPercent(planNum, EbenefitCategory.RoutinePreventive, 100); BenefitT.CreateLimitation(planNum, EbenefitCategory.RoutinePreventive, 1000); //Changing this amount would affect patient portion vs ins portion. But regardless of the amount, this should prevent any pending from showing in the box, which is for general pending only. Procedure proc = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 125); //Prophy //Lists List <ClaimProc> claimProcs = ClaimProcs.Refresh(pat.PatNum); Family fam = Patients.GetFamily(patNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <PatPlan> patPlans = PatPlans.Refresh(patNum); List <Benefit> benefitList = Benefits.Refresh(patPlans, subList); List <Procedure> ProcList = Procedures.Refresh(pat.PatNum); Claim claim = ClaimT.CreateClaim("P", patPlans, planList, claimProcs, ProcList, pat, ProcList, benefitList, subList);//Creates the claim in the same manner as the account module, including estimates and status NotReceived. List <ClaimProcHist> histList = ClaimProcs.GetHistList(patNum, benefitList, patPlans, planList, DateTime.Today, subList); //Validate Assert.AreEqual(0, InsPlans.GetPendingDisplay(histList, DateTime.Today, plan, patPlanNum, -1, patNum, subNum, benefitList)); }
public void PaymentEdit_AllocateUnearned_NoLinkToOriginalPrepayment() { Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name); //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. //We want to do it manually so we don't link this to the orginal prepayment correctly. //Not linking correctly will test that the AllocateUnearned method is implicitly linking prepayments correctly. PaySplitT.CreatePaySplitsForPrepayment(proc1, 50, prov: provNum, clinic: clinic1); //Create new procedure Procedure proc2 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 100, provNum: provNum); //test the PaymentEdit.AllocateUnearned() method. Family fam = Patients.GetFamily(pat.PatNum); List <PaySplit> listFamPrePaySplits = PaySplits.GetPrepayForFam(fam); //Should be $100 double unearnedAmt = (double)PaySplits.GetUnearnedForFam(fam, listFamPrePaySplits); Assert.AreEqual(100, unearnedAmt); List <PaySplit> listPaySplitsUnearned = new List <PaySplit>(); Payment pay = PaymentT.MakePaymentForPrepayment(pat, clinic1); List <PaySplits.PaySplitAssociated> retVal = PaymentEdit.AllocateUnearned(new List <Procedure> { proc2 }, ref listPaySplitsUnearned, pay, unearnedAmt, fam); Assert.AreEqual(2, retVal.Count); //After running the AllocateUnearned, we should implicitly link the incorrect prepayment made when we call CreatePaySplitsForPrepayment above. Assert.AreEqual(-50, listPaySplitsUnearned.Where(x => x.UnearnedType != 0).Sum(x => x.SplitAmt)); }
public void PaymentEdit_Init_AutoSplitProcedureGuarantor() //Legacy_TestFortySeven { string suffix = "47"; Patient pat = PatientT.CreatePatient(suffix); Patient patOld = PatientT.CreatePatient(suffix + "fam"); Patient pat2 = patOld.Copy(); long patNum = pat.PatNum; pat2.Guarantor = patNum; Patients.Update(pat2, patOld); long patNum2 = pat2.PatNum; Procedure procedure1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 50, DateTime.Now.AddDays(-1)); Procedure procedure2 = ProcedureT.CreateProcedure(pat2, "D0120", ProcStat.C, "", 40, DateTime.Now.AddDays(-2)); Procedure procedure3 = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 60, DateTime.Now.AddDays(-3)); Payment payment = PaymentT.MakePaymentNoSplits(patNum, 150, DateTime.Today); Family famForPat = Patients.GetFamily(patNum); List <Patient> listFamForPat = famForPat.ListPats.ToList(); PaymentEdit.InitData init = PaymentEdit.Init(listFamForPat, famForPat, new Family { }, payment, new List <PaySplit>(), new List <Procedure>(), patNum); //Auto Splits will be in opposite order from least recent to most recent. Assert.AreEqual(3, init.AutoSplitData.ListSplitsCur.Count); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[0].SplitAmt != 60 || init.AutoSplitData.ListSplitsCur[0].ProcNum != procedure3.ProcNum || init.AutoSplitData.ListSplitsCur[0].PatNum != patNum); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[1].SplitAmt != 40 || init.AutoSplitData.ListSplitsCur[1].ProcNum != procedure2.ProcNum || init.AutoSplitData.ListSplitsCur[1].PatNum != patNum2); Assert.IsFalse(init.AutoSplitData.ListSplitsCur[2].SplitAmt != 50 || init.AutoSplitData.ListSplitsCur[2].ProcNum != procedure1.ProcNum || init.AutoSplitData.ListSplitsCur[2].PatNum != patNum); }
public void FeeSchedTools_GlobalUpdateWriteoffEstimates_SubscriberInDifferentFamily() { string suffix = MethodBase.GetCurrentMethod().Name; string procStr = "D0145"; double procFee = 100; ProcedureCode procCode = ProcedureCodes.GetProcCode(procStr); //Set up clinic, prov, pat Clinic clinic = ClinicT.CreateClinic(suffix); long feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix); long provNum = ProviderT.CreateProvider(suffix, feeSchedNum: feeSchedNum); Fee fee = FeeT.GetNewFee(feeSchedNum, procCode.CodeNum, procFee, clinic.ClinicNum, provNum); Patient pat = PatientT.CreatePatient(suffix, provNum, clinic.ClinicNum); Patient patSubscriber = PatientT.CreatePatient(suffix + "_Subscriber", provNum, clinic.ClinicNum); //Set up insurance InsuranceInfo info = InsuranceT.AddInsurance(pat, suffix, "p", feeSchedNum); info.PriInsSub.Subscriber = patSubscriber.PatNum; InsSubs.Update(info.PriInsSub); info.ListBenefits.Add(BenefitT.CreatePercentForProc(info.PriInsPlan.PlanNum, procCode.CodeNum, 100)); //Create the procedure and claimproc Procedure proc = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", procFee); ClaimProc priClaimProc = ClaimProcT.CreateClaimProc(pat.PatNum, proc.ProcNum, info.PriInsPlan.PlanNum, info.PriInsSub.InsSubNum, DateTime.Today, -1, -1, -1, ClaimProcStatus.CapEstimate); Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), true, info.ListInsPlans, info.ListPatPlans, info.ListBenefits, pat.Age, info.ListInsSubs); priClaimProc = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ProcNum == proc.ProcNum); Assert.AreEqual(procFee, priClaimProc.InsPayEst); GlobalUpdateWriteoffs(clinic.ClinicNum); priClaimProc = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ClaimProcNum == priClaimProc.ClaimProcNum); Assert.AreEqual(procFee, priClaimProc.InsPayEst); }
public void ProcMultiVisitTests_Crown_PseudoStatusStages() { string suffix = MethodBase.GetCurrentMethod().Name; Patient pat = PatientT.CreatePatient(suffix); List <Procedure> listProcs = new List <Procedure>(); Procedure procBillable = ProcedureT.CreateProcedure(pat, "D2750", ProcStat.TP, "1", 100, new DateTime(2018, 5, 1));//PFM listProcs.Add(procBillable); Procedure procDelivery = ProcedureT.CreateProcedure(pat, "N4118", ProcStat.TP, "1", 0, new DateTime(2018, 8, 20)); //Seat - usually completed several months later. listProcs.Add(procDelivery); ProcMultiVisits.CreateGroup(listProcs); Assert.IsFalse(ProcMultiVisits.IsProcInProcess(procBillable.ProcNum)); //This proc is not in process because there must be at least one complete procedure. Assert.IsFalse(ProcMultiVisits.IsProcInProcess(procDelivery.ProcNum)); //This proc is not in process because there must be at least one complete procedure. Procedure procBillableOld = procBillable.Copy(); procBillable.ProcStatus = ProcStat.C; Procedures.Update(procBillable, procBillableOld); Assert.IsTrue(ProcMultiVisits.IsProcInProcess(procBillable.ProcNum)); //This proc is In Process because it is set complete, while at the same time no all procs in the group are complete. Assert.IsFalse(ProcMultiVisits.IsProcInProcess(procDelivery.ProcNum)); //This proc is not In Process because not set to complete. Procedure procDeliveryOld = procDelivery.Copy(); procDelivery.ProcStatus = ProcStat.C; Procedures.Update(procDelivery, procDeliveryOld); Assert.IsFalse(ProcMultiVisits.IsProcInProcess(procBillable.ProcNum)); //Both procedures complete means the group is now complete (not In Process). Assert.IsFalse(ProcMultiVisits.IsProcInProcess(procDelivery.ProcNum)); //Both procedures complete means the group is now complete (not In Process). }
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 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 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 SetupTest() { PatientT.ClearPatientTable(); AppointmentT.ClearAppointmentTable(); ReactivationT.ClearReactivationTable(); ClinicT.ClearClinicTable(); }
public void Reactivations_GetReactivationList_PatientMarkedDoNotContact() { string name = MethodBase.GetCurrentMethod().Name; Clinic clinic = ClinicT.CreateClinic(name); long provNum = ProviderT.CreateProvider(name); Patient pat = PatientT.CreatePatient(name, provNum, clinic.ClinicNum, TestEmaiAddress, TestPatPhone, ContactMethod.Mail); //Patient has not been seen since further in the past than the ReactivationDaysPast preference. Procedure proc = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 50, procDate: DateTime.Now.AddYears(-3), provNum: provNum); //3 year old proc //Patient has been contacted, and the ReactivationContactInterval has elapsed. Commlog comm = new Commlog() { PatNum = pat.PatNum, CommDateTime = DateTime.Now.AddYears(-1), CommType = _reactivationCommLogType, Mode_ = CommItemMode.Email, SentOrReceived = CommSentOrReceived.Sent, CommSource = CommItemSource.ApptReminder, }; comm.CommlogNum = Commlogs.Insert(comm); //Patient has been marked "Do Not Contact" Reactivations.Insert(new Reactivation() { PatNum = pat.PatNum, DoNotContact = true, }); DateTime dateSince = DateTime.Today.AddDays(-PrefC.GetInt(PrefName.ReactivationDaysPast)); DateTime dateStop = dateSince.AddMonths(-36); //Confirm that the patient does not in the Reactivation List DataTable tbl = Reactivations.GetReactivationList(dateSince, dateStop, false, false, true, provNum, clinic.ClinicNum, 0, 0 , ReactivationListSort.LastContacted, RecallListShowNumberReminders.One); //No patients in the list Assert.AreEqual(0, tbl.Rows.Count); }
public void ProcedureLogic_SortProcedures_CanadianLabs_ProcStatusMismatch() { CultureInfo oldCulture = SetCulture(new CultureInfo("en-CA")); Patient pat = PatientT.CreatePatient("Test"); List <Procedure> listProcs = new List <Procedure>(); //Parent and Lab match on all fields except ProcStatus Procedure parentProc = ProcedureT.CreateProcedure(pat, "D1120", ProcStat.C, "4", 200.00, procDate: DateTime.Now, priority: 0, 0, 0, 0, 0, "", 0); listProcs.Add(parentProc); Procedure parentProc2 = ProcedureT.CreateProcedure(pat, "D1420", ProcStat.C, "6", 200.00, procDate: DateTime.Now, priority: 0, 0, 0, 0, 0, "", 0); listProcs.Add(parentProc2); listProcs.AddRange(CreateAssortedProcs(pat)); Procedure labProc = ProcedureT.CreateProcedure(pat, "99333", ProcStat.TP, "4", 200.00, parentProc.ProcDate, priority: 0, 0, 0, 0, 0, "", parentProc.ProcNum); listProcs.Add(labProc); Procedure labProc2 = ProcedureT.CreateProcedure(pat, "99222", ProcStat.TP, "6", 120.00, parentProc2.ProcDate, priority: 0, 0, 0, 0, 0, "", parentProc2.ProcNum); listProcs.Add(labProc2); ProcedureLogic.SortProcedures(ref listProcs); int parentProcIndex = listProcs.FindIndex(x => x == parentProc); int labProcIndex = listProcs.FindIndex(x => x == labProc); int parentProc2Index = listProcs.FindIndex(x => x == parentProc2); int labProc2Index = listProcs.FindIndex(x => x == labProc2); Assert.AreEqual(parentProcIndex + 1, labProcIndex); //A lab should be directly after its parent Assert.AreEqual(parentProc2Index + 1, labProc2Index); //A lab should be directly after its parent SetCulture(oldCulture); }
public void Patients_GetPatientsByPartialName_TwoWordLastNamePlusFirst() { PatientT.CreatePatient(lName: "Owre", fName: "Sam"); PatientT.CreatePatient(lName: "Van Damme", fName: "Jean-Claude"); List <Patient> listPats = Patients.GetPatientsByPartialName("sam van damme"); Assert.AreEqual(0, listPats.Count); }