///<summary>When a charge is selected this method highlights all paysplits associated with it.</summary>
        private void gridCharges_CellClick(object sender, ODGridClickEventArgs e)
        {
            //Charge total text set here
            List <Tuple <long, long, long> > listAddedParents = new List <Tuple <long, long, long> >();//Prov/Clinic/Pat

            gridSplits.SetSelected(false);
            decimal chargeTotal = 0;

            foreach (GridRow row in gridCharges.SelectedGridRows)
            {
                AccountEntry accountEntry = (AccountEntry)row.Tag;
                if (accountEntry.Tag == null)               //Parent row
                {
                    chargeTotal += PIn.Decimal(row.Cells[row.Cells.Count - 1].Text);
                    listAddedParents.Add(Tuple.Create(accountEntry.ProvNum, accountEntry.ClinicNum, accountEntry.PatNum));
                    continue;
                }
                else
                {
                    for (int j = 0; j < gridSplits.ListGridRows.Count; j++)
                    {
                        PaySplit paySplit = (PaySplit)gridSplits.ListGridRows[j].Tag;
                        if (accountEntry.SplitCollection.Contains(paySplit))
                        {
                            gridSplits.SetSelected(j, true);
                        }
                        if (accountEntry.GetType() == typeof(PayPlanCharge) && paySplit.PayPlanNum == ((PayPlanCharge)accountEntry.Tag).PayPlanNum)
                        {
                            gridSplits.SetSelected(j, true);
                        }
                    }
                    if (!listAddedParents.Exists(x => x.Item1 == accountEntry.ProvNum && x.Item2 == accountEntry.ClinicNum && x.Item3 == accountEntry.PatNum))               //In case a parent AND child are selected, don't add child amounts if parent was added already
                    {
                        chargeTotal += accountEntry.AmountEnd;
                    }
                }
            }
            textChargeTotal.Text = chargeTotal.ToString("F");
        }
Beispiel #2
0
		///<summary>Creates a split similar to how CreateSplitsForPayment does it, but with selected rows of the grid.  If payAmt=0, pay charge in full.</summary>
		private void CreateSplit(AccountEntry charge,double payAmt) {
			PaySplit split=new PaySplit();
			split.DatePay=DateTime.Today;
			if(charge.GetType()==typeof(Procedure)) {//Row selected is a Procedure.
				Procedure proc=(Procedure)charge.Tag;
				split.ProcNum=charge.PriKey;
			}
			else if(charge.GetType()==typeof(PayPlanCharge)) {//Row selected is a PayPlanCharge.
				PayPlanCharge payPlanCharge=(PayPlanCharge)charge.Tag;
				split.PayPlanNum=payPlanCharge.PayPlanNum;
			}
			else if(charge.Tag.GetType()==typeof(Adjustment)) {//Row selected is an Adjustment.
				//Do nothing, nothing to link.
			}
			else {//PaySplits and overpayment refunds.
				//Do nothing, nothing to link.
			}
			double chargeAmt=charge.AmountEnd;
			if(Math.Abs(chargeAmt)<Math.Abs(payAmt) || payAmt==0) {//Full payment of charge
				split.SplitAmt=chargeAmt;
				charge.AmountEnd=0;//Reflect payment in underlying datastructure
			}
			else {//Partial payment of charge
				charge.AmountEnd-=payAmt;
				split.SplitAmt=payAmt;
			}
			if(!PrefC.GetBool(PrefName.EasyNoClinics)) {//Not no clinics
				split.ClinicNum=charge.ClinicNum;
			}
			split.ProvNum=charge.ProvNum;
			split.PatNum=charge.PatNum;
			split.ProcDate=charge.Date;
			split.PayNum=PaymentCur.PayNum;
			charge.ListPaySplits.Add(split);
			ListSplitsCur.Add(split);
		}
