Hooks for appointment behavior

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Hooks for appointment behavior

Post by drtech » Sat Sep 28, 2013 6:36 am

OpenDental.ContrAppts.ContrApptSheet2_DoubleClick around line 3659

_______________________________________________________________________________________________
else {//new patient not added
if(Appointments.HasPlannedEtc(PatCur.PatNum) | (Plugins.HookMethod(this,"ContrAppt.ContrApptSheet2_DoubleClick_ApptOtherShow"))) {
DisplayOtherDlg(true);
}
else {
FormApptsOther FormAO=new FormApptsOther(PatCur.PatNum);//doesn't actually get shown
else {//new patient not added
_______________________________________________________________________________________________

This is tested and verified. I have a few more similar to this I will post below when I get them tested. Thanks
Last edited by drtech on Sun Sep 29, 2013 1:46 pm, edited 2 times in total.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hooks for appointment behavior

Post by drtech » Sat Sep 28, 2013 7:31 pm

Here is the second Hook around line 3203 in ContrAppt.cs
_______________________________________________________________________________________________
else {//appt time not locked
object[] parameters = { apt.Pattern, calcPattern };
if ((Plugins.HookMethod(this, "ContrAppt.ContrApptSheet2_MouseUp_ChangeProvApptLength", parameters)))
{
apt.Pattern = (string)parameters[0];
calcPattern = (string)parameters[1];
goto PluginSkipQuestionProvLength;
}

if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Change length for new provider?")) {
apt.Pattern=calcPattern;
}
PluginSkipQuestionProvLength: { }

}
_______________________________________________________________________________________________
Notice, this adds a label at the bottom for the goto command. This combines patterns as I had to use the HookMethod instead of HookAddCode to get a return bool value to trigger the goto and not the void of HookAddCode.
Last edited by drtech on Sun Sep 29, 2013 1:58 pm, edited 3 times in total.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hook for appointment behavior

Post by drtech » Sat Sep 28, 2013 7:33 pm

If you could update the patterns page to include the empty brackets at the end of the goto label it might be very helpful to others. I spent hours trying to figure out why it wouldn't compile until I figured out I needed to add the brackets.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hook for appointment behavior

Post by drtech » Sun Sep 29, 2013 1:37 pm

Here is my third hook request dealing with appointment behavior, near line 3164 of ContrAppt.cs
____________________________________________________________________________________________________
if((assignedDent!=0 && assignedDent!=apt.ProvNum) || (assignedHyg!=0 && assignedHyg!=apt.ProvHyg)) {
if (Plugins.HookMethod(this, "ContrAppt.ContrApptSheet2_MouseUp_ApptSkipProvChangeQuestion",apt.AptStatus) || MessageBox.Show(Lan.g(this, "Change provider?"), "", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
if(assignedDent!=0) {//the dentist will only be changed if the spot has a dentist.
apt.ProvNum=assignedDent;
}
____________________________________________________________________________________________________
Last edited by drtech on Sun Sep 29, 2013 1:59 pm, edited 1 time in total.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hooks for appointment behavior

Post by drtech » Sun Sep 29, 2013 7:59 pm

fourth hook request dealing with appointment behavior, near line 3270 of ContrAppt.cs
____________________________________________________________________________________________________
else if(!opCur.SetProspective && PatCur.PatStatus==PatientStatus.Prospective) {
//Do we need to warn about changing FROM prospective? Assume so for now.
if(MsgBox.Show(this,MsgBoxButtons.OKCancel,"Patient's status will change from Prospective to Patient.")) {
Patient patOld=PatCur.Copy();
PatCur.PatStatus=PatientStatus.Patient;
Patients.Update(PatCur,patOld);
}
}
}
object[] parameters2 = { apt.AptDateTime, aptOld.AptDateTime, apt.AptStatus};
if ((Plugins.HookMethod(this, "ContrAppt.ContrApptSheet2_MouseUp_ApptDoNotUnbreakApptSameDay", parameters2)))
{
apt.AptStatus = (ApptStatus)parameters2[2];
goto PluginApptDoNotUnbreakApptSameDay;
}

if(apt.AptStatus==ApptStatus.Broken && timeWasMoved) {
apt.AptStatus=ApptStatus.Scheduled;
}
PluginApptDoNotUnbreakApptSameDay: { }
//original location of provider code
if(curOp.ClinicNum==0){
____________________________________________________________________________________________________
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

allends
Posts: 235
Joined: Fri Aug 23, 2013 11:29 am

Re: Hooks for appointment behavior

Post by allends » Wed Oct 02, 2013 2:41 pm

All of these hooks have been added.
Allen
Open Dental Software
http://www.opendental.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hooks for appointment behavior

Post by drtech » Wed Oct 02, 2013 4:43 pm

Great! Thanks a bunch.
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hooks for appointment behavior

Post by drtech » Wed Oct 02, 2013 7:53 pm

Those seem to work great. I just thought of another logic test I am going to add, so If we could insert some additional parameters I would appreciate it!

___________________________________________________________________________________-
//if no dentist/hygenist is assigned to spot, then keep the original dentist/hygenist without prompt. All appts must have prov.
if((assignedDent!=0 && assignedDent!=apt.ProvNum) || (assignedHyg!=0 && assignedHyg!=apt.ProvHyg)) {
if(Plugins.HookMethod(this,"ContrAppt.ContrApptSheet2_MouseUp_apptProvChangeQuestion",apt.AptStatus, apt.ProvNum, apt.ProvHyg, apt.IsHygiene, assignedDent, assignedHyg)
|| MessageBox.Show(Lan.g(this,"Change provider?"),"",MessageBoxButtons.YesNo)==DialogResult.Yes) {
if(assignedDent!=0) {//the dentist will only be changed if the spot has a dentist.
apt.ProvNum=assignedDent;
}
____________________________________________________________________________________
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

allends
Posts: 235
Joined: Fri Aug 23, 2013 11:29 am

Re: Hooks for appointment behavior

Post by allends » Thu Oct 03, 2013 11:32 am

if((assignedDent!=0 && assignedDent!=apt.ProvNum) || (assignedHyg!=0 && assignedHyg!=apt.ProvHyg)) {
if(Plugins.HookMethod(this,"ContrAppt.ContrApptSheet2_MouseUp_apptProvChangeQuestion",apt,assignedDent,assignedHyg)
|| MsgBox.Show(this,MsgBoxButtons.YesNo,"Change provider?")) {
if(assignedDent!=0) {//the dentist will only be changed if the spot has a dentist.
apt.ProvNum=assignedDent;
}

This change is what I think would be best for the hook. Instead of calling the different appointment fields just pass in an entire appointment object. Please test this after you have made the changes so I can backport it.
Allen
Open Dental Software
http://www.opendental.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hooks for appointment behavior

Post by drtech » Thu Oct 03, 2013 11:49 am

I will test that and report back to you
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hooks for appointment behavior

Post by drtech » Wed Nov 20, 2013 2:06 pm

I have reworked this and have the modified code and related additional hooks. They are all tested and working.

Please modify one hook, you can remove another that I now replace with this updated code and then add two additional related hooks in another location:

Reworked #1 and removed #2
ContrlAppt.cs ContrApptSheet2_MouseUp around line 3163 for the start
***********************************************************************************************************
else {
if(apt.DateTimeAskedToArrive.Year>1880) {
MessageBox.Show(Lan.g(this,"Time asked to arrive was ")+apt.DateTimeAskedToArrive.ToShortTimeString());//OK is only option
}
apt.DateTimeAskedToArrive=DateTime.MinValue;
}
}
//if no dentist/hygenist is assigned to spot, then keep the original dentist/hygenist without prompt. All appts must have prov.
if((assignedDent!=0 && assignedDent!=apt.ProvNum) || (assignedHyg!=0 && assignedHyg!=apt.ProvHyg)) {
object[] parameters2 = {apt, assignedDent, assignedHyg, procsForSingleApt, this};
if ((Plugins.HookMethod(this, "ContrAppt.ContrApptSheet2_MouseUp_apptProvChangeQuestion", parameters2)))
{
apt = (Appointment)parameters2[0];
assignedDent = (long)parameters2[1];
assignedDent = (long)parameters2[2];
goto PluginApptProvChangeQuestionEnd;
}

if (MessageBox.Show(Lan.g(this,"Change provider?"),"",MessageBoxButtons.YesNo)==DialogResult.Yes) {
if(assignedDent!=0) {//the dentist will only be changed if the spot has a dentist.
apt.ProvNum=assignedDent;
}
if(assignedHyg!=0) {//the hygienist will only be changed if the spot has a hygienist.
apt.ProvHyg=assignedHyg;
}
if(curOp.IsHygiene) {
apt.IsHygiene=true;
}
else {//op not marked as hygiene op
if(assignedDent==0) {//no dentist assigned
if(assignedHyg!=0) {//hyg is assigned (we don't really have to test for this)
apt.IsHygiene=true;
}
}
else {//dentist is assigned
if(assignedHyg==0) {//hyg is not assigned
apt.IsHygiene=false;
}
//if both dentist and hyg are assigned, it's tricky
//only explicitly set it if user has a dentist assigned to the op
if(curOp.ProvDentist!=0) {
apt.IsHygiene=false;
}
}
}
procsForSingleApt=Procedures.GetProcsForSingle(apt.AptNum,false);
List<long> codeNums=new List<long>();
for(int p=0;p<procsForSingleApt.Count;p++) {
codeNums.Add(procsForSingleApt[p].CodeNum);
}
string calcPattern=Appointments.CalculatePattern(apt.ProvNum,apt.ProvHyg,codeNums,true);
if(apt.Pattern != calcPattern && !PrefC.GetBool(PrefName.AppointmentTimeIsLocked)) {
if(apt.TimeLocked) {
if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Appointment length is locked. Change length for new provider anyway?")) {
apt.Pattern=calcPattern;
}
}
else {//appt time not locked
//Notice I removed a hook here as I figure all this out in the modified version above
if(MsgBox.Show(this,MsgBoxButtons.YesNo,"Change length for new provider?")) {
apt.Pattern=calcPattern;
}
}
}
}
PluginApptProvChangeQuestionEnd: { }

}
}
if(DoesOverlap(apt)) {
***********************************************************************************************************


#3& #4
Schedules.cs around line 362
***********************************************************************************************************
if(listForPeriod.StopTime <= aptDateTime.TimeOfDay){
continue;
}
//matching sched found
Plugins.HookAddCode(null, "Schedules.GetAssignedProvNumForSpot_Found", isSecondary);
return listForPeriod.ProvNum;
}
//if no matching sched found, then use the operatory
Plugins.HookAddCode(null, "Schedules.GetAssignedProvNumForSpot_None", isSecondary);
if (isSecondary)
{
return op.ProvHygienist;
}
else{
return op.ProvDentist;
}

***********************************************************************************************************

If we can get these into version 13.2 that would be great!
Thanks,
David
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

allends
Posts: 235
Joined: Fri Aug 23, 2013 11:29 am

Re: Hooks for appointment behavior

Post by allends » Fri Nov 22, 2013 10:58 am

I added all of these new plugin hooks and backported them to version 13.2.

The only change I had to make was your object array had to be renamed to parameters3

I think another developer beat you to parameters2. :D
Allen
Open Dental Software
http://www.opendental.com

User avatar
drtech
Posts: 1647
Joined: Wed Jun 20, 2007 8:44 am
Location: Springfield, MO
Contact:

Re: Hooks for appointment behavior

Post by drtech » Fri Nov 22, 2013 12:04 pm

Thanks!
David Fuchs
Dentist - Springfield, MO
Smile Dental http://www.887-smile.com

Post Reply