Struggling with this a little bit and it seems simple but not sure how to count the capturing of an obs term.
Simply put I would like to count the number of times weight was captured in a 9 month time span.
For example patient had 4 office visits within the past 9 months, in those 4 visits weight was record in the obs term WEIGHT each time. I want to be able to count that up and display 4.
Thanks in advance!
Thanks to gibsonmi here is the solution I needed:
{!fn xGrabWeightObs() {
local temp = getfield(LIST_OBS("WEIGHT",'signed','delimited','valuedate'), "|", "")
local hold
local counter
for i=1, i<=size(temp),i=i+1 do
hold = getfield(temp[i],"^","")
if hold[2] "" then
if DURATIONDAYS(str(._TODAYSDATE),ADDDATES(hold[2],"0","9","0"))>0 then
counter = counter + 1
endif
counter = counter
endif
endfor
return counter
}}
I don't have one that does that but it shouldn't be too hard, just loop through LIST_OBS() delimited, then compare the date in the second field to str(DOUMENT.CLINICALDATE) with DURATIONDAYS(), if its within 9 months then add one to a local counter variable and after the loop return that variable.
Thanks for the response! How would you compare to 9 month? Using at ADDDATES to the most recent valued pulled from LISTOBS?
if DURATIONDAYS(str(DOCUMENT.CLINICALDATE),ADDDATES(obsArrayName[2],"0","9","0"))>0 then
counter = counter + 1
endif
Read - if the day 9 months after the date of the observation is after the current document date then return true. This should get anything with 9 months of the current date (including dates in the future which theoretically should not exist for this scenario)