this function will find the next appointment for a specific LOC.
{fn dn_find_next_appt(limit_loc){
loc_short=change_loc_form(limit_loc)
if loc_short=="not found" then userOK("Sorry, not able to resolve location names. ") return "" else "" endif
local appt_all=dn_FUTURE_APPT("delim") n=""
if appt_all=="" OR (match(appt_all,loc_short)=0 and match(appt_all,limit_loc)=0)then return "You do not have an appointment scheduled at the " + limit_loc + ". If you need to schedule an appointment please give us a call. " else "" endif
if match(appt_all,"|")=0 then appt_all=getfield(appt_all,"^","") return "Your next appointment at the " + limit_loc + " is on " + appt_all[1] + " at " + appt_all[2] + " with " + appt_all[5] + ". " else "" endif
appt_all=getfield(appt_all,"|","")
result_arr=array
for n=1, n<=size(appt_all), n=n+1
do
if (limit_loc=="no" or match(appt_all[n],loc_short)>0 or match(appt_all[n],limit_loc)>0) then result_arr=getfield(appt_all[n],"^","") break else "" endif
endfor
if result_arr[1]<> "" then return "Your next appointment at the " + limit_loc + " is on " + result_arr[1] + " at " + result_arr[2] + " with " + result_arr[5] + ". If you are unable to make this appointment or need to be seen sooner please call the clinic. " else return "" endif
}}
{fn dn_FUTURE_APPT(arg) {
//DN--3-31-04 modified from mellib stock function
local a, b,c, loc, atype, book, i = 0
local result='' field_delim="" rec_delim=""
if arg=="delim" then field_delim="|" rec_delim="^" else field_delim=hret rec_delim="," endif
local j = getRowCount('_MELCurPatientAppt')
if j == 1 then a = getRow("_MELCurPatientAppt",0,"ApptDate","ApptTime","Appttype","Booklist")
if val(a[1]) >= ._TODAYSDATE then
atype = find('_MELApptDef', 'ApptType', 'ID', a[3])
b = getfield(a[4],',',' :')
loc = find('_MELBook', 'LocationAbbrevName', 'ID',b[1])
c = getfield(a[4],',',' :')
book = find('_MELBook', 'Name', 'ID',c[1])
result = a[1] + rec_delim + appttime(a[2]) + rec_delim + atype + rec_delim + loc + rec_delim + book
endif
else if j > 1 then
while i < j do
i = i+1
a = getRow('_MELCurPatientAppt',i, 'ApptDate','ApptTime','Appttype','Booklist')
if val(a[1]) >= ._TODAYSDATE then
atype = find('_MELApptDef', 'ApptType', 'ID', a[3])
b = getfield(a[4],',',' :')
loc = find('_MELBook', 'LocationAbbrevName', 'ID',b[1])
c = getfield(a[4],',',' :')
book = find('_MELBook', 'Name', 'ID',c[1])
if result=="" then
result = result + a[1] + rec_delim + appttime(a[2]) + rec_delim + atype + rec_delim + change_loc_form(loc) + rec_delim + book else result = result + field_delim + a[1] + rec_delim + appttime(a[2]) + rec_delim + atype + rec_delim + loc + rec_delim + book endif endif
endwhile
endif
endif
if size(result)>1999 then return "Sorry, Too Long" else return result endif
}}
It's actually 2 functions I guess.
The function "call" is:
{dn_find_next_appt(user.homelocationname)}