Hello All,
This is a strange problem. I'm hoping someone else has come across it. I can't seem to update a variable name in MEL.
Some background: I ran into an issue where a function was returning a value that was unexpected and that value depended on whether the form was in a visit with other forms or by itself. The form by itself worked as intended. For reference the top part of the function looks like this:
//variables
local csmyr = sub(str(document.clinicaldate),7,4) //this year
local qyrs = val(OBSNOW("SMOK YR Q")) //quit year
local yrssq = csmyr - qyrs
local smage = PATIENT_AGE()
local smorder = ORDERS_NEW("delimited")
local lastscn = ""
//days since last screening
if (OBSANY("LUNGCASCREEN") <> "") then
lastscn = DURATIONDAYS(OBSANY("LUNGCASCREEN"),sub(str(document.clinicaldate),1,10))
else
lastscn = ""
endif
The rest of the function takes lastscn (among other things) and returns "true" or "false". I determined that the issues was lastscn was being assigned a value of 0 when it should just be blank. Since I was having trouble with the form only when other forms were present, I thought something else in the visit shared the same name and was assigning the value. I thought I simply needed to make the variable name more unique. I did so.
I updated the form in our test system and it works fine with the variable name change. I updated in the production system and when I run a mel trace of the form by itself I can see the update I did (changing lastscn to xyzlastscn) and it works. When I run the form in a visit with other forms it fails like I didn't change anything. When I run a mel trace I don't see the variable name change -- it shows the form assigning a value to lastscn. The form paths and time stamps are the same. Does anyone have any thoughts?
Out test system is on: CPS 12.3.0.2242
The production system is on CPS 12.2.1.3779
I'm using the latest version of VFE.
Thanks,
Brad
Difficult issue without the form and attempts at debugging.
But....., my guess is that you have a sub function whose index is out of the length of the string.
You can verify this by putting userok(size("...string...")) prior to the sub() call.
Sounds like that encounter has a form where the function name is the same as the one you are trying to update. If that is the case, the function definition it will hold onto is the last one it loads. That's the only thing that makes sense if the function is updated in the form by itself and not updated with other forms in the same encounter. You can try to load the encounter, and then manually add the form after the rest of the encounter loads to verify this. If you do that I would expect the function to be the new version.
It would appear that, as Michael suggested, something other form (or text component or usrlib file) is loading and overwriting the function.
When you changed the variable name, did you change the FUNCTION name? You might want to test that. If the 'change' works, then you can evaluate the other content one item at a time with the form in question, checking to see what is causing the overwrite in a MEL trace.
You do not want to leave this one unresolved, even if the function name change works for you. There is clearly some associated code in use that you need to identify.
Lee and Michael,
Thanks for the suggestion. I was definitely scratching my head. I changed the function name and the function calls and that fixed my issue. I went searching through the visit and found the duplicate function. I am going to make a couple of adjustments in the other form and I think should now be in good shape.
Thanks,
Brad