I am able to to the no shows in the patient banner until there is a canceled appointment in the mix. Following is the code I am using:
{global alist = getfield(APPTS_BY_STATUS("no show","FULL"),"\r","")
global asz = size(alist)
if APPTS_BY_STATUS("no show","FULL")0 then "" endif
if APPTS_BY_STATUS("canceled","FULL")>0 then "" endif
if APPTS_BY_STATUS("arrived","FULL")>0 then "" endif
global tempa ""
global rslt=""
for count = 1, count < asz, count = count + 1
do
tempa = getfield(alist[count],",","")
if(alist[count]"") then
if(val(DURATIONDAYS(sub(tempa[count],1,10),str(._TODAYSDATE)))<=540)then
rslt = count + "-NS"
else "" endif
else "" endif
endfor
rslt}
Does anyone know how I can count the no shows and have the code ignore the canceled appointments. Any assistance is appreciated.
The error message is bad length.
Hello,
Just so I understand correctly, are you just looking count the number of "no show" appointments and display that number in the banner?
Thanks,
Terrence Goggans
Yes, count the # of no shows in the last 540 days.
Gotcha. Let me test something and I will back out with an update.
Thanks,
I can't think of why this would work if there aren't cancelled appointments, but not if there are cancelled appointment. I suspect it may have more to do with how many no-show appointments there are. It is possible that you didn't copy the code you are using exactly as there seem to be several errors that I would expect would keep it from working.
I think you could simplify the code significantly.
First of all, I would start using locals rather than globals. Global variables can be very messy and when used in a case like this (banner) can cause information from one chart to "travel" and be displayed in another chart.
I would recommend discarding \n in the first getfield statement as otherwise that might be the first character in every entry after the
The 3 if statements at the beginning seem unnecessary and the first one appears to have an error so I would just remove them.
I am also not sure what the purpose is for the first if statement inside the for loop. I would recommend removing that.
I suspect the problem comes from the reference to tempa[count] as count is a reference to the appointment number and tempa is already that subitem.
I think the final code could be something like the following:
{local alist = getfield(APPTS_BY_STATUS(“no show”,”FULL”),”\r”,”\n”)
local asz = size(alist)
local tempa
local rslt=””
for count = 1, count < asz, count = count + 1 do
tempa = getfield(alist[count],",","")
if(val(DURATIONDAYS(sub(tempa[1],1,10),str(._TODAYSDATE)))<=540) then
rslt = count + "-NS"
else "" endif
endfor
rslt}
NOTE: I haven't tested this.
It could probably be simplified further by getting rid of the "full" parameter as you don't use anything that isn't returned without this.
You probably don't even need the second getfield statement. you could just remove tempa and use alist[count] instead.
I think there is likely a problem with the way the you are checking if appointments were in the last 540 days. My reading of the documentation is that the earliest appointments are always at the beginning. If that is the case this will always return the total number of no-shows unless there are none in the last 540 days. If that is the case, you could do the following:
1. Rewrite to include size(alist) in the for statement rather than asz.
2. Call remove(alist, count, 1) to remove appointments that are not in the last 540 days. Potentially break when you find the first appointment within 540 days.
3. At the end (after the endfor), set rslt to str(size(alist) - 1) + "-NS". At this point all of the appointments that aren't in the range should be removed. The -1 is because I believe the APPTS_BY_STATUS() data symbol might return a trailing \r\n. If it doesn't you should remove the -1 and the comparison in the for loop should be <= rather than <.