Beispiel #1
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);
            }
        }
Beispiel #2
0
        public void LedgersTests_ComputeAging_PayPlanDynamic()
        {
            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  proc1    = ProcedureT.CreateProcedure(pat, "D0210", ProcStat.C, "", 45, DateTime.Today.AddDays(-61), provNum: provNum);
            Procedure  proc2    = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 55, DateTime.Today.AddDays(-32), provNum: provNum);
            Procedure  proc3    = ProcedureT.CreateProcedure(pat, "D0270", ProcStat.C, "", 65, DateTime.Today.AddDays(-15), provNum: provNum);
            Adjustment adjProc2 = AdjustmentT.MakeAdjustment(pat.PatNum, 10, proc2.ProcDate, proc2.ProcDate, proc2.ProcNum, provNum);
            Adjustment adjProc3 = AdjustmentT.MakeAdjustment(pat.PatNum, 20, proc3.ProcDate, proc3.ProcDate, proc3.ProcNum, provNum);
            Adjustment adj      = AdjustmentT.MakeAdjustment(pat.PatNum, 30, DateTime.Today.AddDays(-5), provNum: provNum);

            listProcs.AddRange(new List <Procedure> {
                proc1, proc2, proc3
            });
            listAdjs.AddRange(new List <Adjustment> {
                adj
            });
            PayPlan payPlan = PayPlanT.CreateDynamicPaymentPlan(pat.PatNum, pat.PatNum, DateTime.Today.AddDays(-1), 0, 0, 40, listProcs, listAdjs);
            //PayPlan payplan=PayPlanT.CreatePayPlanWithCredits(pat.PatNum,40,DateTime.Today,provNum:provNum,listProcs,195,pat.PatNum);
            //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(40, 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, 70, 0, 0, 5, 40, YN.Yes);         //new
                CheckAgingProcLifo(pat.PatNum, 75, 0, 0, 0, 40, YN.No);          //old
                CheckAgingProcLifo(pat.PatNum, 75, 0, 0, 0, 40, YN.Unknown);
            }
            finally {
                PrefT.UpdateInt(PrefName.PayPlansVersion, payPlansVersionPrev);
            }
        }
Beispiel #3
0
        public static PayPlanCharge CreatePayPlanCharge(DateTime chargeDate, long patNum, long guarantor, long payplanNum, double prinicpal, long provNum
                                                        , long procNum, PayPlanChargeType chargeType)
        {
            PayPlanCharge ppc = new PayPlanCharge()
            {
                PayPlanNum = payplanNum,
                PatNum     = patNum,
                ChargeDate = chargeDate,
                Principal  = prinicpal,
                Guarantor  = guarantor,
                ProvNum    = provNum,
                ProcNum    = procNum,
                ChargeType = chargeType
            };

            PayPlanCharges.Insert(ppc);
            return(ppc);
        }
Beispiel #4
0
        public static PayPlanCharge CreateOne(long payPlanNum, long guarantor, long patNum, DateTime chargeDate, double principal, double interest,
                                              string note = "", long provNum = 0, long clinicNum = 0, PayPlanChargeType chargeType = PayPlanChargeType.Debit, long procNum = 0)
        {
            PayPlanCharge charge = new PayPlanCharge();

            charge.PayPlanNum = payPlanNum;
            charge.Guarantor  = guarantor;
            charge.PatNum     = patNum;
            charge.ChargeDate = chargeDate;
            charge.Principal  = principal;
            charge.Interest   = interest;
            charge.Note       = note;
            charge.ProvNum    = provNum;
            charge.ClinicNum  = clinicNum;
            charge.ChargeType = chargeType;
            charge.ProcNum    = procNum;
            PayPlanCharges.Insert(charge);
            return(charge);
        }
