Allow lab case entry without a patient

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
tim
Posts: 24
Joined: Wed Mar 08, 2017 5:11 am

Allow lab case entry without a patient

Post by tim » Mon Apr 17, 2017 12:06 pm

Currently, having 0 set for labcase.PatNum will throw a null reference exception from FormLabCaseEdit.FormLabCaseEdit_Load.

Could a check of Patients.GetPat(CaseCur.PatNum) be done so this does not happen? The lab cases form already handles this correctly by not showing a patient name in the data grid.

Thanks!

User avatar
jsalmon
Posts: 1591
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: Allow lab case entry without a patient

Post by jsalmon » Tue Apr 18, 2017 8:54 am

tim wrote:Currently, having 0 set for labcase.PatNum will throw a null reference exception from FormLabCaseEdit.FormLabCaseEdit_Load.

Could a check of Patients.GetPat(CaseCur.PatNum) be done so this does not happen? The lab cases form already handles this correctly by not showing a patient name in the data grid...
I don't like that idea. What kind of lab case doesn't have a corresponding patient? I can only assume that this bug has been recently introduced.

1. How are you getting into this window without a patient associated?
2. What version are you on?
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

User avatar
tim
Posts: 24
Joined: Wed Mar 08, 2017 5:11 am

Re: Allow lab case entry without a patient

Post by tim » Tue Apr 18, 2017 9:04 am

The motivation for this change is our plugin is creating new LabCase records from our external data source, but in some cases there isn't an exact patient match for us to automatically populate in the patient ID.

We ask the operator to resolve this in our UI that is generated in the FormLabCaseEdit.Load_end hook, but that hook does not run due to the exception being thrown.

User avatar
jsalmon
Posts: 1591
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: Allow lab case entry without a patient

Post by jsalmon » Tue Apr 18, 2017 9:18 am

tim wrote:The motivation for this change is our plugin is creating new LabCase records from our external data source, but in some cases there isn't an exact patient match for us to automatically populate in the patient ID.

We ask the operator to resolve this in our UI that is generated in the FormLabCaseEdit.Load_end hook, but that hook does not run due to the exception being thrown.
If we were to change the window to first check for a null patient it wouldn't be to let the user into the window, we would force the user out of the window and create a Database Maintenance because we consider this database corruption.

It sounds like your operator needs to ask for a Plugins.HookMethod and to completely take over the entire "FormLabCaseEdit_Load" method to allow for lab cases with invalid patients to be shown. There might be even more hooks needed for anything else in that window that does not expect an invalid patient.
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

User avatar
tim
Posts: 24
Joined: Wed Mar 08, 2017 5:11 am

Re: Allow lab case entry without a patient

Post by tim » Tue Apr 18, 2017 9:32 am

jsalmon wrote:needs to ask for a Plugins.HookMethod and to completely take over the entire "FormLabCaseEdit_Load" method to allow for lab cases with invalid patients to be shown.
OK, that seems reasonable. Could you add a plugin hook method FormLabCaseEdit_Load at the beginning of FormLabCaseEdit_Load with the arguments CaseCur and IsNew? (I don't think we need anymore hooks on that form, as we completely redraw the UI).

Thanks.

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

Re: Allow lab case entry without a patient

Post by cmcgehee » Wed Apr 26, 2017 4:00 pm

Tim,

We added this hook to the beginning of FormLabCaseEdit_Load:

Code: Select all

if(Plugins.HookMethod(this,"FormLabCaseEdit.Load_start",CaseCur,IsNew)) {
	return;
}
This will be present in 17.1.8.
Chris McGehee
Open Dental Software
http://www.opendental.com

Post Reply