Example #1
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));
        }
        public void FeeSchedTools_CopyFeeSched_Clinics()
        {
            //Make sure there are no duplicate fees already present within the database.
            string dbmResult = DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Check);

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

            //Create a fee for every single procedure code in the database and associate it to the "from" fee schedule.
            foreach (ProcedureCode code in _listProcCodes)
            {
                FeeT.CreateFee(feeSchedNumFrom.FeeSchedNum, code.CodeNum, _rand.Next(5000));
            }
            //Copy the "from" fee schedule into the "to" fee schedule and do it for at least seven clinics.
            FeeScheds.CopyFeeSchedule(feeSchedNumFrom, 0, 0, feeSchedNumTo, Clinics.GetDeepCopy(true).Select(x => x.ClinicNum).ToList(), 0);
            //Make sure that there was NOT a duplicate fee inserted into the database.
            dbmResult = DatabaseMaintenances.FeeDeleteDuplicates(true, DbmMode.Check);
            Assert.AreEqual(dbmResult.Trim(), _feeDeleteDuplicatesExpectedResult, "Duplicate fees detected due to concurrent copying.");
        }
Example #3
0
        public void Clearinghouses_UpdateOverridesForClinic_UpdateOneOfMultiple()
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            Clinic clinic     = ClinicT.CreateClinic(methodName);
            //Insert a default clearinghouse that is not associated to any clinics.  This will be used as the "HqClearinghouseNum" for creating duplicate overrides later.
            Clearinghouse clearinghouseHQClaimConnect = ClearinghouseT.CreateClearinghouse(methodName, commBridge: EclaimsCommBridge.ClaimConnect);
            //Insert two blank Clearinghouse override rows associated to the same clinic into the DB to mimic the real life duplicate row issue.
            Clearinghouse clearinghouseOverrideClaimConnect1 = ClearinghouseT.CreateClearinghouse(methodName, clinic.ClinicNum, EclaimsCommBridge.ClaimConnect,
                                                                                                  ElectronicClaimFormat.x837D_5010_dental, clearinghouseHQClaimConnect.HqClearinghouseNum, false, "test", "pass");
            Clearinghouse clearinghouseOverrideClaimConnect2 = ClearinghouseT.CreateClearinghouse(methodName, clinic.ClinicNum, EclaimsCommBridge.ClaimConnect,
                                                                                                  ElectronicClaimFormat.x837D_5010_dental, clearinghouseHQClaimConnect.HqClearinghouseNum, false, "test", "pass");
            //Make another HQ clearinghouse that is meant for a different eClaims comm bridge to make sure that all overrides associated to this clearinghouse do not change.
            Clearinghouse clearinghouseHQAOS = ClearinghouseT.CreateClearinghouse(methodName, commBridge: EclaimsCommBridge.AOS);
            //Insert two blank Clearinghouse override rows associated to the same clinic into the DB to mimic the real life duplicate row issue.
            Clearinghouse clearinghouseOverrideAOS = ClearinghouseT.CreateClearinghouse(methodName, clinic.ClinicNum, EclaimsCommBridge.AOS,
                                                                                        ElectronicClaimFormat.x837D_5010_dental, clearinghouseHQAOS.HqClearinghouseNum, false, "test", "pass");
            //Get all override rows from the DB
            List <Clearinghouse> listClearinghouseOverrides = Clearinghouses.GetAllNonHq();
            //Mimic the user making some changes to one of the overrides which was causing issues prior to the UpdateOverridesForClinic() paradigm.
            string passwordNew = "Password1!";

            clearinghouseOverrideClaimConnect2.Password = passwordNew;
            //FormClearinghouseEdit manipulates the clearinghouses in memory first but then calls the following method to "sync" all overrides before calling the clearinghouse sync.
            Clearinghouses.SyncOverridesForClinic(ref listClearinghouseOverrides, clearinghouseOverrideClaimConnect2);
            //Check that both rows had their values updated to the Clearinghouse override's values.
            Assert.IsFalse(listClearinghouseOverrides.All(x => x.Password == passwordNew));
        }
        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);
        }
Example #5
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);
        }
Example #6
0
 public void SetupTest()
 {
     PatientT.ClearPatientTable();
     AppointmentT.ClearAppointmentTable();
     ReactivationT.ClearReactivationTable();
     ClinicT.ClearClinicTable();
 }
