Пример #1
0
        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));
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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).
        }
Пример #5
0
        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)));
        }
Пример #6
0
        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);
        }
Пример #7
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);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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));
        }
Пример #10
0
        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);
        }
Пример #11
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);
        }
Пример #12
0
        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)));
        }
Пример #13
0
        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);
        }
Пример #14
0
        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);
        }
Пример #15
0
        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 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));
        }
Пример #17
0
        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
        }
Пример #18
0
        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);
        }
Пример #19
0
        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);
        }
Пример #20
0
        public void LedgersTests_ComputeAgingProcLifo_Case1()
        {
            string     suffix = MethodBase.GetCurrentMethod().Name;
            Patient    pat    = PatientT.CreatePatient(fName: "Aging_Case1", suffix: suffix);
            Procedure  proc85 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 100, DateTime.Today.AddDays(-85));
            Adjustment adj55  = AdjustmentT.MakeAdjustment(pat.PatNum, 10, DateTime.Today.AddDays(-55), proc85.ProcDate, proc85.ProcNum);
            Adjustment adj2   = AdjustmentT.MakeAdjustment(pat.PatNum, -8, DateTime.Today.AddDays(-2), proc85.ProcDate, proc85.ProcNum);

            CheckAgingProcLifo(pat.PatNum, 0, 10, 92, 0, 0, YN.Yes);
            CheckAgingProcLifo(pat.PatNum, 0, 10, 92, 0, 0, YN.No);
            CheckAgingProcLifo(pat.PatNum, 0, 10, 92, 0, 0, YN.Unknown);      //Unset will behave the same as Off for now, until we change default behavior in future.
        }
Пример #21
0
        public void AgingData_GetAgingData_PayPlanBillInAdvanceDays_WithPendingProc()
        {
            string   suffix            = MethodBase.GetCurrentMethod().Name;
            Patient  patient           = PatientT.CreatePatient(suffix);
            long     provNum           = ProviderT.CreateProvider(suffix);
            DateTime datePayPlan       = DateTime.Today.AddDays(5);
            DateTime datePayPlanCreate = DateTime.Today.AddMonths(-1);          //Payment Plan was created a month ago.
            DateTime dateProc          = DateTime.Today;
            DateTime dateStatement     = DateTime.Today.AddDays(-5);

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

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

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

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

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

            //Assert that the patient has been flagged to get a new statement due to procedure that was completed above.
            Assert.IsTrue(listPatAging.Any(x => x.PatNum == patient.PatNum), "The expected patient was not present in the AgingList.");
        }
Пример #22
0
        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);
            }
        }
Пример #23
0
        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);
            }
        }
Пример #24
0
 public void TearDownTest()
 {
     BenefitT.ClearBenefitTable();
     CarrierT.ClearCarrierTable();
     ClaimT.ClearClaimTable();
     ClaimProcT.ClearClaimProcTable();
     EtransT.ClearEtransTable();
     InsPlanT.ClearInsPlanTable();
     InsSubT.ClearInsSubTable();
     PatientT.ClearPatientTable();
     PatPlanT.ClearPatPlanTable();
     ProcedureT.ClearProcedureTable();
     SubstitutionLinkT.ClearSubstitutionLinkTable();
 }
Пример #25
0
        public void AgingData_GetAgingData_PayPlanBillInAdvanceDays_WithNewPayPlan()
        {
            string   suffix            = MethodBase.GetCurrentMethod().Name;
            Patient  patient           = PatientT.CreatePatient(suffix);
            long     provNum           = ProviderT.CreateProvider(suffix);
            DateTime datePayPlanCharge = DateTime.Today.AddDays(5);
            DateTime datePayPlanCreate = DateTime.Today;          //The payment plan that we are about to create will automatically have this date as the SecTDateEntry
            DateTime dateProc          = DateTime.Today.AddDays(-1);
            DateTime dateStatement     = DateTime.Today.AddDays(-1);

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

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

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

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

            Assert.IsTrue(listPatAging.Any(x => x.PatNum == patient.PatNum), "The expected patient was not present in the AgingList.");
        }
