Hello.
I can use the following to list the number of no shows for a patient in the banner if they have a no show:
{global alist = getfield(APPTS_BY_STATUS("no show","FULL"),"\r","")
global asz = size(alist)
global tempa
global rslt=""
for count = 1, count < 4, count = count + 1
do
tempa = getfield(alist[count],",","")
days = DURATIONDAYS(str(._TODAYSDATE),tempa[1])
if days<0 then
rslt = count + "-NS"
else " " endif
endfor
rslt
}
The issue is when the patient has 0 no shows, I receive Bad Value or Bad Index error message in the banner. I believe the error message is because the value it is looking for is not there. Thoughts??
Just wrap everything after your first line in an if/then and if the first variable is empty, return a string indicating no no-shows, otherwise execute your code.
{global alist = getfield(APPTS_BY_STATUS("NO SHOW","FULL"),"\r","")
if APPTS_BY_STATUS("NO SHOW","FULL")"" then
global asz = size(alist)
global tempa
global rslt=""
for count = 1, count < 4, count = count + 1
do
tempa = getfield(alist[count],",","")
days = DURATIONDAYS(str(._TODAYSDATE),tempa[1])
if days<0 then
rslt = count + "-NS"
else "" endif
endfor
endif
rslt
}
Still not working. Do you see what I am missing?
Looks like this line should be:
if APPTS_BY_STATUS("NO SHOW","FULL") <> "" then
rather than
if APPTS_BY_STATUS("NO SHOW","FULL")"" then
{global alist = getfield(APPTS_BY_STATUS("no show","FULL"),"\r","")
global asz = size(alist)if APPTS_BY_STATUS("no show","FULL")<1 then
global tempa
global rslt=""
for count = 1, count < asz, count = count + 1
do
tempa = getfield(alist[count],",","")
days = DURATIONDAYS(str(._TODAYSDATE),tempa[1])
if days<0 then
rslt = count + "-NS"
else "" endif
endfor
rslt
else "" endif
}
This code works, I just need it to look at the previous 18 months (approx 540 days) instead of every no show the patient has ever had.
You could do this:
if days< 0 and days > -540 then
Or you could swap the items in DURANTIONDAYS if you wanted to work with positive numbers.
{global alist = getfield(APPTS_BY_STATUS("no show","FULL"),"\r","")
global asz = size(alist)if APPTS_BY_STATUS("no show","FULL")<1 then
global tempa
global rslt=""
for count = 1, count < asz, count = count + 1
do
tempa = getfield(alist[count],",","")
days = DURATIONDAYS(str(._TODAYSDATE),tempa[1])
if days -540 then
rslt = count + "-NS"
else "" endif
endfor
rslt
else "" endif
}
the above gives me all no shows
{global alist = getfield(APPTS_BY_STATUS("no show","FULL"),"\r","")
global asz = size(alist)if APPTS_BY_STATUS("no show","FULL")<1 then
global tempa
global rslt=""
for count = 1, count < asz, count = count + 1
do
tempa = getfield(alist[count],",","")
days = DURATIONDAYS(tempa[1],str(._TODAYSDATE))
if days 540 then
rslt = count + "-NS"
else "" endif
endfor
rslt
else "" endif
}
The above shows 0 no shows
This code:
days = DURATIONDAYS(tempa[1],str(._TODAYSDATE))
Sets the variable "days" to the difference between the date of the appointment from APPTS_BY_STATUS and today's date. If the appointment date is less than today's date, you get a positive number.
This code:
if days 540 then
doesn't do anything. It MIGHT evaluate to TRUE is the appointment was 540 days earlier than today's date. The code needs to say that if the number returned is greater than 0 and less than or equal to 540 do something with it:
if days <= 540 and days > 0 then
This catches all your no show appointments that are within 540 days prior to today's date.
Also, your counting logic only works if the appointments are returned newest to oldest. You might want to verify that.
You are absolutely correct David. I want to look at my appts newest to oldest but it is looking at the oldest to newest. How do I change the way it is counting? I appreciate you staying with me and helping me. Have a great one.
So try this for the end of your code:
if days <= 540 and days > 0 then
rslt = rslt + 1
else "" endif
endfor
return rslt + "-NS"
That should increment rslt every time it finds one of the appointments you want to count, then at the end returns that total and appends the -NS string. Also, it looks like you have a stray else "" endif at the end of your code. I don't see an if that pairs with it.
Good Luck!