Page 1 of 1

trouble with script meant to perform two tasks

PostPosted: Sun Nov 12, 2006 7:32 pm
by jimrecht
Hi again John:

Thanks again for your ongoing help with this. Now I have a portal to CalDailyApptRx's on one of the tabs in my MiniWindow Edit Appt layout. I have inserted a "modify" button that, when clicked, executes a script that I want to do the following:

1) duplicate the selected Rx record
2) set the StopDate of the selected Rx record to today (in other words, stopping this Rx)
3) go to the newly created Rx record and set its StartDate to today (in other words, initiating this new Rx as of today)
4) insert the cursor in the "Dose" field (because I am now going to change the dose of the Rx)

Here's the script I wrote. Needless to say -- it doesn't work(!)
--
Code: Select all
Set Variable [ $ContactID; Value:CalDailyAppointments::ApptContactID_kf ]
Set Variable [ $ApptDate; Value:CalDailyAppointments::ApptDateStart_k ]
Set Variable [ $ApptID; Value:CalDailyAppointments::ApptID_kprime ]
Set Variable [ $RxNumID; Value:CalDailyContactRx's::RxIDNumber_kf ]
Perform Script [ “Set field depending on tab selected, and Continue Script by Jim 09-16-06” ]
#Insert if statements here, if desired, to trap potential errors or problems (e.g. entering new Rx into an appointment greater than 10 days old).
Go to Related Record [ From table: “CalDailyContactRx's”; Using layout: “Patient Rx's” (ContactRx's) ]
[ Show only related records ]
View As
[ View as Form ]
Set Field [ CalDailyContactRx's::RxStopDate; Get ( CurrentDate ) ]
Duplicate Record/Request
Set Field [ CalDailyExContactRx's::RxStartDate; Get ( CurrentDate ) ]
Clear [ CalDailyContactRx's::RxStopDate ]
[ Select ]
Go to Field [ CalDailyContactRx's::RxDose ]
Pause/Resume Script [ Indefinitely ]
Go to Layout [ original layout ]
Perform Script [ “Go to tab corresponding to appointment type” ]
#Go to the 1st portal row.
Go to Portal Row [ Select; First ]

--

Can you help me figure out where I went wrong?

Yours,
Jim R.

PostPosted: Mon Nov 13, 2006 7:01 am
by John Sindelar
Hi Jim,

The key here is going to the related record. Providing that is using the correct relationship then the basics of the script look good. Just remember that you don't need to set variables like this when you're duping a record, just when you're making new ones.

I'd also set the end date to "" instead of clearing it, since a field has to be on the layout for Clear to work.

Aside form that this looks OK so I'd need to know "how" its not working. Is the new version of the RX not being created, is it duping the wrong record, etc.?

Best,

John

PostPosted: Mon Nov 13, 2006 12:47 pm
by jimrecht
Hi John:

Thanks for the feedback.

When I run this script:

1) it goes to (and duplicates) the wrong record; and
2) it sets the both the stop date and the start date of the same (incorrect) record to today's date.

Hope this helps!

PostPosted: Tue Nov 14, 2006 8:24 am
by John Sindelar
If its going to the wrong record you'll want to check out your Go to Related Record script step: you may be using the wrong relationship.

PostPosted: Tue Nov 14, 2006 8:40 am
by jimrecht
Thanks John. I'm not sure whether I have the correct relationship:

1) the portal is to CalDailyContactRx's
2) CalDailyContactRx's is a TO of ContactRx's
3) the script step reads as follows:

Code: Select all
 Go to Related Record [ From table: “CalDailyContactRx's”; Using layout: “Patient Rx's” (ContactRx's) ]


Does this look correct to you?
--
Jim R.

PostPosted: Tue Nov 14, 2006 9:22 am
by John Sindelar
It does, but if the script is modifying the wrong record then something is up. I probably wouldn't be able to diagnose this without seeing the file. Feel free to email this to me and I'll take a look.

PostPosted: Tue Nov 14, 2006 4:48 pm
by jimrecht
With your assistance, I finally got it to work, John. Thanks again!