Good morning Daniel,
I applied the first revised MEL string you sent and still got the duplicate orders. I set up the doc variable and used the accompanying MEL string and "bingo" no more duplicates!! It works for both possible scenarios, the user placing the doc on hold or toggling between values. I also applied your suggestion of an additional visibility condition with a text "display" indicating that the suicide watch follow-up orders have been placed. I'm going to see if your fix will resolve a similar issue with a form where we have been getting multiple instances of directives in the same encounter.
For some context, the forms we (Ohio Department of Rehabilitation Correction - Behavioral Health services) are using were either OTB - with some modifications, built from scratch by the vendor (Fusion) , or built by me with support from the vendor. Consequently, I have been learning by looking at how existing pieces of code function and adapting them to a specific need. A lot of trial and error.
I really appreciate your willingness to share your expertise.
Thanks again
Dale F
I know how that goes. I learned a lot of how MEL works by trial and error, and studying other peoples forms. I still find myself making little mistakes, and then having to troubleshoot them a few times to make them work. After a while you start to get a feel for the little quirks the system has.
I did find that I spelled Follow-up with a lowercase 'u', and your order has an uppercase one. that is why it failed again. it can be very finicky with exact spelling. here is an updated code for that first one:
{if match(OBSNOW("Watch_FU"), "Standard Follow Up - 1 day. 3 day. and 7 day")>0 and match(ORDERS_NEW("list"),"Suicide Watch Follow-Up") == 0 then
MEL_ADD_ORDER("T", "Mental Health", "Suicide Watch Follow-Up", "", "", "", "1 day", "", "N", "", ADDDATES(str(._TODAYSDATE), "0", "0", "1")) and
MEL_ADD_ORDER("T", "Mental Health", "Suicide Watch Follow-Up", "", "", "", "3 day", "", "N", "", ADDDATES(str(._TODAYSDATE), "0", "0", "3")) and
MEL_ADD_ORDER("T", "Mental Health", "Suicide Watch Follow-Up", "", "", "", "7 day", "", "N", "", ADDDATES(str(._TODAYSDATE), "0", "0", "7"))
else "" endif}
This is where I really should have just copy/pasted so I didn't mess up the spelling. Good luck on learning and making your own content!
If I've learned anything about MEL, it's that the devil is in the details. Copy and paste is definitely the hot tip.
I applied your fix to another form in which we were getting duplicate directives. Works like a charm.
Thanks again Daniel