예제 #1
0
        public void PaymentEdit_Init_ChargesWithUnattachedPayPlanCreditsWithPreviousPayments()
        {
            //new payplan
            Patient   pat     = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            long      prov    = ProviderT.CreateProvider("ProvA");
            Procedure proc1   = ProcedureT.CreateProcedure(pat, "D1120", ProcStat.C, "", 135, DateTime.Today.AddMonths(-4), provNum: prov);
            Procedure proc2   = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 60, DateTime.Today.AddMonths(-4).AddDays(1), provNum: prov);
            PayPlan   payplan = PayPlanT.CreatePayPlanWithCredits(pat.PatNum, 30, DateTime.Today.AddMonths(-3), prov, totalAmt: 195);   //totalAmt since unattached credits

            //Make initial payments.
            PaymentT.MakePayment(pat.PatNum, 30, DateTime.Today.AddMonths(-2), payplan.PayPlanNum, prov, 0, 1);
            PaymentT.MakePayment(pat.PatNum, 30, DateTime.Today.AddMonths(-1), payplan.PayPlanNum, prov, 0, 1);
            //Go to make another payment. 2 pay plan charges should have been "removed" (amtStart to 0) from being paid.
            Payment pay = PaymentT.MakePaymentNoSplits(pat.PatNum, 30, DateTime.Today);

            PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, pay, new List <long> {
                pat.PatNum
            }, true, false);
            PaymentEdit.InitData initData = PaymentEdit.Init(loadData.ListAssociatedPatients, Patients.GetFamily(pat.PatNum), new Family {
            }, pay
                                                             , loadData.ListSplits, new List <Procedure>(), pat.PatNum, loadData: loadData);
            //2 procs and 2 pp charges
            Assert.AreEqual(4, initData.AutoSplitData.ListAccountCharges.FindAll(x => x.AmountStart > 0).Count);
            Assert.AreEqual(2, initData.AutoSplitData.ListAccountCharges.Count(x => x.Tag.GetType() == typeof(Procedure)));
            Assert.AreEqual(4, initData.AutoSplitData.ListAccountCharges.Count(x => x.Tag.GetType() == typeof(PayPlanCharge)));
        }
예제 #2
0
        public void Fees_GetListFromObjects_AppointmentProviderSecondary()
        {
            string        suffix        = MethodBase.GetCurrentMethod().Name;
            ProcedureCode procedureCode = ProcedureCodeT.CreateProcCode("D1110");
            Fee           fee           = CreateSingleFee(suffix, (_defaultFeeAmt * _rand.NextDouble()), hasProv: true, codeNum: procedureCode.CodeNum);
            //Update our new provider so that they are associated to the new fee schedule that was just created.
            Provider prov = Providers.GetProv(fee.ProvNum);

            prov.FeeSched = fee.FeeSched;
            ProviderT.Update(prov);
            //Make an appointment that has the new provider set as the secondary provider.
            Appointment appt = AppointmentT.CreateAppointment(0, DateTime.Now, 0, 0, provHyg: prov.ProvNum);
            //The fees associated to the fee schedule of the appointment's secondary provider should be returned by GetListFromObjects().
            List <Fee> listFees = Fees.GetListFromObjects(new List <ProcedureCode>()
            {
                procedureCode
            },
                                                          null,
                                                          null,
                                                          0,
                                                          0,
                                                          0,
                                                          null,
                                                          null,
                                                          new List <Appointment>()
            {
                appt
            },
                                                          null,
                                                          0);

            Assert.IsTrue(listFees.Exists(x => x.FeeNum == fee.FeeNum));
        }
예제 #3
0
        public void PaymentEdit_AutoSplitForPayment_NoNegativeAutoSplits()
        {
            long      provNumA = ProviderT.CreateProvider("provA");
            Patient   pat      = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            Procedure proc1    = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 70);
            Procedure proc2    = ProcedureT.CreateProcedure(pat, "D0150", ProcStat.C, "", 20);
            //make an overpayment for one of the procedures so it spills over.
            DateTime payDate = DateTime.Today;
            Payment  pay     = PaymentT.MakePayment(pat.PatNum, 71, payDate, procNum: proc1.ProcNum); //pre-existing payment
            //attempt to make another payment. Auto splits should not suggest a negative split.
            Payment newPayment = PaymentT.MakePaymentNoSplits(pat.PatNum, 2, payDate, isNew: true,
                                                              payType: Defs.GetDefsForCategory(DefCat.PaymentTypes, true)[0].DefNum);//current payment we're trying to make

            PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, newPayment, new List <long>()
            {
                pat.PatNum
            }, true, false);
            PaymentEdit.ConstructChargesData chargeData = PaymentEdit.GetConstructChargesData(new List <long> {
                pat.PatNum
            }, pat.PatNum,
                                                                                              PaySplits.GetForPayment(pay.PayNum), pay.PayNum, false);
            PaymentEdit.ConstructResults constructResults = PaymentEdit.ConstructAndLinkChargeCredits(new List <long> {
                pat.PatNum
            }, pat.PatNum
                                                                                                      , chargeData.ListPaySplits, newPayment, new List <Procedure> ());
            PaymentEdit.AutoSplit autoSplits = PaymentEdit.AutoSplitForPayment(constructResults);
            Assert.AreEqual(0, autoSplits.ListAutoSplits.FindAll(x => x.SplitAmt < 0).Count);        //assert no negative auto splits were made.
            Assert.AreEqual(0, autoSplits.ListSplitsCur.FindAll(x => x.SplitAmt < 0).Count);         //auto splits not catching everything
        }
