Example #1
0
        public void X834_ImportInsurancePlans_ReplacePatPlan()
        {
            Patient pat    = Createx834Patient();
            string  suffix = MethodBase.GetCurrentMethod().Name;
            //Create old insurance plan and associate it to them.
            InsuranceInfo insuranceOld = InsuranceT.AddInsurance(pat, "Old Carrier" + suffix);
            //Create x834
            X834 x834 = new X834(new X12object(Properties.Resources.x834Test));
            int  createdPatsCount, updatedPatsCount, skippedPatsCount, createdCarrierCount, createdInsPlanCount, updatedInsPlanCount, createdInsSubCount,
                 updatedInsSubCount, createdPatPlanCount, droppedPatPlanCount, updatedPatPlanCount;
            StringBuilder sbErrorMessages;

            //Pass in true for dropExistingInsurance
            EtransL.ImportInsurancePlans(x834, new List <Patient> {
                pat
            }, true, true, out createdPatsCount,
                                         out updatedPatsCount, out skippedPatsCount, out createdCarrierCount, out createdInsPlanCount, out updatedInsPlanCount, out createdInsSubCount,
                                         out updatedInsSubCount, out createdPatPlanCount, out droppedPatPlanCount, out updatedPatPlanCount, out sbErrorMessages);
            //Get the pat plans for this patient from the database.
            List <PatPlan> listPatPlans = PatPlans.GetPatPlansForPat(pat.PatNum);

            Assert.AreEqual(1, listPatPlans.Count);
            Assert.AreEqual(1, droppedPatPlanCount);
            InsSub subForPatPlan        = InsSubs.GetOne(listPatPlans[0].InsSubNum);

            //These should be different as a new plan was created and the old plan was dropped.
            Assert.AreNotEqual(insuranceOld.PriInsPlan.PlanNum, subForPatPlan.PlanNum);
        }
Example #2
0
        public void X834_ImportInsurancePlans_ReplaceSecondaryPatPlan()
        {
            Patient pat    = Createx834Patient();
            string  suffix = MethodBase.GetCurrentMethod().Name;
            //Create primary insurance plan that appears in the 834.
            InsuranceInfo insurancePrimary = InsuranceT.AddInsurance(pat, "Old Carrier" + suffix, subscriberID: "CG00000B");
            //Create secondary insurance that does not appear in the 834.
            InsuranceInfo insuranceSecondary = InsuranceT.AddInsurance(pat, "Secondary Carrier" + suffix);
            //Get the pat plans for this patient from the database.
            List <PatPlan> listPatPlans = PatPlans.GetPatPlansForPat(pat.PatNum);

            Assert.AreEqual(2, listPatPlans.Count);
            //Create x834
            X834 x834 = new X834(new X12object(Properties.Resources.x834Test));
            int  createdPatsCount, updatedPatsCount, skippedPatsCount, createdCarrierCount, createdInsPlanCount, updatedInsPlanCount, createdInsSubCount,
                 updatedInsSubCount, createdPatPlanCount, droppedPatPlanCount, updatedPatPlanCount;
            StringBuilder sbErrorMessages;

            //Pass in true for dropExistingInsurance
            EtransL.ImportInsurancePlans(x834, new List <Patient> {
                pat
            }, true, true, out createdPatsCount,
                                         out updatedPatsCount, out skippedPatsCount, out createdCarrierCount, out createdInsPlanCount, out updatedInsPlanCount, out createdInsSubCount,
                                         out updatedInsSubCount, out createdPatPlanCount, out droppedPatPlanCount, out updatedPatPlanCount, out sbErrorMessages);
            //Get the pat plans for this patient from the database.
            listPatPlans = PatPlans.GetPatPlansForPat(pat.PatNum);
            Assert.AreEqual(1, listPatPlans.Count);
            Assert.AreEqual(1, droppedPatPlanCount);
            //These should be different as a new plan was created and the old plan was dropped.
            Assert.AreEqual(insurancePrimary.ListPatPlans[0].PatPlanNum, listPatPlans[0].PatPlanNum);
        }
