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.");
        }
        public void FeeSchedTools_CopyFeeSched_Concurrency()
        {
            //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);
            }
            //Create two fee schedules; from and to
            FeeSched feeSchedFrom = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_FROM");
            FeeSched feeSchedTo   = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_TO");

            //Create a single fee and associate it to the "from" fee schedule.
            FeeT.CreateFee(feeSchedFrom.FeeSchedNum, _listProcCodes[_rand.Next(_listProcCodes.Count - 1)].CodeNum, _defaultFeeAmt);
            //Create a helper action that will simply copy the "from" schedule into the "to" schedule for the given fee cache passed in.
            Action actionCopyFromTo = new Action(() => {
                FeeScheds.CopyFeeSchedule(feeSchedFrom, 0, 0, feeSchedTo, null, 0);
            });

            //Mimic each user clicking the "Copy" button from within the Fee Tools window one right after the other (before they click OK).
            actionCopyFromTo();
            actionCopyFromTo();
            //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.");
        }
        public void FeeSchedTools_CopyFeeSched()
        {
            //Create two fee schedules; from and to
            FeeSched fromFeeSched = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_FROM");
            FeeSched toFeeSched   = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_TO");
            //Create a single fee and associate it to the "from" fee schedule.
            long feeCodeNum = _listProcCodes[_rand.Next(_listProcCodes.Count - 1)].CodeNum;

            FeeT.CreateFee(fromFeeSched.FeeSchedNum, feeCodeNum, _defaultFeeAmt * _rand.NextDouble());
            FeeScheds.CopyFeeSchedule(fromFeeSched, 0, 0, toFeeSched, null, 0);
            //Get the two fees and check that they are the same.
            Fee fromFee = Fees.GetFee(feeCodeNum, fromFeeSched.FeeSchedNum, 0, 0);
            Fee toFee   = Fees.GetFee(feeCodeNum, toFeeSched.FeeSchedNum, 0, 0);

            Assert.AreEqual(fromFee.Amount, toFee.Amount);
        }
示例#4
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (!ValidateUserInput())
            {
                return;
            }
            FeeSched    feeSchedCur       = ((ODBoxItem <FeeSched>)comboFeeSched.SelectedItem).Tag;
            List <long> listClinicNumsNew = _listClinicsInGroup.Select(x => x.ClinicNum).ToList();

            //Initial fee sync for new groups or groups that were created without any clinics in the group, or if we just changed the Fee Schedule for the group.
            //If editing an existing fee schedule group that contains no clinic associations, treat it like a new group and set the initial fees.
            if (_feeSchedGroupCur.IsNew || _feeSchedGroupCur.ListClinicNumsAll.Count() < 1 || _feeSchedGroupCur.FeeSchedNum != feeSchedCur.FeeSchedNum)
            {
                if (MsgBox.Show(this, MsgBoxButtons.YesNo, "Would you like to set the initial group fees to a specific clinic's fees?"
                                + "  Answering no will result in the default fees for the fee schedule being used."))
                {
                    List <GridColumn> listColumnHeaders = new List <GridColumn>()
                    {
                        new GridColumn(Lan.g(this, "Abbr"), 75),
                        new GridColumn(Lan.g(this, "Description"), 200)
                    };
                    List <GridRow> listRowValues = new List <GridRow>();
                    _listClinicsInGroup.ForEach(x => {
                        GridRow row = new GridRow(x.Abbr, x.Description);
                        row.Tag     = x;
                        listRowValues.Add(row);
                    });
                    string            formTitle = Lan.g(this, "Clinic Picker");
                    string            gridTitle = Lan.g(this, "Clinics");
                    FormGridSelection form      = new FormGridSelection(listColumnHeaders, listRowValues, formTitle, gridTitle);
                    if (form.ShowDialog() != DialogResult.OK)
                    {
                        MsgBox.Show(this, "A default clinic was not selected.");
                        return;
                    }
                    long clinicNumMaster = ((Clinic)form.ListSelectedTags[0]).ClinicNum;                  //DialogResult.OK means a selection was made.
                    //This list came from _listClinicsInGroup which was used to fill the grid picker that we get clinicNumMaster from.  We need to pop the master
                    //clinic off the list while copying fee schedules or else it will be deleted before copying.
                    //Give the user an out before potentially changing a lot of data in the db.
                    if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Fees are about to be updated.  Continue?"))
                    {
                        return;
                    }
                    ODProgress.ShowAction(() => {
                        listClinicNumsNew.Remove(clinicNumMaster);
                        FeeScheds.CopyFeeSchedule(feeSchedCur, clinicNumMaster, 0, feeSchedCur, listClinicNumsNew, 0);
                        listClinicNumsNew.Add(clinicNumMaster);
                    }, Lans.g(this, "Creating Group, Please Wait..."));
                }
                else                  //Default fees.
                                      //Give the user an out before potentially changing a lot of data in the db.
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Fees are about to be updated.  Continue?"))
                    {
                        return;
                    }
                    ODProgress.ShowAction(() => {
                        FeeScheds.CopyFeeSchedule(feeSchedCur, 0, 0, feeSchedCur, listClinicNumsNew, 0);
                    }, Lans.g(this, "Creating Group, Please Wait..."));
                }
            }
            //Existing group, change the fees for all the new clinics in the group. Use the first clinic in the old clinic list as we already did an empty check
            //and the fees should have already been synched previously.
            else
            {
                if (listClinicNumsNew.Except(_feeSchedGroupCur.ListClinicNumsAll).Count() != 0 || _feeSchedGroupCur.ListClinicNumsAll.Except(listClinicNumsNew).Count() != 0)
                {
                    //Give the user an out before potentially changing a lot of data in the db.
                    if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Clinics added to the group will have their fees updated to match the group.  Clinics removed from" +
                                     " the group will not have their fees changed.  Continue?"))
                    {
                        return;
                    }
                    //For an existing group we can not guarantee that the ClinicNum we are using to copy fee schedules with is actually still in the group. It is ok to
                    //use a ClinicNum that used to be in the group as the fees will still be in sync at this point.
                    //Only update the fees for clinics that were just added to the group, don't attempt to update fess already in the group.
                    List <long> listClinicNumsToSync = listClinicNumsNew.Where(x => !_feeSchedGroupCur.ListClinicNumsAll.Contains(x)).ToList();
                    if (listClinicNumsToSync.Count > 0)
                    {
                        FeeScheds.CopyFeeSchedule(feeSchedCur, _feeSchedGroupCur.ListClinicNumsAll.First(), 0, feeSchedCur, listClinicNumsToSync, 0);
                    }
                }
            }
            _feeSchedGroupCur.Description       = textDescription.Text;
            _feeSchedGroupCur.FeeSchedNum       = feeSchedCur.FeeSchedNum;
            _feeSchedGroupCur.ListClinicNumsAll = listClinicNumsNew;
            DialogResult = DialogResult.OK;
        }