Hello, all.
Currently, in the history view in CPS 10, we use {APPT_NEXT ()} to display the patient's next scheduled appointment. As you all know, it returns:
Date, time, appointment type, location of care, and resource for the next appointment. For example:
03/18/2013, 10:30AM, Acutes CWY, VMC, Yut M.D., Clifford W
I have been asked if
1) It can be made to show the typed in reason for the appointment. This means displaying whatever is typed in the appointment notes. It would then show more than just "Acutes," or whatever the appointment type happens to be. It would include something like "recheck depression" or "cbc, cmp and tsh," etc and be much more helpful to our clinicians.
2) It can be made to list ALL of the patient's upcoming appointments and not just the NEXT one?
I know there are several threads on here already dealing with future appointments, but I could find none that incorporated the appointment notes also. If anyone can help with this I would greatly appreciate it.
Thanks, as always!
I did find the following function that will pull in all future appointments, but haven't come across a way to include the appointment notes:
{fn NEXT_APPTS(returnMethod){
if (toUpper(returnMethod) <> "DELIMITED" AND toUpper(returnMethod) <> "LIST" AND toUpper(returnMethod) <> "COMMA" AND toUpper(returnMethod) <> "FORMATTEDLONG") then
// Default Return Method if no value passed edit this if you want to change the default
returnMethod = "DELIMITED"
endif
// initialize local variables
local retVal = ""
local z = getRowCount("_MELCurPatientAppt")
// loop through rows in _MELCurPatientAppt data object
for i=1, i<=z, i=i+1 do
local a = (getRow("_MELCurPatientAppt",i,"AppointmentsId","ApptStart","ApptTypeId","FacilityId","DoctorID","ResourceId","Status","Canceled"))
if val(durationdays(datestamp(),a[2]))>0 and a[8]="" then
// Appointment type lookup in _MELApptType data object
if (find("_MELApptType","Name","ApptTypeID",a[3]) <> "") then
a[3] = find("_MELApptType","Name","ApptTypeID",a[3])
endif
// Facility lookup in _MELLocation data object
if (find("_MELLocation","ListName","DoctorFacilityID",a[4]) <> "") then
a[4] = find("_MELLocation","ListName","DoctorFacilityID",a[4])
endif
// Doctor lookup in _DoctorFacilityForPatAppt data object
if (find("_DoctorFacilityForPatAppt","ListName","DoctorFacilityID",a[5]) <> "") then
a[5] = find("_DoctorFacilityForPatAppt","ListName","DoctorFacilityID",a[5])
endif
// Resource lookup in _DoctorFacilityForPatAppt data object
if (find("_DoctorFacilityForPatAppt","ListName","DoctorFacilityID",a[6]) <> "") then
a[6] = find("_DoctorFacilityForPatAppt","ListName","DoctorFacilityID",a[6])
endif
// ApptStatus is actually a combination of two fields, Canceled or ApptStatus. If Canceled <> "" then write Canceled, else write contents of ApptStatus
if (a[8] <> "") then
a[7] = "Canceled"
endif
cond
case toUpper(returnMethod) == "DELIMITED"
// Don't add pipe before first element
if (retVal <> "") then
retVal = retVal + "|"
endif
retVal = retVal + str(a[2],"^",a[3],"^",a[4],"^",a[6])
case toUpper(returnMethod) == "LIST"
// Don't add HRET before first element
if (retVal <> "") then
retVal = retVal + HRET
endif
retVal = retVal + str(a[2],", ",a[3],", ",a[4],", ",a[6])
case toUpper(returnMethod) == "COMMA"
// Don't add comma before first element
if (retVal <> "") then
retVal = retVal + ","
endif
// Need to replace commas in elements with semicolon to prevent errors in comma separated list
retVal = retVal + str(ReplaceStr(a[2], ",",";")," ",ReplaceStr(a[3], ",",";")," ",ReplaceStr(a[4], ",",";")," ",ReplaceStr(a[6], ",",";"))
case toUpper(returnMethod) == "FORMATTEDLONG"
// Don't add new lines before first element
if (retVal <> "") then
retVal = retVal + HRET + HRET
endif
// Need to replace commas in elements with semicolon to prevent errors in comma separated list
retVal = retVal + str("ApptTime: ",ReplaceStr(a[2], ",",";"),HRET,"ApptType: ",ReplaceStr(a[3], ",",";"),HRET,"FacilityID: ",ReplaceStr(a[4], ",",";"),HRET,"ResourceID: ",ReplaceStr(a[6], ",",";"))
endcond
endif
endfor
return retVal
}}
this line -
local a = (getRow("_MELCurPatientAppt",i,"AppointmentsId","ApptStart","ApptTypeId","FacilityId","DoctorID","ResourceId","Status","Canceled"))
change to -
local a = (getRow("_MELCurPatientAppt",i,"AppointmentsId","ApptStart","ApptTypeId","FacilityId","DoctorID","ResourceId","Status","Canceled","Notes"))
Then the notes will be stored in a[9], so you can go through each return method and add a[9] where ever you want it displayed, this version will also return all future appointments. This line -
if val(durationdays(datestamp(),a[2]))>0 and a[8]="" then
reads "If the appointment date is greater than todays date and the cancellation field is blank, then add this appointment."
Mike
Sorry - it took me a while to get around to trying this out but it worked perfectly.
Thanks, Mike! I really appreciate your help.
We are upgrading from 10.1.2 to 10.1.3 and found a problem with the appointment code when running in 10.1.3.
In testing 10.1.3, I found that I needed to change the parameter in our getRowCount() from '_MELCurPatientAppt' to '_PatientAppointments'.
In 10.1.2, the call, getRowCount('_MELCurPatientAppt'), returned the correct # of appts, but in 10.1.3 it returned -1. Within the processing of the appointment data I also needed to change the object parameters (see mellib.txt file).
Joan
We are on 10.1.3 and I've found that the above code works for some appointments but not others. For some it only returns the following, for example:
04/12/2013 10:10AM
Is this the problem you encountered, Joan? I haven't been able to find any logic behind why it is working for some but not others. Any ideas?
If you send me your email - or can tell me how to attach a .dlg file to the post - I'll send you the test form I used for testing appointment data.
Joan