Can someone help me with the code necessary to display a popup message If the patient is on certain medications? Thanks!
Sure, itll be different depending on where on how you want it to pop-up, but the basic code could be something like
{!if match(tolower(MEDS_AFTER()),"medication name")>0 then
userok("Popup Message")
endif}
Something like that should work in a patient banner to popup when the user opens a chart, in a document to popup when the document is open or medications are changed. It is limited to working with just exact matches on a single med (or multiple if you string some together with and statements, but that can get long and tedious). If you want it to work for a larger subset of meds or a class of meds, or want the popup timing different we will need more specific information to help you
Thanks, I am specifically looking to see if the patient is on an anticoagulant, then pop up a message to remind the provider. Is there a class just for anticoagulants?
According to my handout its any GPI starting with 83, someone at some point provided this function on CHUG to lookup meds by GPI (sorry I dont remember who to give credit to) where med_class is the GPI code (use "83") num is the number of digits you are providing for the GPI code, (use 2, no paranthesis) and update causes the function to fire. Depending on how you shoose to implement it this may do nothing.
{fn GetMedsByClass(med_class, num, update)
{
local rets = ""
local meds_array = getfield(MEDS_AFTER("delimited"), "|", "")
for i = 1, i <= size(meds_array), i = i + 1
do
local med_array = getfield(meds_array[i], "^", "")
if (ok(med_array[4])) then
if (med_array[4] <> "") then
if (sub(med_array[4], 1, num) == med_class) then
rets = rets + med_array[1] + HRET
else
continue
endif
else
continue
endif
else
continue
endif
endfor
if (rets == "") then
rets = "None"
endif
return rets
}}
Using this changes your popup code to
{!if GetMedsByClass("83", 2, "") <> "None" then
userok("The patient is on the following medications" + hret + hret + GetMedsByClass("83", 2, "") )
endif}
I didnt test any of this but the idea should work at least
That works in letters, and if I have the code below in a data display, but I can't get it to work if all of the code is in the MEL window. It acts as if it is not being triggered. Any ideas on how to make it work by just having it in the MEL window?
{!if GetMedsByClass("83", 2, "") <> "None" then
userok("The patient is on the following medications" + hret + hret + GetMedsByClass("83", 2, "") )
endif}
I placed all of this in the code panel of a blank form and it fired. If you are using a function on form open it either needs to be in a usrlib file (already loaded) or called with a '!' in the form
{!if GetMedsByClass("83", 2, "") <> "None" then
userok("The patient is on the following medications" + hret + hret + GetMedsByClass("83", 2, "") )
endif}
!fn GetMedsByClass(med_class, num, update)
{
local rets = ""
local meds_array = getfield(MEDS_AFTER("delimited"), "|", "")
for i = 1, i <= size(meds_array), i = i + 1
do
local med_array = getfield(meds_array[i], "^", "")
if (ok(med_array[4])) then
if (med_array[4] <> "") then
if (sub(med_array[4], 1, num) == med_class) then
rets = rets + med_array[1] + HRET
else
continue
endif
else
continue
endif
else
continue
endif
endfor
if (rets == "") then
rets = "None"
endif
return rets
}
Thank you! I finally got it to work.