want to have a data display that shows the most current data from 3 different obs terms
So, like find most current entry from
LASTOBSDATETIME("PNEUMOVAX")
LASTOBSDATETIME("PPSVBOOSTER")
LASTOBSDATETIME("RSNPNEUNTGN")
then display
LASTOBSVALUEDATE of that term.
maybe something like this?
COND
case LASTOBSDATETIME("PNEUMOVAX") < LASTOBSDATETIME("RSNPNEUNTGN") < LASTOBSDATETIME("PPSVBOOSTER")
LASTOBSVALUEDATE("PNEUMOVAX")
case LASTOBSDATETIME("RSNPNEUNTGN") < LASTOBSDATETIME("PNEUMOVAX") < LASTOBSDATETIME("PPSVBOOSTER")
LASTOBSVALUEDATE("RSNPNEUNTGN")
case LASTOBSDATETIME("PPSVBOOSTER") < LASTOBSDATETIME("PNEUMOVAX") < LASTOBSDATETIME("RSNPNEUNTGN")
LASTOBSVALUEDATE("PPSVBOOSTER")
ENDCOND
but then i would just get a TRUE of FALSE so i don't know what i need to add
For only 3 dates, you can do this without getting too lengthy. For 4 or more date comparisons, I would probably use arrays and sort them. Put this function in the code window of the form:
{!fn GetLatest(update, obs1, obs2, obs3) { cond case (LASTOBSDATE(obs1) <> "") AND (LASTOBSDATE(obs2) <> "") AND (LASTOBSDATE(obs3) <> "") local most_recent most_recent = "" if (DURATIONDAYS(str(LASTOBSDATE(obs1)), str(LASTOBSDATE(obs2))) <= 0) then most_recent = str(LASTOBSDATE(obs1)) else most_recent = str(LASTOBSDATE(obs2)) endif if (DURATIONDAYS(str(LASTOBSDATE(obs3)), most_recent) <= 0) then str(LASTOBSDATE(obs3)) else most_recent endif case (LASTOBSDATE(obs1) <> "") AND (LASTOBSDATE(obs2) <> "") if (DURATIONDAYS(str(LASTOBSDATE(obs1)), str(LASTOBSDATE(obs2))) <= 0) then str(LASTOBSDATE(obs1)) else str(LASTOBSDATE(obs2)) endif case (LASTOBSDATE(obs1) <> "") AND (LASTOBSDATE(obs3) <> "") if (DURATIONDAYS(str(LASTOBSDATE(obs1)), str(LASTOBSDATE(obs3))) <= 0) then str(LASTOBSDATE(obs1)) else str(LASTOBSDATE(obs3)) endif case (LASTOBSDATE(obs2) <> "") AND (LASTOBSDATE(obs3) <> "") if (DURATIONDAYS(str(LASTOBSDATE(obs2)), str(LASTOBSDATE(obs3))) <= 0) then str(LASTOBSDATE(obs2)) else str(LASTOBSDATE(obs3)) endif case (LASTOBSDATE(obs1) <> "") str(LASTOBSDATE(obs1)) case (LASTOBSDATE(obs2) <> "") str(LASTOBSDATE(obs2)) case (LASTOBSDATE(obs3) <> "") str(LASTOBSDATE(obs3)) else //What you want the data display to read whenever there are no dates for any of the 3 obsterms "None Found" endcond }}
Put this in the data display code window:
{GetLatest(OBS_LIST_CHANGES(), "PNEUMOVAX", "PPSVBOOSTER", "RSNPNEUNTGN")}
I use OBS_LIST_CHANGES() as a parameter to get the function to update whenever any obsvalues are changed. This makes the data display update in real time; however, it comes at the cost of being constantly running. You can remove this if you don't intend for this to be updated while the visit is being updated.
still just displays FALSE
and btw... the test patient I am testing on has a result I expect to see :
PPSVBOOSTER (02/01/2014 1:53 PM) = given
here is trace log info:
>{!GetPneumo(OBS_LIST_CHANGES(), "PNEUMOVAX", "PPSVBOOSTER", "RSNPNEUNTGN") }
02/21/2014 09:09:00.175 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call OBS_LIST_CHANGES()
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] results>""
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call GETPNEUMO("", "PNEUMOVAX", "PPSVBOOSTER", "RSNPNEUNTGN")
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call LASTOBSDATE("PNEUMOVAX")
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] results>"07/13/2011"
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>"07/13/2011" <> ""
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] results>TRUE
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call LASTOBSDATE("PPSVBOOSTER")
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] results>"02/01/2014"
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>"02/01/2014" <> ""
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] results>TRUE
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>TRUE AND TRUE
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] results>TRUE
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call LASTOBSDATE("RSNPNEUNTGN")
02/21/2014 09:09:00.177 INFO Process Id #9936 Thread Id #1 [MelTrace] results>""
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>"" <> ""
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>FALSE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>TRUE AND FALSE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>FALSE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>case FALSE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>FALSE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call LASTOBSDATE("PNEUMOVAX")
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>"07/13/2011"
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>"07/13/2011" <> ""
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>TRUE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call LASTOBSDATE("PPSVBOOSTER")
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>"02/01/2014"
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>"02/01/2014" <> ""
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>TRUE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>TRUE AND TRUE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>TRUE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>case TRUE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>TRUE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call LASTOBSDATE("PNEUMOVAX")
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>"07/13/2011"
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call STR("07/13/2011")
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>"07/13/2011"
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call LASTOBSDATE("PPSVBOOSTER")
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>"02/01/2014"
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call STR("02/01/2014")
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>"02/01/2014"
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call DURATIONDAYS("07/13/2011", "02/01/2014")
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>"934"
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>"934" <= 0
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>FALSE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>if FALSE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] results>FALSE
02/21/2014 09:09:00.178 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call LASTOBSDATE("PPSVBOOSTER")
02/21/2014 09:09:00.179 INFO Process Id #9936 Thread Id #1 [MelTrace] results>"02/01/2014"
02/21/2014 09:09:00.179 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>call STR("02/01/2014")
02/21/2014 09:09:00.179 INFO Process Id #9936 Thread Id #1 [MelTrace] results>"02/01/2014"
02/21/2014 09:09:02.321 INFO Process Id #9936 Thread Id #1 [MelTrace] results>FALSE
02/21/2014 09:09:02.321 INFO Process Id #9936 Thread Id #1 [MelTrace] results>return FALSE
02/21/2014 09:09:02.321 INFO Process Id #9936 Thread Id #1 [MelTrace] execute>end
02/21/2014 09:09:02.321 INFO Process Id #9936 Thread Id #1 [MelTrace] results>FALSE
do I need a return statement at the end?
I think yes but don't know what to put there.
if I add a userok(str(LASTOBSDATE(obs2)))
it shows the correct date.
how do I tell it to return the one that is newest?
Oh, forgot to add the returns. See if this fixes it
{!fn GetLatest(update, obs1, obs2, obs3) { cond case (LASTOBSDATE(obs1) <> "") AND (LASTOBSDATE(obs2) <> "") AND (LASTOBSDATE(obs3) <> "") local most_recent most_recent = "" if (DURATIONDAYS(str(LASTOBSDATE(obs1)), str(LASTOBSDATE(obs2))) <= 0) then most_recent = str(LASTOBSDATE(obs1)) else most_recent = str(LASTOBSDATE(obs2)) endif if (DURATIONDAYS(str(LASTOBSDATE(obs3)), most_recent) <= 0) then return str(LASTOBSDATE(obs3)) else return most_recent endif case (LASTOBSDATE(obs1) <> "") AND (LASTOBSDATE(obs2) <> "") if (DURATIONDAYS(str(LASTOBSDATE(obs1)), str(LASTOBSDATE(obs2))) <= 0) then return str(LASTOBSDATE(obs1)) else return str(LASTOBSDATE(obs2)) endif case (LASTOBSDATE(obs1) <> "") AND (LASTOBSDATE(obs3) <> "") if (DURATIONDAYS(str(LASTOBSDATE(obs1)), str(LASTOBSDATE(obs3))) <= 0) then return str(LASTOBSDATE(obs1)) else return str(LASTOBSDATE(obs3)) endif case (LASTOBSDATE(obs2) <> "") AND (LASTOBSDATE(obs3) <> "") if (DURATIONDAYS(str(LASTOBSDATE(obs2)), str(LASTOBSDATE(obs3))) <= 0) then return str(LASTOBSDATE(obs2)) else return str(LASTOBSDATE(obs3)) endif case (LASTOBSDATE(obs1) <> "") return str(LASTOBSDATE(obs1)) case (LASTOBSDATE(obs2) <> "") return str(LASTOBSDATE(obs2)) case (LASTOBSDATE(obs3) <> "") return str(LASTOBSDATE(obs3)) else //What you want the data display to read whenever there are no dates for any of the 3 obsterms return "None Found" endcond }}
Since you changed the name of the function, you'll need to do that again.
ahhhh
there it is...
thanks SO much
I edited it a couple of times because I missed a few returns. Make sure you have the most recent version I put up!