My function below works great as long as there is information in the follow-up obs term, but if not I receive a VOID error. Nothing I have tried is working, can anyone help with this?
{fn listobsdateonly(obsname){
local obsarray1
local obsarray2
local obsreturn
obsarray1 = getfield(LIST_OBS(obsname,'update','delimited','value'),"|","")
for i = 1, i <= size(obsarray1), i=i+1 do
obsarray2 = getfield(obsarray1[i],"^","")
if obsreturn <> "" then
obsreturn = obsreturn + hret
endif
obsreturn = obsreturn + obsarray2[1] + " (" + obsarray2[2] + ")"
endfor
return obsreturn
}}
Follow-up appointment to be scheduled (date listed is an approximate date):
{listobsdateonly('FOLLOW-UP')}
for loops always execute once and do the check after. check the size of your array before the for loop.
The only loop I know that executes once without checking the conditional is a do while loop. For loops should check the value before entering the loop; however, it will do the addition (i = i + 1) at the end of each loop.
Maybe the problem here is that you are getting an array of size 1 that just has an empty string in the first spot? In which case you would probably need to check for size(obsarray1) == 1 and obsarray1[1] == ""
Thank you both, I tried a few changes with the loop but they didn't work. Do you think maybe it could be because it is returning obsreturn at the end but there is no value for it to return? Though I tried fixing that too with an alternate return and it didn't help.
Oh, I see what you mean. Just decalre obsreturn with empty string:
{fn listobsdateonly(obsname){ local obsarray1 local obsarray2 local obsreturn
obsreturn = ""
obsarray1 = getfield(LIST_OBS(obsname,'update','delimited','value'),"|","") for i = 1, i <= size(obsarray1), i=i+1 do obsarray2 = getfield(obsarray1[i],"^","") if obsreturn <> "" then obsreturn = obsreturn + hret endif obsreturn = obsreturn + obsarray2[1] + " (" + obsarray2[2] + ")" endfor return obsreturn }}
That was it, great. I had tried declaring it but without the =
Thanks 🙂
Have you thought about using LAST_SIGNED_OBS_DATE("obs") ?
This is used in the clinical visit summay so it needs to capture obs inside the update that aren't signed yet, thanks for checking though.
there is also LAST_OBS_DATE() and LAST_OBS_DATETIME()
There are multiple follow-up values in one update sometimes (annual exam, diabetes etc.) I built a form to go along with it. It is for open access practices.