Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        private InsPlan GeneratePPOPlan(string suffix, bool codeSubstNone = true)
        {
            long    baseFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Normal_" + suffix, true);
            Carrier carrier         = CarrierT.CreateCarrier("Carrier_" + suffix);

            return(InsPlanT.CreateInsPlanPPO(carrier.CarrierNum, baseFeeSchedNum, codeSubstNone));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        private InsPlan GenerateMediFlatInsPlan(string suffix, bool codeSubstNone = true)
        {
            long    baseFeeSchedNum  = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Normal_" + suffix, true);
            long    copayFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.CoPay, "Copay_" + suffix, true);
            Carrier carrier          = CarrierT.CreateCarrier("Carrier_" + suffix);

            return(InsPlanT.CreateInsPlanMediFlatCopay(carrier.CarrierNum, baseFeeSchedNum, copayFeeSchedNum, codeSubstNone));
        }
Ejemplo n.º 5
0
 /// <summary>Creates a FeeSchedule, and if specified, a clinic and a provnum, and a fee associated to these three parameters with the specified
 /// fee amount.. The procedure code is assigned randomly from the list of procedure codes, though the last procedure code will never be picked so
 /// that we can safely use _listProcCodes.Last() for testing non-existing fees.</summary>
 private Fee CreateSingleFee(string suffix, double amt = _defaultFeeAmt, bool hasClinic = false, bool hasProv = false, long feeSchedNum = 0, long codeNum = 0,
                             long clinicNum            = 0, long provNum = 0, bool isGlobalFeeSched = false)
 {
     feeSchedNum = feeSchedNum == 0 ? FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix, isGlobalFeeSched) : feeSchedNum;
     clinicNum   = hasClinic && clinicNum == 0 ? ClinicT.CreateClinic(suffix).ClinicNum : clinicNum;
     provNum     = hasProv && provNum == 0 ? ProviderT.CreateProvider(suffix) : provNum;
     codeNum     = codeNum == 0 ? _listProcCodes[_rand.Next(_listProcCodes.Count - 2)].CodeNum : codeNum;
     return(FeeT.GetNewFee(feeSchedNum, codeNum, amt, clinicNum, provNum));
 }
Ejemplo n.º 6
0
        /// <summary>Creates the request number of fee schedules, clinics and providers, and creates fees for each combination and code num.</summary>
        private FeeTestArgs CreateManyFees(int numFeeScheds, int numClinics, int numProvs, string suffix)
        {
            FeeTestArgs retVal = new FeeTestArgs();

            //Set up fee schedules
            for (int i = 0; i < numFeeScheds; i++)
            {
                retVal.ListFeeSchedNums.Add(FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix, false));
            }
            //Set up clinics
            Prefs.UpdateBool(PrefName.EasyNoClinics, false);
            for (int i = 0; i < numClinics; i++)
            {
                retVal.ListClinics.Add(ClinicT.CreateClinic(suffix + i));
            }
            //Set up providers
            for (int i = 0; i < numProvs; i++)
            {
                retVal.ListProvNums.Add(ProviderT.CreateProvider(suffix));
            }
            //Create the fees
            List <Fee> listFees = new List <Fee>();

            foreach (long codeNum in _listProcCodes.Select(x => x.CodeNum))
            {
                foreach (long feeSchedNum in retVal.ListFeeSchedNums)
                {
                    foreach (Clinic clinic in retVal.ListClinics)
                    {
                        foreach (long provNum in retVal.ListProvNums)
                        {
                            listFees.Add(new Fee()
                            {
                                FeeSched  = feeSchedNum,
                                ClinicNum = clinic.ClinicNum,
                                ProvNum   = provNum,
                                CodeNum   = codeNum,
                                Amount    = _defaultFeeAmt * _rand.NextDouble()
                            });
                        }
                    }
                }
            }
            Fees.InsertMany(listFees);
            retVal.ListFees = Fees.GetByFeeSchedNumsClinicNums(retVal.ListFeeSchedNums, retVal.ListClinics.Select(x => x.ClinicNum).ToList())
                              .Union(Fees.GetByFeeSchedNumsClinicNums(new List <long>()
            {
                _standardFeeSchedNum
            }, new List <long>()
            {
                0
            })).ToList();
            //create an empty feeschedule for the Insert/Update/Delete tests
            retVal.emptyFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Empty" + suffix, false);
            return(retVal);
        }
