End goal here is to pull the medications that are controlled substances and display those. Using MEDS_AFTER there doesn't seem to be a field that identifies whether a drug is a controlled substance or not.
I use the following piece frequently to pull meds
{!fn xGrabMeds() {
local temp = getfield(MEDS_AFTER("delimited"), "|", "")
local hold
local rslt =""
for i=1, i<=size(temp),i=i+1 do
hold = getfield(temp[i],"^","")
if hold[1] <> "" then
if rslt <> "" then
rslt = rslt + hret
endif
rslt = rslt + hold[1] + ","
endif
endfor
return rslt
}}
If there is a field that identifies a controlled substance I could put that in for my hold and I think that would do, otherwise I would have to filter out the description field with LISTSUBSET maybe?
Anyway; hoping I missed something or there's another symbol out there for this. Thanks in advance.
Index 4 of the MEDS_AFTER array holds the GPI number. The best you could hope for is to create a subroutine that evaluates GPI masks for the target medications. As a general rule, analgesic/narcotic medications fall in the 64-71 range (65 is narcotic specific), but understand that off label uses as well as DEA rules can place other medications within a GPI series in a controlled status, so those would need to be accounted for as well.
A simple cond-case plus a match(GPI Mask,Rx GPI) == 1 (the mask should always start at index 1) statement should get you there and make it easy to expand as needed. You can make you mask as loose (fewer numbers but no less than 2) or as tight (up to the full GPI number) as needed. Using a case statement makes it easy to adjust.
Using the above, you could create masks that would let you define most of the narcotic meds (65) in an effort to get the project off the ground. From there, identify the 'outliers' and add them to the case statement as desired.
Hope this helps.