예제 #4
0
        public void Fees_GetListFromObjects_ProviderPatientSecondary()
        {
            string        suffix        = MethodBase.GetCurrentMethod().Name;
            ProcedureCode procedureCode = ProcedureCodeT.CreateProcCode("D1110");
            Fee           fee           = CreateSingleFee(suffix, (_defaultFeeAmt * _rand.NextDouble()), hasProv: true, codeNum: procedureCode.CodeNum);
            //Update our new provider so that they are associated to the new fee schedule that was just created.
            Provider prov = Providers.GetProv(fee.ProvNum);

            prov.FeeSched = fee.FeeSched;
            ProviderT.Update(prov);
            //Act like this provider is a secondary provider of a patient which should return the fees for the provider by GetListFromObjects().
            List <Fee> listFees = Fees.GetListFromObjects(new List <ProcedureCode>()
            {
                procedureCode
            },
                                                          null,
                                                          null,
                                                          0,
                                                          prov.ProvNum,
                                                          0,
                                                          null,
                                                          null,
                                                          null,
                                                          null,
                                                          0);

            Assert.IsTrue(listFees.Exists(x => x.FeeNum == fee.FeeNum));
        }
예제 #5
0
        public void Fees_GetListFromObjects_ProviderProcCodeDefault()
        {
            string        suffix        = MethodBase.GetCurrentMethod().Name;
            ProcedureCode procedureCode = ProcedureCodeT.CreateProcCode("D1110");
            Fee           fee           = CreateSingleFee(suffix, (_defaultFeeAmt * _rand.NextDouble()), hasProv: true, codeNum: procedureCode.CodeNum);
            //Update our new provider so that they are associated to the new fee schedule that was just created.
            Provider prov = Providers.GetProv(fee.ProvNum);

            prov.FeeSched = fee.FeeSched;
            ProviderT.Update(prov);
            //Make the default provider associated to the procedure code our new provider.
            procedureCode.ProvNumDefault = prov.ProvNum;
            ProcedureCodeT.Update(procedureCode);
            //The fees associated to the fee schedule of the procedure code's default provider should be returned by GetListFromObjects().
            List <Fee> listFees = Fees.GetListFromObjects(new List <ProcedureCode>()
            {
                procedureCode
            },
                                                          null,
                                                          null,
                                                          0,
                                                          0,
                                                          0,
                                                          null,
                                                          null,
                                                          null,
                                                          null,
                                                          0);

            Assert.IsTrue(listFees.Exists(x => x.FeeNum == fee.FeeNum));
        }
예제 #6
0
        public void Fees_GetListFromObjects_ProviderFirst()
        {
            string        suffix        = MethodBase.GetCurrentMethod().Name;
            ProcedureCode procedureCode = ProcedureCodeT.CreateProcCode("D1110");
            Fee           fee           = CreateSingleFee(suffix, (_defaultFeeAmt * _rand.NextDouble()), codeNum: procedureCode.CodeNum);
            //Update the database so that provFirst is associated to the new fee schedule we just created.
            Provider provFirst = Providers.GetFirst();

            provFirst.FeeSched = fee.FeeSched;
            ProviderT.Update(provFirst);
            //Since our new fee is associated to the fee schedule of the first provider, it should be returned by GetListFromObjects().
            List <Fee> listFees = Fees.GetListFromObjects(new List <ProcedureCode>()
            {
                procedureCode
            },
                                                          null,
                                                          null,
                                                          0,
                                                          0,
                                                          0,
                                                          null,
                                                          null,
                                                          null,
                                                          null,
                                                          0);

            Assert.IsTrue(listFees.Exists(x => x.FeeNum == fee.FeeNum));
        }