Пример #26
0
        ///<summary>A helper method to create 10 Procedures for a given Patient, half with ProcStat.C and half with ProcStat.TP,
        ///each with different priorities, toothnums, dates and procfees. This method is not Canada specific and can be used for all Cultures.</summary>
        private List <Procedure> CreateAssortedProcs(Patient pat)
        {
            List <Procedure> listProcs = new List <Procedure>();

            for (int i = 0; i < 5; i++)
            {
                Procedure newProc = ProcedureT.CreateProcedure(pat, "D2220", ProcStat.C, i.ToString(), i * 100.00, DateTime.Now.AddDays(i), i, 0, 0, 0, 0, "", 0);
                listProcs.Add(newProc);
            }
            for (int i = 0; i < 5; i++)
            {
                Procedure newProc = ProcedureT.CreateProcedure(pat, "D2220", ProcStat.TP, i.ToString(), i * 100.00, DateTime.Now.AddDays(i), i, 0, 0, 0, 0, "", 0);
                listProcs.Add(newProc);
            }
            return(listProcs);
        }
Пример #27
0
        public void PaymentEdit_Init_AutoSplitForPaymentNegativePaymentAmount()          //Legacy_TestFortyFour
        {
            string         suffix        = "44";
            Patient        pat           = PatientT.CreatePatient(suffix);
            long           patNum        = pat.PatNum;
            Procedure      procedure1    = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 40, DateTime.Now.AddDays(-1));
            Payment        payment       = PaymentT.MakePaymentNoSplits(patNum, -50, 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 no paysplits since it doesn't make sense to create negative payments when there are outstanding charges.
            Assert.AreEqual(0, init.AutoSplitData.ListSplitsCur.Count);
        }
Пример #28
0
        public void PaymentEdit_AllocateUnearned_LinkToOriginalPrepayment()
        {
            Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            //create prepayment of $100
            long   provNum = ProviderT.CreateProvider("SG");
            Clinic clinic1 = ClinicT.CreateClinic("Clinic1");
            Family fam     = Patients.GetFamily(pat.PatNum);
            //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);
            //Setup to run the PaymentEdit.AllocateUnearned
            List <PaySplit> listPaySplits       = new List <PaySplit>();
            List <PaySplit> listFamPrePaySplits = PaySplits.GetPrepayForFam(fam);
            //Unearned amount should be $100.
            double unearnedAmt = (double)PaySplits.GetUnearnedForFam(fam, listFamPrePaySplits);

            Assert.AreEqual(100, unearnedAmt);
            //Create the payment we will use to allocate some of the $100 prepayment.
            Payment pay = PaymentT.MakePaymentForPrepayment(pat, clinic1);
            //Run the AllocateUnearned method. This a list of paysplitAssociated.
            //The ref list of paysplits should also have the new paysplits that are associated to the original prepayment.
            List <PaySplits.PaySplitAssociated> listPaySplitAssociated = PaymentEdit.AllocateUnearned(new List <Procedure> {
                proc1
            }, ref listPaySplits, pay, unearnedAmt, fam);

            //Insert the paysplits and link the prepayment paysplits. This is similar to what is done when a user creates a payment from FormPayment.cs.
            PaySplitT.InsertPrepaymentSplits(listPaySplits, listPaySplitAssociated);
            //The ref list of paysplits should have the correct allocated prepayment amount.
            Assert.AreEqual(-50, listPaySplits.Where(x => x.UnearnedType != 0).Sum(x => x.SplitAmt));
            //Create new procedure
            Procedure proc2 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 100, provNum: provNum);

            //Now do what we just did again for a new procedure. The unallocated amount should be $50.
            listFamPrePaySplits = PaySplits.GetPrepayForFam(fam);
            unearnedAmt         = (double)PaySplits.GetUnearnedForFam(fam, listFamPrePaySplits);
            Assert.AreEqual(50, unearnedAmt);
            List <PaySplit> listPaySplitsUnearned = new List <PaySplit>();

            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);
            Assert.AreEqual(-50, listPaySplitsUnearned.Where(x => x.UnearnedType != 0).Sum(x => x.SplitAmt));
        }
