I have a userok script that I cannot get to function correctly. The section that is troubling me, is the part where it looks to see if a document variable is populated to determine whether or not to display. If I leave the code as-is below, the userok popup does not display and the document variable field is immediately populated with the OK text. If the "DOCUMENT.POPUP_SEEN1 = "OK"" portion is taken out, the popup displays... repeatedly (hence the need for the section of code).
{!IF DOCUMENT.POPUP_SEEN1<>"" THEN "" ELSE IF USER_JOBTITLE() <> "Physician"
THEN "" ELSE IF OBSNOW("SMOK STATUS") == "Current every day smoker" OR OBSNOW("SMOK STATUS") == "Current some day smoker" OR OBSNOW("SMOK STATUS") == "Smoker, current status unknown" OR OBSNOW("SMOK STATUS") == "Heavy tobacco smoker" OR OBSNOW("SMOK STATUS") == "Light tobacco smoker" THEN userok("Records indicate this patient consumes tobacco." + HRET + "Consider Smoking Cessation counseling.") ELSE "" ENDIF ENDIF DOCUMENT.POPUP_SEEN1 = "OK" ENDIF}
Any ideas on a fix or a better way to code this action? Thanks!
Try it like this and see if it works:
{DOCUMENT.POPUP_SEEN1}
{!
if DOCUMENT.POPUP_SEEN1 <> "OK" AND USER_JOBTITLE() == "Physician" then
if OBSNOW("SMOK STATUS") == "Current every day smoker" OR OBSNOW("SMOK STATUS") == "Current some day smoker"
OR OBSNOW("SMOK STATUS") == "Smoker, current status unknown" OR OBSNOW("SMOK STATUS") == "Heavy tobacco smoker"
OR OBSNOW("SMOK STATUS") == "Light tobacco smoker" then
userok("Records indicate this patient consumes tobacco." + HRET + "Consider Smoking Cessation counseling.")
DOCUMENT.POPUP_SEEN1 = "OK"
else "" endif
else "" endif
}
Inserted the above into the form and tested. The popup displays continuously and nothing is written to the DOCUMENT.POPUP_SEEN1 to turn off the userok function.
It seems to be working in my environment (CPS 12).
Make sure {DOCUMENT.POPUP_SEEN1} is declared somewhere on the right side. You can also post your mel trace log, and I can look over it to see if there seems to be some kind of interference from something else.
Try putting the DOCUMENT.POPUP_SCREEN1 = "OK" first, and then the userok prompt. And just use a carriage return instead of the HRET statement.
DOCUMENT.POPUP_SEEN1 = "OK"
userok("Records indicate this patient consumes tobacco.
Consider Smoking Cessation counseling.")
Robin Tardif
Hayes Management Consulting.