I'm trying to display the first obs term values (oldest date) documented in an encounter, and don't really know where to start as none of the existing symbols seem to fit what I need.
Say I have an encounter with fields connected to 5 obs terms:
TERM1
TERM2
TERM3
TERM4
TERM5
I want to display only the first values that were filled in which would basically be the opposite of OBSANY. There no OBSFIRST type of symbol that I can fine.
Does anyone have a custom function to pull this?
I'll take whatever you have as a starting point for the above, but ultimately what I'm trying to get to (not sure if this can be done) is this:
The providers can fill out any combination of these 5 obs terms in the first encounter. For this example let's say they filled in terms 1, 2, 4, and 5 but left term 3 blank. How can I display the first values only that have the same date or encounter? In this scenario I would never display the value of obs term 3 because it was not documented in the initial exam although it could have been documented in a follow-up encounter.
To get the first value of an obsterm, check out LIST_OBS in the EMR Help. You can loop through the array backwards (negative counter) and grab it that way.
To get obsterms as a set, you need to:
1) Define a specific date for said set - I typically use an associated obsterm that is always filled out as an 'anchor date'. Depending on what you are looking for will determine how you find it.
2) Loop through all the desired obsterms using list_obs individually.
3) If the obs date matches the date of the anchor obs, break and return that value, otherwise continue looping. If no date match is found, no result is returned.
Example (strDate = the anchor obs date ; strObs = the obsname for the value being sought):
{! fn fnCheckObsDate_LC(strDate,strObs)
{
local retStr = ""
local strTemp = ""
local strBuf = ""
local i
local strList = ""
strList = LIST_OBS(strObs, "signed", "delimited", "value")
strTemp = getfield(strList, "|", "")
for i = 1, i <= size(strTemp), i = i + 1 do
strTemp[i] = getfield(strTemp[i], "^", "")
strBuf = strTemp[i][2]
if strDate == strBuf then
retStr = strTemp[i][1]
break
else
retStr = ""
endif
endfor
return retStr
}
}
Hope this helps.
You could also loop through the data returned from LIST_OBS and do a DURATIONDAYS, comparing each one against the oldest one you have saved and keep "saving" the oldest one until you have looped through the whole data set.