///<summary>Updates a selected row with the user selected values. Returns the new RemAfter value for the passed in procedure.</summary> private MultiAdjEntry UpdateAdjValues(MultiAdjEntry row) { Def selectedAdjType; if (listTypePos.SelectedIndex != -1) { selectedAdjType = _listAdjPosCats[listTypePos.SelectedIndex]; } else //Nothing was selected in listTypePos so there has to be a selection for negative. { selectedAdjType = _listAdjNegCats[listTypeNeg.SelectedIndex]; } //set prov if (((ODBoxItem <Provider>)comboProv.SelectedItem).Text == "Inherit") //Inherit was carefully approved by Nathan (and reluctantly Allen) { if (row.Proc != null) { row.Adj.ProvNum = row.Proc.ProvNum; } } else { row.Adj.ProvNum = ((ODBoxItem <Provider>)comboProv.SelectedItem).Tag.ProvNum; } //set clinic long selectedClinicNum = 0; if (PrefC.HasClinicsEnabled) { if (((ODBoxItem <Clinic>)comboClinic.SelectedItem).Text == "Inherit") { if (row.Proc != null) { selectedClinicNum = row.Proc.ClinicNum; } } else { selectedClinicNum = ((ODBoxItem <Clinic>)comboClinic.SelectedItem).Tag.ClinicNum; } } row.Adj.AdjType = selectedAdjType.DefNum; row.Adj.ClinicNum = selectedClinicNum; row.Adj.AdjDate = PIn.Date(dateAdjustment.Text); row.Adj.AdjNote = PIn.String(textNote.Text); row.Adj.PatNum = _patCur.PatNum; if (row.Proc == null) //Unassigned adjustments have to be fixed amounts, or else they will be 0. { row.AdjAmtType = AdjAmtType.FixedAmt; } else { row.AdjAmtType = SetAdjAmtType(); } row.AdjAmtOrPerc = PIn.Double(textAmt.Text); return(row); }
///<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); } } }
///<summary>This method converts the AccountEntry objects we get back from AccountModules.GetListUnpaidAccountCharges() to MultiAdjEntry objects. ///These are used to fill the grid and do all relevant logic in this form. This method will return a fresh list of procedures and will not show ///any existing adjustments that may have been made in this form already. Called on load and when checkShowImplicit is clicked. ///When called from checkShowImplicit any existing adjustments made will not be shown.(Ask Andrew about this functionality)</summary> private List <MultiAdjEntry> FillListGridEntries(CreditCalcType calc) { List <MultiAdjEntry> retVal = new List <MultiAdjEntry>(); #region Get required data List <Procedure> listProcedures = Procedures.GetCompleteForPats(new List <long> { _patCur.PatNum }); //Does not get charges for the future. List <PaySplit> listPaySplits = PaySplits.GetForPats(new List <long> { _patCur.PatNum }).Where(x => x.UnearnedType == 0).ToList(); List <Adjustment> listAdjustments = Adjustments.GetAdjustForPats(new List <long> { _patCur.PatNum }); //Might contain payplan payments. Do not include unearned. List <PayPlanCharge> listPayPlanCharges = PayPlanCharges.GetDueForPayPlans(PayPlans.GetForPats(null, _patCur.PatNum), _patCur.PatNum).ToList(); List <ClaimProc> listInsPayAsTotal = ClaimProcs.GetByTotForPats(new List <long> { _patCur.PatNum }); List <ClaimProc> listClaimProcs = ClaimProcs.GetForProcs(listProcedures.Select(x => x.ProcNum).ToList()); #endregion List <AccountEntry> listAccountCharges = AccountModules.GetListUnpaidAccountCharges(listProcedures, listAdjustments , listPaySplits, listClaimProcs, listPayPlanCharges, listInsPayAsTotal, calc, new List <PaySplit>()); List <AccountEntry> listAccountChargesIncludeAll = null; if (calc == CreditCalcType.ExcludeAll) { //We need to get all credits so that our AmtRemBefore can reflect what has truly been allocated to the procedure. listAccountChargesIncludeAll = AccountModules.GetListUnpaidAccountCharges(listProcedures, listAdjustments , listPaySplits, listClaimProcs, listPayPlanCharges, listInsPayAsTotal, CreditCalcType.IncludeAll, new List <PaySplit>()); } MultiAdjEntry multiEntry = null; foreach (AccountEntry entry in listAccountCharges) { //We only want AccountEntries that are completed procedures. if (entry.GetType() != typeof(ProcExtended)) { continue; } ProcExtended procEntry = (ProcExtended)entry.Tag; if ((_listSelectedProcs != null && _listSelectedProcs.Any(x => x.ProcNum == procEntry.Proc.ProcNum)) || //Allow selected procs to show if paid off entry.AmountEnd != 0) //All unpaid procedures should always show up per Nathan { double amtRemBefore = (double)(listAccountChargesIncludeAll?.FirstOrDefault(x => x.Tag.GetType() == typeof(ProcExtended) && ((ProcExtended)x.Tag).Proc.ProcNum == procEntry.Proc.ProcNum) ?? entry).AmountStart; multiEntry = new MultiAdjEntry(procEntry.Proc, (double)entry.AmountStart, (double)entry.AmountEnd, amtRemBefore); retVal.Add(multiEntry); } } OrderListGridEntries(); return(retVal); }
private void butDelete_Click(object sender, EventArgs e) { for (int i = 0; i < gridMain.SelectedIndices.Count(); i++) { MultiAdjEntry selectedRow = (MultiAdjEntry)gridMain.Rows[gridMain.SelectedIndices[i]].Tag; if (selectedRow.Adj != null) //user selected an adjustment row { if (selectedRow.Proc == null) //unattached adjustment { _listGridEntries.Remove(selectedRow); continue; } _listGridEntries.RemoveAll(x => x.AdjustmentEntryNum == selectedRow.AdjustmentEntryNum); //Should only be one, but will clean up accidental duplicates if a bug occurs } } butAdd.Enabled = true; FillGrid(); }
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(); }
///<summary>This method converts the AccountEntry objects we get back from AccountModules.GetListUnpaidAccountCharges() to MultiAdjEntry objects. ///These are used to fill the grid and do all relevant logic in this form. This method will return a fresh list of procedures and will not show ///any existing adjustments that may have been made in this form already. Called on load and when checkShowImplicit is clicked. ///When called from checkShowImplicit any existing adjustments made will not be shown.(Ask Andrew about this functionality)</summary> private List <MultiAdjEntry> FillListGridEntries(CreditCalcType calc) { //CONSIDER ANY CHANGES MADE HERE MAY ALSO NEED TO BE ADDED TO FormProcSelect. List <MultiAdjEntry> retVal = new List <MultiAdjEntry>(); #region Get required data List <Procedure> listProcedures = Procedures.GetCompleteForPats(new List <long> { _patCur.PatNum }); //Does not get charges for the future. List <PaySplit> listPaySplits = PaySplits.GetForPats(new List <long> { _patCur.PatNum }).Where(x => x.UnearnedType == 0).ToList(); List <Adjustment> listAdjustments = Adjustments.GetAdjustForPats(new List <long> { _patCur.PatNum }); //Might contain payplan payments. Do not include unearned. List <PayPlanCharge> listPayPlanCharges = PayPlanCharges.GetDueForPayPlans(PayPlans.GetForPats(null, _patCur.PatNum), _patCur.PatNum).ToList(); List <ClaimProc> listInsPayAsTotal = ClaimProcs.GetByTotForPats(new List <long> { _patCur.PatNum }); List <ClaimProc> listClaimProcs = ClaimProcs.GetForProcs(listProcedures.Select(x => x.ProcNum).ToList()); #endregion List <AccountEntry> listAccountCharges = AccountModules.GetListUnpaidAccountCharges(listProcedures, listAdjustments, listPaySplits, listClaimProcs , listPayPlanCharges, listInsPayAsTotal, calc, new List <PaySplit>()); List <AccountEntry> listAccountChargesIncludeAll = null; if (calc == CreditCalcType.ExcludeAll) { //We need to get all credits so that our AmtRemBefore can reflect what has truly been allocated to the procedure. listAccountChargesIncludeAll = AccountModules.GetListUnpaidAccountCharges(listProcedures, listAdjustments , listPaySplits, listClaimProcs, listPayPlanCharges, listInsPayAsTotal, CreditCalcType.IncludeAll, new List <PaySplit>()); } MultiAdjEntry multiEntry = null; foreach (AccountEntry entry in listAccountCharges) { //We only want AccountEntries that are completed procedures. if (entry.GetType() != typeof(ProcExtended)) { continue; } ProcExtended procEntry = (ProcExtended)entry.Tag; bool isProcSelectedInAccount = false; if (_listSelectedProcs != null && _listSelectedProcs.Any(x => x.ProcNum == procEntry.Proc.ProcNum)) { isProcSelectedInAccount = true; } if (calc == CreditCalcType.ExcludeAll) //show everything. Regardless of procs loading window or amount remaining. { double amtRemBefore = (double)(listAccountChargesIncludeAll?.FirstOrDefault(x => x.Tag.GetType() == typeof(ProcExtended) && ((ProcExtended)x.Tag).Proc.ProcNum == procEntry.Proc.ProcNum) ?? entry).AmountStart; multiEntry = new MultiAdjEntry(procEntry.Proc, (double)entry.AmountStart, (double)entry.AmountEnd, amtRemBefore); retVal.Add(multiEntry); } else if (calc.In(CreditCalcType.IncludeAll, CreditCalcType.AllocatedOnly) && (entry.AmountEnd != 0 || isProcSelectedInAccount)) { //Unpaid procedures should always show per Nathan. If proc was specifically selected before entering window, show it anyways. multiEntry = new MultiAdjEntry(procEntry.Proc, (double)entry.AmountStart, (double)entry.AmountEnd, (double)entry.AmountStart); retVal.Add(multiEntry); } } OrderListGridEntries(); return(retVal); }