Hi,
I'm trying to write a MEL expression to find the most recent of two obs terms, and then find the next most recent. I think I probably need to put the two obs terms into an array and then compare them... but I'm having trouble putting that into practice.
Has anyone done something similar and can help out?
Thanks!
Have you tried using the LIST_OBS() function for each OBS TERM, return the result into an array and then looping through the array for the most recent and the next oldest OBS (i.e., loop at most twice)?
Just FYI, LIST_OBS returns all values for an obsterm, already descending date sorted. So if you only need the 2 most recent values for an obsterm, you only need the first 2 rows returned by LIST_OBS for that obsterm. - Beverly
The following code will display the last three BP readings. Perhaps you can use this as a guide.
{local sA1, sA2, a1, a2, s1="", i=0, imax=0
sA1 = getfield(LIST_OBS("BP SYSTOLIC","signed","list","valuedate"),")",HRET)
sA2 = getfield(LIST_OBS("BP DIASTOLIC","signed","list","valuedate"),")",HRET)
imax = (if size(sA1)<=3, size(sA1), 3)
s1=""
for i=1,i<=imax,i=i+1 do
a1 = getfield(str(sA1[i]),"(","")
a2 = getfield(str(sA2[i]),"(","")
s1=s1+(if s1<>"",HRET,"")+a1[1]+"(systolic) / "+a2[1]+" (diastolic) ("+a1[2]+")"
endfor
s1}
Which would create:
120 (systolic) / 80 (diastolic) (02/06/2015 4:31:42 PM)
134 (systolic) / 78 (diastolic) (11/17/2014 3:51:10 PM)
125 (systolic) / 78 (diastolic) (11/17/2014 3:25:39 PM)
Can anyone help me with this code but using the {APPT_BY_STATUS(“no show”)} function to return the patient's last three no show appointments?