예제 #7
0
        public void Fees_GetListFromObjects_ProviderPracticeDefault()
        {
            string        suffix        = MethodBase.GetCurrentMethod().Name;
            ProcedureCode procedureCode = ProcedureCodeT.CreateProcCode("D1110");
            Fee           fee           = CreateSingleFee(suffix, (_defaultFeeAmt * _rand.NextDouble()), hasProv: true, codeNum: procedureCode.CodeNum);
            //Update our new provider so that they are associated to the new fee schedule that was just created.
            Provider prov = Providers.GetProv(fee.ProvNum);

            prov.FeeSched = fee.FeeSched;
            ProviderT.Update(prov);
            //Update the database so that the practice provider is the provider associated to our new fee.
            long practiceDefaultProvOld = PrefC.GetLong(PrefName.PracticeDefaultProv);

            PrefT.UpdateLong(PrefName.PracticeDefaultProv, fee.ProvNum);
            //Since our new fee is associated to the fee schedule of the practice default provider, it should be returned by GetListFromObjects().
            List <Fee> listFees = Fees.GetListFromObjects(new List <ProcedureCode>()
            {
                procedureCode
            },
                                                          null,
                                                          null,
                                                          0,
                                                          0,
                                                          0,
                                                          null,
                                                          null,
                                                          null,
                                                          null,
                                                          0);

            //Put the default provider back the way it was prior to asserting.
            PrefT.UpdateLong(PrefName.PracticeDefaultProv, practiceDefaultProvOld);
            Assert.IsTrue(listFees.Exists(x => x.FeeNum == fee.FeeNum));
        }
예제 #8
0
        public void PaymentEdit_AllocateUnearned_NoLinkToOriginalPrepayment()
        {
            Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            //create prepayment of $100
            long   provNum = ProviderT.CreateProvider("SG");
            Clinic clinic1 = ClinicT.CreateClinic("Clinic1");
            //create original prepayment.
            PaySplit prePay = PaySplitT.CreatePrepayment(pat.PatNum, 100, DateTime.Today.AddDays(-1), provNum, clinic1.ClinicNum);
            //complete a procedure
            Procedure proc1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 50, provNum: provNum);

            //Manually allocate prepayment without linking to the original prepayment.
            //We want to do it manually so we don't link this to the orginal prepayment correctly.
            //Not linking correctly will test that the AllocateUnearned method is implicitly linking prepayments correctly.
            PaySplitT.CreatePaySplitsForPrepayment(proc1, 50, prov: provNum, clinic: clinic1);
            //Create new procedure
            Procedure proc2 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 100, provNum: provNum);
            //test the PaymentEdit.AllocateUnearned() method.
            Family          fam = Patients.GetFamily(pat.PatNum);
            List <PaySplit> listFamPrePaySplits = PaySplits.GetPrepayForFam(fam);
            //Should be $100
            double unearnedAmt = (double)PaySplits.GetUnearnedForFam(fam, listFamPrePaySplits);

            Assert.AreEqual(100, unearnedAmt);
            List <PaySplit> listPaySplitsUnearned = new List <PaySplit>();
            Payment         pay = PaymentT.MakePaymentForPrepayment(pat, clinic1);
            List <PaySplits.PaySplitAssociated> retVal = PaymentEdit.AllocateUnearned(new List <Procedure> {
                proc2
            }, ref listPaySplitsUnearned, pay, unearnedAmt, fam);

            Assert.AreEqual(2, retVal.Count);
            //After running the AllocateUnearned, we should implicitly link the incorrect prepayment made when we call CreatePaySplitsForPrepayment above.
            Assert.AreEqual(-50, listPaySplitsUnearned.Where(x => x.UnearnedType != 0).Sum(x => x.SplitAmt));
        }
예제 #9
0
        public void Reactivations_GetReactivationList_PatientMarkedDoNotContact()
        {
            string  name    = MethodBase.GetCurrentMethod().Name;
            Clinic  clinic  = ClinicT.CreateClinic(name);
            long    provNum = ProviderT.CreateProvider(name);
            Patient pat     = PatientT.CreatePatient(name, provNum, clinic.ClinicNum, TestEmaiAddress, TestPatPhone, ContactMethod.Mail);
            //Patient has not been seen since further in the past than the ReactivationDaysPast preference.
            Procedure proc = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 50, procDate: DateTime.Now.AddYears(-3), provNum: provNum);   //3 year old proc
            //Patient has been contacted, and the ReactivationContactInterval has elapsed.
            Commlog comm = new Commlog()
            {
                PatNum         = pat.PatNum,
                CommDateTime   = DateTime.Now.AddYears(-1),
                CommType       = _reactivationCommLogType,
                Mode_          = CommItemMode.Email,
                SentOrReceived = CommSentOrReceived.Sent,
                CommSource     = CommItemSource.ApptReminder,
            };

            comm.CommlogNum = Commlogs.Insert(comm);
            //Patient has been marked "Do Not Contact"
            Reactivations.Insert(new Reactivation()
            {
                PatNum       = pat.PatNum,
                DoNotContact = true,
            });
            DateTime dateSince = DateTime.Today.AddDays(-PrefC.GetInt(PrefName.ReactivationDaysPast));
            DateTime dateStop  = dateSince.AddMonths(-36);
            //Confirm that the patient does not in the Reactivation List
            DataTable tbl = Reactivations.GetReactivationList(dateSince, dateStop, false, false, true, provNum, clinic.ClinicNum, 0, 0
                                                              , ReactivationListSort.LastContacted, RecallListShowNumberReminders.One);

            //No patients in the list
            Assert.AreEqual(0, tbl.Rows.Count);
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #12
0
        public void Fees_GetFee_PartialClinicNoProv()
        {
            Fee  expectedFee = CreateSingleFee(MethodBase.GetCurrentMethod().Name, _defaultFeeAmt * _rand.NextDouble(), true, false);
            long provNum     = ProviderT.CreateProvider(MethodBase.GetCurrentMethod().Name);
            Fee  actualFee   = Fees.GetFee(expectedFee.CodeNum, expectedFee.FeeSched, expectedFee.ClinicNum, provNum);

            Assert.IsTrue(AreSimilar(expectedFee, actualFee));
        }
