Page 1 of 1
Add Hook for the Plugin
Posted: Tue Oct 31, 2023 7:53 am
by OMH - developer
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!
Re: Add Hook for the Plugin
Posted: Tue Oct 31, 2023 10:07 am
by SLeon
I have added this to our list and will update this thread once it is complete. Thank you.
Re: Add Hook for the Plugin
Posted: Thu Nov 02, 2023 2:09 pm
by SWoinowsky
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!
Re: Add Hook for the Plugin
Posted: Thu Nov 09, 2023 11:21 am
by OMH - developer
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
Re: Add Hook for the Plugin
Posted: Thu Nov 16, 2023 10:45 am
by SLeon
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).
Re: Add Hook for the Plugin
Posted: Tue Nov 21, 2023 8:58 am
by OMH - developer
Understood, Thank you.
Looking forward for the update.
Re: Add Hook for the Plugin
Posted: Wed Nov 22, 2023 11:18 am
by SWoinowsky
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?
Re: Add Hook for the Plugin
Posted: Wed Nov 29, 2023 7:48 am
by OMH - developer
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.
Re: Add Hook for the Plugin
Posted: Thu Nov 30, 2023 2:33 pm
by SWoinowsky
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!
Re: Add Hook for the Plugin
Posted: Thu Dec 07, 2023 6:18 am
by OMH - developer
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.