Example #7
0
 public static void TearDownClass()
 {
     TaskListT.ClearTaskListTable();
     TaskT.ClearTaskTable();
     TaskSubscriptionT.ClearTaskSubscriptionTable();
     ClinicT.ClearClinicTable();
 }
        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);
        }
Example #9
0
        public void Clearinghouses_UpdateOverridesForClinic_UpdateAllDuplicateOverrideRows()
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            Clinic clinic     = ClinicT.CreateClinic(methodName);
            //Insert a default clearinghouse that is not associated to any clinics.  This will be used as the "HqClearinghouseNum" for creating duplicate overrides later.
            Clearinghouse clearinghouseHQ = ClearinghouseT.CreateClearinghouse(methodName);
            //Insert two blank Clearinghouse override rows associated to the same clinic into the DB to mimic the real life duplicate row issue.
            Clearinghouse clearinghouseOverride1 = ClearinghouseT.CreateClearinghouse(methodName, clinic.ClinicNum, EclaimsCommBridge.ClaimConnect,
                                                                                      ElectronicClaimFormat.x837D_5010_dental, clearinghouseHQ.HqClearinghouseNum, false, "test", "pass");
            Clearinghouse clearinghouseOverride2 = ClearinghouseT.CreateClearinghouse(methodName, clinic.ClinicNum, EclaimsCommBridge.ClaimConnect,
                                                                                      ElectronicClaimFormat.x837D_5010_dental, clearinghouseHQ.HqClearinghouseNum, false, "test", "pass");
            //Get all override rows from the DB
            List <Clearinghouse> listClearinghouseOverrides = Clearinghouses.GetAllNonHq();
            //Mimic the user making some changes to one of the overrides which was causing issues prior to the UpdateOverridesForClinic() paradigm.
            string passwordNew = "Password1!";

            clearinghouseOverride2.Password = passwordNew;
            //FormClearinghouseEdit manipulates the clearinghouses in memory first but then calls the following method to "sync" all overrides before calling the clearinghouse sync.
            Clearinghouses.SyncOverridesForClinic(ref listClearinghouseOverrides, clearinghouseOverride2);
            //Check that both rows had their values updated to the Clearinghouse override's values.
            Clearinghouse co1 = listClearinghouseOverrides.First(x => x.ClearinghouseNum == clearinghouseOverride1.ClearinghouseNum);
            Clearinghouse co2 = listClearinghouseOverrides.First(x => x.ClearinghouseNum == clearinghouseOverride2.ClearinghouseNum);

            Assert.AreEqual(passwordNew, co1.Password);
            Assert.AreEqual(passwordNew, co2.Password);
        }
Example #10
0
        public void Fees_GetFee_PartialProvDefaultClinic()
        {
            Fee    expectedFee = CreateSingleFee(MethodBase.GetCurrentMethod().Name, _defaultFeeAmt * _rand.NextDouble(), false, true);
            Clinic clinic      = ClinicT.CreateClinic(MethodBase.GetCurrentMethod().Name);
            Fee    actualFee   = Fees.GetFee(expectedFee.CodeNum, expectedFee.FeeSched, clinic.ClinicNum, expectedFee.ProvNum);

            Assert.IsTrue(AreSimilar(expectedFee, actualFee));
        }
Example #11
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));
        }
Example #12
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));
 }
Example #13
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);
        }
Example #14
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));
        }
