Hi, I have a function that collects all the tobacco use info in one place, to add to an assessment.
It works fine, but problem is, its fired from a data display, and if I add or change the meds, it doesn't update the Assessment unless I open the form again, to look at the display (and then it updates immediately).
Most Watcher functions will fire as soon as an OBS term changes, but I wonder how I can get this one to fire as soon as the med is changed or added?
Here is the Watcher code that pulls all the data together:
{fn SMKASM(var1,var2,var3,var4) {
SMOK_ASSESSMENT=
""
If (OBSNOW(
"SMOK STATUS"))<>"" then SMOK_ASSESSMENT=SMOK_ASSESSMENT + "Smoking Status: " + OBSNOW("SMOK STATUS") + HRET ENDIF
If (OBSNOW(
"SMOK ADVICE"))=="yes" then SMOK_ASSESSMENT=SMOK_ASSESSMENT + "Advice to quit tobacco use given today." + HRET ENDIF
If (OBSNOW(
"QUIT SMK STG"))<>"" then SMOK_ASSESSMENT=SMOK_ASSESSMENT + "Quit Stage: " + OBSNOW("QUIT SMK STG") + HRET ENDIF
If (CCC_sys_filter_meds(
"6210")<>"") then SMOK_ASSESSMENT=SMOK_ASSESSMENT + "Current Rx for Smoking Cessation: " + CCC_sys_filter_meds("6210") + HRET ENDIF
return SMOK_ASSESSMENT}
}
I have a Data display which maps the meds to an OBS term (but still no joy)
{OBSNOW(
"SMOKCESSMEDS",(CCC_sys_filter_meds("6210")))}
and here is the function call:
{IF (match(PROB_AFTER(),
"TOBACCO USER") > 0) then MEL_ADD_ASSESSMENT('DX OF','TOBACCO USER','ICD10-F17.200','C',str(SMKASM(OBSNOW("SMOK STATUS"),OBSNOW("SMOK ADVICE"),OBSNOW("QUIT SMK STG"),OBSNOW("SMOKCESSMEDS")))) else "" endif}
{IF (match(PROB_AFTER(),
"TOBACCO USER") > 0) then fmt("TOBACCO USER ASSESSMENT/PLAN:","B") + "
"
+ str(SMKASM(OBSNOW("SMOK STATUS"),OBSNOW("SMOK ADVICE"),OBSNOW("QUIT SMK STG"),OBSNOW("SMOKCESSMEDS"))) else "" endif}
Any advice would be appreciated. Thanks.
CJZ
I would set a global variable equal to MEDS_AFTER()...
{!global med_at_load = MEDS_AFTER()}
then...
{if MEDS_AFTER() <> meds_at_load then
statements...update display...
endif}
Thanks for the suggestion; it didn't work but gave me the idea to do this:
{!OBSNOW("SMOKCESSMEDS",(CCC_sys_filter_meds("6210")))} in the functions list
and set the Data display to show:
{"TOBACCO USER ASSESSMENT/PLAN:" + "
" + str(SMKASM(OBSNOW("SMOK STATUS"),OBSNOW("SMOK ADVICE"),OBSNOW("QUIT SMK STG"),OBSNOW("SMOKCESSMEDS")))}
Since the function sends OBSNOW("SMOKCESSMEDS") as the fourth variable in the display, now it updates every time I change the meds.
Mysterious Watcher expressions!! - I still don't understand them completely, but at least this works...