I am trying to produce the date of the patients last mammogram. We use 2 different OBS terms and patients can have both. I tried this:
{IF LASTOBSDATE("MAMMOGRAM") == "" and LASTOBSDATE("BMAMSCRTOB")== "" THEN "No mammogram on file"
ELSE LASTOBSDATE("MAMMOGRAM") "+" LASTOBSDATE("BMAMSCRTOB")
ENDIF}
It seems to pulling the correct date, but if the patient had both shouldn't it produce both dates?
Thanks
Laurie
.
.
.
ELSE LASTOBSDATE(“MAMMOGRAM”) +" "+ LASTOBSDATE(“BMAMSCRTOB”)
.
.
.
Thank you. Worked perfectly.
Laurie
We actually use a function that allows us to pass it multiple Obs Terms and it will return the Obs Term with the most recent date and the value of that date.
Would you be willing to share the function?
Thanks
Laurie
OK, first I'll show you how we call the function:
fnUtilityGetMostRecentObsName(array("CHLAMYD CULT", "CHLAMYD DNA", "C TRACHO DNA"))
Here is the code for the function, it resides in the Utility library, so I do not know if this is something my predecessors created or if it is canned function:
{
local lCounter
local lSize
local lMostRecent
local lCurrentDate
local lDate
lMostRecent = 0
lSize = size(arrObsName)
for lCounter = 1, lCounter <= lSize, lCounter = lCounter + 1 do
lCurrentDate = LASTOBSDATE(arrObsName[lCounter]) /* Determine date of most recent value for this observation */
if (lCurrentDate <> "") then
if (lMostRecent > 0) then /* If there is another "valid" observation already found */
if (DURATIONDAYS(lDate, lCurrentDate) > 0) then /* If last date for observation is after last date for other "valid" observation */
lMostRecent = lCounter
lDate = lCurrentDate
endif
else
lMostRecent = lCounter
lDate = lCurrentDate
endif
endif
endfor
if (lMostRecent > 0) then /* If a valid observation has been found */
return (arrObsName[lMostRecent]) /* Return its name */
endif
return ("")
}