Exemplo n.º 1
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);
            ProcedureCodes.RefreshCache();
            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, "", plan.PlanNum), 80);
            double amt = InsPlans.GetAllowed(procCode.ProcCode, plan.FeeSched, plan.AllowedFeeSched, plan.CodeSubstNone, plan.PlanType, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(defaultFee.Amount, amt);
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void FeeSchedTools_GlobalUpdateFees()
        {
            PrefT.UpdateBool(PrefName.MedicalFeeUsedForNewProcs, false);
            string        suffix    = MethodBase.GetCurrentMethod().Name;
            string        procStr   = "D0120";
            string        procStr2  = "D0145";
            double        procFee   = 100;
            ProcedureCode procCode  = ProcedureCodes.GetProcCode(procStr);
            ProcedureCode procCode2 = ProcedureCodes.GetProcCode(procStr2);
            //Set up clinic, prov, pat
            Clinic  clinic      = ClinicT.CreateClinic(suffix);
            long    feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix, false);
            long    provNum     = ProviderT.CreateProvider(suffix, feeSchedNum: feeSchedNum);
            Fee     fee         = FeeT.GetNewFee(feeSchedNum, procCode.CodeNum, procFee, clinic.ClinicNum, provNum);
            Fee     fee2        = FeeT.GetNewFee(feeSchedNum, procCode2.CodeNum, procFee, clinic.ClinicNum, provNum);
            Patient pat         = PatientT.CreatePatient(suffix, provNum, clinic.ClinicNum);
            //Chart a procedure for this proccode/pat as well as a different proccode
            Procedure proc  = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", fee.Amount);
            Procedure proc2 = ProcedureT.CreateProcedure(pat, procStr2, ProcStat.TP, "", fee2.Amount);

            //Update the fee amount for only the D0120 code
            fee.Amount = 50;
            Fees.Update(fee);
            //Now run global update fees
            Procedures.GlobalUpdateFees(Fees.GetByClinicNum(clinic.ClinicNum), clinic.ClinicNum, clinic.Abbr);
            //Make sure we have the same number of updated fees, and fee amounts for both procs
            proc  = Procedures.GetOneProc(proc.ProcNum, false);
            proc2 = Procedures.GetOneProc(proc2.ProcNum, false);
            Assert.AreEqual(fee.Amount, proc.ProcFee);
            Assert.AreEqual(fee2.Amount, proc2.ProcFee);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public void FeeSchedTools_CopyFeeSched_Concurrency()
        {
            //Make sure there are no duplicate fees already present within the database.
            string dbmResult = DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Check);

            if (dbmResult.Trim() != _feeDeleteDuplicatesExpectedResult)
            {
                DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Fix);
            }
            //Create two fee schedules; from and to
            FeeSched feeSchedFrom = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_FROM");
            FeeSched feeSchedTo   = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_TO");

            //Create a single fee and associate it to the "from" fee schedule.
            FeeT.CreateFee(feeSchedFrom.FeeSchedNum, _listProcCodes[_rand.Next(_listProcCodes.Count - 1)].CodeNum, _defaultFeeAmt);
            //Create a helper action that will simply copy the "from" schedule into the "to" schedule for the given fee cache passed in.
            Action actionCopyFromTo = new Action(() => {
                FeeScheds.CopyFeeSchedule(feeSchedFrom, 0, 0, feeSchedTo, null, 0);
            });

            //Mimic each user clicking the "Copy" button from within the Fee Tools window one right after the other (before they click OK).
            actionCopyFromTo();
            actionCopyFromTo();
            //Make sure that there was NOT a duplicate fee inserted into the database.
            dbmResult = DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Check);
            Assert.AreEqual(dbmResult.Trim(), _feeDeleteDuplicatesExpectedResult, "Duplicate fees detected due to concurrent copying.");
        }
Exemplo n.º 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);
        }
