New Hooks

This forum is for programmers who have questions about the source code.
Post Reply
SPHCDave
Posts: 7
Joined: Mon Jul 29, 2019 6:32 am
Location: Jacksonville, FL

New Hooks

Post by SPHCDave » Thu Sep 05, 2019 6:38 am

Hi,

I need to have 2 new hooks added.

1) In the ContrAccount.cs - The new hook is in the ToolBarMain_ButtonClick method. It needs to be inserted right after the "Payment" case statement.

private void ToolBarMain_ButtonClick(object sender, OpenDental.UI.ODToolBarButtonClickEventArgs e) {
if(e.Button.Tag.GetType()==typeof(string)){
//standard predefined button
switch(e.Button.Tag.ToString()){
//case "Patient":
// OnPat_Click();
// break;
case "Payment":
*********************** begin new hook **************************************
if (Plugins.HookMethod(this, "ContrAccount.ToolBarMain_Payment"))
{
return;
}
*********************** end new hook **************************************
bool isTsiPayment =(TsiTransLogs.IsTransworldEnabled(PatCur.ClinicNum)
&& Patients.IsGuarCollections(PatCur.Guarantor)
&& !MsgBox.Show(this,MsgBoxButtons.YesNo,"The guarantor of this family has been sent to TSI for a past due balance. "

2) In the FormPayment.cs - The new hook is in the SavePaymentToDb method. It needs to be inserted right before the line - if (_isCCDeclined) {


if(amt!=0 && listPayType.SelectedIndex==-1) {
MsgBox.Show(this,"A payment type must be selected.");
return false;
}
}
*********************** begin new hook **************************************
object[] parameters = { listPayType.SelectedItem, textNote.Text, _isCCDeclined, _paymentCur };
Plugins.HookAddCode(this, "FormPayment.SavePaymentToDb_afterUnearnedCurCheck", parameters);
textNote.Text = textNote.Text + (string)parameters[1];
_isCCDeclined = (bool)parameters[2];
*********************** end new hook **************************************
if (_isCCDeclined) {
textAmount.Text=0.ToString("f");//So that a declined transaction does not affect account balance

Thanks,
Dave

PatrickC
Posts: 56
Joined: Thu Jun 06, 2019 11:37 am

Re: New Hooks

Post by PatrickC » Thu Sep 05, 2019 9:13 am

Hi Dave,

Hook Request 1:

I can put in the requested HookMethod, which will replace the code within the case statement. I just need to confirm that there are no parameters which you would be passing in. Since this is replacing a Case statement, I replaced the return with a break.

Code: Select all

case "Payment":
	if (Plugins.HookMethod(this,"ContrAccount.ToolBarMain_ButtonClick_Payment")) {
		break;
	}
	bool isTsiPayment=(TsiTransLogs.IsTransworldEnabled(PatCur.ClinicNum)
Hook Request 2:

I can put this in pretty much as is. I did adjust the assignment of textNote.text so that it wouldn't double in situations where your hook isn't active. The code before your request differs in head from what you indicated in your request. Please confirm that the hooks location, and my adjustments, are still acceptable.

Code: Select all

if(unearnedCur.IsLessThan(0)
	&& !(unearnedCur+(double)PaySplits.GetUnearnedForFam(_famCur,payNumExcluded:_paymentCur.PayNum)).IsGreaterThanOrEqualToZero()
	&& !MsgBox.Show(this,MsgBoxButtons.YesNo,"You are attempting to create a negative unearned amount. Continue?"))
{
	return false;
}
object[] parameters = { listPayType.SelectedItem, textNote.Text, _isCCDeclined, _paymentCur };
Plugins.HookAddCode(this,"FormPayment.SavePaymentToDb_afterUnearnedCurCheck",parameters);
textNote.Text = (string)parameters[1];
_isCCDeclined = (bool)parameters[2];
if(_isCCDeclined) {
Patrick Carlson
Open Dental Software
http://www.opendental.com

SPHCDave
Posts: 7
Joined: Mon Jul 29, 2019 6:32 am
Location: Jacksonville, FL

Re: New Hooks

Post by SPHCDave » Mon Sep 09, 2019 8:56 am

Hi Patrick,

Hook 1 should be fine like you have it. I just need to know when the Payment button is selected so I don't need any fields passed with it.

Hook 2 is good also.

Thank you,
Dave

PatrickC
Posts: 56
Joined: Thu Jun 06, 2019 11:37 am

Re: New Hooks

Post by PatrickC » Mon Sep 09, 2019 10:34 am

Hooks have been added, and will be included in Beta version 19.2.23.
Patrick Carlson
Open Dental Software
http://www.opendental.com

SPHCDave
Posts: 7
Joined: Mon Jul 29, 2019 6:32 am
Location: Jacksonville, FL

Re: New Hooks

Post by SPHCDave » Fri Sep 13, 2019 6:47 am

Patrick,

Do you know when the next non-beta release with these hooks will be made?
What version will that be?

Thanks,
Dave

User avatar
cmcgehee
Posts: 711
Joined: Tue Aug 25, 2015 5:06 pm
Location: Salem, Oregon

Re: New Hooks

Post by cmcgehee » Mon Sep 16, 2019 7:26 am

We generally release a new version in September of October. I haven't heard anything official about when we'll release, but it should be in the next few weeks.
Chris McGehee
Open Dental Software
http://www.opendental.com

Post Reply