Example #15
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));
        }
 public void ClinicPrefHelper_SyncPrefs()
 {
     #region Test Setup
     //Set up the initial preference value
     Prefs.UpdateBool(PrefName.EClipboardAllowSelfCheckIn, true);
     //Create several clinics to use
     Prefs.UpdateBool(PrefName.EasyNoClinics, false);
     List <Clinic> listClinics = new List <Clinic>();
     for (int i = 0; i < 10; i++)
     {
         listClinics.Add(ClinicT.CreateClinic());
     }
     //Set up the initial preference values
     System.Random rnd = new System.Random();
     foreach (Clinic cl in listClinics)
     {
         ClinicPrefs.InsertPref(PrefName.EClipboardAllowSelfCheckIn, cl.ClinicNum, POut.Bool(rnd.Next(2) == 0));
     }
     ClinicPrefs.RefreshCache();
     //Set up the ClinicPrefHelper
     OpenDental.ClinicPrefHelper clinicPrefHelper = new OpenDental.ClinicPrefHelper(PrefName.EClipboardAllowSelfCheckIn);
     #endregion Test Setup
     #region Test Body
     //Randomyly change the clinic preferences
     List <Tuple <long, string> > listChanges = new List <Tuple <long, string> >();
     foreach (Clinic cl in listClinics)
     {
         string val = POut.Bool(rnd.Next(2) == 0);
         clinicPrefHelper.ValChangedByUser(PrefName.EClipboardAllowSelfCheckIn, cl.ClinicNum, val);
         listChanges.Add(Tuple.Create(cl.ClinicNum, val));
     }
     //Sync the prefs and handle the other elements this method does
     clinicPrefHelper.SyncPref(PrefName.EClipboardAllowSelfCheckIn);
     #endregion Test Body
     #region Test Results
     //SyncPref should have refreshed the cache so we are good to get the list
     List <ClinicPref> listActual = ClinicPrefs.GetPrefAllClinics(PrefName.EClipboardAllowSelfCheckIn);
     foreach (ClinicPref cp in listActual)
     {
         Assert.AreEqual(cp.ValueString, listChanges.First(x => x.Item1 == cp.ClinicNum).Item2);
     }
     #endregion Test Results
 }
Example #17
0
        public void EmailMessages_FindAndReplacePostalAddressTag()
        {
            //Format disclaimer.
            PrefT.UpdateString(PrefName.EmailDisclaimerTemplate, "This email has been sent to you from:\r\n[PostalAddress].\r\n\r\nHow to unsubscribe:\r\nIf you no longer want to receive any email messages from us, simply reply to this email with the word \"unsubscribe\" in the subject line.");
            //Setup practice address.
            PrefT.UpdateString(PrefName.PracticeAddress, "Practice Address1 Here");
            PrefT.UpdateString(PrefName.PracticeAddress2, "3275 Marietta St SE");
            PrefT.UpdateString(PrefName.PracticeCity, "Salem");
            PrefT.UpdateString(PrefName.PracticeST, "OR");
            PrefT.UpdateString(PrefName.PracticeZip, "97317");
            //Setup clinic address.
            Clinic clinic = ClinicT.CreateClinic();

            clinic.Address = "Clinic Address1 Here";
            Clinics.Update(clinic);
            Clinics.RefreshCache();
            //Turn feature off.
            PrefT.UpdateBool(PrefName.EmailDisclaimerIsOn, false);
            string emailBody = "Hi, this is an email.\r\n\r\nRegards,\r\nEvery OD Engineer... ever.";
            string emailBodyWithDisclaimer = EmailMessages.FindAndReplacePostalAddressTag(emailBody, 0);

            //Feature is off so no disclaimer added.
            Assert.AreEqual(emailBody, emailBodyWithDisclaimer);
            //Turn feature on.
            PrefT.UpdateBool(PrefName.EmailDisclaimerIsOn, true);
            //Turn clinics off.
            PrefT.UpdateBool(PrefName.EasyNoClinics, true);
            emailBodyWithDisclaimer = EmailMessages.FindAndReplacePostalAddressTag(emailBody, 0);
            //Feature is on so disclaimer added (no clinic).
            Assert.AreNotEqual(emailBody, emailBodyWithDisclaimer);
            Assert.IsTrue(emailBodyWithDisclaimer.EndsWith("subject line."));
            Assert.IsTrue(emailBodyWithDisclaimer.Contains("Practice Address"));
            Assert.IsFalse(emailBodyWithDisclaimer.Contains("Clinic Address"));
            //Turn clinics on.
            PrefT.UpdateBool(PrefName.EasyNoClinics, false);
            emailBodyWithDisclaimer = EmailMessages.FindAndReplacePostalAddressTag(emailBody, clinic.ClinicNum);
            //Feature is on so disclaimer added (with clinic).
            Assert.AreNotEqual(emailBody, emailBodyWithDisclaimer);
            Assert.IsTrue(emailBodyWithDisclaimer.EndsWith("subject line."));
            Assert.IsTrue(emailBodyWithDisclaimer.Contains("Clinic Address"));
            Assert.IsFalse(emailBodyWithDisclaimer.Contains("Practice Address"));
        }
        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);
        }