Example #3
0
        public void X834_ImportInsurancePlans_DoNotReplacePatPlan()
        {
            Patient pat    = Createx834Patient();
            string  suffix = MethodBase.GetCurrentMethod().Name;
            //Create old insurance plan and associate it to them.
            InsuranceInfo insuranceOld = InsuranceT.AddInsurance(pat, "Old Carrier" + suffix);
            //Create x834
            X834 x834 = new X834(new X12object(Properties.Resources.x834Test));
            int  createdPatsCount, updatedPatsCount, skippedPatsCount, createdCarrierCount, createdInsPlanCount, updatedInsPlanCount, createdInsSubCount,
                 updatedInsSubCount, createdPatPlanCount, droppedPatPlanCount, updatedPatPlanCount;
            StringBuilder sbErrorMessages;

            EtransL.ImportInsurancePlans(x834, new List <Patient> {
                pat
            }, true, false, out createdPatsCount,
                                         out updatedPatsCount, out skippedPatsCount, out createdCarrierCount, out createdInsPlanCount, out updatedInsPlanCount, out createdInsSubCount,
                                         out updatedInsSubCount, out createdPatPlanCount, out droppedPatPlanCount, out updatedPatPlanCount, out sbErrorMessages);
            //Get the pat plans for this patient from the database.
            List <PatPlan> listPatPlans = PatPlans.GetPatPlansForPat(pat.PatNum);

            //No patient was created. Should have matched the one we created.
            Assert.AreEqual(0, createdPatsCount);
            //There should be two now as the old was kept.
            Assert.AreEqual(2, listPatPlans.Count);
            Assert.AreEqual(1, createdPatPlanCount);
        }
Example #4
0
        ///<summary>Creates a general deductible of $50, a deductible of $50 on D0220, sets a $30 D0220 complete and creates a claim,
        ///creates a $100 D2750, that is TP'ed, and then creates a $30 D0220 that is TP'ed.</summary>
        ///<param name="actAssert">The first claimproc is for the D2750 and the second claimproc is for the second D0220.</param>
        public void GetDeductibleByCodeDeductLessThanGeneral(string suffix, Action <ClaimProc, ClaimProc> actAssert)
        {
            Patient pat = PatientT.CreatePatient(suffix);

            InsuranceT.AddInsurance(pat, suffix);
            List <InsSub>  listSubs     = InsSubT.GetInsSubs(pat);
            List <InsPlan> listPlans    = InsPlans.RefreshForSubList(listSubs);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);
            InsPlan        plan         = InsPlanT.GetPlanForPriSecMed(PriSecMed.Primary, listPatPlans, listPlans, listSubs);

            BenefitT.CreateDeductibleGeneral(plan.PlanNum, BenefitCoverageLevel.Individual, 50);
            BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Diagnostic, 100);
            BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Crowns, 50);
            BenefitT.CreateDeductible(plan.PlanNum, EbenefitCategory.Diagnostic, 0);
            BenefitT.CreateDeductible(plan.PlanNum, "D0220", 50);
            List <Benefit> listBens = Benefits.Refresh(listPatPlans, listSubs);
            Procedure      proc1    = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 30);//proc1 - Intraoral - periapical first film

            ClaimT.CreateClaim("P", listPatPlans, listPlans, new List <ClaimProc>(), new List <Procedure> {
                proc1
            }, pat, new List <Procedure> {
                proc1
            }, listBens,
                               listSubs);
            Procedure        proc2      = ProcedureT.CreateProcedure(pat, "D2750", ProcStat.TP, "", 100, priority: 0); //proc2 - Crown
            Procedure        proc3      = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.TP, "", 30, priority: 1);  //proc3 - Intraoral - periapical first film
            List <ClaimProc> claimProcs = ProcedureT.ComputeEstimates(pat, listPatPlans, listPlans, listSubs, listBens);
            ClaimProc        claimProc2 = claimProcs.FirstOrDefault(x => x.ProcNum == proc2.ProcNum);
            ClaimProc        claimProc3 = claimProcs.FirstOrDefault(x => x.ProcNum == proc3.ProcNum);

            actAssert(claimProc2, claimProc3);
        }
        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);
        }
