I feel like I've done this in a past form, but cannot locate it, so I'm turning to my fellow Chuggers. 🙂 I want to create a MEL watcher expression that will look for an order being entered, then take a few actions: print a handout, write data to the MUActivityLog, write a value to a document variable.
I want a value written to the document variable to then look to it before re-running the above sequence of events (to prevent multiple handouts and data write backs).
Below is what I have. All works, minus the document variable write back. Resulting in a never-ending loop of handouts and data write backs. 🙂
{!if document.tons_aden <> "" then "" else if match(orders_new(),"42820") > 0 then
printhandout("Handouts\Tonsillectomy and Adenoidectomy") and
ADD_MUACTIVITY_LOG(12,find("_UserSearch","loginname","RealName",
DOCUMENT.PROVIDER), "Handout Given: Post Op Tonsillectomy
and Adenoidectomy" and document.tons_aden = "done" else "" endif endif}
You just give the commands in a row (no ands).
If blah then
dothis
dothat
dothisandthat
else
dothis
endif
Here is your code back... I haven't tested it in my system, but I am guessing it may work like you are intending.
{!if document.tons_aden “” then break
else if match(orders_new(),”42820″) > 0 then
printhandout(“Handouts\Tonsillectomy and Adenoidectomy”)
ADD_MUACTIVITY_LOG(12,find(“_UserSearch”,”loginname”,”RealName”,DOCUMENT.PROVIDER), “Handout Given: Post Op Tonsillectomy and Adenoidectomy”)
document.tons_aden = “done”
else break endif endif}
I recommend putting ORDERS_NEW("delimited") in your watcher expression, that way it only evaluates when ORDERS_NEW changes. Something like this...(disclaimer, untested, will probably crash)
{
!OrderUp(ORDERS_NEW("delimited"))
}
! fn OrderUp(ord)
{
cond
case ord == "": /*Do Nothing*/
case document.tons_aden <> "": /*Do Nothing*/
case match(ord,"42820") > 0:
printhandout(“Handouts\Tonsillectomy and Adenoidectomy”)
ADD_MUACTIVITY_LOG(12, find(“_UserSearch”,”loginname”,”RealName”,DOCUMENT.PROVIDER), “Handout Given: Post Op Tonsillectomy and Adenoidectomy”)
document.tons_aden = “done”
endcond
}
Thank you, I knew it was going to be something horribly simple as line breaks. 🙂 Thanks again!