We use a wathcer form, that checks values of obs terms, and loads forms based on the results.
It was working for the longest time, but now, it is loading the same form every time the note is opened, resulting in multiple copies of the same form. The code is pretty basic. The only thing that was changed is the criteria and form name. Can anyone tell me what might be the issue ?
{if PROB_AFTER("delimited")"" then findform() else "" endif}
{!fn findform(){
local form_name=""
local form_place=""
local form_list_array=getfield(GET_FORM_LIST(),"|","")
for count=1, count<=size(form_list_array), count=count+1 do
local form_list=getfield(form_list_array[count],"^","")
form_name=form_list[2]
if form_name="Heart Diab Renal Watcher" then form_place=count else "" endif
endfor
If obsany("CMPLANPRINT")"" then
ADD_FORM_COMP('Enterprise\FSLOC','Care Plan',str(form_place))
else "" endif
If val(lastobsvalue("HGBA1C")) > 8.99 then
ADD_FORM_COMP('Enterprise\FSLOC','Care Plan',str(form_place))
else "" endif
}}
Your criteria looks incorrect. Shouldn't it be PROB_AFTER("delimited") == "" ?
Also, you should test for the existence of the form you are inserting and skip inserting if it exists.
there are a couple places like that
"If obsany("CMPLANPRINT")”” then"
If obsany("CMPLANPRINT")==”” then
is another
Cutting and pasting removed the symbols , but they do exist in the code. Sorry.