Example #19
0
        public void Fees_GetFee_ClinicSpecificFees()
        {
            Patient pat         = PatientT.CreatePatient("58");
            long    feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Standard UCR", false);
            long    codeNum     = ProcedureCodes.GetCodeNum("D2750");
            long    clinicNum2  = ClinicT.CreateClinic("2-58").ClinicNum;
            long    clinicNum3  = ClinicT.CreateClinic("3-58").ClinicNum;
            long    clinicNum1  = ClinicT.CreateClinic("1-58").ClinicNum;

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

            Assert.AreEqual(fee1, 65);
            Assert.AreEqual(fee2, 70);
            Assert.AreEqual(fee3, 75);
        }
Example #20
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);
        }
Example #21
0
        public static void SetupClass(TestContext testContext)
        {
            _defRegionN = DefT.CreateDefinition(DefCat.Regions, "RegionN", "RegionN");
            _defRegionS = DefT.CreateDefinition(DefCat.Regions, "RegionS", "RegionS");
            _clinicN    = ClinicT.CreateClinic("ClinicN", regionDef: _defRegionN);
            _clinicNW   = ClinicT.CreateClinic("ClinicNW", regionDef: _defRegionN);
            _clinicS    = ClinicT.CreateClinic("ClinicS", regionDef: _defRegionS);
            _patN       = PatientT.CreatePatient("Tasks", clinicNum: _clinicN.ClinicNum, lName: _clinicN.Description, fName: "Patient");
            _patS       = PatientT.CreatePatient("Tasks", clinicNum: _clinicS.ClinicNum, lName: _clinicS.Description, fName: "Patient");
            _userA      = UserodT.CreateUser(userName: "******", clinicNum: _clinicN.ClinicNum, isClinicIsRestricted: false);
            _userNW     = UserodT.CreateUser(userName: "******", clinicNum: _clinicNW.ClinicNum, isClinicIsRestricted: true);
            Userods.RefreshCache();
            List <UserClinic> listUserClinics = new List <UserClinic>()
            {
                new UserClinic(_clinicNW.ClinicNum, _userNW.UserNum)
            };

            if (UserClinics.Sync(listUserClinics, _userNW.UserNum))            //Either syncs new list, or clears old list if no longer restricted.
            {
                UserClinics.RefreshCache();
            }
        }