Exemplo n.º 8
0
        public void FeeSchedTools_CopyFeeSched_Clinics()
        {
            //Make sure there are no duplicate fees already present within the database.
            string dbmResult = DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Check);

            if (dbmResult.Trim() != _feeDeleteDuplicatesExpectedResult)
            {
                DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Fix);
            }
            //Make sure that there are more than six clinics
            ClinicT.ClearClinicTable();
            for (int i = 0; i < 10; i++)
            {
                ClinicT.CreateClinic(MethodBase.GetCurrentMethod().Name + "_" + i);
            }
            //Create two fee schedules; from and to
            FeeSched feeSchedNumFrom = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_FROM");
            FeeSched feeSchedNumTo   = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_TO");

            //Create a fee for every single procedure code in the database and associate it to the "from" fee schedule.
            foreach (ProcedureCode code in _listProcCodes)
            {
                FeeT.CreateFee(feeSchedNumFrom.FeeSchedNum, code.CodeNum, _rand.Next(5000));
            }
            //Copy the "from" fee schedule into the "to" fee schedule and do it for at least seven clinics.
            FeeScheds.CopyFeeSchedule(feeSchedNumFrom, 0, 0, feeSchedNumTo, Clinics.GetDeepCopy(true).Select(x => x.ClinicNum).ToList(), 0);
            //Make sure that there was NOT a duplicate fee inserted into the database.
            dbmResult = DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Check);
            Assert.AreEqual(dbmResult.Trim(), _feeDeleteDuplicatesExpectedResult, "Duplicate fees detected due to concurrent copying.");
        }
Exemplo n.º 9
0
        public void InsPlans_GetAllowed_CapAllowedFeeSched()
        {
            InsPlan       plan       = GenerateCapPlan(MethodBase.GetCurrentMethod().Name);
            ProcedureCode procCode   = _listProcCodes[11];
            Fee           feeAllowed = FeeT.GetNewFee(plan.AllowedFeeSched, procCode.CodeNum, 70);
            double        amt        = InsPlans.GetAllowed(procCode.ProcCode, plan.FeeSched, plan.AllowedFeeSched, plan.CodeSubstNone, plan.PlanType, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(feeAllowed.Amount, amt);
        }
Exemplo n.º 10
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));
 }
