private void butPaySupp_Click(object sender, System.EventArgs e) {
			if(!Security.IsAuthorized(Permissions.InsPayCreate)){//date not checked here, but it will be checked when actually creating the check
				return;
			}
			if(gridProc.SelectedIndices.Length==0){
				MessageBox.Show(Lan.g(this,"This is only for additional payments on procedures already marked received.  Please highlight procedures first."));
				return;
			}
			bool allAreRecd=true;
			for(int i=0;i<gridProc.SelectedIndices.Length;i++){
				if(ClaimProcsForClaim[gridProc.SelectedIndices[i]].Status!=ClaimProcStatus.Received)
					allAreRecd=false;
			}
			if(!allAreRecd){
				MessageBox.Show(Lan.g(this,"All selected procedures must be status received."));
				return;
			} 
			List<ClaimProc> cpList=new List<ClaimProc>();
			for(int i=0;i<gridProc.SelectedIndices.Length;i++){
				ClaimProc ClaimProcCur=ClaimProcsForClaim[gridProc.SelectedIndices[i]];
				ClaimProcCur.FeeBilled=0;
				ClaimProcCur.ClaimPaymentNum=0;//no payment attached
				//claimprocnum will be overwritten
				ClaimProcCur.DedApplied=0;
				ClaimProcCur.InsPayAmt=0;
				ClaimProcCur.InsPayEst=0;
				ClaimProcCur.Remarks="";
				ClaimProcCur.Status=ClaimProcStatus.Supplemental;
				ClaimProcCur.WriteOff=0;
				ClaimProcCur.DateCP=DateTimeOD.Today;
				ClaimProcCur.DateEntry=DateTimeOD.Today;
				ClaimProcs.Insert(ClaimProcCur);//this inserts a copy of the original with the changes as above.
				cpList.Add(ClaimProcCur);
			}
			FormClaimPayTotal FormCPT=new FormClaimPayTotal(PatCur,FamCur,PlanList,PatPlanList,SubList);
			FormCPT.ClaimProcsToEdit=cpList.ToArray();
			FormCPT.ShowDialog();
			if(FormCPT.DialogResult!=DialogResult.OK) {
				//ClaimProcs were inserted already, refresh the list to reflect the new entries.
				ClaimProcList=ClaimProcs.Refresh(PatCur.PatNum);
				FillGrids();
				return;
			}
			//save changes now
			for(int i=0;i<FormCPT.ClaimProcsToEdit.Length;i++) {
				ClaimProcs.Update(FormCPT.ClaimProcsToEdit[i]);
			}
//fix: need to debug the recalculation feature to take this status into account.
			ClaimProcList=ClaimProcs.Refresh(PatCur.PatNum);
			FillGrids();
		}
		private void butPayProc_Click(object sender, System.EventArgs e) {
			if(!Security.IsAuthorized(Permissions.InsPayCreate)){//date not checked here, but it will be checked when actually creating the check
				return;
			}
			//this will work for regular claims and for preauths.
			//it will enter edit mode if it can only find received procs not attached to payments yet.
			if(gridProc.SelectedIndices.Length==0){
				//first, autoselect rows if not received:
				for(int i=0;i<ClaimProcsForClaim.Count;i++){
					if(ClaimProcsForClaim[i].Status==ClaimProcStatus.NotReceived
						&& ClaimProcsForClaim[i].ProcNum>0){//and is procedure
						gridProc.SetSelected(i,true);
					}
				}
			}
			if(gridProc.SelectedIndices.Length==0){
				//then, autoselect rows if not paid on:
				for(int i=0;i<ClaimProcsForClaim.Count;i++){
					if(ClaimProcsForClaim[i].ClaimPaymentNum==0
						&& ClaimProcsForClaim[i].ProcNum>0){//and is procedure
						gridProc.SetSelected(i,true);
					}
				}
			}
			if(gridProc.SelectedIndices.Length==0){
				//if still no rows selected
				MessageBox.Show(Lan.g(this,"All procedures in the list have already been paid."));
				return;
			}
			bool allAreProcs=true;
			for(int i=0;i<gridProc.SelectedIndices.Length;i++){
				if(ClaimProcsForClaim[gridProc.SelectedIndices[i]].ProcNum==0)
					allAreProcs=false;
			}
			if(!allAreProcs){
				MessageBox.Show(Lan.g(this,"You can only select procedures."));
				return;
			}
			for(int i=0;i<gridProc.SelectedIndices.Length;i++) {
				if(ClaimProcsForClaim[gridProc.SelectedIndices[i]].ClaimPaymentNum!=0) {//if attached to a check
					MessageBox.Show(Lan.g(this,"Procedures that are attached to checks cannot be included."));
					return;
				}
			}
			for(int i=0;i<gridProc.SelectedIndices.Length;i++) {
				if(ClaimProcsForClaim[gridProc.SelectedIndices[i]].Status==ClaimProcStatus.Received
					|| ClaimProcsForClaim[gridProc.SelectedIndices[i]].Status==ClaimProcStatus.Supplemental
					|| ClaimProcsForClaim[gridProc.SelectedIndices[i]].Status==ClaimProcStatus.CapComplete) 
				{
					MessageBox.Show(Lan.g(this,"Procedures that are already received cannot be included."));
					//This expanded security prevents making changes to historical entries of zero with a writeoff.
					return;
				}
			}
			List<ClaimProc> cpList=new List<ClaimProc>();
			for(int i=0;i<gridProc.SelectedIndices.Length;i++) {
				//copy selected claimprocs to temporary array for editing.
				//no changes to the database will be made within that form.
				cpList.Add(ClaimProcsForClaim[gridProc.SelectedIndices[i]].Copy());
				if(ClaimCur.ClaimType=="PreAuth"){
					cpList[i].Status=ClaimProcStatus.Preauth;
				}
				else if(ClaimCur.ClaimType=="Cap"){
					;//do nothing.  The claimprocstatus will remain Capitation.
				}
				else{
					cpList[i].Status=ClaimProcStatus.Received;
					cpList[i].DateEntry=DateTime.Now;//date is was set rec'd
					cpList[i].InsPayAmt=cpList[i].InsPayEst;
				}
				cpList[i].DateCP=DateTimeOD.Today;
			}
			if(ClaimCur.ClaimType=="PreAuth") {
				FormClaimPayPreAuth FormCPP=new FormClaimPayPreAuth(PatCur,FamCur,PlanList,PatPlanList,SubList);
				FormCPP.ClaimProcsToEdit=cpList;
				FormCPP.ShowDialog();
				if(FormCPP.DialogResult!=DialogResult.OK) {
					return;
				}
				//save changes now
				for(int i=0;i<FormCPP.ClaimProcsToEdit.Count;i++) {
					ClaimProcs.Update(FormCPP.ClaimProcsToEdit[i]);
					ClaimProcs.SetInsEstTotalOverride(FormCPP.ClaimProcsToEdit[i].ProcNum,FormCPP.ClaimProcsToEdit[i].PlanNum,
						FormCPP.ClaimProcsToEdit[i].InsPayEst,ClaimProcList);
				}
			}
			else {
				FormClaimPayTotal FormCPT=new FormClaimPayTotal(PatCur,FamCur,PlanList,PatPlanList,SubList);
				FormCPT.ClaimProcsToEdit=cpList.ToArray();
				FormCPT.ShowDialog();
				if(FormCPT.DialogResult!=DialogResult.OK){
					return;
				}
				//save changes now
				for(int i=0;i<FormCPT.ClaimProcsToEdit.Length;i++){
					ClaimProcs.Update(FormCPT.ClaimProcsToEdit[i]);
				}
			}
			comboClaimStatus.SelectedIndex=5;//Received
			if(textDateRec.Text==""){
				textDateRec.Text=DateTime.Today.ToShortDateString();
			}
			ClaimProcList=ClaimProcs.Refresh(PatCur.PatNum);
			FillGrids();
		}