示例#1
0
        private static Claim CreatePredetermination(Patient pat, List <Procedure> procList, long provTreat)
        {
            Family           fam           = Patients.GetFamily(pat.PatNum);
            List <InsSub>    subList       = InsSubs.RefreshForFam(fam);
            List <InsPlan>   planList      = InsPlans.RefreshForSubList(subList);
            List <PatPlan>   patPlanList   = PatPlans.Refresh(pat.PatNum);
            List <Benefit>   benefitList   = Benefits.Refresh(patPlanList, subList);
            List <ClaimProc> claimProcList = ClaimProcs.Refresh(pat.PatNum);
            List <Procedure> procsForPat   = Procedures.Refresh(pat.PatNum);
            InsSub           sub           = InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList, 1), subList);
            InsPlan          insPlan       = InsPlans.GetPlan(sub.PlanNum, planList);
            Claim            claim         = new Claim();

            Claims.Insert(claim);      //to retreive a key for new Claim.ClaimNum
            claim.PatNum      = pat.PatNum;
            claim.DateService = procList[0].ProcDate;
            claim.DateSent    = DateTime.Today;
            claim.ClaimStatus = "W";
            claim.InsSubNum   = PatPlans.GetInsSubNum(patPlanList, 1);
            claim.InsSubNum2  = PatPlans.GetInsSubNum(patPlanList, 2);
            InsSub sub1 = InsSubs.GetSub(claim.InsSubNum, subList);
            InsSub sub2 = InsSubs.GetSub(claim.InsSubNum, subList);

            claim.PlanNum       = sub1.PlanNum;
            claim.PlanNum2      = sub2.PlanNum;
            claim.PatRelat      = PatPlans.GetRelat(patPlanList, 1);
            claim.PatRelat2     = PatPlans.GetRelat(patPlanList, 2);
            claim.ClaimType     = "PreAuth";
            claim.ProvTreat     = provTreat;
            claim.IsProsthesis  = "N";
            claim.ProvBill      = Providers.GetBillingProvNum(claim.ProvTreat, 0);
            claim.EmployRelated = YN.No;
            ClaimProc        cp;
            List <Procedure> procListClaim = new List <Procedure>();  //this list will exclude lab fees

            for (int i = 0; i < procList.Count; i++)
            {
                if (procList[i].ProcNumLab == 0)
                {
                    procListClaim.Add(procList[i]);
                }
            }
            for (int i = 0; i < procListClaim.Count; i++)
            {
                cp = new ClaimProc();
                ClaimProcs.CreateEst(cp, procListClaim[i], insPlan, sub);
                cp.ClaimNum   = claim.ClaimNum;
                cp.Status     = ClaimProcStatus.NotReceived;
                cp.CodeSent   = ProcedureCodes.GetProcCode(procListClaim[i].CodeNum).ProcCode;
                cp.LineNumber = (byte)(i + 1);
                ClaimProcs.Update(cp);
            }
            claimProcList = ClaimProcs.Refresh(pat.PatNum);
            ClaimL.CalculateAndUpdate(procsForPat, planList, claim, patPlanList, benefitList, pat.Age, subList);
            return(claim);
        }
示例#2
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);
            }
        }
示例#3
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);
            }
        }
示例#4
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");
        }