Example #22
0
        public void Procedures_GlobalUpdateFees()
        {
            string name = MethodBase.GetCurrentMethod().Name;
            Random rand = new Random();
            //set up fees
            List <Clinic> listClinics = new List <Clinic>();

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

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

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

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

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

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

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

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

            Assert.AreEqual(listToCount.Count, updatedCount);
        }
 public void SetupTest()
 {
     ClinicT.ClearClinicTable();
     ClinicPrefT.ClearClinicPrefTable();
 }
 public void TearDownTest()
 {
     ClinicT.ClearClinicTable();
     ClinicPrefT.ClearClinicPrefTable();
 }
 public void ClinicPrefHelper_GetClinicsWithChanges()
 {
     #region Test Setup
     //Set up clinics
     Prefs.UpdateBool(PrefName.EasyNoClinics, false);
     Clinic clinicA = ClinicT.CreateClinic();           //This clinic will always use defaults
     Clinic clinicB = ClinicT.CreateClinic();           //This clinic will start using defaults and then use its own values
     Clinic clinicC = ClinicT.CreateClinic();           //This clinic will always use its own values, which will not change
     Clinic clinicD = ClinicT.CreateClinic();           //This clinic will always use its own values, which will change
     Clinic clinicE = ClinicT.CreateClinic();           //This clinic will start using its own values, and then change to the defaults
     //Set up the baseline preferences
     //using EClipboard prefs because they are actually used as clinic prefs, but any pref could be used
     Prefs.UpdateBool(PrefName.EClipboardAllowSelfCheckIn, true);
     Prefs.UpdateBool(PrefName.EClipboardAllowSelfPortraitOnCheckIn, true);
     //Set up the clinic preferences
     ClinicPrefs.InsertPref(PrefName.EClipboardAllowSelfCheckIn, clinicC.ClinicNum, POut.Bool(false));
     ClinicPrefs.InsertPref(PrefName.EClipboardAllowSelfPortraitOnCheckIn, clinicC.ClinicNum, POut.Bool(false));
     ClinicPrefs.InsertPref(PrefName.EClipboardAllowSelfCheckIn, clinicD.ClinicNum, POut.Bool(false));
     ClinicPrefs.InsertPref(PrefName.EClipboardAllowSelfPortraitOnCheckIn, clinicD.ClinicNum, POut.Bool(false));
     ClinicPrefs.InsertPref(PrefName.EClipboardAllowSelfCheckIn, clinicE.ClinicNum, POut.Bool(false));
     ClinicPrefs.InsertPref(PrefName.EClipboardAllowSelfPortraitOnCheckIn, clinicE.ClinicNum, POut.Bool(false));
     ClinicPrefs.RefreshCache();
     //Set up the ClinicPrefHelper
     OpenDental.ClinicPrefHelper clinicPrefHelper = new OpenDental.ClinicPrefHelper(PrefName.EClipboardAllowSelfCheckIn, PrefName.EClipboardAllowSelfPortraitOnCheckIn);
     #endregion Test Setup
     #region Test Body
     //Make the changes to the preferences
     //Update one of the default preference values
     clinicPrefHelper.ValChangedByUser(PrefName.EClipboardAllowSelfCheckIn, 0, POut.Bool(false));
     //Update ClinicB to use one of its own values
     clinicPrefHelper.ValChangedByUser(PrefName.EClipboardAllowSelfPortraitOnCheckIn, clinicB.ClinicNum, POut.Bool(false));
     //Update clinicD to change its own values
     clinicPrefHelper.ValChangedByUser(PrefName.EClipboardAllowSelfCheckIn, clinicD.ClinicNum, POut.Bool(true));
     //Remove all clinicE prefs to indicate it should use the default
     clinicPrefHelper.ValChangedByUser(PrefName.EClipboardAllowSelfCheckIn, clinicE.ClinicNum, POut.Bool(clinicPrefHelper.GetDefaultBoolVal(PrefName.EClipboardAllowSelfCheckIn)));
     clinicPrefHelper.ValChangedByUser(PrefName.EClipboardAllowSelfPortraitOnCheckIn, clinicE.ClinicNum, POut.Bool(clinicPrefHelper.GetDefaultBoolVal(PrefName.EClipboardAllowSelfPortraitOnCheckIn)));
     #endregion Test Body
     #region Test Results
     //Test that GetClinicsWithChanges gets the right clinics for each EClipboardAllowSelfCheckIn
     List <long> listExpectedClinicNumsChanged_A = new List <long>()
     {
         0,                 //We changed the default preference
         clinicD.ClinicNum, //We changed this preference
         clinicE.ClinicNum  //We removed these preferences
     };
     List <long> results = clinicPrefHelper.GetClinicsWithChanges(PrefName.EClipboardAllowSelfCheckIn);
     Assert.AreEqual(3, results.Union(listExpectedClinicNumsChanged_A).Distinct().Count());
     //Test that GetClinicsWithChanges gets the right clinics for each EClipboardAllowSelfCheckIn
     List <long> listExpectedClinicNumsChanged_B = new List <long>()
     {
         clinicB.ClinicNum,                //We changed this preference
         clinicE.ClinicNum                 //We removed these preferences
     };
     results = clinicPrefHelper.GetClinicsWithChanges(PrefName.EClipboardAllowSelfPortraitOnCheckIn);
     Assert.AreEqual(2, results.Union(listExpectedClinicNumsChanged_B).Distinct().Count());
     #endregion Test Results
     #region Test Clean Up
     ClinicPrefs.Sync(new List <ClinicPref>(), ClinicPrefs.GetPrefAllClinics(PrefName.EClipboardAllowSelfCheckIn));
     ClinicPrefs.Sync(new List <ClinicPref>(), ClinicPrefs.GetPrefAllClinics(PrefName.EClipboardAllowSelfPortraitOnCheckIn));
     Clinics.Delete(clinicA);
     Clinics.Delete(clinicB);
     Clinics.Delete(clinicC);
     Clinics.Delete(clinicD);
     Clinics.Delete(clinicE);
     #endregion Test Clean Up
 }
