Good morning CHUG, I have a nephrologist who would like to be able to bring in the last 3 obsterms for various labs. He has created various quicktext that pulls in the last obsterm but he recently said he would really like to be able to pull in the last 3 results so he can see trending. Any suggestions?
Thanks.
I have the following in my notes:
This tip came through the CHUG listserv on 3/26/2010 from David Shower:
I use this code (which I probably got from a fellow CHUGger) in an action button to show the last 3 results:
{local obsarray6
obsarray6 = getfield(LIST_OBS("WEIGHT","signed","list","valuedate"),")","(,")
userok(str(sub(obsarray6,1,3), HRET))
}
I know David is active on CHUG, so a belated thanks to him for posting this way back when!
Thanks so much. I'll give it a try.
Sorry to revive an old thread but just wanted a little guidance on creating a quick text similar to this.
Want to make a quick text that displays the last 3 blood pressure readings recordedfor the patient. This is difficult since the values are recorded separately.. "BP SYSTOLIC" and BP DIASTOLIC"
Ideally , i would want the quick text to display like this
114 (systolic) / 77 (diastolic) (08/18/2014 8:39:02 AM)
123 (systolic) / 67 (diastolic) (08/15/2014 8:39:02 AM)
112 (systolic) / 87 (diastolic) (08/13/2014 8:39:02 AM)
I've tried using
{LIST_OBS('BP SYSTOLIC','Signed','list',"valuedate")}
{LIST_OBS('BP DIASTOLIC','Signed','list',"valuedate")}
but it lists all recorded readings and the BP values are separated. Not ideal for a quick text.
Any advice? Thanks in advance!
This was a fun "project", and I got it working.
Define a quicktext, I named it ".prevbp"
Here is the body of the quicktext
{local sA1, sA2, a1, a2, s1="", i=0, imax=0
sA1 = getfield(LIST_OBS("BP SYSTOLIC","signed","list","valuedate"),")",HRET)
sA2 = getfield(LIST_OBS("BP DIASTOLIC","signed","list","valuedate"),")",HRET)
imax = (if size(sA1)<=3, size(sA1), 3)
for i=1,i<=imax,i=i+1 do
a1 = getfield(str(sA1[i]),"(","")
a2 = getfield(str(sA2[i]),"(","")
s1 = s1 + (if s1<>"",HRET,"") + a1[1] + "(systolic) / " + a2[1] + " (diastolic) (" + a1[2] + ")"
endfor
sA1 = getfield(s1,HRET,HRET)
userok(str(sub(sA1,1,3), HRET)) ""}
or if you need it printed in the chart note, replace the last 2 lines with this:
s1}
Let me know how it goes 🙂
- Beverly
Thanks Beverly!
So i used:
{local sA1, sA2, a1, a2, s1="", i=0, imax=0
sA1 = getfield(LIST_OBS("BP SYSTOLIC","signed","list","valuedate"),")",HRET)
sA2 = getfield(LIST_OBS("BP DIASTOLIC","signed","list","valuedate"),")",HRET)
imax = (if size(sA1)<=3, size(sA1), 3)
for i=1,i<=imax,i=i+1 do
a1 = getfield(str(sA1[i]),"(","")
a2 = getfield(str(sA2[i]),"(","")
s1 = s1 + (if s1<>"",HRET,"") + a1[1] + "(systolic) / " + a2[1] + " (diastolic) (" + a1[2] + ")"
endfor
s1}
since I needed it displayed in the chart note. It works! But there is a bit of a kink.
First time you use the quicktext..it displays this:
125(systolic) / 63 (diastolic) (04/05/2013 1:08:03 PM) 120 (systolic) / 95 (diastolic) (08/29/2012 1:21:22 PM) 150 (systolic) / 80 (diastolic) (12/07/2011 1:48:19 PM)
But let's say we delete the filled text to place it somewhere else, and type the quicktext again.. it will display twice.
125(systolic) / 63 (diastolic) (04/05/2013 1:08:03 PM) 120 (systolic) / 95 (diastolic) (08/29/2012 1:21:22 PM) 150 (systolic) / 80 (diastolic) (12/07/2011 1:48:19 PM) 125 (systolic) / 63 (diastolic) (04/05/2013 1:08:03 PM) 120 (systolic) / 95 (diastolic) (08/29/2012 1:21:22 PM) 150 (systolic) / 80 (diastolic) (12/07/2011 1:48:19 PM)
And each time the list gets longer, which is interesting.
125(systolic) / 63 (diastolic) (04/05/2013 1:08:03 PM) 120 (systolic) / 95 (diastolic) (08/29/2012 1:21:22 PM) 150 (systolic) / 80 (diastolic) (12/07/2011 1:48:19 PM) 125 (systolic) / 63 (diastolic) (04/05/2013 1:08:03 PM) 120 (systolic) / 95 (diastolic) (08/29/2012 1:21:22 PM) 150 (systolic) / 80 (diastolic) (12/07/2011 1:48:19 PM) 125 (systolic) / 63 (diastolic) (04/05/2013 1:08:03 PM) 120 (systolic) / 95 (diastolic) (08/29/2012 1:21:22 PM) 150 (systolic) / 80 (diastolic) (12/07/2011 1:48:19 PM)
Any thoughts? Thanks again for all your help.
It appears the Quicktext does not re-initialize the local parameters when run within the same encounter instance. The results you are getting is because s1 is not being reset to "" between calls.
To fix this, I have added an explicit s1="" above the for loop.
(Also, since Quicktext is limited to 512 characters, I needed to delete extra spaces from line 9 to free up space to put in this new line. So this kind of thing is really limited by how much code can be fit into 512 spaces. No long variable names!)
This fixes the problem...
{local sA1, sA2, a1, a2, s1="", i=0, imax=0
sA1 = getfield(LIST_OBS("BP SYSTOLIC","signed","list","valuedate"),")",HRET)
sA2 = getfield(LIST_OBS("BP DIASTOLIC","signed","list","valuedate"),")",HRET)
imax = (if size(sA1)<=3, size(sA1), 3)
s1=""
for i=1,i<=imax,i=i+1 do
a1 = getfield(str(sA1[i]),"(","")
a2 = getfield(str(sA2[i]),"(","")
s1=s1+(if s1<>"",HRET,"")+a1[1]+"(systolic) / "+a2[1]+" (diastolic) ("+a1[2]+")"
endfor
sA1 = getfield(s1,HRET,HRET)
userok(str(sub(sA1,1,3), HRET)) s1}
If you do not need the userok Popup, just use this...
{local sA1, sA2, a1, a2, s1="", i=0, imax=0
sA1 = getfield(LIST_OBS("BP SYSTOLIC","signed","list","valuedate"),")",HRET)
sA2 = getfield(LIST_OBS("BP DIASTOLIC","signed","list","valuedate"),")",HRET)
imax = (if size(sA1)<=3, size(sA1), 3)
s1=""
for i=1,i<=imax,i=i+1 do
a1 = getfield(str(sA1[i]),"(","")
a2 = getfield(str(sA2[i]),"(","")
s1=s1+(if s1<>"",HRET,"")+a1[1]+"(systolic) / "+a2[1]+" (diastolic) ("+a1[2]+")"
endfor
s1}
- Beverly
Works like a charm. Thanks Beverly!!
Thanks Beverly. Looks to be a very useful set of script commands.
🙂