Esempio n. 1
0
        ///<summary>Refreshes the list for the specified guarantor, and then determines if there are any valid plans with that patient as the guarantor.  If more than one valid payment plan, displays list to select from.  If any valid plans, then it returns that plan, else returns null.</summary>
        public static PayPlan GetValidPlan(int guarNum, bool isIns)
        {
            PayPlan[] PlanListAll = Refresh(guarNum, 0);
            PayPlan[] PayPlanList = GetListOneType(PlanListAll, isIns);
            if (PayPlanList.Length == 0)
            {
                return(null);
            }
            if (PayPlanList.Length == 1)           //if there is only one valid payplan
            {
                return(PayPlanList[0].Copy());
            }
            PayPlanCharge[] ChargeList = PayPlanCharges.Refresh(guarNum);
            //enhancement needed to weed out payment plans that are all paid off
            //more than one valid PayPlan
            FormPayPlanSelect FormPPS = new FormPayPlanSelect(PayPlanList, ChargeList);

            FormPPS.ShowDialog();
            if (FormPPS.DialogResult == DialogResult.OK)
            {
                return(PayPlanList[FormPPS.IndexSelected].Copy());
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
 private void checkPayPlan_Click(object sender, System.EventArgs e)
 {
     if (checkPayPlan.Checked)
     {
         if (checkPatOtherFam.Checked)                //prevents a bug.
         {
             checkPayPlan.Checked = false;
             return;
         }
         PayPlan[] planListAll = PayPlans.Refresh(FamCur.List[listPatient.SelectedIndex].PatNum, 0);
         PayPlan[] payPlanList = PayPlans.GetListOneType(planListAll, false);
         if (payPlanList.Length == 0)              //no valid plans
         {
             MsgBox.Show(this, "The selected patient is not the guarantor for any payment plans.");
             checkPayPlan.Checked = false;
             return;
         }
         if (payPlanList.Length == 1)               //if there is only one valid payplan
         {
             PaySplitCur.PayPlanNum = payPlanList[0].PayPlanNum;
             return;
         }
         //more than one valid PayPlan
         PayPlanCharge[]   chargeList = PayPlanCharges.Refresh(FamCur.List[listPatient.SelectedIndex].PatNum);
         FormPayPlanSelect FormPPS    = new FormPayPlanSelect(payPlanList, chargeList);
         //FormPPS.ValidPlans=payPlanList;
         FormPPS.ShowDialog();
         if (FormPPS.DialogResult == DialogResult.Cancel)
         {
             checkPayPlan.Checked = false;
             return;
         }
         PaySplitCur.PayPlanNum = payPlanList[FormPPS.IndexSelected].PayPlanNum;
     }
     else             //payPlan unchecked
     {
         PaySplitCur.PayPlanNum = 0;
     }
 }
Esempio n. 3
0
 private void checkPayPlan_Click(object sender, System.EventArgs e)
 {
     if(checkPayPlan.Checked){
         if(checkPatOtherFam.Checked){//prevents a bug.
             checkPayPlan.Checked=false;
             return;
         }
         //PayPlan[] planListAll=PayPlans.Refresh(FamCur.List[listPatient.SelectedIndex].PatNum,0);
         List<PayPlan> payPlanList=PayPlans.GetValidPlansNoIns(FamCur.ListPats[listPatient.SelectedIndex].PatNum);
         if(payPlanList.Count==0){//no valid plans
             MsgBox.Show(this,"The selected patient is not the guarantor for any payment plans.");
             checkPayPlan.Checked=false;
             return;
         }
         if(payPlanList.Count==1){ //if there is only one valid payplan
             PaySplitCur.PayPlanNum=payPlanList[0].PayPlanNum;
             return;
         }
         //more than one valid PayPlan
         List<PayPlanCharge> chargeList=PayPlanCharges.Refresh(FamCur.ListPats[listPatient.SelectedIndex].PatNum);
         FormPayPlanSelect FormPPS=new FormPayPlanSelect(payPlanList,chargeList);
         //FormPPS.ValidPlans=payPlanList;
         FormPPS.ShowDialog();
         if(FormPPS.DialogResult==DialogResult.Cancel){
             checkPayPlan.Checked=false;
             return;
         }
         PaySplitCur.PayPlanNum=payPlanList[FormPPS.IndexSelected].PayPlanNum;
     }
     else{//payPlan unchecked
         PaySplitCur.PayPlanNum=0;
     }
 }
Esempio n. 4
0
 private void FormPayment_Load(object sender,System.EventArgs e)
 {
     if(IsNew) {
         checkPayTypeNone.Enabled=true;
         if(!Security.IsAuthorized(Permissions.PaymentCreate)) {//date not checked here
             DialogResult=DialogResult.Cancel;
             return;
         }
     }
     else {
         checkPayTypeNone.Enabled=false;
         checkRecurring.Checked=PaymentCur.IsRecurringCC;
         if(!Security.IsAuthorized(Permissions.PaymentEdit,PaymentCur.PayDate)) {
             butOK.Enabled=false;
             butDeleteAll.Enabled=false;
             butAdd.Enabled=false;
             gridMain.Enabled=false;
             butPay.Enabled=false;
             checkRecurring.Enabled=false;
         }
     }
     if(PrefC.GetBool(PrefName.EasyNoClinics)) {
         comboClinic.Visible=false;
         labelClinic.Visible=false;
     }
     else {
         comboClinic.Items.Clear();
         comboClinic.Items.Add(Lan.g(this,"none"));
         comboClinic.SelectedIndex=0;
         for(int i=0;i<Clinics.List.Length;i++) {
             comboClinic.Items.Add(Clinics.List[i].Description);
             if(Clinics.List[i].ClinicNum==PaymentCur.ClinicNum) {
                 comboClinic.SelectedIndex=i+1;
             }
         }
     }
     creditCards=CreditCards.Refresh(PatCur.PatNum);
     for(int i=0;i<creditCards.Count;i++) {
         comboCreditCards.Items.Add(creditCards[i].CCNumberMasked);
     }
     comboCreditCards.Items.Add("New card");
     comboCreditCards.SelectedIndex=0;
     tableBalances=Patients.GetPaymentStartingBalances(PatCur.Guarantor,PaymentCur.PayNum);
     //this works even if patient not in family
     textPaidBy.Text=FamCur.GetNameInFamFL(PaymentCur.PatNum);
     textDateEntry.Text=PaymentCur.DateEntry.ToShortDateString();
     textDate.Text=PaymentCur.PayDate.ToShortDateString();
     textAmount.Text=PaymentCur.PayAmt.ToString("F");
     textCheckNum.Text=PaymentCur.CheckNum;
     textBankBranch.Text=PaymentCur.BankBranch;
     for(int i=0;i<DefC.Short[(int)DefCat.PaymentTypes].Length;i++) {
         listPayType.Items.Add(DefC.Short[(int)DefCat.PaymentTypes][i].ItemName);
         if(DefC.Short[(int)DefCat.PaymentTypes][i].DefNum==PaymentCur.PayType) {
             listPayType.SelectedIndex=i;
         }
     }
     if(PaymentCur.PayType==0) {
         checkPayTypeNone.Checked=true;
     }
     //if(listPayType.SelectedIndex==-1) {
     //	listPayType.SelectedIndex=0;
     //}
     textNote.Text=PaymentCur.PayNote;
     if(PaymentCur.DepositNum==0) {
         labelDeposit.Visible=false;
         textDeposit.Visible=false;
     }
     else {
         textDeposit.Text=Deposits.GetOne(PaymentCur.DepositNum).DateDeposit.ToShortDateString();
         textAmount.ReadOnly=true;
         textAmount.BackColor=SystemColors.Control;
         butPay.Enabled=false;
     }
     SplitList=PaySplits.GetForPayment(PaymentCur.PayNum);//Count might be 0
     SplitListOld=new List<PaySplit>();
     //SplitListOld.AddRange(SplitList);//Do NOT do this.  It's a shallow copy only.  Not what we want.
     for(int i=0;i<SplitList.Count;i++) {
         SplitListOld.Add(SplitList[i].Copy());
     }
     if(IsNew) {
         List<PayPlan> payPlanList=PayPlans.GetValidPlansNoIns(PatCur.PatNum);
         if(payPlanList.Count==0) {
             //
         }
         else if(payPlanList.Count==1) { //if there is only one valid payplan
             if(!PayPlans.PlanIsPaidOff(payPlanList[0].PayPlanNum)) {
                 AddOneSplit();//the amount and date will be updated upon closing
                 SplitList[SplitList.Count-1].PayPlanNum=payPlanList[0].PayPlanNum;
             }
         }
         else {
             List<PayPlanCharge> chargeList=PayPlanCharges.Refresh(PatCur.PatNum);
             //enhancement needed to weed out payment plans that are all paid off
             //more than one valid PayPlan
             FormPayPlanSelect FormPPS=new FormPayPlanSelect(payPlanList,chargeList);
             FormPPS.ShowDialog();
             if(FormPPS.DialogResult==DialogResult.OK) {
                 //return PayPlanList[FormPPS.IndexSelected].Clone();
                 AddOneSplit();//the amount and date will be updated upon closing
                 SplitList[SplitList.Count-1].PayPlanNum=payPlanList[FormPPS.IndexSelected].PayPlanNum;
             }
         }
         /*
         PayPlan payPlanCur=GetValidPlan(PatCur.PatNum,false);// PayPlans.GetValidPlan(PatCur.PatNum,false);
         if(payPlanCur!=null) {//a valid payPlan was located
             AddOneSplit();//the amount and date will be updated upon closing
             SplitList[SplitList.Count-1].PayPlanNum=payPlanCur.PayPlanNum;
         }*/
     }
     FillMain();
     if(InitialPaySplit!=0) {
         for(int i=0;i<SplitList.Count;i++) {
             if(InitialPaySplit==SplitList[i].SplitNum) {
                 gridMain.SetSelected(i,true);
             }
         }
     }
     if(IsNew) {
         //Fill comboDepositAccount based on autopay for listPayType.SelectedIndex
         SetComboDepositAccounts();
         textDepositAccount.Visible=false;
     }
     else {
         //put a description in the textbox.  If the user clicks on the same or another item in listPayType,
         //then the textbox will go away, and be replaced by comboDepositAccount.
         labelDepositAccount.Visible=false;
         comboDepositAccount.Visible=false;
         Transaction trans=Transactions.GetAttachedToPayment(PaymentCur.PayNum);
         if(trans==null) {
             textDepositAccount.Visible=false;
         }
         else {
             //add only the description based on PaymentCur attached to transaction
             List<JournalEntry> jeL=JournalEntries.GetForTrans(trans.TransactionNum);
             for(int i=0;i<jeL.Count;i++) {
                 if(Accounts.GetAccount(jeL[i].AccountNum).AcctType==AccountType.Asset) {
                     textDepositAccount.Text=jeL[i].DateDisplayed.ToShortDateString();
                     if(jeL[i].DebitAmt>0) {
                         textDepositAccount.Text+=" "+jeL[i].DebitAmt.ToString("c");
                     }
                     else {//negative
                         textDepositAccount.Text+=" "+(-jeL[i].CreditAmt).ToString("c");
                     }
                     break;
                 }
             }
         }
     }
     CheckUIState();
 }
Esempio n. 5
0
 private void checkPayPlan_Click(object sender,System.EventArgs e)
 {
     //*****if there is more than one split, then this checkbox is not even available.
     if(SplitList.Count==0) {
         AddOneSplit();//won't use returned value
         FillMain();
         checkPayPlan.Checked=true;
         //now there is exactly one.  The amount will be updated as the form closes.
     }
     if(checkPayPlan.Checked) {
         //PayPlan payPlanCur=PayPlans.GetValidPlan(SplitList[0].PatNum);
         List<PayPlan> payPlanList=PayPlans.GetValidPlansNoIns(SplitList[0].PatNum);
         if(payPlanList.Count==0) {
             MsgBox.Show(this,"The selected patient is not the guarantor for any payment plans.");
             checkPayPlan.Checked=false;
             return;
         }
         else if(payPlanList.Count==1) { //if there is only one valid payplan
             SplitList[0].PayPlanNum=payPlanList[0].PayPlanNum;
         }
         else {//multiple valid plans
             List<PayPlanCharge> chargeList=PayPlanCharges.Refresh(SplitList[0].PatNum);
             //enhancement needed to weed out payment plans that are all paid off
             //more than one valid PayPlan
             FormPayPlanSelect FormPPS=new FormPayPlanSelect(payPlanList,chargeList);
             FormPPS.ShowDialog();
             if(FormPPS.DialogResult==DialogResult.OK) {
                 SplitList[0].PayPlanNum=payPlanList[FormPPS.IndexSelected].PayPlanNum;
             }
             else {
                 checkPayPlan.Checked=false;
                 return;
             }
         }
         /*
         if(payPlanCur==null){//no valid plans
             MsgBox.Show(this,"The selected patient is not the guarantor for any payment plans.");
             checkPayPlan.Checked=false;
             return;
         }
         SplitList[0].PayPlanNum=payPlanCur.PayPlanNum;*/
     }
     else {//payPlan unchecked
         SplitList[0].PayPlanNum=0;
     }
     FillMain();
 }
Esempio n. 6
0
		private void checkPayPlan_Click(object sender,EventArgs e) {
			if(checkPayPlan.Checked) {
				List<PayPlan> payPlanList=PayPlans.GetValidInsPayPlans(ClaimProcCur.PatNum,ClaimProcCur.PlanNum,ClaimProcCur.InsSubNum,ClaimProcCur.ClaimNum);
				if(payPlanList.Count==0) {//no valid plans
					MsgBox.Show(this,"The patient does not have a valid payment plan with this insurance plan attached that has not been paid in full and is not tracking expected payments for an existing claim already.");
					checkPayPlan.Checked=false;
					return;
				}
				if(payPlanList.Count==1) { //if there is only one valid payplan
					ClaimProcCur.PayPlanNum=payPlanList[0].PayPlanNum;
					return;
				}
				//more than one valid PayPlan
				List<PayPlanCharge> chargeList=PayPlanCharges.Refresh(ClaimProcCur.PatNum);
				FormPayPlanSelect FormPPS=new FormPayPlanSelect(payPlanList,chargeList);
				FormPPS.ShowDialog();
				if(FormPPS.DialogResult==DialogResult.Cancel) {
					checkPayPlan.Checked=false;
					return;
				}
				ClaimProcCur.PayPlanNum=payPlanList[FormPPS.IndexSelected].PayPlanNum;
			}
			else {//payPlan unchecked
				ClaimProcCur.PayPlanNum=0;
			}
		}
Esempio n. 7
0
		///<summary>Enter either by total and/or by procedure, depending on whether or not procedure detail was provided in the 835 for this claim.
		///This function creates the payment claimprocs and displays the payment entry window.</summary>
		public static void EnterPayment(Hx835_Claim claimPaid,Claim claim,bool isAutomatic) {
			Patient pat=Patients.GetPat(claim.PatNum);
			Family fam=Patients.GetFamily(claim.PatNum);
			List<InsSub> listInsSubs=InsSubs.RefreshForFam(fam);
			List<InsPlan> listInsPlans=InsPlans.RefreshForSubList(listInsSubs);
			List<PatPlan> listPatPlans=PatPlans.Refresh(claim.PatNum);
			List<ClaimProc> listClaimProcsForClaim=ClaimProcs.RefreshForClaim(claim.ClaimNum);
			ClaimProc cpByTotal=new ClaimProc();
			cpByTotal.DedApplied=(double)claimPaid.PatientPortion;
			cpByTotal.AllowedOverride=(double)claimPaid.AllowedAmt;
			cpByTotal.InsPayAmt=(double)claimPaid.InsPaid;
			cpByTotal.WriteOff=(double)claimPaid.Writeoff;
			List<ClaimProc> listClaimProcsToEdit=new List<ClaimProc>();
			//Automatically set PayPlanNum if there is a payplan with matching PatNum, PlanNum, and InsSubNum that has not been paid in full.
			long insPayPlanNum=0;
			if(claim.ClaimType!="PreAuth" && claim.ClaimType!="Cap") {//By definition, capitation insurance pays in one lump-sum, not over an extended period of time.
				//By sending in ClaimNum, we ensure that we only get the payplan a claimproc from this claim was already attached to or payplans with no claimprocs attached.
				List<PayPlan> listPayPlans=PayPlans.GetValidInsPayPlans(claim.PatNum,claim.PlanNum,claim.InsSubNum,claim.ClaimNum);
				if(listPayPlans.Count==1) {
					insPayPlanNum=listPayPlans[0].PayPlanNum;
				}
				else if(listPayPlans.Count>1 && !isAutomatic) {
					//More than one valid PayPlan.  Cannot show this prompt when entering automatically, because it would disrupt workflow.
					List<PayPlanCharge> listPayPlanCharges=PayPlanCharges.Refresh(claim.PatNum);
					FormPayPlanSelect FormPPS=new FormPayPlanSelect(listPayPlans,listPayPlanCharges);
					FormPPS.ShowDialog();
					if(FormPPS.DialogResult==DialogResult.OK) {
						insPayPlanNum=listPayPlans[FormPPS.IndexSelected].PayPlanNum;
					}
				}
			}
			//Choose the claimprocs which are not received.
			for(int i=0;i<listClaimProcsForClaim.Count;i++) {
				if(listClaimProcsForClaim[i].ProcNum==0) {//Exclude any "by total" claimprocs.  Choose claimprocs for procedures only.
					continue;
				}
				if(listClaimProcsForClaim[i].Status!=ClaimProcStatus.NotReceived) {//Ignore procedures already received.
					continue;
				}
				listClaimProcsToEdit.Add(listClaimProcsForClaim[i]);//Procedures not yet received.
			}
			//If all claimprocs are received, then choose claimprocs if not paid on.
			if(listClaimProcsToEdit.Count==0) {
				for(int i=0;i<listClaimProcsForClaim.Count;i++) {
					if(listClaimProcsForClaim[i].ProcNum==0) {//Exclude any "by total" claimprocs.  Choose claimprocs for procedures only.
						continue;
					}
					if(listClaimProcsForClaim[i].ClaimPaymentNum!=0) {//Exclude claimprocs already paid.
						continue;
					}
					listClaimProcsToEdit.Add(listClaimProcsForClaim[i]);//Procedures not paid yet.
				}
			}
			//For each NotReceived/unpaid procedure on the claim where the procedure information can be successfully located on the EOB, enter the payment information.
			List <List <Hx835_Proc>> listProcsForClaimProcs=claimPaid.GetPaymentsForClaimProcs(listClaimProcsToEdit);
			for(int i=0;i<listClaimProcsToEdit.Count;i++) {
				ClaimProc claimProc=listClaimProcsToEdit[i];
				List<Hx835_Proc> listProcsForProcNum=listProcsForClaimProcs[i];
				//If listProcsForProcNum.Count==0, then procedure payment details were not not found for this one specific procedure.
				//This can happen with procedures from older 837s, when we did not send out the procedure identifiers, in which case ProcNum would be 0.
				//Since we cannot place detail on the service line, we will leave the amounts for the procedure on the total payment line.
				//If listProcsForPorcNum.Count==1, then we know that the procedure was adjudicated as is or it might have been bundled, but we treat both situations the same way.
				//The 835 is required to include one line for each bundled procedure, which gives is a direct manner in which to associate each line to its original procedure.
				//If listProcForProcNum.Count > 1, then the procedure was either split or unbundled when it was adjudicated by the payer.
				//We will not bother to modify the procedure codes on the claim, because the user can see how the procedure was split or unbunbled by viewing the 835 details.
				//Instead, we will simply add up all of the partial payment lines for the procedure, and report the full payment amount on the original procedure.
				claimProc.DedApplied=0;
				claimProc.AllowedOverride=0;
				claimProc.InsPayAmt=0;
				claimProc.WriteOff=0;
				StringBuilder sb=new StringBuilder();
				for(int j=0;j<listProcsForProcNum.Count;j++) {
					Hx835_Proc procPaidPartial=listProcsForProcNum[j];
					claimProc.DedApplied+=(double)procPaidPartial.PatientPortion;
					claimProc.AllowedOverride+=(double)procPaidPartial.AllowedAmt;
					claimProc.InsPayAmt+=(double)procPaidPartial.InsPaid;
					claimProc.WriteOff+=(double)procPaidPartial.Writeoff;
					if(sb.Length>0) {
						sb.Append("\r\n");
					}
					sb.Append(procPaidPartial.GetRemarks());
				}
				claimProc.Remarks=sb.ToString();
				if(claim.ClaimType=="PreAuth") {
					claimProc.Status=ClaimProcStatus.Preauth;
				}
				else if(claim.ClaimType=="Cap") {
					//Do nothing.  The claimprocstatus will remain Capitation.
				}
				else {
					claimProc.Status=ClaimProcStatus.Received;
					claimProc.DateEntry=DateTime.Now;//Date is was set rec'd
					claimProc.PayPlanNum=insPayPlanNum;//Payment plans do not exist for PreAuths or Capitation claims, by definition.
				}
				claimProc.DateCP=DateTimeOD.Today;
			}
			//Displace the procedure totals from the "by total" payment, since they have now been accounted for on the individual procedure lines.  Totals will not be affected if no procedure details could be located.
			//If a total payment was previously entered manually, this will subtract the existing total payment from the new total payment, causing the new total payment to be discarded below where zero amounts are checked.
			for(int i=0;i<listClaimProcsForClaim.Count;i++) {
				ClaimProc claimProc=listClaimProcsForClaim[i];
				cpByTotal.DedApplied-=claimProc.DedApplied;
				cpByTotal.AllowedOverride-=claimProc.AllowedOverride;
				cpByTotal.InsPayAmt-=claimProc.InsPayAmt;
				cpByTotal.WriteOff-=claimProc.WriteOff;
			}
			bool isByTotalIncluded=true;
			//Do not create a total payment if the payment contains all zero amounts, because it would not be useful.  Written to account for potential rounding errors in the amounts.
			if(Math.Round(cpByTotal.DedApplied,2,MidpointRounding.AwayFromZero)==0
				&& Math.Round(cpByTotal.AllowedOverride,2,MidpointRounding.AwayFromZero)==0
				&& Math.Round(cpByTotal.InsPayAmt,2,MidpointRounding.AwayFromZero)==0
				&& Math.Round(cpByTotal.WriteOff,2,MidpointRounding.AwayFromZero)==0)
			{
				isByTotalIncluded=false;
			}
			if(claim.ClaimType=="PreAuth") {
				//In the claim edit window we currently block users from entering PreAuth payments by total, presumably because total payments affect the patient balance.
				isByTotalIncluded=false;
			}
			else if(claim.ClaimType=="Cap") {
				//In the edit claim window, we currently warn and discourage users from entering Capitation payments by total, because total payments affect the patient balance.
				isByTotalIncluded=false;
			}
			if(isByTotalIncluded) {
				cpByTotal.Status=ClaimProcStatus.Received;
				cpByTotal.ClaimNum=claim.ClaimNum;
				cpByTotal.PatNum=claim.PatNum;
				cpByTotal.ProvNum=claim.ProvTreat;
				cpByTotal.PlanNum=claim.PlanNum;
				cpByTotal.InsSubNum=claim.InsSubNum;
				cpByTotal.DateCP=DateTimeOD.Today;
				cpByTotal.ProcDate=claim.DateService;
				cpByTotal.DateEntry=DateTime.Now;
				cpByTotal.ClinicNum=claim.ClinicNum;
				cpByTotal.Remarks=claimPaid.GetRemarks();
				cpByTotal.PayPlanNum=insPayPlanNum;
				//Add the total payment to the beginning of the list, so that the ins paid amount for the total payment will be highlighted when FormEtrans835ClaimPay loads.
				listClaimProcsForClaim.Insert(0,cpByTotal);
			}
			FormEtrans835ClaimPay FormP=new FormEtrans835ClaimPay(claimPaid,claim,pat,fam,listInsPlans,listPatPlans,listInsSubs);
			FormP.ListClaimProcsForClaim=listClaimProcsForClaim;
			if(isAutomatic) {
				FormP.ReceivePayment();
			}
			else if(FormP.ShowDialog()!=DialogResult.OK) {
				if(cpByTotal.ClaimProcNum!=0) {
					ClaimProcs.Delete(cpByTotal);
				}
			}
		}
Esempio n. 8
0
		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].PayPlanNum=0;
					if(i==0) {
						//Automatically set PayPlanNum if there is a payplan with matching PatNum, PlanNum, and InsSubNum that has not been paid in full.
						//By sending in ClaimNum, we ensure that we only get the payplan a claimproc from this claim was already attached to or payplans with no claimprocs attached.
						List<PayPlan> payPlanList=PayPlans.GetValidInsPayPlans(cpList[i].PatNum,cpList[i].PlanNum,cpList[i].InsSubNum,cpList[i].ClaimNum);
						if(payPlanList.Count==1) {
							cpList[i].PayPlanNum=payPlanList[0].PayPlanNum;
						}
						else if(payPlanList.Count>1) {
							//more than one valid PayPlan
							List<PayPlanCharge> chargeList=PayPlanCharges.Refresh(cpList[i].PatNum);
							FormPayPlanSelect FormPPS=new FormPayPlanSelect(payPlanList,chargeList);
							FormPPS.ShowDialog();
							if(FormPPS.DialogResult==DialogResult.OK) {
								cpList[i].PayPlanNum=payPlanList[FormPPS.IndexSelected].PayPlanNum;
							}
						}
					}
					else {
						cpList[i].PayPlanNum=cpList[0].PayPlanNum;//set all procs to the same payplan, they can change it later if not correct for each claimproc that is different
					}
				}
				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();
		}