Example #6
0
        ///<summary>Creates a procedure and computes estimates for a patient where the secondary insurance has a COB rule of Medicaid.</summary>
        private void ComputeEstimatesMedicaidCOB(string suffix, double procFee, double priAllowed, double secAllowed, int priPercentCovered,
                                                 int secPercentCovered, Action <ClaimProc /*Primary*/, ClaimProc /*Secondary*/, Procedure> assertAct)
        {
            Patient pat            = PatientT.CreatePatient(suffix);
            long    ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix);

            InsuranceT.AddInsurance(pat, suffix, "p", ppoFeeSchedNum);
            long medicaidFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix);

            InsuranceT.AddInsurance(pat, suffix, "p", medicaidFeeSchedNum, 2, cobRule: EnumCobRule.SecondaryMedicaid);
            List <InsSub>  listSubs     = InsSubT.GetInsSubs(pat);
            List <InsPlan> listPlans    = InsPlans.RefreshForSubList(listSubs);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);
            InsPlan        priPlan      = InsPlanT.GetPlanForPriSecMed(PriSecMed.Primary, listPatPlans, listPlans, listSubs);

            BenefitT.CreateCategoryPercent(priPlan.PlanNum, EbenefitCategory.Diagnostic, priPercentCovered);
            InsPlan secPlan = InsPlanT.GetPlanForPriSecMed(PriSecMed.Secondary, listPatPlans, listPlans, listSubs);

            BenefitT.CreateCategoryPercent(secPlan.PlanNum, EbenefitCategory.Diagnostic, secPercentCovered);
            List <Benefit> listBens = Benefits.Refresh(listPatPlans, listSubs);
            string         procStr  = "D0150";
            Procedure      proc     = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", procFee);
            ProcedureCode  procCode = ProcedureCodes.GetProcCode(procStr);

            FeeT.CreateFee(ppoFeeSchedNum, procCode.CodeNum, priAllowed);
            FeeT.CreateFee(medicaidFeeSchedNum, procCode.CodeNum, secAllowed);
            Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), false, listPlans, listPatPlans, listBens, pat.Age, listSubs);
            List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum);

            assertAct(listClaimProcs.FirstOrDefault(x => x.PlanNum == priPlan.PlanNum), listClaimProcs.FirstOrDefault(x => x.PlanNum == secPlan.PlanNum), proc);
        }
Example #7
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);
        }
Example #8
0
        ///<summary>Creates a procedure and returns its procedure fee.</summary>
        private double GetProcFee(string suffix, bool doUseMedicalCode)
        {
            Prefs.UpdateBool(PrefName.InsPpoAlwaysUseUcrFee, true);
            Prefs.UpdateBool(PrefName.MedicalFeeUsedForNewProcs, doUseMedicalCode);
            Patient pat            = PatientT.CreatePatient(suffix);
            long    ucrFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "UCR " + suffix);

            FeeSchedT.UpdateUCRFeeSched(pat, ucrFeeSchedNum);
            long ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix);

            InsuranceT.AddInsurance(pat, suffix, "p", ppoFeeSchedNum, 1, true);
            List <InsSub>  listSubs     = InsSubT.GetInsSubs(pat);
            List <InsPlan> listPlans    = InsPlans.RefreshForSubList(listSubs);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);
            string         procStr      = "D0150";
            string         procStrMed   = "D0120";
            ProcedureCode  procCode     = ProcedureCodes.GetProcCode(procStr);
            ProcedureCode  procCodeMed  = ProcedureCodes.GetProcCode(procStrMed);

            procCode.MedicalCode = procCodeMed.ProcCode;
            FeeT.CreateFee(ucrFeeSchedNum, procCode.CodeNum, 300);
            FeeT.CreateFee(ppoFeeSchedNum, procCode.CodeNum, 120);
            FeeT.CreateFee(ucrFeeSchedNum, procCodeMed.CodeNum, 175);
            FeeT.CreateFee(ppoFeeSchedNum, procCodeMed.CodeNum, 85);
            Procedure proc = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", 300);

            return(Procedures.GetProcFee(pat, listPatPlans, listSubs, listPlans, procCode.CodeNum, proc.ProvNum, proc.ClinicNum, procCode.MedicalCode));
        }
        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));
        }
