Page 1 of 1

LaunchToolbarButton being called multiple times

Posted: Fri Apr 10, 2020 11:55 am
by dcrider
I have a plugin overriding LaunchToolbarButton(long patNum), however I might be using it incorrectly.

If a user has switched patients at all before clicking my button, all previously selected patNums are passed in one at a time. I have logic checking for certain criteria that fails for some patients and not for others. When multiple patNums are passed in, if even one fails my plugin exists with a message to the user that the patient didn't meet the criteria, even if the currently selected patient fulfills that criteria.

Is there something I'm missing here? Here's the code (the criteria check happens when the CurrentPatient value is changed and OurPatient is instantiated in the constructor of FormMain)

Code: Select all

public override void LaunchToolbarButton(long patNum)
{
     if (DataCheck.TableExists("rd_location"))
     {
           FormMain formMain = new FormMain();
          if (patNum != 0 && formMain.OurPatient!= null)
          {
              formMain.OurPatient.CurrentPatient = Patients.GetPat(patNum);
          }
     }
}

Re: LaunchToolbarButton being called multiple times

Posted: Fri Apr 10, 2020 1:47 pm
by joes
Our engineer who typically answers questions of this kind is out today. I'll make sure that he is aware of your post. I hope to have a response for you on Monday.

Re: LaunchToolbarButton being called multiple times

Posted: Fri Apr 10, 2020 1:53 pm
by dcrider
Thank you for the update.

Re: LaunchToolbarButton being called multiple times

Posted: Mon Apr 13, 2020 8:11 am
by cmcgehee
dcrider,

I'm not seeing a mechanism that would cause LaunchToolbarButton to be called more than once. If you put a breakpoint at

Code: Select all

if (DataCheck.TableExists("rd_location"))
does it get hit more than once with different patNums?

Re: LaunchToolbarButton being called multiple times

Posted: Mon Apr 13, 2020 8:59 am
by dcrider
Here's the issue. When I select a patient, then click my button and interact with it in any way (i.e. fill in a textbox or click a button), then close my form, select a different patient and click my button, I get the patNum of the previously selected patient, then the currently selected patient. And it's cumulative, so if I do that with 10 patients, I get all previous ones every time.

Re: LaunchToolbarButton being called multiple times

Posted: Mon Apr 13, 2020 11:10 am
by dcrider
It must be something with my code that's keeping the last patient; the patNum passed in is only ever the currently selected patient, as expected