Example #26
0
        public void AlertItems_GetUniqueAlerts_Addclinic()
        {
            //This test will check the funcionality of alert items which are marked to show in all clinics(AlertItem.ClinicNum==-1).
            //Expected behaviour is that a user subscribed to all alert categories, and all clinics(AlertSub.ClinicNum==-1),
            //will see the alert no matter which clinic they are in.
            //In addition, when a new clinic is added, the user will be able to see alerts in that new clinic without the need to reenter
            //FormUserEdit and select "All" again under clinics for alert subscriptions.
            //Clear AlertSub table.
            AlertSubT.ClearAlertSubTable();
            //Create Users
            Userod userAdmin  = UserodT.CreateUser();
            Userod userNormal = UserodT.CreateUser();
            //Create Clinics
            List <Clinic> listClinics = new List <Clinic>();

            for (int i = 0; i < 2; i++)
            {
                listClinics.Add(ClinicT.CreateClinic());
            }
            //Create AlertItems
            //First alert Item is an alert item for all clinics(ClinicNum==-1).
            CreateAlertItem(true);
            //Second AlertItem is an AlertItem for HQ(ClinicNum==0).
            CreateAlertItem(false);
            List <AlertCategory> listAlertCats   = AlertCategories.GetDeepCopy();
            List <AlertSub>      listAlertSubOld = new List <AlertSub>();
            List <AlertSub>      listAlertSubNew = new List <AlertSub>();

            foreach (AlertCategory alertCat in listAlertCats)
            {
                AlertSub alSub = new AlertSub(userAdmin.UserNum, -1, alertCat.AlertCategoryNum);
                listAlertSubNew.Add(alSub);
            }
            AlertSubs.Sync(listAlertSubNew, listAlertSubOld);
            //Check number of alerts which will display in headquarters clinic.
            //Call CheckUniqueAlerts for user subscribed to all alert categories
            List <List <AlertItem> > listUniqueAlertsAll = AlertItems.GetUniqueAlerts(userAdmin.UserNum, 0);
            List <List <AlertItem> > listUniqueAlertsOne = AlertItems.GetUniqueAlerts(userNormal.UserNum, 0);

            //Assert lists are correct
            //UserAdmin should see two alerts, one for the generic headquarters alert and one for the eConnector all clinics alert.
            Assert.AreEqual(2, listUniqueAlertsAll.Count());
            //UserNormal is not subscribed to any clinics or alert categories and should not see any alerts.
            Assert.AreEqual(0, listUniqueAlertsOne.Count());
            //Add clinic
            listClinics.Add(ClinicT.CreateClinic());
            //Check that alert for all clinics is included for userAdmin(subscribed to all clinics)
            listUniqueAlertsAll = AlertItems.GetUniqueAlerts(userAdmin.UserNum, listClinics.LastOrDefault().ClinicNum);
            Assert.AreEqual(1, listUniqueAlertsAll.Count());
            //Check new clinic for user who is not subscribed to all alerts.
            listUniqueAlertsOne = AlertItems.GetUniqueAlerts(userNormal.UserNum, listClinics.LastOrDefault().ClinicNum);
            Assert.AreEqual(0, listUniqueAlertsOne.Count());
            //Add new alert for new clinic only.
            CreateAlertItem(false, listClinics.LastOrDefault().ClinicNum);
            //Check that userAdmin sees new alert item in new clinic. Should have 2, one all clinic econnector alert and the new clinic specific alert.
            listUniqueAlertsAll = AlertItems.GetUniqueAlerts(userAdmin.UserNum, listClinics.LastOrDefault().ClinicNum);
            Assert.AreEqual(2, listUniqueAlertsAll.Count());
            //Check that userNormal sees no alerts in new clinic, as they are not subscribed to any alert categories, nor clinics.
            listUniqueAlertsOne = AlertItems.GetUniqueAlerts(userNormal.UserNum, listClinics.LastOrDefault().ClinicNum);
            Assert.AreEqual(0, listUniqueAlertsOne.Count());
        }