Beispiel #3
0
 ///<summary>Links charges to credits explicitly based on FKs first, then implicitly based on Date.</summary>
 private void LinkChargesToCredits()
 {
     #region Explicit
     for (int i = 0; i < _listAccountCharges.Count; i++)
     {
         AccountEntry charge = _listAccountCharges[i];
         for (int j = 0; j < _listPaySplits.Count; j++)
         {
             PaySplit paySplit    = _listPaySplits[j];
             decimal  paySplitAmt = (decimal)paySplit.SplitAmt;
             //Procedures that were being paid on through this payment plan should not get removed from this grid, even if they are fully paid off.
             if (charge.GetType() == typeof(Procedure) &&
                 paySplit.ProcNum == charge.PriKey &&
                 (paySplit.PayPlanNum == 0 || paySplit.PayPlanNum != _payPlanCur.PayPlanNum))
             {
                 charge.ListPaySplits.Add(paySplit);
                 charge.AmountEnd   -= paySplitAmt;
                 _accountCredits    -= paySplitAmt;
                 charge.AmountStart -= paySplitAmt;
             }
             else if (charge.GetType() == typeof(PayPlanCharge) && ((PayPlanCharge)charge.Tag).PayPlanNum == paySplit.PayPlanNum && charge.AmountEnd > 0 && paySplit.SplitAmt > 0)
             {
                 charge.AmountEnd -= paySplitAmt;
                 _accountCredits  -= paySplitAmt;
             }
         }
         for (int j = 0; j < _listAdjustments.Count; j++)
         {
             Adjustment adjustment    = _listAdjustments[j];
             decimal    adjustmentAmt = (decimal)adjustment.AdjAmt;
             if (charge.GetType() == typeof(Procedure) && adjustment.ProcNum == charge.PriKey)
             {
                 charge.AmountEnd += adjustmentAmt;
                 if (adjustment.AdjAmt < 0)
                 {
                     _accountCredits += adjustmentAmt;
                 }
                 charge.AmountStart += adjustmentAmt;
                 //If the adjustment is attached to a procedure decrease the procedure's amountoriginal so we know what it was just prior to autosplitting.
             }
         }
         for (int j = 0; j < _listPayPlanCharges.Count; j++)
         {
             PayPlanCharge payPlanCharge = _listPayPlanCharges[j];
             if (charge.GetType() == typeof(Procedure) && payPlanCharge.ProcNum == charge.PriKey)                  //payPlanCharge.ProcNum will only be set for credits.
             {
                 charge.AmountEnd   -= (decimal)payPlanCharge.Principal;
                 charge.AmountStart -= (decimal)payPlanCharge.Principal;
                 _accountCredits    -= (decimal)payPlanCharge.Principal;
             }
         }
         //Credits for the current payment plan don't get linked here, they get linked on the grid (Above)
         //for(int j = 0;j < ListPayPlanCreditsCur.Count;j++) {
         //	PayPlanCharge payPlanCharge=ListPayPlanCreditsCur[j];
         //	if(charge.GetType()==typeof(Procedure) && payPlanCharge.ProcNum == charge.PriKey) {
         //		charge.AmountEnd-=(decimal)payPlanCharge.Principal;
         //		charge.AmountStart-=(decimal)payPlanCharge.Principal;
         //		_accountCredits-=(decimal)payPlanCharge.Principal;
         //	}
         //}
         //
         //claimprocs explicitly linked to the procedures for this patient.
         for (int j = 0; j < _listClaimProcs.Count; j++)
         {
             ClaimProc claimProcCur = _listClaimProcs[j];
             if (charge.GetType() != typeof(Procedure) || claimProcCur.ProcNum != charge.PriKey)
             {
                 continue;
             }
             decimal amt = 0;
             if ((claimProcCur.Status == ClaimProcStatus.Estimate || claimProcCur.Status == ClaimProcStatus.NotReceived))
             {
                 //Estimated Payment
                 amt = (decimal)claimProcCur.InsEstTotal;
                 if (claimProcCur.InsEstTotalOverride != -1)
                 {
                     amt = (decimal)claimProcCur.InsEstTotalOverride;
                 }
                 charge.AmountEnd   -= amt;
                 charge.AmountStart -= amt;
                 //Estimated Writeoff
                 amt = 0;
                 if (claimProcCur.WriteOffEstOverride != -1)
                 {
                     amt = (decimal)claimProcCur.WriteOffEstOverride;
                 }
                 else if (claimProcCur.WriteOffEst != -1)
                 {
                     amt = (decimal)claimProcCur.WriteOffEst;
                 }
                 charge.AmountEnd   -= amt;
                 charge.AmountStart -= amt;
             }
             else if (claimProcCur.Status == ClaimProcStatus.Received || claimProcCur.Status == ClaimProcStatus.Supplemental ||
                      claimProcCur.Status == ClaimProcStatus.CapClaim || claimProcCur.Status == ClaimProcStatus.CapComplete)
             {
                 //actual payment and actual writeoff.
                 amt = (decimal)claimProcCur.InsPayAmt + (decimal)claimProcCur.WriteOff;
                 charge.AmountEnd   -= amt;
                 charge.AmountStart -= amt;
             }
         }
     }
     #endregion Explicit
     //Apply negative charges as if they're credits.
     for (int i = 0; i < _listAccountCharges.Count; i++)
     {
         AccountEntry entryCharge = _listAccountCharges[i];
         if (entryCharge.AmountEnd < 0)
         {
             _accountCredits      -= entryCharge.AmountEnd;
             entryCharge.AmountEnd = 0;
         }
     }
     #region Implicit
     //Now we have a date-sorted list of all the unpaid charges as well as all non-attributed credits.
     //We need to go through each and pay them off in order until all we have left is the most recent unpaid charges.
     for (int i = 0; i < _listAccountCharges.Count && _accountCredits > 0; i++)
     {
         AccountEntry charge = _listAccountCharges[i];
         decimal      amt    = Math.Min(charge.AmountEnd, _accountCredits);
         charge.AmountEnd   -= amt;
         _accountCredits    -= amt;
         charge.AmountStart -= amt;              //Decrease amount original for the charge so we know what it was just prior to when the autosplits were made.
     }
     #endregion Implicit
 }