Add Hook for the Plugin

For users or potential users.
Post Reply
OMH - developer
Posts: 6
Joined: Wed Aug 23, 2023 6:26 am

Add Hook for the Plugin

Post by OMH - developer » Tue Oct 31, 2023 7:53 am

Hi,
We are working on adding customizations to OpenDental, our hook for one of those features is,
"Plugins.HookAddCode(this, "ContrChart.FillPtInfo_end", Pd.Patient);"

please add it to your latest version at the location "Opendental > ControlChart.cs > FillPtInfo > Before 'gridPtInfo.EndUpdate();' line. (FYI: We are working on 22.4 version)
Let me know if you need anything else.

Thank you!

SLeon
Posts: 482
Joined: Mon Mar 01, 2021 10:00 am

Re: Add Hook for the Plugin

Post by SLeon » Tue Oct 31, 2023 10:07 am

I have added this to our list and will update this thread once it is complete. Thank you.

SWoinowsky
Posts: 3
Joined: Thu Nov 02, 2023 1:51 pm

Re: Add Hook for the Plugin

Post by SWoinowsky » Thu Nov 02, 2023 2:09 pm

Hello!

We were able to add a hook where you requested, the location description was changed to reflect the actual location of the hook:

Code: Select all

Plugins.HookAddCode(this, "ContrChart.FillPtInfo_BeforeEndUpdate", Pd.Patient);
It will be available in version 23.3.5!

Thank you!

OMH - developer
Posts: 6
Joined: Wed Aug 23, 2023 6:26 am

Re: Add Hook for the Plugin

Post by OMH - developer » Thu Nov 09, 2023 11:21 am

Thanks for the quick update.
But the hook has been added to at a different location due to multiple "gridPtInfo.EndUpdate();" in the page, please add the following hooks at the scripts provided below to the latest version
  • Please add the hook - Plugins.HookAddCode(this, "ContrChart.FillPtInfo_end", Pd.Patient); 'Module > ControlChart.cs' at

    Code: Select all

    		else {
    			gridPtInfo.ListGridRows.Add(row);
    		}               
        }
        Plugins.HookAddCode(this, "ContrChart.FillPtInfo_end", Pd.Patient);
    
    
    
        gridPtInfo.EndUpdate();
    }
  • Please add the hook - Plugins.HookAddCode(this, "ContrFamily.LayoutToolBar_end", _patCur, _odPictureBoxPat); 'Module > ControlFamily.cs', at two places as shown below

    Code: Select all

    try {
    	_odPictureBoxPat.Image?.Dispose();
    	if(_loadData.HasPatPict==YN.Unknown) {
            Plugins.HookAddCode(this, "ContrFamily.LayoutToolBar_end", _patCur,_odPictureBoxPat);
            _odPictureBoxPat.Image=Documents.GetPatPict(_patCur.PatNum,ImageStore.GetPatientFolder(_patCur,ImageStore.GetPreferredAtoZpath()));
    	}
    	else {
            Plugins.HookAddCode(this, "ContrFamily.LayoutToolBar_end", _patCur, _odPictureBoxPat);
            _odPictureBoxPat.Image=Documents.GetPatPict(_patCur.PatNum,ImageStore.GetPatientFolder(_patCur,ImageStore.GetPreferredAtoZpath()),_loadData.PatPict);
    	}
    }
    catch {
  • Please add the hook - Plugins.HookAddCode(this, "DisplayField.FillPtInfo_end", new object[2] { _listDisplayFieldsAvail, _listDisplayFieldsShowing }); 'Module = FormDisplayFields.cs' at

    Code: Select all

    	listAvailable.Items.Clear();
    	listAvailable.Items.AddList(_listDisplayFieldsAvail,x=>x.ToString());
        Plugins.HookAddCode(this, "DisplayField.FillPtInfo_end", new object[2] { _listDisplayFieldsAvail, _listDisplayFieldsShowing });
    }
    
    private void gridMain_CellDoubleClick(object sender,ODGridClickEventArgs e) {
    
  • Please add the hook - Plugins.HookAddCode(this, "SelectPatient.FillPtInfo_end", new object[2] { _tablePats, _listDisplayFields }); 'Module > formpatientselect' at

    Code: Select all

    	if (PIn.Long(_tablePats.Rows[i][0].ToString()) == PatNumInitial)
    	{
    		gridMain.SetSelected(i, true);
    		break;
    	}
    }
    Plugins.HookAddCode(this, "SelectPatient.FillPtInfo_end", new object[2] { _tablePats, _listDisplayFields });
    this.AcceptButton = butOK;
Thank you

SLeon
Posts: 482
Joined: Mon Mar 01, 2021 10:00 am

Re: Add Hook for the Plugin

