Esempio n. 1
0
        ///<summary>Adds adjustments to _listGridEntries for the selected procedures (if any) or for an "unattached" proc if no selected entries.</summary>
        private void AddAdjustments(List <MultiAdjEntry> listSelectedEntries)
        {
            //loop through and update all adjustment rows
            foreach (MultiAdjEntry adjRow in listSelectedEntries.FindAll(x => x.Adj != null))
            {
                UpdateAdjValues(adjRow);
            }
            Def selectedAdjType;

            if (listTypePos.SelectedIndex != -1)
            {
                selectedAdjType = _listAdjPosCats[listTypePos.SelectedIndex];
            }
            else
            {
                selectedAdjType = _listAdjNegCats[listTypeNeg.SelectedIndex];
            }
            //Create new adjustment
            Adjustment adjCur = new Adjustment();

            adjCur.AdjType = selectedAdjType.DefNum;
            adjCur.AdjDate = PIn.Date(dateAdjustment.Text);
            adjCur.AdjNote = PIn.String(textNote.Text);
            adjCur.PatNum  = _patCur.PatNum;
            if (listSelectedEntries.Count == 0)           //User did not select anything and hit "add", so they must want to add an unattached adjustment.
            {
                InsertUnattachedRow();
                adjCur.ProvNum   = _patCur.PriProv;
                adjCur.ClinicNum = _patCur.ClinicNum;
                adjCur.ProcDate  = adjCur.AdjDate;
                adjCur.ProcNum   = 0;
                MultiAdjEntry adjRow = new MultiAdjEntry(adjCur, adjCur.AdjAmt);
                adjRow.AdjAmtType   = AdjAmtType.FixedAmt;
                adjRow.AdjAmtOrPerc = PIn.Double(textAmt.Text);
                adjRow.RecalculateAdjAmt(0);
                _listGridEntries.Add(adjRow);
            }
            else                                                                                        //One or more procedure rows selected, create adjustments
            {
                foreach (MultiAdjEntry procRow in listSelectedEntries.FindAll(x => x.IsProcedureRow())) //Loop through all selected procedures
                {
                    Adjustment adj = adjCur.Clone();
                    adj.ProcDate = procRow.Proc.ProcDate;
                    adj.ProcNum  = procRow.Proc.ProcNum;
                    MultiAdjEntry adjRow = new MultiAdjEntry(procRow.Proc, adj, procRow.RemAfter, procRow.AmtRemBefore);
                    adjRow              = UpdateAdjValues(adjRow);     //This will set all of the important values from UI selections
                    adjRow.AdjAmtType   = SetAdjAmtType();
                    adjRow.AdjAmtOrPerc = PIn.Double(textAmt.Text);
                    _listGridEntries.Add(adjRow);
                }
            }
        }
Esempio n. 2
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            List <MultiAdjEntry> listSelectedEntries = new List <MultiAdjEntry>();

            for (int i = 0; i < gridMain.SelectedIndices.Count(); i++)
            {
                listSelectedEntries.Add((MultiAdjEntry)(gridMain.Rows[gridMain.SelectedIndices[i]].Tag));
            }
            #region User Input Validation
            if (listSelectedEntries.Count() == 0 && _rigorousAdjustments == 0)
            {
                MsgBox.Show(this, "You must select a procedure to add the adjustment to.");
                return;
            }
            if (listTypePos.SelectedIndex == -1 && listTypeNeg.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please pick an adjustment type.");
                return;
            }
            if (comboProv.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please pick a provider.");
                return;
            }
            if (PrefC.HasClinicsEnabled && comboClinic.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please pick a clinic.");
                return;
            }
            if (string.IsNullOrWhiteSpace(dateAdjustment.Text) || dateAdjustment.errorProvider1.GetError(dateAdjustment) != "")
            {
                MsgBox.Show(this, "Please enter a valid date.");
                return;
            }
            if (PIn.Date(dateAdjustment.Text) > DateTime.Today && !PrefC.GetBool(PrefName.FutureTransDatesAllowed))
            {
                MsgBox.Show(this, "Adjustments cannot be made for future dates");
                return;
            }
            if (string.IsNullOrWhiteSpace(textAmt.Text) || textAmt.errorProvider1.GetError(textAmt) != "")
            {
                MsgBox.Show(this, "Please enter a valid amount.");
                return;
            }
            #endregion
            //loop through and update all adjustment rows
            foreach (MultiAdjEntry adjRow in listSelectedEntries.FindAll(x => x.Adj != null))
            {
                UpdateAdjValues(adjRow);
            }
            Def selectedAdjType;
            if (listTypePos.SelectedIndex != -1)
            {
                selectedAdjType = _listAdjPosCats[listTypePos.SelectedIndex];
            }
            else
            {
                selectedAdjType = _listAdjNegCats[listTypeNeg.SelectedIndex];
            }
            //Create new adjustment
            Adjustment adjCur = new Adjustment();
            adjCur.AdjType = selectedAdjType.DefNum;
            adjCur.AdjDate = PIn.Date(dateAdjustment.Text);
            adjCur.AdjNote = PIn.String(textNote.Text);
            adjCur.PatNum  = _patCur.PatNum;
            if (listSelectedEntries.Count == 0)           //User did not select anything and hit "add", so they must want to add an unattached adjustment.
            {
                InsertUnattachedRow();
                adjCur.ProvNum   = _patCur.PriProv;
                adjCur.ClinicNum = _patCur.ClinicNum;
                adjCur.ProcDate  = adjCur.AdjDate;
                adjCur.ProcNum   = 0;
                MultiAdjEntry adjRow = new MultiAdjEntry(adjCur, adjCur.AdjAmt);
                adjRow.AdjAmtType   = AdjAmtType.FixedAmt;
                adjRow.AdjAmtOrPerc = PIn.Double(textAmt.Text);
                adjRow.RecalculateAdjAmt(0);
                _listGridEntries.Add(adjRow);
            }
            else                                                                                        //One or more procedure rows selected, create adjustments
            {
                foreach (MultiAdjEntry procRow in listSelectedEntries.FindAll(x => x.IsProcedureRow())) //Loop through all selected procedures
                {
                    Adjustment adj = adjCur.Clone();
                    adj.ProcDate = procRow.Proc.ProcDate;
                    adj.ProcNum  = procRow.Proc.ProcNum;
                    MultiAdjEntry adjRow = new MultiAdjEntry(procRow.Proc, adj, procRow.RemAfter);
                    adjRow              = UpdateAdjValues(adjRow);     //This will set all of the important values from UI selections
                    adjRow.AdjAmtType   = SetAdjAmtType();
                    adjRow.AdjAmtOrPerc = PIn.Double(textAmt.Text);
                    _listGridEntries.Add(adjRow);
                }
            }
            gridMain.Title = "Available Procedures with Adjustments";
            FillGrid();
        }