I have written some code for a button called "Insert Previous", so that clicking this button checks a bunch of checkboxes corresponding to a patient's previous complaints. The code works beautifully when I click the button, but in the Chart Note I get some MEL garbage that looks like this:
global F456465_654967 = OBSNOW("ROSGEN COMPL") <- NESTED CALLS EXCEED LIMIT
The function I've written, called ros_insert_previous(), has no return value. It just sets the values of some observation terms (corresponding to checkboxes) using the syntax:
OBSNOW("ROSGEN COMPL",new_value)
My function only contains 'local' variables, and is designed to work for all bodily systems. Only when it is called by the 'General' category, does this happen. Other systems may have more or less checkboxes, and all systems call my function in exactly the same way.
I only want to remove this garbage from the note, as the function is brief, fast, and works properly. Occasionally, the garbage will print immediately upon opening the form even without clicking the button that triggers my code. Sometimes, it doesn't happen at all. My code is the only code running that references OBSNOW("ROSGEN COMPL").
Can anyone help me make my doctors happy, so they don't freak out and think the form is crashing when they open it?
Can you post the ros_insert_previous function and how you're calling it?
{
fn ros_insert_prev(system)
{
local compl_str=""
local deny_str=""
local whole_str=""
local deny_index=""
local compl_index=""
local end_compl_index=""
local compl=""
local deny=""
local comment_index = ""
if(system=="ROS:General")then
compl="ROSGEN COMPL"
deny = "ROSGEN DENY"
endif
if(system=="ROS eyes")then
compl="ROSEYE COMPL"
deny = "ROSEYE DENY"
endif
if(system=="ROS ENT")then
compl="ROSENT COMPL"
deny = "ROSENT DENY"
endif
(above repeated for all systems)
.
.
.
.
.
whole_str=OBSPREV(system)
comment_index=match(whole_str,". Comments:")
//remove comments
if(comment_index<>0)then
whole_str=remove(whole_str,comment_index)
endif
deny_index=match(whole_str,"Denies")
compl_index=match(whole_str,"Complains of")
//complaints only
if(deny_index==0)then
compl_index=compl_index+13
compl_str=sub(whole_str,compl_index)
compl_str=replacestr(compl_str,".","")
OBSNOW(compl,compl_str)
endif
compl_index=match(whole_str,"Complains of")
//denies only
if(compl_index==0)then
deny_index=deny_index+7
deny_str=sub(whole_str,deny_index)
deny_str=replacestr(deny_str,".","")
OBSNOW(deny,deny_str)
endif
deny_index=match(whole_str,"Denies")
compl_index=match(whole_str,"Complains of")
//both complaints and denies
if(deny_index<>0 and compl_index<>0)then
compl_index=compl_index+13
deny_index=deny_index+7
end_compl_index=match(whole_str,". D")
compl_str = sub(whole_str,compl_index,end_compl_index-compl_index)
deny_str = sub(whole_str,deny_index)
deny_str=replacestr(deny_str," .","")
OBSNOW(compl,compl_str)
OBSNOW(deny,deny_str)
endif
}
}
calls made like : ros_insert_previous(system)
ros_insert_previous("ROS:General")
There's some MEL code from GE running also. Just a simple concatenation of the complaints + denies into a single obs term.
{obsnow("ROS:General", ListBoxResult(OBSNOW("ROSGEN COMPL"),OBSNOW("ROSGEN DENY"),OBSNOW("ROS GEN COMM")))}
{obsnow("ROS eyes", ListBoxResult(OBSNOW("ROSEYE COMPL"),OBSNOW("ROSEYE DENY"),OBSNOW("ROS EYES COM")))}
Again, the only thing printing weird in the note is
Global F45646887_544564 = OBSNOW("ROSGEN COMPL") <-NESTED CALLS EXCEED LIMIT
Each system has an "Insert Previous" button, connected to RUNPROCESS of:
{ros_insert_previous(system)}
Only system affected is "General."
I would try stripping everything not related to ROS:GENERAL and see if it still happens. If it does, try running with a trace. My guess is that there's a processing loop somewhere...your code triggering GE's code which triggers your code again and so on...
SOLUTION:
I moved the
obsnow("ROS:General", ListBoxResult(OBSNOW("ROSGEN COMPL"),OBSNOW("ROSGEN DENY"),OBSNOW("ROS GEN COMM")))
obsnow("ROS eyes", ListBoxResult(OBSNOW("ROSEYE COMPL"),OBSNOW("ROSEYE DENY"),OBSNOW("ROS EYES COM")))
code to the Page Close Handlers area. Since I only needed to update these values when I was done with an update, this worked for my case. I was able to escape the processing loop, and still maintain the functionality that I needed.
No more MEL garbage in my Chart Note!!!
That's a fine solution for CPS 9.5. BEWARE that on CPS 10 the page close handlers do not always execute! They only execute at certain times, including using the "Previous Form" and "Next Form" buttons. If you have a form open and end the update without leaving it, the page close handlers never execute.
A new version that is a regression from the previous version....?
Another way to say it would be "a serious risk to data integrity."