Пример #29
0
        public void InsPlan_GetDedRemainDisplay_IndividualAndFamilyDeductiblesInsRemaining()
        {
            string  suffix = "20";
            Patient pat    = PatientT.CreatePatient(suffix);       //guarantor
            long    patNum = pat.PatNum;
            Patient pat2   = PatientT.CreatePatient(suffix);

            PatientT.SetGuarantor(pat2, pat.PatNum);
            Patient pat3 = PatientT.CreatePatient(suffix);

            PatientT.SetGuarantor(pat3, 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;
            PatPlan patPlan  = PatPlanT.CreatePatPlan(1, pat.PatNum, subNum);  //all three patients have the same plan
            PatPlan patPlan2 = PatPlanT.CreatePatPlan(1, pat2.PatNum, subNum); //all three patients have the same plan
            PatPlan patPlan3 = PatPlanT.CreatePatPlan(1, pat3.PatNum, subNum); //all three patients have the same plan

            BenefitT.CreateDeductibleGeneral(planNum, BenefitCoverageLevel.Individual, 75);
            BenefitT.CreateDeductibleGeneral(planNum, BenefitCoverageLevel.Family, 150);
            ClaimProcT.AddInsUsedAdjustment(pat3.PatNum, planNum, 0, subNum, 75);               //Adjustment goes on the third patient
            Procedure proc = ProcedureT.CreateProcedure(pat2, "D2750", ProcStat.C, "20", 1280); //proc for second patient with a deductible already applied.

            ClaimProcT.AddInsPaid(pat2.PatNum, planNum, proc.ProcNum, 304, subNum, 50, 597);
            proc = ProcedureT.CreateProcedure(pat, "D4355", ProcStat.TP, "", 135);      //proc is for the first patient
            long procNum = proc.ProcNum;
            //Lists
            List <ClaimProc>     claimProcs  = ClaimProcs.Refresh(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 <ClaimProcHist> histList    = ClaimProcs.GetHistList(patNum, benefitList, patPlans, planList, DateTime.Today, subList);
            List <ClaimProcHist> loopList    = new List <ClaimProcHist>();
            //Validate
            List <ClaimProcHist> HistList = ClaimProcs.GetHistList(pat.PatNum, benefitList, patPlans, planList, DateTime.Today, subList);
            double dedFam = Benefits.GetDeductGeneralDisplay(benefitList, planNum, patPlan.PatPlanNum, BenefitCoverageLevel.Family);
            double ded    = Benefits.GetDeductGeneralDisplay(benefitList, planNum, patPlan.PatPlanNum, BenefitCoverageLevel.Individual);
            double dedRem = InsPlans.GetDedRemainDisplay(HistList, DateTime.Today, planNum, patPlan.PatPlanNum, -1, planList, pat.PatNum, ded, dedFam);  //test family and individual deductible together

            Assert.AreEqual(25, dedRem);
            dedRem = InsPlans.GetDedRemainDisplay(HistList, DateTime.Today, planNum, patPlan.PatPlanNum, -1, planList, pat.PatNum, ded, -1);  //test individual deductible by itself
            Assert.AreEqual(75, dedRem);
        }
Пример #30
0
        public void PaymentEdit_Init_AutoSplitForPaymentNegativePaymentAmountNegProcedure()          //Legacy_TestFortySix
        {
            string         suffix        = "46";
            Patient        pat           = PatientT.CreatePatient(suffix);
            long           patNum        = pat.PatNum;
            Procedure      procedure1    = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", -40, DateTime.Now.AddDays(-1));
            Payment        payment       = PaymentT.MakePaymentNoSplits(patNum, -50, 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 one paysplit for the amount passed in that is unallocated.
            Assert.AreEqual(1, init.AutoSplitData.ListSplitsCur.Count);
            Assert.IsFalse(init.AutoSplitData.ListSplitsCur[0].SplitAmt != -50 || init.AutoSplitData.ListSplitsCur[0].ProcNum != 0);
        }