예제 #13
0
        public void Providers_GetAll_BlankDateTerm()
        {
            long            provNum       = ProviderT.CreateProvider(MethodBase.GetCurrentMethod().Name);//New Provider with default Provider.Birthdate.
            List <Provider> listProviders = Providers.GetAll();
            Provider        prov          = listProviders.FirstOrDefault(x => x.ProvNum == provNum);

            Assert.AreEqual(DateTime.MinValue, prov.DateTerm);
        }
예제 #14
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));
 }
예제 #15
0
        public void Fees_GetFee_PartialNotFound()
        {
            string name       = MethodBase.GetCurrentMethod().Name;
            Fee    createdFee = CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble());
            Clinic clinic     = ClinicT.CreateClinic(name);
            long   provNum    = ProviderT.CreateProvider(name);

            Assert.IsNull(Fees.GetFee(_listProcCodes.Last().CodeNum, createdFee.FeeSched, clinic.ClinicNum, provNum));
        }
예제 #16
0
        /// <summary>Creates the request number of fee schedules, clinics and providers, and creates fees for each combination and code num.</summary>
        private FeeTestArgs CreateManyFees(int numFeeScheds, int numClinics, int numProvs, string suffix)
        {
            FeeTestArgs retVal = new FeeTestArgs();

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

            foreach (long codeNum in _listProcCodes.Select(x => x.CodeNum))
            {
                foreach (long feeSchedNum in retVal.ListFeeSchedNums)
                {
                    foreach (Clinic clinic in retVal.ListClinics)
                    {
                        foreach (long provNum in retVal.ListProvNums)
                        {
                            listFees.Add(new Fee()
                            {
                                FeeSched  = feeSchedNum,
                                ClinicNum = clinic.ClinicNum,
                                ProvNum   = provNum,
                                CodeNum   = codeNum,
                                Amount    = _defaultFeeAmt * _rand.NextDouble()
                            });
                        }
                    }
                }
            }
            Fees.InsertMany(listFees);
            retVal.ListFees = Fees.GetByFeeSchedNumsClinicNums(retVal.ListFeeSchedNums, retVal.ListClinics.Select(x => x.ClinicNum).ToList())
                              .Union(Fees.GetByFeeSchedNumsClinicNums(new List <long>()
            {
                _standardFeeSchedNum
            }, new List <long>()
            {
                0
            })).ToList();
            //create an empty feeschedule for the Insert/Update/Delete tests
            retVal.emptyFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Empty" + suffix, false);
            return(retVal);
        }
예제 #17
0
        public void Fees_GetFee_PartialDefaultForCode()
        {
            string name        = MethodBase.GetCurrentMethod().Name;
            Fee    expectedFee = CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble());
            Clinic clinic      = ClinicT.CreateClinic(name);
            long   provNum     = ProviderT.CreateProvider(name);
            Fee    actualFee   = Fees.GetFee(expectedFee.CodeNum, expectedFee.FeeSched, clinic.ClinicNum, provNum);

            Assert.IsTrue(AreSimilar(expectedFee, actualFee));
        }
