How do you show who signed a specific observation? I am looking for a hook to be able to display who/when the Medication List was last reviewed. This is the output I am going for:
Medications last reviewed:
01/01/2012 4:45:00 PM, John Doe
Any help would be much appreciated. Thanks, Chuggers!
LASTOBSVALUEBYUSER("obsterm")
@jjordet, that just returns the value of the currently logged in user:
LASTOBSVALUEBYUSER(‘Height’)
Returns the last height observation value signed by the currently logged in user.
69
I'm looking for the name of the user who signed off on the specified obs:
UserWhoLastSignedThisObs('HEIGHT')
returns:
John Doe
Any idea?
This is the LASTOBSVALUEBYUSER function:
!fn LastObsValueByUser (obsname){
// This function retrieves the last signed observation value
// signed in a document bu the currently logged in user
// ASSUMPTION: values are always ordered by Obsdate decending
// List_Obs is based on ViewPencilObs (mldefs7.txt) which is currently sorted
// by date but not guaranteed to remain that way
local aObsdata = getfield(List_Obs(obsname,'Signed','Delimited','value'),"|","")
local aThisObs
local result = ""
for i=1, i <= size(aObsdata), i=i+1
do
aThisObs = getfield(aObsdata[i],"^","")
//skip any value not from this LOC
if aThisObs[5] <> USER.REALNAME then result = "" else
if aThisObs[5] == USER.REALNAME then result = aThisObs[1] break
endif
endif
endfor
return result}
You should be able to do something similar and reference aThisObs[5].
Thanks @jjordet, I was able to take your function and modify it as you suggested to our needs. Much, much thanks at ya!
BTW, I noticed that LASTOBSVALUEBYUSER() is a working function that just returns last height observation value signed by the currently logged in user. I didn't know that you could modify an existing function in CPS like that.
Is there a simple function to pull when the Medications List or Allergies or Problems were last reviewed? Or to mark them as reviewed?
You don't want to modify an existing function. You want to create a new function fimilar to that one.
Really appreciating the help/clarification, @jjordet!
So if I understand you correctly, the LASTOBSVALUEBYUSER('obsname') is an existing CPS function baked into CPS...However in your example above you created a new watcher function with the same name !fn LastObsValueByUser('obsname') that is completely unrelated to the CPS function LASTOBSVALUEBYUSER('obsname') ?
What I meant was to make a function similar to the one shown, like:
!fn LastObsValueUser (obsname){
// This function retrieves the user of the last signed observation value
// signed in a document
// ASSUMPTION: values are always ordered by Obsdate decending
// List_Obs is based on ViewPencilObs (mldefs7.txt) which is currently sorted
// by date but not guaranteed to remain that way
local aObsdata = getfield(List_Obs(obsname,'Signed','Delimited','value'),"|","")
local aThisObs
local result = ""
aThisObs = getfield(aObsdata[1],"^","")
result = aThisObs[5]
return result}
Got it. BTW, how/where is best to test functions? I recall someone explaining to me that setting up a text component that is called by quick text is a good method... But if that is a good method, how would you pass in variables function(var1,var2) to the called function? Or does anyone have a better testing workflow?
Your quicktext would call the function with the parameters...functionname(param1, param2, etc...)
Okay, so I do need to hard-code the arguments into the quick text function. Got it, thanks so much!