Example #10
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);
            }
        }
Example #11
0
        public void Benefits_OverAgeWithLifetimeMax()
        {
            string        suffix = MethodBase.GetCurrentMethod().Name;
            Patient       pat    = PatientT.CreatePatient(suffix, birthDate: DateTime.Now.AddYears(-20));
            InsuranceInfo ins    = InsuranceT.AddInsurance(pat, suffix);

            BenefitT.CreateCategoryPercent(ins.PrimaryInsPlan.PlanNum, EbenefitCategory.Orthodontics, 50);
            BenefitT.CreateAgeLimitation(ins.PrimaryInsPlan.PlanNum, EbenefitCategory.Orthodontics, 18);
            BenefitT.CreateOrthoMax(ins.PrimaryInsPlan.PlanNum, 1000);
            ins.RefreshBenefits();
            Procedure        proc           = ProcedureT.CreateProcedure(pat, "D8090", ProcStat.TP, "", 3000);//comprehensive orthodontic treatment
            List <ClaimProc> listClaimProcs = ProcedureT.ComputeEstimates(pat, ins);

            Assert.AreEqual(0, listClaimProcs.First().InsEstTotal);
        }
Example #12
0
        public void LedgersTests_ComputeAgingProcLifo_InsWoEst_And_InsPayEst()
        {
            string        suffix  = MethodBase.GetCurrentMethod().Name;
            Patient       pat     = PatientT.CreatePatient(fName: "Aging_InsEst", suffix: suffix);
            InsuranceInfo insInfo = InsuranceT.AddInsurance(pat, "AgingInsEst");
            Procedure     proc95  = ProcedureT.CreateProcedure(pat, "D0270", ProcStat.C, "", 1000, DateTime.Today.AddDays(-95));
            ClaimProc     cp95    = new ClaimProc();

            ClaimProcs.CreateEst(cp95, proc95, insInfo.PriInsPlan, insInfo.PriInsSub);
            cp95.Status      = ClaimProcStatus.NotReceived;
            cp95.InsEstTotal = 800;
            cp95.InsPayEst   = 800;
            cp95.WriteOffEst = 200;
            cp95.WriteOff    = 200;
            ClaimProcs.Update(cp95);
            Procedure proc85 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 100, DateTime.Today.AddDays(-85));
            ClaimProc cp85   = new ClaimProc();

            ClaimProcs.CreateEst(cp85, proc85, insInfo.PriInsPlan, insInfo.PriInsSub);
            cp85.Status      = ClaimProcStatus.NotReceived;
            cp85.InsEstTotal = 60;
            cp85.InsPayEst   = 60;
            cp85.WriteOffEst = 40;
            cp85.WriteOff    = 40;
            ClaimProcs.Update(cp85);
            int agingProcLifoPrev = PrefC.GetInt(PrefName.AgingProcLifo);

            try {
                PrefT.UpdateInt(PrefName.AgingProcLifo, (int)YN.No);
                Dictionary <long, DataRow> dictAging = Ledgers.GetAgingGuarTransTable(DateTime.Today, new List <long> {
                    pat.Guarantor
                });
                Assert.AreEqual(PIn.Double(dictAging[pat.Guarantor]["InsPayEst"].ToString()), 860);
                Assert.AreEqual(PIn.Double(dictAging[pat.Guarantor]["InsWoEst"].ToString()), 240);
                PrefT.UpdateInt(PrefName.AgingProcLifo, (int)YN.Yes);
                dictAging = Ledgers.GetAgingGuarTransTable(DateTime.Today, new List <long> {
                    pat.Guarantor
                });
                Assert.AreEqual(PIn.Double(dictAging[pat.Guarantor]["InsPayEst"].ToString()), 860);
                Assert.AreEqual(PIn.Double(dictAging[pat.Guarantor]["InsWoEst"].ToString()), 240);
            }
            finally {
                PrefT.UpdateInt(PrefName.AgingProcLifo, agingProcLifoPrev);
            }
        }
        public void ProcMultiVisitTests_CrownGroupComplete_ClaimDates()
        {
            string           suffix       = MethodBase.GetCurrentMethod().Name;
            Patient          pat          = PatientT.CreatePatient(suffix);
            InsuranceInfo    insInfo      = InsuranceT.AddInsurance(pat, 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);
            List <ClaimProc> listClaimProcs = ProcedureT.ComputeEstimates(pat, insInfo);

            ProcMultiVisits.CreateGroup(listProcs);
            Procedure procBillableOld = procBillable.Copy();

            procBillable.ProcStatus = ProcStat.C;
            Procedures.Update(procBillable, procBillableOld);
            Procedure procDeliveryOld = procDelivery.Copy();

            procDelivery.ProcStatus = ProcStat.C;
            Procedures.Update(procDelivery, procDeliveryOld);
            Assert.AreEqual(ProcMultiVisits.IsProcInProcess(procBillable.ProcNum), false);           //Both procedures complete means the group is now complete (not In Process).
            Assert.AreEqual(ProcMultiVisits.IsProcInProcess(procDelivery.ProcNum), false);           //Both procedures complete means the group is now complete (not In Process).
            Claim claim = new Claim();

            claim.DateSent     = DateTimeOD.Today;
            claim.DateSentOrig = DateTime.MinValue;
            claim.ClaimStatus  = "W";
            //Dates of service are calculated inside AccountModules.CreateClaim().
            //The procDelivery cannot be attached to the claim in the UI, because $0 procs are blocked by UI.  Therefore, we only attach the procBilled to the claim here.
            ODTuple <bool, Claim, string> clmResult = AccountModules.CreateClaim(claim, "P", insInfo.ListPatPlans, insInfo.ListInsPlans, listClaimProcs, listProcs,
                                                                                 insInfo.ListInsSubs, pat, null, new List <Procedure> {
                procBillable
            }, "", insInfo.PriInsPlan, insInfo.PriInsSub, Relat.Self);

            Assert.AreEqual(clmResult.Item3, "");                                //Ensure no validation errors creating the claim.  This is to verify the integrity of the unit test design.
            Assert.AreEqual(clmResult.Item2.DateService, procDelivery.ProcDate); //Claim date of service must always be the greatest date in the multi visit group.
            listClaimProcs = ClaimProcs.RefreshForClaim(clmResult.Item2.ClaimNum);
            Assert.AreEqual(listClaimProcs[0].ProcDate, procDelivery.ProcDate);  //Proc date of service must always be the greatest date in the multi visit group, even if performed on a different day.
        }
        public void FeeSchedTools_GlobalUpdateWriteoffEstimates()
        {
            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.FixedBenefit, 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);
            //Set up insurance
            InsuranceInfo  info         = InsuranceT.AddInsurance(pat, suffix, "c", feeSchedNum);
            List <InsSub>  listSubs     = info.ListInsSubs;
            List <InsPlan> listPlans    = info.ListInsPlans;
            List <PatPlan> listPatPlans = info.ListPatPlans;
            InsPlan        priPlan      = info.PriInsPlan;
            InsSub         priSub       = info.PriInsSub;

            info.ListBenefits.Add(BenefitT.CreatePercentForProc(priPlan.PlanNum, procCode.CodeNum, 90));
            //Create the procedure and claimproc
            Procedure proc         = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", procFee);
            ClaimProc priClaimProc = ClaimProcT.CreateClaimProc(pat.PatNum, proc.ProcNum, priPlan.PlanNum, priSub.InsSubNum, DateTime.Today, -1, -1, -1,
                                                                ClaimProcStatus.CapEstimate);

            Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), true, listPlans, listPatPlans, info.ListBenefits, pat.Age, info.ListInsSubs);
            priClaimProc = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ProcNum == proc.ProcNum);
            Assert.AreEqual(procFee, priClaimProc.WriteOff);
            procFee = 50;
            Procedure procNew = proc.Copy();

            procNew.ProcFee = procFee;
            Procedures.Update(procNew, proc);
            //GlobalUpdate
            long updated = GlobalUpdateWriteoffs(clinic.ClinicNum);

            Assert.AreEqual(1, updated);
            ClaimProc priClaimProcDb = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ClaimProcNum == priClaimProc.ClaimProcNum);

            Assert.AreEqual(procFee, priClaimProcDb.WriteOff);
        }
        public void RpProcNotBilledIns_GetProcsNotBilled_ShowProcsBeforeIns()
        {
            string        suffix        = MethodBase.GetCurrentMethod().Name;
            Patient       patient       = PatientT.CreatePatient(suffix);
            Carrier       carrier       = CarrierT.CreateCarrier(suffix);
            ProcedureCode procedureCode = ProcedureCodeT.CreateProcCode("T7782");
            Procedure     procedure     = ProcedureT.CreateProcedure(patient, procedureCode.ProcCode, ProcStat.C, "", 55, procDate: DateTime.Now.AddDays(-3));
            //Add insurance after the procedure has been set complete.
            InsuranceInfo insuranceInfo = InsuranceT.AddInsurance(patient, carrier.CarrierName, ordinal: 1, isMedical: true);
            //The patient should not be returned when 'showProcsBeforeIns' is set to false.
            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));
            //The patient should be returned when 'showProcsBeforeIns' is set to true.
            table = RpProcNotBilledIns.GetProcsNotBilled(new List <long>(), true, DateTime.Now.AddDays(-10), DateTime.Now, true, false);
            Assert.IsNotNull(table);
            Assert.IsTrue(table.Rows.Count > 0);
            Assert.IsTrue(table.Select().Select(x => PIn.Long(x["PatNum"].ToString())).Contains(patient.PatNum));
        }