예제 #18
0
        public void AgingData_GetAgingData_PayPlanBillInAdvanceDays_WithPendingProc()
        {
            string   suffix            = MethodBase.GetCurrentMethod().Name;
            Patient  patient           = PatientT.CreatePatient(suffix);
            long     provNum           = ProviderT.CreateProvider(suffix);
            DateTime datePayPlan       = DateTime.Today.AddDays(5);
            DateTime datePayPlanCreate = DateTime.Today.AddMonths(-1);          //Payment Plan was created a month ago.
            DateTime dateProc          = DateTime.Today;
            DateTime dateStatement     = DateTime.Today.AddDays(-5);

            //Create a payment plan where the first charge date in the future.
            PayPlanT.CreatePayPlan(patient.PatNum, 1000, 500, datePayPlan, provNum);
            //Create a completed procedure that was completed today, before the first payplan charge date.
            ProcedureT.CreateProcedure(patient, "D1100", ProcStat.C, "", 5, dateProc);
            //Insert a statement that was sent during the "bill in advance days" for the payment plan charge above.
            StatementT.CreateStatement(patient.PatNum, mode_: StatementMode.Mail, isSent: true, dateSent: dateStatement);
            //Make sure that the preference PayPlansBillInAdvanceDays is set to a day range that encompasses the first payment plan charge date.
            PrefT.UpdateLong(PrefName.PayPlansBillInAdvanceDays, 10);
            //This scenario is exploiting the fact that the statement created 5 days ago was technically created for the payment plan (in advance).
            //Because of this fact, the patient shouldn't show up in the billing list until something new happens after the statement date.
            //The procedure that was completed today should cause the patient to show up in the billing list (something new happened).
            SerializableDictionary <long, PatAgingData> dictPatAgingData = AgingData.GetAgingData(false, true, false, false, false, new List <long>());

            //Assert that the patient has been returned due to the completed procedure.
            Assert.IsTrue(dictPatAgingData.ContainsKey(patient.PatNum), "No aging data was returned for the patient.");
            //Assert all pertinent PatAgingData for this unit test.
            Assert.IsNotNull(dictPatAgingData[patient.PatNum].ListPatAgingTransactions);
            PatAgingTransaction patAgingTransactionPP = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                        .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.PayPlanCharge);

            //Act like the payment plan was created a month ago.
            patAgingTransactionPP.SecDateTEntryTrans = datePayPlanCreate;
            PatAgingTransaction patAgingTransactionProc = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                          .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.Procedure);

            Assert.IsNotNull(patAgingTransactionPP);
            Assert.IsNotNull(patAgingTransactionProc);
            Assert.AreEqual(datePayPlan, patAgingTransactionPP.DateLastTrans);
            Assert.AreEqual(dateProc, patAgingTransactionProc.DateLastTrans);
            SerializableDictionary <long, List <PatAgingTransaction> > dictPatAgingTrans = new SerializableDictionary <long, List <PatAgingTransaction> >();

            foreach (KeyValuePair <long, PatAgingData> kvp in dictPatAgingData)
            {
                dictPatAgingTrans[kvp.Key] = kvp.Value.ListPatAgingTransactions;
            }
            //The last transaction date should be the procedure date and not the pay plan charge date (even though pay plan is later).
            Assert.AreEqual(dateProc, AgingData.GetDateLastTrans(dictPatAgingTrans[patient.PatNum], dateStatement).Date);
            List <PatAging> listPatAging = Patients.GetAgingList("", DateTime.Today.AddMonths(-1), new List <long>(), false, false, 0, false, false, new List <long>(),
                                                                 false, false, new List <long>(), new List <long>(), dictPatAgingTrans);

            //Assert that the patient has been flagged to get a new statement due to procedure that was completed above.
            Assert.IsTrue(listPatAging.Any(x => x.PatNum == patient.PatNum), "The expected patient was not present in the AgingList.");
        }
예제 #19
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);
            }
        }
예제 #20
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);
            }
        }
