We have a lab letter that we mail out to patients that informs them of their fasting APE lab appointment date. I want to add their next two appointments on that letter to inform our patients of their lab appointment and their APE appointment date.
{APPT_Next()} only inserts their fasting lab appointment. What else do I need to do to get their actual APE date?
Any help appreciated!
Thanks!
Ashley Corbean
@guilfordmedical" rel="nofollow" target="_blank">acorbean@guilfordmedical
arg 'delim' for '|' & '^'
'' for hret & ','
mine 'mine' for current user's appts
'loc' for current loc's appts
'all' for all users appts
next 'next' for only next appt
'all' for all appts
{fn ListFutureAppointments(arg, mine, next)
{
local rec_delim = ""
local field_delim = ""
local count
local appt = array()
local atype
local book = array()
local bookcount
local loc
local username
local i = 0
local j
local status
local result = ""
if arg=="delim" then
rec_delim = "|"
field_delim = "^"
else
rec_delim = hret
field_delim = ", "
endif
count = getRowCount("_MELCurPatientAppt") // _MEL???? are global variables from mellib.txt
// Loop thru patients appointments and stop after first for current user
while i<count
and (next<>"next"
or (result==""
and next=="next")) do
appt = getRow("_MELCurPatientAppt", i, "ApptDate", "ApptTime", "Appttype", "Booklist", "ApptStatus")
// Check for future appointment
if VAL(appt[1])>=._TODAYSDATE then // doesn't look right
// if DURATIONDAYS(appt[1], str(._TODAYSDATE))>0 then // told doesn't work
// Get the type of appointment … ApptType from _MELApptDef where ID = appt[3]
atype = find("_MELApptDef", "ApptType", "ID", appt[3])
// Get the books associated with appointment
book = getfield(appt[4], ":", "")
bookcount = size(book)
// Loop thru books
j = 2
while j<bookcount do
// Is appointment still scheduled
if appt[5]==0 then
// Get the location of care from the each book
loc = find("_MELBook", "LOCID", "ID", book[j])
loc = find("_MELLoc", "Name", "LOCID", loc)
// Get the user name from the each book
username = find("_MELBook", "UserName", "ID", book[j])
// Build the result if book matches current user
if mine=="all"
or (mine=="mine"
and match(username, 1, user.firstname)>0
and match(username, 1, user.lastname)>0)
or (mine=="loc"
and match(loc, 1, user.curlocationname)>0) then
if result<>"" then
result = result + rec_delim
endif
result = result + appt[1] + field_delim + appttime(appt[2]) + field_delim + loc + field_delim + username
endif
endif
j = j + 1
endwhile
endif
i = i + 1
endwhile
return result
}
}
guilfordmedical said:
We have a lab letter that we mail out to patients that informs them of their fasting APE lab appointment date. I want to add their next two appointments on that letter to inform our patients of their lab appointment and their APE appointment date.
{APPT_Next()} only inserts their fasting lab appointment. What else do I need to do to get their actual APE date?
Any help appreciated!
Thanks!
Ashley Corbean
@guilfordmedical" rel="nofollow" target="_blank">acorbean@guilfordmedical
We use the function APPTS_BY_STATUS("Confirmed", "FULL") to return future appointments. This function will give you a list of all appointments in a delimited list and you can loop through the list and only grab the specific appointments that you want.
A couple things to note:
1. I apologize if there are any MEL errors in the code - I modified an existing function we use to meet what you are looking for, assuming the appointment type is APE.
2. Jerroll's solution above is excellent and should also solve the issue for you...however, a word of caution. I have been told by GE Support that while they will support functions that are listed in the CPS Help Menu, global MEL variables (such as _MELCurPatientAppt) are not guaranteed to work from version to version of the EMR. In short, the explanation from support was that these global variables are used by the GE developers and are not meant for us to access (even though they made it very easy for us to do so). Just a friendly piece of advice, as we were using one of these MEL variables several versions ago, upgraded, and the function calling this MEL variable no longer worked. I try to use functions listed in CPS > Help when possible, although if there is no function available (or if the function doesn't work properly), the global MEL variables are your only option.
{fn upComingApptList(){ local retStr = "" local apptArrayOV1 local apptArrayOV2 local apptArrayOVDTL_DATES = array("DELETE", "ME") local apptArrayOVDTL_TIMES = array("DELETE", "ME") local apptArrayOVDTL_TYPES = array("DELETE", "ME") local apptArrayOVDTL_PROV = array("DELETE", "ME") if APPTS_BY_STATUS("Confirmed", "FULL") <> "" then apptArrayOV1 = getfield(APPTS_BY_STATUS("Confirmed", "FULL"), "\r", "") for x = 1, x <= size(apptArrayOV1) - 1, x = x + 1 do apptArrayOV2 = getfield(apptArrayOV1[x], ",", "") if match(apptArrayOV2[3], 1, "APE") > 0 and durationdays(apptArrayOV2[1], str(._TODAYSDATE)) < 0 then INSERT(apptArrayOVDTL_DATES, size(apptArrayOVDTL_DATES) + 1, apptArrayOV2[1]) INSERT(apptArrayOVDTL_TIMES, size(apptArrayOVDTL_TIMES) + 1, apptArrayOV2[2]) INSERT(apptArrayOVDTL_TYPES, size(apptArrayOVDTL_TYPES) + 1, apptArrayOV2[3]) cond case size(apptArrayOV2) == 6: INSERT(apptArrayOVDTL_PROV, size(apptArrayOVDTL_PROV) + 1, apptArrayOV2[6] + " " + apptArrayOV2[5]) case size(apptArrayOV2) == 5: INSERT(apptArrayOVDTL_PROV, size(apptArrayOVDTL_PROV) + 1, apptArrayOV2[5]) endcond endif endfor endif if size(apptArrayOVDTL_DATES) <= 2 then retStr = "No APE Appointment Scheduled." else for x = 3, x <= size(apptArrayOVDTL_DATES), x = x + 1 do if retStr <> "" then retStr = retStr + HRET endif retStr = retStr + apptArrayOVDTL_DATES[x] + " " + apptArrayOVDTL_TIMES[x] + " -" + "\t" + apptArrayOVDTL_TYPES[x] if apptArrayOVDTL_PROV[x] <> "" then retStr = retStr + "," + apptArrayOVDTL_PROV[x] endif endfor endif if retStr <> "" and match(retStr, 1, "\n\n") > 0 then retStr = replaceStr(retStr, "\n\n", "\n") endif return retStr }}
We are on CPS 12. Jerroll's example does not work for me. I just tried yours and it did not work either. I have copied them to wordpad, then pasted them in my letter template. I did not change anything either in the MEL that was provided. I will try again tomorrow.
Thanks for posting these! I appreciate it!
Ashley
guilfordmedical said:
We are on CPS 12. Jerroll's example does not work for me. I just tried yours and it did not work either. I have copied them to wordpad, then pasted them in my letter template. I did not change anything either in the MEL that was provided. I will try again tomorrow.
Thanks for posting these! I appreciate it!
Ashley
Hi Ashley,
I just remembered something...appointment status is important for this function. Do your future appointments have a status of "Confirmed"? If not, you can change this line early in the function to whatever the status is:
apptArrayOV1 = getfield(APPTS_BY_STATUS("Confirmed", "FULL"), "\r", "")