Beispiel #5
0
        public static PayPlan CreatePayPlan(long patNum, double totalAmt, double payAmt, DateTime datePayStart, long provNum)
        {
            PayPlan payPlan = new PayPlan();

            payPlan.Guarantor   = patNum;
            payPlan.PatNum      = patNum;
            payPlan.PayAmt      = totalAmt;
            payPlan.PayPlanDate = datePayStart;
            payPlan.PayAmt      = totalAmt;
            PayPlans.Insert(payPlan);
            PayPlanCharge charge = new PayPlanCharge();

            charge.PayPlanNum = payPlan.PayPlanNum;
            charge.PatNum     = patNum;
            charge.ChargeDate = datePayStart;
            charge.Principal  = totalAmt;
            charge.ChargeType = PayPlanChargeType.Credit;
            double sumCharges    = 0;
            int    countPayments = 0;

            while (sumCharges < totalAmt)
            {
                charge            = new PayPlanCharge();
                charge.ChargeDate = datePayStart.AddMonths(countPayments);
                charge.PatNum     = patNum;
                charge.Guarantor  = patNum;
                charge.PayPlanNum = payPlan.PayPlanNum;
                charge.Principal  = Math.Min(payAmt, totalAmt - sumCharges);
                charge.ProvNum    = provNum;
                sumCharges       += charge.Principal;
                charge.ChargeType = PayPlanChargeType.Debit;
                PayPlanCharges.Insert(charge);
                countPayments++;
            }
            return(payPlan);
        }
Beispiel #6
0
        /// <summary>Creates a payplan and payplan charges with credits. Credit amount generated based off the total amount of the procedures in the list.
        /// If credits are not attached,list of procedures must be null and a total amount must be specified.</summary>
        public static PayPlan CreatePayPlanWithCredits(long patNum, double payAmt, DateTime datePayStart, long provNum = 0, List <Procedure> listProcs = null
                                                       , double totalAmt = 0, long guarantorNum = 0, long clinicNum = 0)
        {
            double totalAmount;

            guarantorNum = guarantorNum == 0?patNum:guarantorNum;        //if it's 0, default to the patNum.
            if (listProcs != null)
            {
                totalAmount = listProcs.Sum(x => x.ProcFee);
            }
            else
            {
                totalAmount = totalAmt;
            }
            PayPlan payPlan = CreatePayPlanNoCharges(patNum, totalAmount, datePayStart, guarantorNum);       //create charges later depending on if attached to procs or not.

            if (listProcs != null)
            {
                foreach (Procedure proc in listProcs)
                {
                    PayPlanCharge credit = new PayPlanCharge();
                    credit.PayPlanNum = payPlan.PayPlanNum;
                    credit.PatNum     = patNum;
                    credit.ProcNum    = proc.ProcNum;
                    credit.ProvNum    = proc.ProvNum;
                    credit.Guarantor  = patNum;                 //credits should always appear on the patient of the payment plan.
                    credit.ChargeDate = datePayStart;
                    credit.ClinicNum  = clinicNum;
                    credit.Principal  = proc.ProcFee;
                    credit.ChargeType = PayPlanChargeType.Credit;
                    PayPlanCharges.Insert(credit);                    //attach the credit for the proc amount.
                }
            }
            else              //make one credit for the lump sum.
            {
                PayPlanCharge credit = new PayPlanCharge();
                credit.PayPlanNum = payPlan.PayPlanNum;
                credit.PatNum     = patNum;
                credit.ChargeDate = datePayStart;
                credit.ProvNum    = provNum;
                credit.ClinicNum  = clinicNum;
                credit.Guarantor  = patNum;             //credits should always appear on the patient of the payment plan.
                credit.Principal  = totalAmount;
                credit.ChargeType = PayPlanChargeType.Credit;
                PayPlanCharges.Insert(credit);                //attach the credit for the total amount.
            }
            //make debit charges for the payment plan
            double sumCharges    = 0;
            int    countPayments = 0;

            while (sumCharges < totalAmount)
            {
                PayPlanCharge charge = new PayPlanCharge();
                charge.ChargeDate = datePayStart.AddMonths(countPayments);
                charge.PatNum     = patNum;
                charge.Guarantor  = guarantorNum;
                charge.ClinicNum  = clinicNum;
                charge.PayPlanNum = payPlan.PayPlanNum;
                charge.Principal  = Math.Min(payAmt, totalAmount - sumCharges);
                charge.ProvNum    = provNum;
                sumCharges       += charge.Principal;
                charge.ChargeType = PayPlanChargeType.Debit;
                PayPlanCharges.Insert(charge);
                countPayments++;
            }
            return(payPlan);
        }