No Problem. I may have steered you wrong a bit, as I misread what your if statement was checking. If they already pick that obs term, and that is what you are checking, then it will keep repeating.
Go ahead and remove my code, and try this one instead:
{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}
The statement I added is {match(ORDERS_NEW("list"),"Suicide Watch Follow-up") == 0} This will check the orders placed today, and if they select the Obsterm for standard follow up as you have described, and no orders have been placed, it will run your code. Once the orders are in the system, the code will not run again in this note. Notice that I se ORDERS_NEW, so it only checks for orders placed in the current note, not all orders in the patient chart record.
To use a document variable, you would create a new edit field and name it SUI_ORDER. Make sure to delete the text translation so it doesn't randomly show up in the provider's note. You would then place the edit in a visibility field, and in the logic section, enter FALSE.
finally, change your code with this function:
{if match(OBSNOW("Watch_FU"), "Standard Follow Up - 1 day. 3 day. and 7 day")>0 and DOCUMENT.SUI_ORDER == "" 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"))
DOCUMENT.SUI_ORDER = "Suicide Watch Orders Placed"
else "" endif}
You can do either one of these options in your other forms. I sometimes use the Doc Variable if I want specific text to show in the note, or if I have multiple visibility fields controlled by the same option. You can even make a new Visibility field that has the following logic {DOCUMENT.SUI_ORDER <> ""} and then put a text item to say "Suicide Watch orders placed."
There is a lot you can do, but let me know if you need further info on the code above, or s not work. Sorry for the goof-up before. 🙂
Thank you,
Daniel C.