Esempio n. 9
0
		private void butPayTotal_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;
			}
			//preauths are only allowed "payment" entry by procedure since a total would be meaningless
			if(ClaimCur.ClaimType=="PreAuth"){
				MessageBox.Show(Lan.g(this,"PreAuthorizations can only be entered by procedure."));
				return;
			}
			if(ClaimCur.ClaimType=="Cap"){
				if(MessageBox.Show(Lan.g(this,"If you enter by total, the insurance payment will affect the patient balance.  It is recommended to enter by procedure instead.  Continue anyway?"),"",MessageBoxButtons.OKCancel)!=DialogResult.OK)
				return;
			}
			Double dedEst=0;
			Double payEst=0;
			for(int i=0;i<ClaimProcsForClaim.Count;i++){
				if(ClaimProcsForClaim[i].Status!=ClaimProcStatus.NotReceived){
					continue;
				}
				if(ClaimProcsForClaim[i].ProcNum==0){
					continue;//also ignore non-procedures.
				}
				//ClaimProcs.Cur=ClaimProcs.ForClaim[i];
				dedEst+=ClaimProcsForClaim[i].DedApplied;
				payEst+=ClaimProcsForClaim[i].InsPayEst;
			}
			ClaimProc ClaimProcCur=new ClaimProc();
			//ClaimProcs.Cur.ProcNum 
			ClaimProcCur.ClaimNum=ClaimCur.ClaimNum;
			ClaimProcCur.PatNum=ClaimCur.PatNum;
			ClaimProcCur.ProvNum=ClaimCur.ProvTreat;
			//ClaimProcs.Cur.FeeBilled
			//ClaimProcs.Cur.InsPayEst
			ClaimProcCur.DedApplied=dedEst;
			ClaimProcCur.Status=ClaimProcStatus.Received;
			ClaimProcCur.InsPayAmt=payEst;
			//remarks
			//ClaimProcs.Cur.ClaimPaymentNum
			ClaimProcCur.PlanNum=ClaimCur.PlanNum;
			ClaimProcCur.InsSubNum=ClaimCur.InsSubNum;
			ClaimProcCur.DateCP=DateTimeOD.Today;
			ClaimProcCur.ProcDate=ClaimCur.DateService;
			ClaimProcCur.DateEntry=DateTime.Now;//will get set anyway
			ClaimProcCur.ClinicNum=ClaimCur.ClinicNum;
			//Automatically set PayPlanNum if there is a payplan with matching PatNum, PlanNum, and InsSubNum that has not been paid in full.
			//By sending in ClaimNum, we ensure that we only get the payplan a claimproc from this claim was already attached to or payplans with no claimprocs attached.
			List<PayPlan> payPlanList=PayPlans.GetValidInsPayPlans(ClaimProcCur.PatNum,ClaimProcCur.PlanNum,ClaimProcCur.InsSubNum,ClaimProcCur.ClaimNum);
			ClaimProcCur.PayPlanNum=0;
			if(payPlanList.Count==1) {
				ClaimProcCur.PayPlanNum=payPlanList[0].PayPlanNum;
			}
			else if(payPlanList.Count>1) {
				//more than one valid PayPlan
				List<PayPlanCharge> chargeList=PayPlanCharges.Refresh(ClaimProcCur.PatNum);
				FormPayPlanSelect FormPPS=new FormPayPlanSelect(payPlanList,chargeList);
				FormPPS.ShowDialog();
				if(FormPPS.DialogResult==DialogResult.OK) {
					ClaimProcCur.PayPlanNum=payPlanList[FormPPS.IndexSelected].PayPlanNum;
				}
			}
			ClaimProcs.Insert(ClaimProcCur);
			List<ClaimProcHist> loopList=null;
			FormClaimProc FormCP=new FormClaimProc(ClaimProcCur,null,FamCur,PatCur,PlanList,null,ref loopList,PatPlanList,true,SubList);
			FormCP.IsInClaim=true;
			FormCP.ShowDialog();
			if(FormCP.DialogResult!=DialogResult.OK){
				ClaimProcs.Delete(ClaimProcCur);
			}
			else{
				for(int i=0;i<ClaimProcsForClaim.Count;i++){
					if(ClaimProcsForClaim[i].Status!=ClaimProcStatus.NotReceived){
						continue;
					}
					//ClaimProcs.Cur=ClaimProcs.ForClaim[i];
					ClaimProcsForClaim[i].Status=ClaimProcStatus.Received;
					if(ClaimProcsForClaim[i].DedApplied>0){
						ClaimProcsForClaim[i].InsPayEst+=ClaimProcsForClaim[i].DedApplied;
						ClaimProcsForClaim[i].DedApplied=0;//because ded will show as part of payment now.
					}
					ClaimProcsForClaim[i].DateEntry=DateTime.Now;//the date is was switched to rec'd
					ClaimProcs.Update(ClaimProcsForClaim[i]);
				}
			}
			comboClaimStatus.SelectedIndex=5;//Received
			if(textDateRec.Text==""){
				textDateRec.Text=DateTime.Today.ToShortDateString();
			}
			ClaimProcList=ClaimProcs.Refresh(PatCur.PatNum);
			FillGrids();
		}