Post by SLeon » Thu Nov 16, 2023 10:45 am

I have added these additional hooks to our list and we will update this thread once the is complete.

Note that the first of these four was completed in the original job. It was backported to 23.3.5, so the surrounding code will look different than your current version (22.4).

OMH - developer
Posts: 6
Joined: Wed Aug 23, 2023 6:26 am

Re: Add Hook for the Plugin

Post by OMH - developer » Tue Nov 21, 2023 8:58 am

Understood, Thank you.

Looking forward for the update.

SWoinowsky
Posts: 3
Joined: Thu Nov 02, 2023 1:51 pm

Re: Add Hook for the Plugin

Post by SWoinowsky » Wed Nov 22, 2023 11:18 am

So that we can best approach the implementation of these hooks, could you describe the intended use of the hooks for the Family module and the Patient Select form?

OMH - developer
Posts: 6
Joined: Wed Aug 23, 2023 6:26 am

Re: Add Hook for the Plugin

Post by OMH - developer » Wed Nov 29, 2023 7:48 am

Sure, Hook in Family module is to display Patient image from our database while the one in patient select form is to add and display additional columns that are not available in the display fields.

SWoinowsky
Posts: 3
Joined: Thu Nov 02, 2023 1:51 pm

Re: Add Hook for the Plugin

Post by SWoinowsky » Thu Nov 30, 2023 2:33 pm

Thank you for your response! For the sake of maintaining your intended behavior with the hooks, there are some changes that may be worth considering. I'd like to run them by you and see if they might make your goals a little easier.

For the Family Module, there is code immediately following where you requested to put your hook:

Code: Select all

object[] objectArrayParameters={_patient,pictureBoxPat};
Plugins.HookAddCode(this,"ContrFamily.FillPatientPicture_BeforeImageAssign",objectArrayParameters);
if(_loadData.HasPatPict==YN.Unknown) {
pictureBoxPat.Image=Documents.GetPatPict(_patient.PatNum,patFolder);
}
else {
pictureBoxPat.Image=Documents.GetPatPict(_patient.PatNum,patFolder,_loadData.PatPict);
}
This code would cause an overwrite of any changes that were made to pictureBoxPat.Image. If that is a problem, we would like to use the other code hook called HookMethod, which would prevent the code following your hook from running. It would look like this:

Code: Select all

object[] objectArrayParameters={_patient,pictureBoxPat};
Plugins.HookMethod(this,"ContrFamily.FillPatientPicture_BeforeImageAssign",objectArrayParameters);
if(_loadData.HasPatPict==YN.Unknown) {
pictureBoxPat.Image=Documents.GetPatPict(_patient.PatNum,patFolder);
}
else {
pictureBoxPat.Image=Documents.GetPatPict(_patient.PatNum,patFolder,_loadData.PatPict);
}
Regarding the hook in FormPatientSelect, the addition of new grid columns and entries is considerably complicated after the grid has already been populated. We would like to suggest using HookAddMethod before the grid population. This would allow you to simply rewrite the algorithm that adds columns and entries to the grid, which may be much more straightforward. Here is how it would look:

Code: Select all

	_tablePats=dataView.ToTable();
}
object[] objectArrayParameters={ _tablePats,_listDisplayFields };
Plugins.HookMethod(this,"FormPatientSelect.FillGridFinal_BeforeGridUpdate",objectArrayParameters);
gridMain.BeginUpdate();
gridMain.ListGridRows.Clear();
If these changes work for you, we can get them implemented straight away! Otherwise, please let us know if these changes will cause any difficulty for you, or if you have any questions regarding these changes. Thanks!

OMH - developer
Posts: 6
Joined: Wed Aug 23, 2023 6:26 am

Re: Add Hook for the Plugin

Post by OMH - developer » Thu Dec 07, 2023 6:18 am

Sure, we changed the hooks to hookmethod as you suggested, and they work as intended in the below locations,

For the Family Module

Code: Select all

	private void FillPatientPicture() {
            Plugins.HookMethod(this, "ContrFamily.LayoutToolBar_end", _patCur, _odPictureBoxPat);
            _odPictureBoxPat.Image?.Dispose();
For the FormPatientSelect, adding hook before the grid population results in displaying data twice on the patient select screen, from both the hook and grid population which I believe can only be resolved if you add it after i.e. in the below mentioned location,

Code: Select all

	gridMain.ListGridRows.Add(row);
}
object[] objectArrayParameters = { _tablePats, _listDisplayFields };
Plugins.HookMethod(this, "FormPatientSelect.FillGridFinal_BeforeGridUpdate", objectArrayParameters);
gridMain.EndUpdate();
Please let us know if there is anything else you would like us to change,
Thank you.

Post Reply