示例#5
0
        /// <summary>claimType="P","S","PreAuth","W" (waiting to send).</summary>
        public static Claim CreateClaim(string claimType, List <PatPlan> PatPlanList, List <InsPlan> InsPlanList, List <ClaimProc> ClaimProcList, List <Procedure> procsForPat, Patient pat, List <Procedure> procsForClaim, List <Benefit> benefitList, List <InsSub> SubList, bool calculateLineNumber = true)
        {
            //Claim ClaimCur=CreateClaim("P",PatPlanList,InsPlanList,ClaimProcList,procsForPat);
            InsPlan PlanCur1 = new InsPlan();
            InsSub  SubCur1  = new InsSub();
            InsPlan PlanCur2 = new InsPlan();
            InsSub  SubCur2  = new InsSub();

            switch (claimType)
            {
            case "P":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList);
                //PlanCur2=InsPlans.GetPlan(SubCur.PlanNum,InsPlanList);//can end up null
                break;

            case "S":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList);
                //PlanCur2=InsPlans.GetPlan(SubCur.PlanNum,InsPlanList);//can end up null
                break;

            case "PreAuth":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList);
                break;

            case "W":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList);
                break;

            case "Med":
                SubCur1  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, PatPlans.GetOrdinal(PriSecMed.Medical, PatPlanList, InsPlanList, SubList)), SubList);
                PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList);
                SubCur2  = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, PatPlans.GetOrdinal(PriSecMed.Primary, PatPlanList, InsPlanList, SubList)), SubList);
                break;
            }
            //DataTable table=DataSetMain.Tables["account"];
            Procedure proc;

            //proc=Procedures.GetProcFromList(procsForPat,PIn.Long(table.Rows[gridAccount.SelectedIndices[0]]["ProcNum"].ToString()));
            //long clinicNum=proc.ClinicNum;
            ClaimProc[] claimProcs = new ClaimProc[procsForClaim.Count];          //1:1 with procs
            long        procNum;

            for (int i = 0; i < procsForClaim.Count; i++)       //loop through selected procs
            //and try to find an estimate that can be used
            {
                procNum       = procsForClaim[i].ProcNum;
                claimProcs[i] = Procedures.GetClaimProcEstimate(procNum, ClaimProcList, PlanCur1, SubCur1.InsSubNum);
            }
            for (int i = 0; i < claimProcs.Length; i++)       //loop through each claimProc
            //and create any missing estimates. This handles claims to 3rd and 4th ins co's.
            {
                if (claimProcs[i] == null)
                {
                    claimProcs[i] = new ClaimProc();
                    proc          = procsForClaim[i];
                    ClaimProcs.CreateEst(claimProcs[i], proc, PlanCur1, SubCur1);
                }
            }
            Claim claim = new Claim();

            Claims.Insert(claim);            //to retreive a key for new Claim.ClaimNum
            claim.PatNum        = pat.PatNum;
            claim.DateService   = claimProcs[claimProcs.Length - 1].ProcDate;
            claim.ClinicNum     = procsForClaim[0].ClinicNum;
            claim.DateSent      = DateTime.Today;
            claim.DateSentOrig  = claim.DateSent;
            claim.ClaimStatus   = "S";
            claim.AttachedFlags = "Mail";
            //datereceived
            switch (claimType)
            {
            case "P":
                claim.PlanNum    = SubCur1.PlanNum;
                claim.InsSubNum  = PatPlans.GetInsSubNum(PatPlanList, 1);
                claim.PatRelat   = PatPlans.GetRelat(PatPlanList, 1);
                claim.ClaimType  = "P";
                claim.PlanNum2   = SubCur2.PlanNum;                    //might be 0 if no sec ins
                claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 2);
                claim.PatRelat2  = PatPlans.GetRelat(PatPlanList, 2);
                break;

            case "S":
                claim.PlanNum    = SubCur1.PlanNum;
                claim.InsSubNum  = PatPlans.GetInsSubNum(PatPlanList, 2);
                claim.PatRelat   = PatPlans.GetRelat(PatPlanList, 2);
                claim.ClaimType  = "S";
                claim.PlanNum2   = SubCur2.PlanNum;
                claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 1);
                claim.PatRelat2  = PatPlans.GetRelat(PatPlanList, 1);
                break;

            case "W":
                claim.PlanNum     = SubCur1.PlanNum;
                claim.InsSubNum   = PatPlans.GetInsSubNum(PatPlanList, 2);
                claim.PatRelat    = PatPlans.GetRelat(PatPlanList, 2);
                claim.ClaimType   = "P";
                claim.ClaimStatus = "W";
                claim.PlanNum2    = SubCur2.PlanNum;
                claim.InsSubNum2  = PatPlans.GetInsSubNum(PatPlanList, 1);
                claim.PatRelat2   = PatPlans.GetRelat(PatPlanList, 1);
                break;

            case "Med":
                claim.PlanNum    = SubCur1.PlanNum;
                claim.InsSubNum  = PatPlans.GetInsSubNum(PatPlanList, 1);
                claim.PatRelat   = PatPlans.GetRelat(PatPlanList, 1);
                claim.ClaimType  = "Other";
                claim.PlanNum2   = SubCur2.PlanNum;                    //might be 0 if no other ins
                claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 2);
                claim.PatRelat2  = PatPlans.GetRelat(PatPlanList, 2);
                break;
            }
            claim.ProvTreat     = procsForClaim[0].ProvNum;
            claim.IsProsthesis  = "I";
            claim.ProvBill      = Providers.GetBillingProvNum(claim.ProvTreat, claim.ClinicNum);
            claim.EmployRelated = YN.No;
            //attach procedures
            Procedure ProcCur;

            for (int i = 0; i < claimProcs.Length; i++)
            {
                ProcCur = procsForClaim[i];
                claimProcs[i].ClaimNum = claim.ClaimNum;
                claimProcs[i].Status   = ClaimProcStatus.NotReceived;            //status for claims unsent or sent.
                //writeoff handled in ClaimL.CalculateAndUpdate()
                claimProcs[i].CodeSent = ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProcCode;
                if (claimProcs[i].CodeSent.Length > 5 && claimProcs[i].CodeSent.Substring(0, 1) == "D")
                {
                    claimProcs[i].CodeSent = claimProcs[i].CodeSent.Substring(0, 5);
                }
                if (calculateLineNumber)
                {
                    claimProcs[i].LineNumber = (byte)(i + 1);
                }
                ClaimProcs.Update(claimProcs[i]);
            }
            ClaimProcList = ClaimProcs.Refresh(pat.PatNum);
            Claims.CalculateAndUpdate(procsForPat, InsPlanList, claim, PatPlanList, benefitList, pat.Age, SubList);
            return(claim);
        }