예제 #21
0
        public void AgingData_GetAgingData_PayPlanBillInAdvanceDays_WithNewPayPlan()
        {
            string   suffix            = MethodBase.GetCurrentMethod().Name;
            Patient  patient           = PatientT.CreatePatient(suffix);
            long     provNum           = ProviderT.CreateProvider(suffix);
            DateTime datePayPlanCharge = DateTime.Today.AddDays(5);
            DateTime datePayPlanCreate = DateTime.Today;          //The payment plan that we are about to create will automatically have this date as the SecTDateEntry
            DateTime dateProc          = DateTime.Today.AddDays(-1);
            DateTime dateStatement     = DateTime.Today.AddDays(-1);

            //Create a payment plan where the first charge date in the future.
            PayPlanT.CreatePayPlan(patient.PatNum, 1000, 500, datePayPlanCharge, provNum);
            //Create a completed procedure that was completed yesterday, before the first payplan charge date AND before the payment plan creation date.
            ProcedureT.CreateProcedure(patient, "D1100", ProcStat.C, "", 5, dateProc);
            //Insert a statement that was sent during the "bill in advance days" for the payment plan charge AND before the payment plan creation date.
            StatementT.CreateStatement(patient.PatNum, mode_: StatementMode.Mail, isSent: true, dateSent: dateStatement);
            //Make sure that the preference PayPlansBillInAdvanceDays is set to a day range that encompasses the first payment plan charge date.
            PrefT.UpdateLong(PrefName.PayPlansBillInAdvanceDays, 10);
            //This scenario is exploiting the fact that the statement created yesterday was NOT technically created for the payment plan (in advance).
            //Because of this fact, the patient should show up in the billing list because something new has happened after the statement date.
            //The new payment plan should not be associated to the previous statement due to the SecTDateEntry.
            SerializableDictionary <long, PatAgingData> dictPatAgingData = AgingData.GetAgingData(false, true, false, false, false, new List <long>());

            //Assert that the patient has been returned due to owing money on the payment plan that was created.
            Assert.IsTrue(dictPatAgingData.ContainsKey(patient.PatNum), "No aging data was returned for the patient.");
            Assert.IsNotNull(dictPatAgingData[patient.PatNum].ListPatAgingTransactions);
            PatAgingTransaction patAgingTransactionPP = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                        .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.PayPlanCharge);
            PatAgingTransaction patAgingTransactionProc = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                          .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.Procedure);

            Assert.IsNotNull(patAgingTransactionPP);
            Assert.IsNotNull(patAgingTransactionProc);
            Assert.AreEqual(datePayPlanCharge, patAgingTransactionPP.DateLastTrans);
            Assert.AreEqual(dateProc, patAgingTransactionProc.DateLastTrans);
            SerializableDictionary <long, List <PatAgingTransaction> > dictPatAgingTrans = new SerializableDictionary <long, List <PatAgingTransaction> >();

            foreach (KeyValuePair <long, PatAgingData> kvp in dictPatAgingData)
            {
                dictPatAgingTrans[kvp.Key] = kvp.Value.ListPatAgingTransactions;
            }
            //The last transaction date should be the charge date of the pay plan charge which indicates that the statement doesn't apply
            //to the payment plan because the payment plan was created AFTER the statement that just so happens to fall within the "bill in advance days".
            Assert.AreEqual(datePayPlanCharge, AgingData.GetDateLastTrans(dictPatAgingTrans[patient.PatNum], dateStatement).Date);
            List <PatAging> listPatAging = Patients.GetAgingList("", DateTime.Today.AddMonths(-1), new List <long>(), false, false, 0, false, false, new List <long>(),
                                                                 false, false, new List <long>(), new List <long>(), dictPatAgingTrans);

            Assert.IsTrue(listPatAging.Any(x => x.PatNum == patient.PatNum), "The expected patient was not present in the AgingList.");
        }
예제 #22
0
        public void PaymentEdit_AllocateUnearned_LinkToOriginalPrepayment()
        {
            Patient pat = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            //create prepayment of $100
            long   provNum = ProviderT.CreateProvider("SG");
            Clinic clinic1 = ClinicT.CreateClinic("Clinic1");
            Family fam     = Patients.GetFamily(pat.PatNum);
            //create original prepayment.
            PaySplit prePay = PaySplitT.CreatePrepayment(pat.PatNum, 100, DateTime.Today.AddDays(-1), provNum, clinic1.ClinicNum);
            //complete a procedure
            Procedure proc1 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 50, provNum: provNum);
            //Setup to run the PaymentEdit.AllocateUnearned
            List <PaySplit> listPaySplits       = new List <PaySplit>();
            List <PaySplit> listFamPrePaySplits = PaySplits.GetPrepayForFam(fam);
            //Unearned amount should be $100.
            double unearnedAmt = (double)PaySplits.GetUnearnedForFam(fam, listFamPrePaySplits);

            Assert.AreEqual(100, unearnedAmt);
            //Create the payment we will use to allocate some of the $100 prepayment.
            Payment pay = PaymentT.MakePaymentForPrepayment(pat, clinic1);
            //Run the AllocateUnearned method. This a list of paysplitAssociated.
            //The ref list of paysplits should also have the new paysplits that are associated to the original prepayment.
            List <PaySplits.PaySplitAssociated> listPaySplitAssociated = PaymentEdit.AllocateUnearned(new List <Procedure> {
                proc1
            }, ref listPaySplits, pay, unearnedAmt, fam);

            //Insert the paysplits and link the prepayment paysplits. This is similar to what is done when a user creates a payment from FormPayment.cs.
            PaySplitT.InsertPrepaymentSplits(listPaySplits, listPaySplitAssociated);
            //The ref list of paysplits should have the correct allocated prepayment amount.
            Assert.AreEqual(-50, listPaySplits.Where(x => x.UnearnedType != 0).Sum(x => x.SplitAmt));
            //Create new procedure
            Procedure proc2 = ProcedureT.CreateProcedure(pat, "D1110", ProcStat.C, "", 100, provNum: provNum);

            //Now do what we just did again for a new procedure. The unallocated amount should be $50.
            listFamPrePaySplits = PaySplits.GetPrepayForFam(fam);
            unearnedAmt         = (double)PaySplits.GetUnearnedForFam(fam, listFamPrePaySplits);
            Assert.AreEqual(50, unearnedAmt);
            List <PaySplit> listPaySplitsUnearned = new List <PaySplit>();

            pay = PaymentT.MakePaymentForPrepayment(pat, clinic1);
            List <PaySplits.PaySplitAssociated> retVal = PaymentEdit.AllocateUnearned(new List <Procedure> {
                proc2
            }, ref listPaySplitsUnearned, pay, unearnedAmt, fam);

            Assert.AreEqual(2, retVal.Count);
            Assert.AreEqual(-50, listPaySplitsUnearned.Where(x => x.UnearnedType != 0).Sum(x => x.SplitAmt));
        }
