I am building a form and need to pull medications from the med list into a data display that are only in certain med classes. I can get it to work for one class, but need it to look for multiple classes. I found the follow code on here and am using it. What do I need to do to make it look for more than one class? I am fairly new to MEL and programming.
{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 }}{FMT("Antihypertensive Medications", "B,U,2") + HRET +FMT(GetMedsByClass("36", 2), "")}
Any help will be greatly appreciated!
Rebecca
I wrote this function to look for certain narcotics for an Oklahoma law - it looks for multiple GPI codes. It might help you get started:
fn ListPMPSubstances(strWhichMedList)
{
/* Parameters are 1 for MEDS_AFTER and 2 for MEDS_NEW
MEDS_AFTER is used for OUT-Prob Med Allergy Review
MEDS_NEW is used for CPOE A&P-CCC */
local i = 0
local curMedTotal = 0
local curMeds = ""
local medType = ""
local SchedDrugs = ""
local strPMPMedList
COND
CASE strWhichMedList = "1"
strPMPMedList = MEDS_AFTER("delimited")
CASE strWhichMedList = "2"
strPMPMedList = MEDS_NEW("delimited")
ELSE
return ""
ENDCOND
curMeds = getfield(strPMPMedList, "|","")
if str(curMeds) <> "" then
curMedTotal = size(curMeds)
endif
for i = 1, i <= curMedTotal, i = i+1 do
curMeds[i] = getfield(curMeds[i],"^","")
medType = curMeds[i][4]
if (medType <> "") then
if sub(medType,1,2) = "65" or sub(medType,1,6) = "571000" or sub(medType,1,6) = "721000" or sub(medType,1,7) = "7510002" or sub(medType,1,8) = "75990002" or sub(medType,1,8) = "75990003" or sub(medType,1,10) = "7599800230" then
SchedDrugs = SchedDrugs + curMeds[i][1] + HRET
else
""
endif
else
""
endif
endfor
return SchedDrugs
}
}