Example #16
0
        public void Procedures_ComputeEstimates_PrimaryInsuranceMedicaidCOB()
        {
            string        suffix         = MethodBase.GetCurrentMethod().Name;
            Patient       pat            = PatientT.CreatePatient(suffix);
            long          ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix);
            InsuranceInfo insInfo        = InsuranceT.AddInsurance(pat, suffix, "p", ppoFeeSchedNum, 1, cobRule: EnumCobRule.SecondaryMedicaid);
            InsPlan       priPlan        = InsPlanT.GetPlanForPriSecMed(PriSecMed.Primary, insInfo.ListPatPlans, insInfo.ListInsPlans, insInfo.ListInsSubs);

            BenefitT.CreateCategoryPercent(priPlan.PlanNum, EbenefitCategory.Diagnostic, percent: 50);
            List <Benefit> listBens = Benefits.Refresh(insInfo.ListPatPlans, insInfo.ListInsSubs);
            string         procStr  = "D0150";
            Procedure      proc     = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", 125);
            ProcedureCode  procCode = ProcedureCodes.GetProcCode(procStr);

            FeeT.CreateFee(ppoFeeSchedNum, procCode.CodeNum, amount: 80);
            Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), false, insInfo.ListInsPlans, insInfo.ListPatPlans, listBens, pat.Age,
                                        insInfo.ListInsSubs);
            List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum);

            Assert.AreEqual(40, listClaimProcs[0].InsEstTotal, 0.001);
            Assert.AreEqual(45, listClaimProcs[0].WriteOffEst, 0.001);
        }