Ejemplo n.º 7
0
        private InsPlan GenerateCapPlan(string suffix, bool createAllowed = true, bool codeSubstNone = true)
        {
            long baseFeeSchedNum    = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Normal_" + suffix, true);
            long allowedFeeSchedNum = 0;

            if (createAllowed)
            {
                allowedFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Allowed_" + suffix, true);
            }
            Carrier carrier = CarrierT.CreateCarrier("Carrier_" + suffix);

            return(InsPlanT.CreateInsPlanCapitation(carrier.CarrierNum, baseFeeSchedNum, allowedFeeSchedNum, codeSubstNone));
        }
Ejemplo n.º 8
0
        public void FeeCache_AddFee()
        {
            FeeCache cache       = new FeeCache();
            long     feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name);
            Fee      fee         = new Fee()
            {
                FeeSched  = feeSchedNum,
                ClinicNum = 0,
                ProvNum   = 0,
                CodeNum   = _listProcCodes[_rand.Next(_listProcCodes.Count - 1)].CodeNum,
                Amount    = _defaultFeeAmt
            };

            cache.Add(fee);
            Assert.IsNotNull(cache.GetFee(fee.CodeNum, fee.FeeSched, fee.ClinicNum, fee.ProvNum, true));
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        public void Claims_CalculateAndUpdate_PreauthOrderWriteoff()
        {
            string suffix = MethodBase.GetCurrentMethod().Name;
            //create the patient and insurance information
            Patient pat = PatientT.CreatePatient(suffix);
            //proc - Crown
            Procedure proc         = ProcedureT.CreateProcedure(pat, "D2750", ProcStat.C, "8", 1000);
            long      feeSchedNum1 = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix);

            FeeT.CreateFee(feeSchedNum1, proc.CodeNum, 900);
            Carrier carrier = CarrierT.CreateCarrier(suffix);
            InsPlan insPlan = InsPlanT.CreateInsPlanPPO(carrier.CarrierNum, feeSchedNum1);

            BenefitT.CreateAnnualMax(insPlan.PlanNum, 1000);
            BenefitT.CreateCategoryPercent(insPlan.PlanNum, EbenefitCategory.Crowns, 100);
            InsSub  sub = InsSubT.CreateInsSub(pat.PatNum, insPlan.PlanNum);
            PatPlan pp  = PatPlanT.CreatePatPlan(1, pat.PatNum, sub.InsSubNum);
            //create lists and variables required for ComputeEstimates()
            List <InsSub>    SubList         = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum));
            List <InsPlan>   listInsPlan     = InsPlans.RefreshForSubList(SubList);
            List <PatPlan>   listPatPlan     = PatPlans.Refresh(pat.PatNum);
            List <Benefit>   listBenefits    = Benefits.Refresh(listPatPlan, SubList);
            List <Procedure> listProcsForPat = Procedures.Refresh(pat.PatNum);
            List <Procedure> procsForClaim   = new List <Procedure>();

            procsForClaim.Add(proc);
            //Create the claim and associated claimprocs
            //The order of these claimprocs is the whole point of the unit test.
            //Create Preauth
            ClaimProcs.CreateEst(new ClaimProc(), proc, insPlan, sub, 0, 500, true, true);
            //Create Estimate
            ClaimProcs.CreateEst(new ClaimProc(), proc, insPlan, sub, 1000, 1000, true, false);
            List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum);
            Claim            claimWaiting   = ClaimT.CreateClaim("W", listPatPlan, listInsPlan, listClaimProcs, listProcsForPat, pat, procsForClaim, listBenefits, SubList, false);

            Assert.AreEqual(100, claimWaiting.WriteOff, "WriteOff Amount");
        }
Ejemplo n.º 11
0
        public void InsPlans_GetAllowed_NoFeeSched()
        {
            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);
            ProcedureCode procCode = _listProcCodes[13];

            procCode.SubstitutionCode = _listProcCodes[14].ProcCode;
            ProcedureCodes.Update(procCode);
            Provider prov         = Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv));
            long     provFeeSched = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name);

            prov.FeeSched = provFeeSched;
            Providers.Update(prov);
            Providers.RefreshCache();
            Fee    defaultFee = FeeT.GetNewFee(Providers.GetProv(PrefC.GetLong(PrefName.PracticeDefaultProv)).FeeSched, ProcedureCodes.GetSubstituteCodeNum(procCode.ProcCode, ""), 80);
            double amt        = InsPlans.GetAllowed(procCode.ProcCode, plan.FeeSched, plan.AllowedFeeSched, plan.CodeSubstNone, plan.PlanType, "", 0, 0);

            Assert.AreEqual(defaultFee.Amount, amt);
        }
Ejemplo n.º 12
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),
            });
        }