예제 #23
0
        ///<summary>Tests that, when creating Patient Characteristics for submission to NewCrop, the Patient's height, heightUnits, weight
        ///and weightUnits are _only_ included when specified. In the below case, only the height information is gvien and thus only the height
        ///information should be in the final results.</summary>
        public void NewCrop_AddingHeightOnly()
        {
            long    provNum = ProviderT.CreateProvider("DOC", "Beverly", "Crusher");                                                                        //Provider
            Patient pat     = PatientT.CreatePatient(priProvNum: provNum, email: "*****@*****.**",
                                                     phone: "1234567", lName: "Wayne", fName: "Bruce", preferredName: "Batman", setPortalAccessInfo: true); //Patient
            Employee       emp            = EmployeeT.CreateEmployee("");                                                                                   //Employee
            ProviderClinic providerClinic = ProviderClinicT.CreateProviderClinic(Providers.GetProv(provNum), dEANum: "93485", stateRxID: "439578");

            ProviderClinicT.Update(providerClinic);
            Vitalsign vitals = VitalsignT.CreateVitalsign(patNum: pat.PatNum, height: 6, heightExamCode: "3137-7", weightExamCode: "3141-9");   //Vitalsigns

            VitalsignT.Update(vitals: vitals, patNum: pat.PatNum);
            ErxXml.BuildNewCropClickThroughXml(Providers.GetProv(provNum), emp, pat, out NCScript nCScript);
            Assert.AreEqual("6", nCScript.Patient.PatientCharacteristics.height);
            Assert.AreEqual("inches", nCScript.Patient.PatientCharacteristics.heightUnits);
            Assert.AreEqual(null, nCScript.Patient.PatientCharacteristics.weight);
            Assert.AreEqual(WeightUnitType.Item, nCScript.Patient.PatientCharacteristics.weightUnits);           //WeightUnitType.Item is default for enum (0)
        }
예제 #24
0
        public void PDMPLogicoy_GetURL_TestData()
        {
            long     provNum = ProviderT.CreateProvider("provPDMP", fName: "Barry", lName: "Anderson");
            Provider prov    = Providers.GetProv(provNum);

            prov.NationalProvID = "2621233875";
            Patient     pat                = PatientT.CreatePatient(fName: "Bilbo", lName: "Baggins", birthDate: new DateTime(1959, 12, 26), priProvNum: provNum);
            string      testUsername       = "******";
            string      testPassword       = "******";
            string      stateWhereLicensed = "IL";
            string      strDeaNum          = "BR3932553";
            string      facilityId         = "RVC";
            PDMPLogicoy pdmp               = new PDMPLogicoy(testUsername, testPassword, pat, prov, stateWhereLicensed, strDeaNum, facilityId);
            string      urlActual          = pdmp.GetURL();
            string      urlUniqueID        = ".*";//Ex: "68fa8c70-d253-417b-a438-13909ee2134d&amp;"
            string      urlExpected        = "https://openid\\.logicoy\\.com/pdmp/dataServices/getReport/fetchSummaryReport\\?SSOToken=" + urlUniqueID + "stateCode=IL";

            Assert.IsTrue(Regex.IsMatch(urlActual, urlExpected));
        }
예제 #25
0
        public void PaymentEdit_Init_AttachedAdjustment()
        {
            Patient    pat        = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            long       provNum    = ProviderT.CreateProvider("prov1");
            Procedure  proc       = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 135, DateTime.Today.AddMonths(-1).AddDays(1), provNum: provNum);
            Adjustment adjustment = AdjustmentT.MakeAdjustment(pat.PatNum, 20, DateTime.Today.AddDays(-15), provNum: provNum, procNum: proc.ProcNum);
            Payment    payCur     = PaymentT.MakePaymentNoSplits(pat.PatNum, 20);

            PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, payCur, new List <long> {
                pat.PatNum
            }, true, false);
            PaymentEdit.InitData initData = PaymentEdit.Init(loadData.ListAssociatedPatients, Patients.GetFamily(pat.PatNum), new Family {
            }, payCur
                                                             , loadData.ListSplits, new List <Procedure>(), pat.PatNum, loadData: loadData);
            //Verify there is only one charge (the procedure's charge + the adjustment for the amount original)
            Assert.AreEqual(1, initData.AutoSplitData.ListAccountCharges.Count);
            Assert.AreEqual(typeof(Procedure), initData.AutoSplitData.ListAccountCharges[0].Tag.GetType());
            Assert.AreEqual(155, initData.AutoSplitData.ListAccountCharges[0].AmountOriginal);
        }
