We are on EMR 9.8. We have a patient instruction handout that shows the patients appointments. Currently we use {APPTS_BY_STATUS("scheduled")}. The problem I have is there are appointments in our system with a date prior to current date that are still in a "scheduled" status. Has anyone wrote an array or coded to omit the past appointments from printing on a handout? Any help would by greatly appreciated!
I use the following in my user banner. It determines the next scheduled appointment and last arrived appointment. If you review the coding halfway (to the setting of nextappt) you will see what I did to only get future appointments. I used the fps to only get the first next appt; once I find the earliest next appt, I flip that flag to stop looking.
{global apls = getfield(APPTS_BY_STATUS("scheduled","FULL"),"\r","")
global apsz = size(apls)
global nxtap = ""
global nextappt = ""
fps = 1
for count = 1, count < apsz, count = count + 1
do
datedelim =match(apls[count],"/")
if datedelim > 0 then
appt_dt = sub(apls[count],datedelim-2,10)
days = DURATIONDAYS(str(._TODAYSDATE),appt_dt)
if val(days) >= 0 then
if fps = 1
then nxtap=appt_dt;fps=0
else "" endif
else "" endif
endif
endfor
nextappt=nxtap
global apptlisting = getfield(APPTS_BY_STATUS("ARRIVED","FULL"),"\r","")
global apptsize = size(apptlisting)
global lastappt2 = ""
for count = 1, count < apptsize, count = count + 1
do
datedelim =match(apptlisting[count],"/")
if datedelim > 0 then
appt_date = sub(apptlisting[count],datedelim-2,10)
days = DURATIONDAYS(str(._TODAYSDATE),appt_date)
if val(days) <=0 then lastappt2 = appt_date else lastappt2 = "" endif
else ""
endif
endfor
}
Thank you very much! That is exactly what I was looking for.