Beispiel #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);
        }
        public void FeeSchedTools_GlobalUpdateWriteoffEstimates_SubscriberInDifferentFamily()
        {
            string        suffix   = MethodBase.GetCurrentMethod().Name;
            string        procStr  = "D0145";
            double        procFee  = 100;
            ProcedureCode procCode = ProcedureCodes.GetProcCode(procStr);
            //Set up clinic, prov, pat
            Clinic  clinic        = ClinicT.CreateClinic(suffix);
            long    feeSchedNum   = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix);
            long    provNum       = ProviderT.CreateProvider(suffix, feeSchedNum: feeSchedNum);
            Fee     fee           = FeeT.GetNewFee(feeSchedNum, procCode.CodeNum, procFee, clinic.ClinicNum, provNum);
            Patient pat           = PatientT.CreatePatient(suffix, provNum, clinic.ClinicNum);
            Patient patSubscriber = PatientT.CreatePatient(suffix + "_Subscriber", provNum, clinic.ClinicNum);
            //Set up insurance
            InsuranceInfo info = InsuranceT.AddInsurance(pat, suffix, "p", feeSchedNum);

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

            Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), true, info.ListInsPlans, info.ListPatPlans, info.ListBenefits, pat.Age,
                                        info.ListInsSubs);
            priClaimProc = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ProcNum == proc.ProcNum);
            Assert.AreEqual(procFee, priClaimProc.InsPayEst);
            GlobalUpdateWriteoffs(clinic.ClinicNum);
            priClaimProc = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ClaimProcNum == priClaimProc.ClaimProcNum);
            Assert.AreEqual(procFee, priClaimProc.InsPayEst);
        }
        public void 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);
        }
Beispiel #4
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));
 }
Beispiel #5
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);
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
Beispiel #8
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);
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }
        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);
        }
Beispiel #12
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);
            });
        }
Beispiel #13
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);
        }