I am trying to create a form which will allow the user to load all of the necessary forms from within an update. I am using ADD_FORM_COMP and loading a bunch of forms. I get MEL vomit saying that the observation terms have no value and <--VOID. If I put the update on hold and go back in, the MEL vomit disappears but I have a new issue. The order of the forms changes. Where the form was:
HPI
Vitals
Physical Exam
Assessment/Plan
It will move them around:
Vitals
Assessment/Plan
HPI
Physical Exam
Any thoughts on why this is happening???? Thanks!!
1. This sounds like the code you have is running before the OBS data can load. Timing has caused a lot of form development headaches like this.
2. Is this a Text component, or a Form Component.
3. Can you post your code so we can see if there are any errors?
Thank you,
Daniel Carpenter
Run a MEL trace. I suspect there is an initialization issue where a function is called but not yet loaded into memory, or a local variable is referenced when it should be global, or perhaps even an index error in an array/loop, lastly, it could be an ordinal insertion issue if you are using those to add the form. This behavior can be seen with these types of 'critical errors' that halt MEL processing.
Understand that sequential MEL_ADD_FORM calls come with unique challenges and are difficult to manage overall due to how the EMR re-evaluates symbols upon load of a form. Making matter worse, in my opinion, the data symbol does not refresh itself properly making it painful to add multiple forms, especially if any of them issue the 'open' command. Care must be taken to balance loading each form against the watcher expressions (including translations) they contain.
So the MEL is basically
if document.updatetype == "Intake1" then
ADD_FORM_COMP("Enterprise","HPI - Online","","","")
ADD_FORM_COMP("Enterprise","Vitals","","","")
ADD_FORM_COMP("Enterprise","Physical Examination Component","","","")
else if document.updatetype == "Intake2" then
ADD_FORM_COMP("Enterprise","HPI Physical","","","")
ADD_FORM_COMP("Enterprise","Vitals","","","")
ADD_FORM_COMP("Enterprise","Physical Examination Component","","","")
else if document.updatetype == "Intake3" then
ADD_FORM_COMP("Enterprise","FollowupHPI","","","")
ADD_FORM_COMP("Enterprise","Physical Examination Component","","","")
ADD_FORM_COMP("Enterprise","Vitals","","","")
else ""
endif
endif
endif
I agree with lee that you should run a MEL trace while using the form. It could be another form messing with your code, or it could be a timing issue that is causing the form to not run properly on startup, and then to be wonky once the form is refreshed. Let us know if you need assistance on using MEL Trace.
On a side note, is "DOCUMENT.UPDATETYPE" a variable that the user picks, or is it something that is set in your code elsewhere?
Ken,
If you run a MEL Trace, do you see the doc var being populated on the first pass or is it valued at NULL? While I don't think it to matter, it may help knowing 'downstream' for troubleshooting.
Also, consider using cond-case-endcond instead of if-then-endif. For applications like these, MEL seems to like it better, oddly enough.
Lastly, you might try one or both of the following:
- Include the position parameter, be it 'AFTER_CURRENT' or an ordinal number. - This may force the proper position, however, as I mentioned before, this data symbol is limited with a refresh 'feature' (MEL will immediately refresh most everything BUT this symbol when a form is loaded) that may yield the same result, unfortunately.
- Add the forms via a function instead of within the base code itself (an individual call for each form to be added - so 3 calls total). It seems to me that sometimes the immediate MEL ' code stack' can be 'reset' after this symbol is executed, meaning any trailing code can possibly be ignored. Using individual function calls as a brute force measure may be helpful since the last trigger in the execution is merely a return out of the function, returning it to the next function call - rinse and repeat.