2 hook requests :)

This forum is for programmers who have questions about the source code.
Post Reply
alkhaef
Posts: 105
Joined: Fri Jul 02, 2010 10:37 am
Location: Los Angeles, CA

2 hook requests :)

Post by alkhaef » Wed Sep 28, 2011 4:41 pm

Hello friends.

I'd like to request a HookAddCode type of hook in "OpenDental\Forms Reports\formRpOutstandingIns.cs" in butRefresh_Click().

Code: Select all

		private void butRefresh_Click(object sender,EventArgs e) {
// PLEASE ADD HOOK HERE - NO PARAMETERS NECESSARY :-D.
			FillGrid();
		}
...and also another HookAddCode type in "OpenDentBusiness\Data Interface\Claims.cs" near the end of GetOutInsClaims().

Code: Select all

				command+="AND claim.ClaimType!='Preauth' ";
			}
			command+="ORDER BY carrier.Phone,insplan.PlanNum, carrier.Phone,insplan.PlanNum";
// PLEASE ADD HOOK HERE, AND PLEASE INCLUDE "command" IN THE PARAMETER SET :-D.
			DataTable table=Db.GetTable(command);
			return table;
Thanks a million!
Al
Help! I've OD'ed on OD! :)

User avatar
jordansparks
Site Admin
Posts: 5770
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: 2 hook requests :)

Post by jordansparks » Thu Sep 29, 2011 3:22 am

Those seem fine.
Jordan Sparks, DMD
http://www.opendental.com

michael
Posts: 38
Joined: Wed Aug 04, 2010 8:49 am

Re: 2 hook requests :)

Post by michael » Thu Sep 29, 2011 9:06 am

Code: Select all

Plugins.HookAddCode(null,"Claims.GetOutInsClaims_end",command);
has been added to Claims.cs and

Code: Select all

Plugins.HookAddCode(this,"FormRpOutstandingIns.butRefresh_begin");
has been added to FormRpOutstandingIns.cs.

These will be in 11.0.31 and 11.1.1 (beta).

alkhaef
Posts: 105
Joined: Fri Jul 02, 2010 10:37 am
Location: Los Angeles, CA

Re: 2 hook requests :)

Post by alkhaef » Fri Sep 30, 2011 8:31 am

Thanks guys!

I did notice, however, that strings in c#, although reference types, are immutable.

So for me to be able to touch the string in my plugin, we'd have to use a string builder, or do something like the following:

Code: Select all

			command+="ORDER BY carrier.Phone,insplan.PlanNum, carrier.Phone,insplan.PlanNum";
//START
			object[] paramArray = {(object)(command)};
			Plugins.HookAddCode(null, "Claims.GetOutInsClaims_beforequeryrun", paramArray);
			command = (string)(paramArray[0]);
//END
			DataTable table = Db.GetTable(command);
			return table;
Al
Help! I've OD'ed on OD! :)

User avatar
jordansparks
Site Admin
Posts: 5770
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: 2 hook requests :)

Post by jordansparks » Fri Sep 30, 2011 11:16 am

Well, there's no need to explicitly create the paramArray since it uses the params keyword. So it would be more like this:

Code: Select all

object boxedCommand = command;
Plugins.HookAddCode(null, "Claims.GetOutInsClaims_beforequeryrun", boxedCommand);
command = (string)boxedCommand;
But we haven't tested that, and I'm not 100% certain that that's how strings get boxed/unboxed.
Jordan Sparks, DMD
http://www.opendental.com

alkhaef
Posts: 105
Joined: Fri Jul 02, 2010 10:37 am
Location: Los Angeles, CA

Re: 2 hook requests :)

Post by alkhaef » Fri Sep 30, 2011 11:52 am

Hi Dr. Sparks,

That was what I thought (and tried) too, but it didn't seem to work. Here's what happened after the hook was invoked:

My Plugin.cs's parameter[0]: correct updated value
OD's Plugins.cs's parameter[0]: correct updated value
OD's Claims.cs's boxedCommand: incorrect original value
OD's Claims.cs's command: incorrect original value

Odd, eh? The only difference I could think of between the call to Plugins.cs's HookAddCode and the call to my plugin's HookAddCode was the pre-creation of the array, bypassing the params keyword usage.

It still doesn't make much sense to me, but rather than investigate c#'s/.net's quirks, I took the lazy-brute-force route and found something that does work - building the array oneself. If you guys end up finding a cleaner way, then all the better.

Thanks again
Al
Help! I've OD'ed on OD! :)

User avatar
jordansparks
Site Admin
Posts: 5770
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: 2 hook requests :)

Post by jordansparks » Fri Sep 30, 2011 7:28 pm

After testing with strings and with ints, I would like the following pattern to be used for these situations

Code: Select all

object[] parameters={command};
Plugins.HookAddCode(null, "Claims.GetOutInsClaims_beforequeryrun", parameters);
command=(string)parameters[0];
It's also been documented in the manual.
Jordan Sparks, DMD
http://www.opendental.com

michael
Posts: 38
Joined: Wed Aug 04, 2010 8:49 am

Re: 2 hook requests :)

Post by michael » Mon Oct 03, 2011 11:21 am

Hook has been changed according to Jordan's specification in the head and in the beta version (11.1).

Post Reply