예제 #26
0
        public void PaymentEdit_Init_AdjustmentPreferWithPosAdjustment()
        {
            PrefT.UpdateInt(PrefName.AutoSplitLogic, (int)AutoSplitPreference.Adjustments);
            Patient    pat        = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            long       provNum    = ProviderT.CreateProvider("prov1");
            Procedure  proc1      = ProcedureT.CreateProcedure(pat, "D0220", ProcStat.C, "", 75, DateTime.Today.AddMonths(-1), provNum: provNum);
            Procedure  proc2      = ProcedureT.CreateProcedure(pat, "D0120", ProcStat.C, "", 135, DateTime.Today.AddMonths(-1).AddDays(1), provNum: provNum);
            Adjustment adjustment = AdjustmentT.MakeAdjustment(pat.PatNum, 20, DateTime.Today.AddDays(-15), provNum: provNum);
            Payment    payCur     = PaymentT.MakePaymentNoSplits(pat.PatNum, 20);

            PaymentEdit.LoadData loadData = PaymentEdit.GetLoadData(pat, payCur, new List <long> {
                pat.PatNum
            }, true, false);
            PaymentEdit.InitData initData = PaymentEdit.Init(loadData.ListAssociatedPatients, Patients.GetFamily(pat.PatNum), new Family {
            }, payCur
                                                             , loadData.ListSplits, new List <Procedure>(), pat.PatNum, loadData: loadData);
            //Verify the logic chooses to pay off the adjustment first
            Assert.AreEqual(1, initData.AutoSplitData.ListAccountCharges.Count(x => x.Tag.GetType() == typeof(Adjustment) && x.AmountEnd == 0));
        }
예제 #27
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);
        }
예제 #28
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);
        }
예제 #29
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);
        }
예제 #30
0
        public void AgingData_GetAgingData_PayPlanBillInAdvanceDays_WithStatement()
        {
            string  suffix  = MethodBase.GetCurrentMethod().Name;
            Patient patient = PatientT.CreatePatient(suffix);
            long    provNum = ProviderT.CreateProvider(suffix);
            //Create a payment plan where the first charge date is in the future.
            DateTime dateTimePayPlanCharge = DateTime.Today.AddDays(5);
            DateTime dateStatement         = DateTime.Today;

            PayPlanT.CreatePayPlan(patient.PatNum, 1000, 500, dateTimePayPlanCharge, provNum);
            //Make sure that the preference PayPlansBillInAdvanceDays is set to a day range that encompasses the first payment plan charge date.
            PrefT.UpdateLong(PrefName.PayPlansBillInAdvanceDays, 10);
            SerializableDictionary <long, PatAgingData> dictPatAgingData = AgingData.GetAgingData(false, true, false, false, false, new List <long>());

            //Assert that the patient has been returned due to owing money on a payment plan that falls within the "bill in advance days" preference.
            Assert.IsTrue(dictPatAgingData.ContainsKey(patient.PatNum), "No aging data was returned for the patient.");
            //Assert all pertinent PatAgingData for this unit test.
            Assert.IsNotNull(dictPatAgingData[patient.PatNum].ListPatAgingTransactions);
            PatAgingTransaction patAgingTransaction = dictPatAgingData[patient.PatNum].ListPatAgingTransactions
                                                      .FirstOrDefault(x => x.TransactionType == PatAgingTransaction.TransactionTypes.PayPlanCharge);

            Assert.IsNotNull(patAgingTransaction);
            Assert.AreEqual(dateTimePayPlanCharge, patAgingTransaction.DateLastTrans);
            //Insert a statement that was sent today.  This should cause the patient to be excluded from the PatAging list returned.
            StatementT.CreateStatement(patient.PatNum, mode_: StatementMode.Mail, isSent: true, dateSent: dateStatement);
            SerializableDictionary <long, List <PatAgingTransaction> > dictPatAgingTrans = new SerializableDictionary <long, List <PatAgingTransaction> >();

            foreach (KeyValuePair <long, PatAgingData> kvp in dictPatAgingData)
            {
                dictPatAgingTrans[kvp.Key] = kvp.Value.ListPatAgingTransactions;
            }
            //Assert that GetDateLastTrans() returns the date we are expecting.
            Assert.AreEqual(DateTime.MinValue, AgingData.GetDateLastTrans(dictPatAgingTrans[patient.PatNum], dateStatement).Date);
            List <PatAging> listPatAging = Patients.GetAgingList("", DateTime.Today.AddMonths(-1), new List <long>(), false, false, 0, false, false, new List <long>(), false, false,
                                                                 new List <long>(), new List <long>(), dictPatAgingTrans);

            //Assert that the patient will not get a new statement due to the statement that was created above.
            Assert.IsFalse(listPatAging.Any(x => x.PatNum == patient.PatNum), "The patient was not supposed to be present in the AgingList.");
        }