Notifications
Clear all
Topic starter
My goal is to remove a medication (let's say benazepril for now) and then add another medication - we're trying to enact a switching protocol.
Why does the code below simply return the Description of the first med on the list and completely ignore the BENAZEPRIL there? My hope was to obtain the DDID for logical comparisons and the MID to remove the med.
{global meds=getfield(MEDS_PRIOR("delim"),"|","" )
global DDID, MID
for i=1, i<size(meds), i=i+1
do
meds[i] = getfield(meds[i],"^","")
endfor
for i=1, i<size(meds), i=i+1
do
if match(meds[i][3],1,"BENAZ")
THEN
DDID=meds[i][3]
MID=meds[i][4]
ENDIF
endfor
DDID
}
Posted : February 2, 2015 10:53 am
try spelling out delimited.
Also, your match statement is missing >0 check:
if match(meds[i][3],1,”BENAZ”)>0 THEN...
-- and did you want to do your match against the description?
If so, you should be checking field 1.
if match(meds[i][1],1,”BENAZ”)>0 THEN...
You should be assigning MID from field 12 (I think), not field 4.
field 4 is GPI code.
and...In your second FOR loop, after you find DDID and MID,
add a break statement to stop looping.
THEN
DDID=meds[i][3]
MID=meds[i][12]
break
ENDIF
- Beverly
Posted : February 4, 2015 7:18 am