Page 1 of 1
Contact's appointments as found set
Posted:
Fri Mar 13, 2009 8:13 am
by jimrecht
Hi John:
When I bring up an appointment record from a contact's "activity" portal on the contact layout, the record count indicators (in the upper left hand corner of the "mini window edit appointment" layout) give me a convenient way to scroll through the current contact's appointments.
I would like to have the the same capability when viewing an appointment from the Calendar Daily layout. In other words, when I click on an appointment on the calendar, I would like that same record count indicator to allow me to scroll through all of that particular patient's appointments (preferably in chronological order).
Can it be done?
Yours,
Jim Recht
Posted:
Fri Mar 13, 2009 9:14 am
by John Sindelar
Sure.
Those arrows appear whenever there is more than one record in the found set: most often when you click on a conflicting record.
So all you have to do is make sure the found set contains the records you wish to browse through. You'll do this by creating a self-join from CalDailyAppointments to another instance of the same table based on patient ID. Then, in the script "Edit Appointment { Column , Type }" you'll find the DAY comment and after the Go To Related Record command you'll add a second that goes to the records from this new, self join relationship. That will make the found set all appointments for the same patient and your arrows will work.
You'll need to decide what to do about the existing behavior of making conflicting records the found set: you can see that code right in the same part of the script in the "Show Duplicates If Any" comment. You can put your new GTRR line in the Else of this "Show Duplicates..." section to preserve the conflict behavior (replacing the three steps already there), or you can delete this whole "Show Duplicates.." section from the DAY part of the script. You'll want to do one or the other.
Hope that helps Jim.
Posted:
Fri Mar 13, 2009 11:12 am
by jimrecht
This is great John. Now I get the records I want. However, they're not in chronological order. Is there any way to get at that?
Jim
Posted:
Fri Mar 13, 2009 12:28 pm
by John Sindelar
Just throw a Sort script step in right after your new Go To Related Record script step. Sort by CalDailyAppointment's ApptDateStart and then ApptTimeStart fields.
Posted:
Fri Mar 13, 2009 1:48 pm
by jimrecht
Well, this is the craziest thing John.
Now, clicking on an appointment in the Daily view brings up the EditAppointment window just fine, with the appropriate contact and the found set of that contact's appointments. But the current record is not the correct one (i.e. not the record with the date and time that I clicked in Daily view).
For example: Contact A has 3 appointments (let's say they occurred on 1/1/01 at 1PM, 2/2/02 at 2PM, and 3/3/03 at 3PM). I go to 3/3/03 in Daily view, and there I see Contact A on my calendar at 3PM. I click on that, and up comes the EditAppointment window, showing one of Contact A's appointments - but not necessarily the appointment on 3/3/03 at 3PM! The record count is 3, and I can scroll through the 3 records; they're indeed in chronological order.
What's going on?
Yours,
Jim
Posted:
Sun Mar 15, 2009 12:54 pm
by John Sindelar
You'll need to add to your script to manage this...
Set a variable with the current appointment's ID right before you're new Go To Related Record script step.
Then, after your sort freeze window, go to the first record and Loop. Exit the loop of the current record has the ID you recorded in your variable. Otherwise got to the next record, exit after last.
That should take care of it for you.
Posted:
Mon Mar 16, 2009 5:10 pm
by jimrecht
Fantastic, John. This is great. Thanks a million!