Exemplo n.º 11
0
        public void InsPlans_GetAllowed_PPOExact()
        {
            InsPlan       plan     = GeneratePPOPlan(MethodBase.GetCurrentMethod().Name);
            ProcedureCode procCode = _listProcCodes[6];
            Fee           fee      = FeeT.GetNewFee(plan.FeeSched, procCode.CodeNum, 65);
            double        allowed  = InsPlans.GetAllowed(procCode.ProcCode, plan.FeeSched, plan.AllowedFeeSched, plan.CodeSubstNone, plan.PlanType, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(fee.Amount, allowed);
        }
Exemplo n.º 12
0
        public void InsPlans_GetCopay_ExactFee()
        {
            ProcedureCode procCode   = _listProcCodes[3];
            InsPlan       plan       = GenerateMediFlatInsPlan(MethodBase.GetCurrentMethod().Name);
            Fee           feeDefault = FeeT.GetNewFee(plan.FeeSched, procCode.CodeNum, 50);
            Fee           feeCopay   = FeeT.GetNewFee(plan.CopayFeeSched, procCode.CodeNum, 15);
            double        amt        = InsPlans.GetCopay(procCode.CodeNum, plan.FeeSched, plan.CopayFeeSched, plan.CodeSubstNone, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(feeCopay.Amount, amt);
        }
Exemplo n.º 13
0
        public void InsPlans_GetCopay_NoExactFeeUseDefault()
        {
            ProcedureCode procCode   = _listProcCodes[1];
            InsPlan       plan       = GenerateMediFlatInsPlan(MethodBase.GetCurrentMethod().Name);
            Fee           feeDefault = FeeT.GetNewFee(plan.FeeSched, procCode.CodeNum, 25);

            Prefs.UpdateBool(PrefName.CoPay_FeeSchedule_BlankLikeZero, false);
            double amt = InsPlans.GetCopay(procCode.CodeNum, plan.FeeSched, plan.CopayFeeSched, plan.CodeSubstNone, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(feeDefault.Amount, amt);
        }
Exemplo n.º 14
0
        public void InsPlans_GetCopay_SubstituteFee()
        {
            ProcedureCode procCode = _listProcCodes[4];

            procCode.SubstitutionCode = _listProcCodes[5].ProcCode;
            ProcedureCodes.Update(procCode);
            InsPlan plan          = GenerateMediFlatInsPlan(MethodBase.GetCurrentMethod().Name, false);
            Fee     feeDefault    = FeeT.GetNewFee(plan.FeeSched, procCode.CodeNum, 100);
            Fee     feeSubstitute = FeeT.GetNewFee(plan.CopayFeeSched, ProcedureCodes.GetSubstituteCodeNum(procCode.ProcCode, "", plan.PlanNum), 45);
            double  amt           = InsPlans.GetCopay(procCode.CodeNum, plan.FeeSched, plan.CopayFeeSched, plan.CodeSubstNone, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(feeSubstitute.Amount, amt);
        }
Exemplo n.º 15
0
        public void InsPlans_GetAllowed_PPOSubstituteMoreExpensive()
        {
            InsPlan       plan     = GeneratePPOPlan(MethodBase.GetCurrentMethod().Name, false);
            ProcedureCode procCode = _listProcCodes[9];

            procCode.SubstitutionCode = _listProcCodes[10].ProcCode;
            ProcedureCodes.Update(procCode);
            Fee    feeOrig = FeeT.GetNewFee(plan.FeeSched, procCode.CodeNum, 85);
            Fee    feeSubs = FeeT.GetNewFee(plan.FeeSched, ProcedureCodes.GetSubstituteCodeNum(procCode.SubstitutionCode, "", plan.PlanNum), 200);
            double allowed = InsPlans.GetAllowed(procCode.ProcCode, plan.FeeSched, plan.AllowedFeeSched, plan.CodeSubstNone, plan.PlanType, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(feeOrig.Amount, allowed);
        }
Exemplo n.º 16
0
        public void FeeSchedTools_CopyFeeSched()
        {
            //Create two fee schedules; from and to
            FeeSched fromFeeSched = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_FROM");
            FeeSched toFeeSched   = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_TO");
            //Create a single fee and associate it to the "from" fee schedule.
            long feeCodeNum = _listProcCodes[_rand.Next(_listProcCodes.Count - 1)].CodeNum;

            FeeT.CreateFee(fromFeeSched.FeeSchedNum, feeCodeNum, _defaultFeeAmt * _rand.NextDouble());
            FeeScheds.CopyFeeSchedule(fromFeeSched, 0, 0, toFeeSched, null, 0);
            //Get the two fees and check that they are the same.
            Fee fromFee = Fees.GetFee(feeCodeNum, fromFeeSched.FeeSchedNum, 0, 0);
            Fee toFee   = Fees.GetFee(feeCodeNum, toFeeSched.FeeSchedNum, 0, 0);

            Assert.AreEqual(fromFee.Amount, toFee.Amount);
        }
Exemplo n.º 17
0
        public void Claims_CalculateAndUpdate_ProcedureCodeDowngradeHigherFee()
        {
            string  suffix         = "61";
            Patient pat            = PatientT.CreatePatient(suffix);
            long    ucrFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "UCR Fees" + suffix);
            long    ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO Downgrades" + suffix);
            Carrier carrier        = CarrierT.CreateCarrier(suffix);
            InsPlan plan           = InsPlanT.CreateInsPlan(carrier.CarrierNum);
            InsSub  sub            = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum);
            long    subNum         = sub.InsSubNum;

            BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Restorative, 100);
            PatPlanT.CreatePatPlan(1, pat.PatNum, subNum);
            ProcedureCode originalProcCode  = ProcedureCodes.GetProcCode("D2391");
            ProcedureCode downgradeProcCode = ProcedureCodes.GetProcCode("D2140");

            originalProcCode.SubstitutionCode = "D2140";
            originalProcCode.SubstOnlyIf      = SubstitutionCondition.Always;
            ProcedureCodes.Update(originalProcCode);
            FeeT.CreateFee(ucrFeeSchedNum, originalProcCode.CodeNum, 140);
            FeeT.CreateFee(ucrFeeSchedNum, downgradeProcCode.CodeNum, 120);
            FeeT.CreateFee(ppoFeeSchedNum, originalProcCode.CodeNum, 80);
            FeeT.CreateFee(ppoFeeSchedNum, downgradeProcCode.CodeNum, 100);
            Procedure        proc             = ProcedureT.CreateProcedure(pat, "D2391", ProcStat.C, "1", 140);//Tooth 1
            List <ClaimProc> claimProcs       = ClaimProcs.Refresh(pat.PatNum);
            List <ClaimProc> claimProcListOld = new List <ClaimProc>();
            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 <Procedure> ProcList    = Procedures.Refresh(pat.PatNum);
            InsPlan          insPlan     = planList[0];//Should only be one
            InsPlan          planOld     = insPlan.Copy();

            insPlan.PlanType = "p";
            insPlan.FeeSched = ppoFeeSchedNum;
            InsPlans.Update(insPlan, planOld);
            //Creates the claim in the same manner as the account module, including estimates.
            Claim     claim  = ClaimT.CreateClaim("P", patPlans, planList, claimProcs, ProcList, pat, ProcList, benefitList, subList);
            ClaimProc clProc = ClaimProcs.Refresh(pat.PatNum)[0];          //Should only be one

            Assert.AreEqual(80, clProc.InsEstTotal);
            Assert.AreEqual(60, clProc.WriteOff);
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        public void Fees_GetByFeeSchedNumsClinicNums_MiddleTier()
        {
            List <long> listFeeSchedNums = new List <long>();
            long        codeNum1         = ProcedureCodes.GetCodeNum("D1110");
            long        codeNum2         = ProcedureCodes.GetCodeNum("D1206");

            for (int i = 0; i < 300; i++)
            {
                FeeSched feeSched = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, "FS" + i);
                FeeT.GetNewFee(feeSched.FeeSchedNum, codeNum1, 11);
                FeeT.GetNewFee(feeSched.FeeSchedNum, codeNum2, 13);
                listFeeSchedNums.Add(feeSched.FeeSchedNum);
            }
            DataAction.RunMiddleTierMock(() => {
                List <FeeLim> listFees = Fees.GetByFeeSchedNumsClinicNums(listFeeSchedNums, new List <long> {
                    0
                });
                Assert.AreEqual(600, listFees.Count);
            });
        }
Exemplo n.º 20
0
        public void Fees_GetFee_ClinicSpecificFees()
        {
            Patient pat         = PatientT.CreatePatient("58");
            long    feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Standard UCR", false);
            long    codeNum     = ProcedureCodes.GetCodeNum("D2750");
            long    clinicNum2  = ClinicT.CreateClinic("2-58").ClinicNum;
            long    clinicNum3  = ClinicT.CreateClinic("3-58").ClinicNum;
            long    clinicNum1  = ClinicT.CreateClinic("1-58").ClinicNum;

            FeeT.CreateFee(feeSchedNum, codeNum, 65, clinicNum1, 0);
            FeeT.CreateFee(feeSchedNum, codeNum, 70, clinicNum2, 0);
            FeeT.CreateFee(feeSchedNum, codeNum, 75, clinicNum3, 0);
            double fee1 = Fees.GetFee(codeNum, feeSchedNum, clinicNum1, 0).Amount;
            double fee2 = Fees.GetFee(codeNum, feeSchedNum, clinicNum2, 0).Amount;
            double fee3 = Fees.GetFee(codeNum, feeSchedNum, clinicNum3, 0).Amount;

            Assert.AreEqual(fee1, 65);
            Assert.AreEqual(fee2, 70);
            Assert.AreEqual(fee3, 75);
        }
Exemplo n.º 21
0
        public void Fees_GetFee_ProviderSpecificFees()
        {
            Patient pat         = PatientT.CreatePatient("57");
            long    feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPOInsPlan1", false);
            long    codeNum     = ProcedureCodes.GetCodeNum("D2750");
            long    provNum1    = ProviderT.CreateProvider("1-57");
            long    provNum2    = ProviderT.CreateProvider("2-57");
            long    provNum3    = ProviderT.CreateProvider("3-57");

            FeeT.CreateFee(feeSchedNum, codeNum, 50, 0, provNum1);
            FeeT.CreateFee(feeSchedNum, codeNum, 55, 0, provNum2);
            FeeT.CreateFee(feeSchedNum, codeNum, 60, 0, provNum3);
            double fee1 = Fees.GetFee(codeNum, feeSchedNum, 0, provNum1).Amount;
            double fee2 = Fees.GetFee(codeNum, feeSchedNum, 0, provNum2).Amount;
            double fee3 = Fees.GetFee(codeNum, feeSchedNum, 0, provNum3).Amount;

            Assert.AreEqual(50, fee1);
            Assert.AreEqual(55, fee2);
            Assert.AreEqual(60, fee3);
        }
Exemplo n.º 22
0
        public void Fees_GetFee_ClinicAndProviderSpecificFees()
        {
            Patient pat         = PatientT.CreatePatient("59");
            long    feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Standard", false);
            long    codeNum     = ProcedureCodes.GetCodeNum("D2750");
            long    provNum1    = ProviderT.CreateProvider("1-59");
            long    provNum2    = ProviderT.CreateProvider("2-59");
            long    clinicNum1  = ClinicT.CreateClinic("1-59").ClinicNum;
            long    clinicNum2  = ClinicT.CreateClinic("2-59").ClinicNum;

            FeeT.CreateFee(feeSchedNum, codeNum, 80, clinicNum1, provNum1);
            FeeT.CreateFee(feeSchedNum, codeNum, 85, clinicNum1, provNum2);
            FeeT.CreateFee(feeSchedNum, codeNum, 90, clinicNum2, provNum2);
            double fee1 = Fees.GetFee(codeNum, feeSchedNum, clinicNum1, provNum1).Amount;
            double fee2 = Fees.GetFee(codeNum, feeSchedNum, clinicNum1, provNum2).Amount;
            double fee3 = Fees.GetFee(codeNum, feeSchedNum, clinicNum2, provNum2).Amount;

            Assert.AreEqual(fee1, 80);
            Assert.AreEqual(fee2, 85);
            Assert.AreEqual(fee3, 90);
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
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");
        }
Exemplo n.º 25
0
        public void Procedures_GlobalUpdateFees()
        {
            string name = MethodBase.GetCurrentMethod().Name;
            Random rand = new Random();
            //set up fees
            List <Clinic> listClinics = new List <Clinic>();

            for (int i = 0; i < 3; i++)
            {
                listClinics.Add(ClinicT.CreateClinic(name + "_" + i));
            }
            List <long> listFeeSchedNums = new List <long>();

            for (int i = 0; i < 2; i++)
            {
                listFeeSchedNums.Add(FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, name + "_" + i, false));
            }
            List <long> listProvNums = new List <long>();

            for (int i = 0; i < 2; i++)
            {
                long feeSched = listFeeSchedNums[rand.Next(listFeeSchedNums.Count - 1)];
                listProvNums.Add(ProviderT.CreateProvider(name + "_" + i, feeSchedNum: feeSched));
            }
            List <ProcedureCode> listProcCodes = ProcedureCodes.GetAllCodes();
            List <Fee>           listFees      = new List <Fee>();

            foreach (ProcedureCode procCode in listProcCodes)
            {
                foreach (long feeSched in listFeeSchedNums)
                {
                    foreach (Clinic clinic in listClinics)
                    {
                        foreach (long provNum in listProvNums)
                        {
                            listFees.Add(FeeT.GetNewFee(feeSched, procCode.CodeNum, 50 * rand.NextDouble(), clinic.ClinicNum, provNum));
                        }
                    }
                }
            }
            //set up patients
            List <Patient> listPatients = new List <Patient>();

            for (int i = 0; i < 3; i++)
            {
                listPatients.Add(PatientT.CreatePatient(name + "_" + i,
                                                        listProvNums[rand.Next(listProvNums.Count - 1)],
                                                        listClinics[rand.Next(listClinics.Count - 1)].ClinicNum));
            }
            //TP some procedures
            List <Fee> listTPFees = new List <Fee>();

            for (int i = 0; i < 100; i++)
            {
                ProcedureCode procCode = listProcCodes[rand.Next(listProcCodes.Count - 1)];
                Patient       patient  = listPatients[rand.Next(listPatients.Count - 1)];
                Fee           fee      = Fees.GetFee(procCode.CodeNum, Providers.GetProv(patient.PriProv).FeeSched, patient.ClinicNum, patient.PriProv);
                Procedure     proc     = ProcedureT.CreateProcedure(patient, procCode.ProcCode, ProcStat.TP, "", fee.Amount);
                listTPFees.Add(fee);
            }
            //change some of the fees
            List <Fee> listTPFeesChanged    = listTPFees.OrderBy(x => rand.Next()).Take(50).ToList();
            List <Fee> listNonTPFeesChanged = (listFees.Except(listTPFees)).OrderBy(x => rand.Next()).Take(50).ToList();
            FeeCache   cache = new FeeCache(listTPFeesChanged.Union(listNonTPFeesChanged).ToList());

            cache.BeginTransaction();
            foreach (Fee fee in listTPFeesChanged)
            {
                fee.Amount = 50 * rand.NextDouble();
                cache.Update(fee);
            }
            foreach (Fee fee in listNonTPFeesChanged)
            {
                fee.Amount = 50 * rand.NextDouble();
                cache.Update(fee);
            }
            cache.SaveToDb();
            //Run the global update
            long updatedCount = 0;

            cache = new FeeCache();
            for (int i = 0; i < listClinics.Count; i++)
            {
                updatedCount += Procedures.GlobalUpdateFees(cache.GetFeesForClinics(listClinics.Select(x => x.ClinicNum)), listClinics[i].ClinicNum, listClinics[i].Abbr);
            }
            //check the counts are the same
            List <Fee> listToCount = listTPFees.Where(x => listTPFeesChanged.Select(y => y.FeeNum).Contains(x.FeeNum)).ToList();

            Assert.AreEqual(listToCount.Count, updatedCount);
        }
Exemplo n.º 26
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),
            });
        }