Example #17
0
        ///<summary>Creates a procedure and computes estimates for a patient where the secondary insurance has a COB rule of Medicaid.</summary>
        private void ComputeEstimatesFixedBenefits(string suffix, double procFee, double ppoFee, double fixedBenefitFee
                                                   , int priPercentCoveredOverride, bool hasSecondary, double secFee, Action <FixedBenefitAssertItem> assertAct)
        {
            Patient       pat                     = PatientT.CreatePatient(suffix);
            string        procStr                 = "D0150";
            Procedure     proc                    = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", procFee);
            ProcedureCode procCode                = ProcedureCodes.GetProcCode(procStr);
            long          ppoFeeSchedNum          = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix);
            long          catPercFeeSchedNum      = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Category % " + suffix);
            long          fixedBenefitFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.FixedBenefit, "Fixed Benefit " + suffix);

            if (ppoFee > -1)
            {
                FeeT.CreateFee(ppoFeeSchedNum, procCode.CodeNum, ppoFee);
            }
            FeeT.CreateFee(fixedBenefitFeeSchedNum, procCode.CodeNum, fixedBenefitFee);
            InsuranceT.AddInsurance(pat, suffix, "p", ppoFeeSchedNum, copayFeeSchedNum: fixedBenefitFeeSchedNum);
            if (hasSecondary)
            {
                FeeT.CreateFee(catPercFeeSchedNum, procCode.CodeNum, secFee);
                InsuranceT.AddInsurance(pat, suffix, "", catPercFeeSchedNum, 2, false, EnumCobRule.Standard);
            }
            List <InsSub>  listSubs     = InsSubT.GetInsSubs(pat);
            List <InsPlan> listPlans    = InsPlans.RefreshForSubList(listSubs);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);
            InsPlan        priPlan      = InsPlanT.GetPlanForPriSecMed(PriSecMed.Primary, listPatPlans, listPlans, listSubs);
            InsPlan        secPlan      = null;

            if (hasSecondary)
            {
                secPlan = InsPlanT.GetPlanForPriSecMed(PriSecMed.Secondary, listPatPlans, listPlans, listSubs);
                //TODO:  Add diagnostic code benefit for 100%
                BenefitT.CreateCategoryPercent(secPlan.PlanNum, EbenefitCategory.Diagnostic, 100);
            }
            List <Benefit> listBens = Benefits.Refresh(listPatPlans, listSubs);

            Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), false, listPlans, listPatPlans, listBens, pat.Age, listSubs);
            List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum);

            if (priPercentCoveredOverride > 0)
            {
                foreach (ClaimProc cpCur in listClaimProcs)
                {
                    cpCur.PercentOverride = priPercentCoveredOverride;
                    ClaimProcs.Update(cpCur);
                }
                Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), false, listPlans, listPatPlans, listBens, pat.Age, listSubs);
                listClaimProcs = ClaimProcs.Refresh(pat.PatNum);
            }
            foreach (ClaimProc cpCur in listClaimProcs)
            {
                cpCur.PercentOverride = priPercentCoveredOverride;
                ClaimProcs.Update(cpCur);
            }
            Procedures.ComputeEstimates(proc, pat.PatNum, listClaimProcs, false, listPlans, listPatPlans, listBens, pat.Age, listSubs);
            listClaimProcs = ClaimProcs.Refresh(pat.PatNum);
            assertAct(new FixedBenefitAssertItem()
            {
                Procedure          = proc,
                PrimaryClaimProc   = listClaimProcs.FirstOrDefault(x => x.PlanNum == priPlan.PlanNum),
                SecondaryClaimProc = secPlan == null ? null : listClaimProcs.FirstOrDefault(x => x.PlanNum == secPlan.PlanNum),
            });
        }