Example #27
0
        public void PaymentEdit_ImplicitlyLinkPrepaymentsHelper()
        {
            Patient pat       = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            Patient patFam    = PatientT.CreatePatient(MethodBase.GetCurrentMethod().Name);
            Patient patFamOld = patFam.Copy();

            patFam.Guarantor = pat.PatNum;
            Patients.Update(patFam, patFamOld);
            //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.
            List <PaySplit> listPaySplits = PaySplitT.CreatePaySplitsForPrepayment(proc1, 50, prov: provNum, clinic: clinic1);

            ResetPrepayments(pat);
            long nonMatch = 100000;
            //test the PaymentEdit.AllocateUnearned() method.
            double unearnedAmt = (double)PaySplits.GetUnearnedForFam(Patients.GetFamily(pat.PatNum), _listFamPrePaySplits);
            //Logic check PatNum - match, ProvNum - match, ClinicNum - match
            double retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumMatch: true, isClinicNumMatch: true);

            Assert.AreEqual(50, retVal);
            //Logic check PatNum - match, ProvNum - match, ClinicNum - zero
            ResetPrepayments(pat);
            //update the clinicnum to 0
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, provNum, 0, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumMatch: true, isClinicNumZero: true);
            Assert.AreEqual(50, retVal);
            //previous Test one should be $100
            ResetPrepayments(pat);
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumMatch: true, isClinicNumMatch: true);
            Assert.AreEqual(100, retVal);
            //Logic check PatNum - match, ProvNum - match, ClinicNum - non zero & non match
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, provNum, 100000, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumMatch: true, isClinicNonZeroNonMatch: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - match, ProvNum - zero, ClinicNum - match
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, 0, clinic1.ClinicNum, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumZero: true, isClinicNumMatch: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - match, ProvNum - zero, ClinicNum - zero
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, 0, 0, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumZero: true, isClinicNumZero: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - match, ProvNum - zero, ClinicNum - non zero & non match
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, 0, nonMatch, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumZero: true, isClinicNonZeroNonMatch: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - match, ProvNum - non zero & non match, ClinicNum - match
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, nonMatch, clinic1.ClinicNum, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNonZeroNonMatch: true, isClinicNumMatch: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - match, ProvNum - non zero & non match, ClinicNum - zero
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, nonMatch, 0, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNonZeroNonMatch: true, isClinicNumZero: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - match, ProvNum - non zero & non match, ClinicNum - non zero & non match
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, pat.PatNum, nonMatch, nonMatch, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNonZeroNonMatch: true, isClinicNonZeroNonMatch: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - other family members, ProvNum - match, ClinicNum - match
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, provNum, clinic1.ClinicNum, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumMatch: true, isClinicNumMatch: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - other family members, ProvNum - match, ClinicNum - zero
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, provNum, 0, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumMatch: true, isClinicNumZero: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - other family members, ProvNum - match, ClinicNum - non zero & non match
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, provNum, nonMatch, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumMatch: true, isClinicNonZeroNonMatch: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - other family members, ProvNum - zero, ClinicNum - match
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, 0, clinic1.ClinicNum, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumZero: true, isClinicNumMatch: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - other family members, ProvNum - zero, ClinicNum - zero
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, 0, 0, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumZero: true, isClinicNumZero: true);
            Assert.AreEqual(50, retVal);
            //Logic checkPatNum - other family members, ProvNum - zero, ClinicNum - non zero & non match
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, 0, nonMatch, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNumZero: true, isClinicNonZeroNonMatch: true);
            Assert.AreEqual(50, retVal);
            //Old test from above
            ResetPrepayments(pat);
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isPatMatch: true, isProvNumMatch: true, isClinicNumMatch: true);
            Assert.AreEqual(100, retVal);
            //Logic checkPatNum - other family members, ProvNum - non zero & non match, ClinicNum - match
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, nonMatch, clinic1.ClinicNum, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNonZeroNonMatch: true, isClinicNumMatch: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - other family members, ProvNum - non zero & non match, ClinicNum - zero
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, nonMatch, 0, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNonZeroNonMatch: true, isClinicNumZero: true);
            Assert.AreEqual(50, retVal);
            //Logic check PatNum - other family members, ProvNum - non zero & non match, ClinicNum - non zero & non match
            ResetPrepayments(pat);
            _listFamPrePaySplits.ForEach(x => UpdatePaySplitHelper(x, patFam.PatNum, nonMatch, nonMatch, _listNegPrePay.First().PayNum));
            retVal = PaymentEdit.ImplicitlyLinkPrepaymentsHelper(_listPosPrePay, _listNegPrePay, unearnedAmt, isFamMatch: true, isProvNonZeroNonMatch: true, isClinicNonZeroNonMatch: true);
            Assert.AreEqual(50, retVal);
        }