Just wondering if this is an option. I have a provider who is looking to see previous values from opposing listboxes.
Thank you!
Rebecca B.
WMPNY
Should be able to do it as long as you are saving them as observation terms
I have a form but I am not sure that it will work. Maybe I set it up wrong?
The opposing listboxes are being combined via a function and are both document variables, so once I add a INSERT PREVIOUS button it only fills out one box. (EVEN IF SELECTIONS WERE MADE FROM THE OPPOSITE LISTBOX)
Below is my function.
{fn fnCommaCombine(){
?
local rslt =
""
?
for i = 1, i <= getnargs(), i = i + 1 do
rslt = fncombineutility(rslt,getarg(i))
endfor
?
return rslt
}}
{fn fnCombineutility(one,two){
if (one <>
"") and (two <> "") then
return (one +
", " + two)
else
return (one + two)
endif
}}
{OBSNOW(
"ROS:GENERAL",fncommacombine(DOCUMENT.GENERAL,DOCUMENT.LISTBOX))}
{OBSNOW(
"ROS EYES",fncommacombine(DOCUMENT.GENERAL1,DOCUMENT.LISTBOX1))}
{OBSNOW(
"ROS ENT",fncommacombine(DOCUMENT.GENERAL111,DOCUMENT.LISTBOX111))}
{OBSNOW(
"ROS: CARDIAC",fncommacombine(DOCUMENT.GENERAL112,DOCUMENT.LISTBOX112))}
{OBSNOW(
"ROS:PULMON",fncommacombine(DOCUMENT.GENERAL1121,DOCUMENT.LISTBOX1121))}
{OBSNOW(
"ROS: GI",fncommacombine(DOCUMENT.GENERAL112111,DOCUMENT.LISTBOX112111))}
{OBSNOW(
"ROS: GU",fncommacombine(DOCUMENT.GENERAL88,DOCUMENT.LISTBOX88))}
{OBSNOW(
"ROS ENDO",fncommacombine(DOCUMENT.GENERAL112113,DOCUMENT.LISTBOX112113))}
{OBSNOW(
"ROS:MUSCSKEL",fncommacombine(DOCUMENT.GENERAL8,DOCUMENT.LISTBOX8))}
{OBSNOW(
"ROS SKIN",fncommacombine(DOCUMENT.GENERAL9,DOCUMENT.LISTBOX9))}
{OBSNOW(
"ROS: NEURO",fncommacombine(DOCUMENT.GENERAL91,DOCUMENT.LISTBOX91))}
{OBSNOW(
"ROS: PSYCH",fncommacombine(DOCUMENT.GENERAL911,DOCUMENT.LISTBOX911))}
{OBSNOW(
"ROS HEME",fncommacombine(DOCUMENT.GENERAL9111,DOCUMENT.LISTBOX9111))}
{OBSNOW(
"ROS BREAST",fncommacombine(DOCUMENT.GENERAL91111,DOCUMENT.LISTBOX91111))}
Most ROS forms have a function similar to below, in a case such as this you could insert the "Complains" sentence in one listbox and the "Denies" sentence in the other. In your example above I dont see anything that differentiates between the two fields, is the general variable a list box also?
{fn ListBoxResult(cstr,dstr,ostr) {
local fullStr = ""
if (size(cstr) > 0) then
fullStr = "Complains of " + cstr + ". "
endif
if (size(dstr) > 0) then
fullStr = fullstr + "Denies " + dstr + ". "
endif
if (size(ostr) > 0) then
fullStr = fullstr + ostr
endif
return fullStr
}
}
Yes, that is correct. The general variable is part of an opposing listbox. Do I set both opposing boxes to the same OBS Term? Do you have any form examples of this? I just can't seem to make it work. Maybe I am overthinking it.
I'm bumping this post. Sorry, I am hoping for some help here.
Anyone, is there a way to do a opposing that listboxes that are attached to the same obs term...that I can add a button to insert previous values?
Rebecca B.
we typically combine values with a tilde "~" into an obsterm,
{fn Combine()
{
local nargs = GETNARGS()
local delim
local result = ""
local index
local arg
if nargs>0 then
delim = GETARG(1)
for index = 2, index <= nargs, index = index + 1 do
arg = GETARG(index)
if arg<>"" then
if result<>"" then
result = result + STR(delim) + STR(arg)
else
result = STR(arg)
endif
endif
endfor
endif
return STR(result)
}
}
OBSNOW("...", Combine("~", variable1, variable2, etc))
and then when we want to use the previous value, we split it out by calling this function:
{fn SplitTildes(value, retval)
{
local obs_array = GETFIELD(value, "~", "")
local sizearray = SIZE(obs_array)
if sizearray==0
or sizearray<retval then
return ""
else
return obs_array[retval]
endif
}
}
like variable1 = SplitTildes(OBSPREV("..."), 1)
returns the first part of the value
variable2 = SplitTildes(OBSPREV("..."), 2)
returns the second part of the value, and so on...
I am not sure if we are answering your question…
Opposing listboxes must be defined by their OWN variable or obsterm.
opposing listbox for complains of = document.positive
opposing listbox for denies = document.negative
so if
document.positive = "fevers,fatigue"
document.negative = "sweats,appetite loss"
document.other = "some comment…"
So conceptually, you could do this…
OBSNOW("General",document.positive + "^" + document.negative + "^" + document.other)
OBSNOW("General") ends up = "fevers,fatigue^sweats,appetite loss^some comment")
then next visit, if you get obsprev("General")
you would need to split the value using (for example)
local anAry = getfield(OBSPREV("General"),"^","")
document.positive = anAry[1]
document.negative = anAry[2]
document.other = anAry[3]
is this what you were looking for ?
You may have to modify the above if you want to include "complains of" and "denies" in the correct places.
Your function
{OBSNOW(
"ROS:GENERAL",fncommacombine(DOCUMENT.GENERAL,DOCUMENT.LISTBOX))}
is storing both "complains of" and "denies" into the single obsterm, and completely losing the context of which part belongs to "complains of" and which belongs to "denies", because it is just appending them together with commas…
My sample above uses the caret "^" so you know which part belongs to complains of, denies, or comment…
I think you could use Jerrolls Combine function, which uses tilde "~" instead...
OBSNOW("General", Combine("~", document.positive, document.negative, document.comment) )
Then to get OBSPREV, use his other function SplitTildes
document.positive = SplitTildes( OBSPREV("General"), 1)
document.negative = SplitTildes( OBSPREV("General"), 2)
document.other = SplitTildes( OBSPREV("General"), 3)
Does that look correct Jerroll ?
- Beverly
That's correct. The Combine function can use any character as a separator, but the SplitTildes function only works with a tilde.
Or you could use our other function below, which will pull data from an obs term, either previous for all users, or what you entered previously. You specify 2 listboxes, with their corresponding values, and an MLEF. If data matches a listbox's values, it populates the corresponding listbox, if it doesn't match, it populates the MLEF.
NOTE: this will NOT work if both lists have the same values (opposing), unless your listboxes are setup like some of ours...'value' and 'no value'. In this scenario, you don't need to combine fields with tildes, just commas.
{fn Split2ListMulti(obs, mp, list1, list1_vals, list2, list2_vals, mlef)
{// splits mine/prev obs value into up to 2 listboxes and 1 MLEF if not already populated
local list1_val = EVAL(list1)
local list2_val = EVAL(list2)
local mlef_val = EVAL(mlef)
local arr1 = array()
local A = ""
local B = ""
local C = ""
local sizearray
local x
local testvalue
if list1_val==""
and list2_val==""
and mlef_val==""
and (mp=="mine"
or mp=="prev") then
if mp=="mine" then
arr1 = GETFIELD(SignMine(obs), ",", "")
else
if mp=="prev" then
arr1 = GETFIELD(OBSPREV(obs), ",", "")
endif
endif
sizearray = SIZE(arr1)
for x = 1, x<=sizearray, x = x + 1 do
testvalue = Trim(arr1[x])
if MATCH(list1_vals, 1, testvalue)>0 then
if A == "" then
A = testvalue
else
A = A + ", " + testvalue
endif
else
if MATCH(list2_vals, 1, testvalue)>0 then
if B == "" then
B = testvalue
else
B = B + ", " + testvalue
endif
else
if C == "" then
C = testvalue
else
C = C + ", " + testvalue
endif
endif
endif
endfor
if list1<>"" then
EVAL(list1 + ' = "' + A + '"')
endif
if list2<>"" then
EVAL(list2 + ' = "' + B + '"')
endif
if mlef<>"" then
EVAL(mlef + ' = "' + C + '"')
endif
endif
return ""
}
}
Thank you. This is helpful.
One last question.
Can I combine three values with the below function?
{fn fnCommaCombine(){
?
local rslt = ""
?
for i = 1, i <= getnargs(), i = i + 1 do
rslt = fncombineutility(rslt,getarg(i))
endfor
?
return rslt
}}
{fn fnCombineutility(one,two){
if (one <> "") and (two <> "") then
return (one + ", " + two)
else
return (one + two)
endif
}}
That looks familiar
Yes, you can add as many or as few as you want to.
{fncommacombine(document.var1,document.var2,document.var3)}
Yes, it should look familiar. thank you for that.
The only thing I am confused about is when I use that function and then during the subsequent visit bring in previous values it's not bringing in the "complains of" or "denies" heading. ?
Sorry, I think I am making this much harder than it needs to be.
arr1 = GETFIELD(SignMine(obs), ",", "")
Jerroll, what is SignMine ? Is that a custom function ?
Or would you instead be using LASTOBSVALUEBYUSER(obs) ?
The problem I have with LASTOBSVALUEBYUSER(...) is that it does not return the "date" of signature.
Rebecca,
Maybe if you post a few lines of the code, the lines where you "save" the listboxes into one of the obsterms, then the lines where you try to pull obsprev data back and assign it to the listboxes...
Sorry...here are the missing functions. Our Combine function will take up to 254 arguments, with the first being the separator character.
{fn SignMine(obs)
{
local c
local l
local r = ""
if LIST_OBS(obs,'Signed','delimited','value')<>"" then
local a1 = GETFIELD(LIST_OBS(obs,'Signed','delimited','value'), "|", "")
l = SIZE(a1)
for c = 1, c <= l, c = c + 1 do
if SIZE(a1[c])>0 then
local a2 = GETFIELD(a1[c], "^", "")
if a2[4]==USER.REALNAME then
r = a2[1]
c = l
endif
endif
endfor
endif
if r<>"" then
return r
else
return LASTOBSVALUEBYUSER(obs)
endif
}
}
{fn Trim(string)
{
local result = string
local dowhile = true
local sizeresult
while dowhile do
if SIZE(result)==0 then
dowhile = false
else
if result[1]<>" " then
dowhile = false
else
result = REMOVE(result, 1, 1)
endif
endif
endwhile
dowhile = true
sizeresult = SIZE(result)
while dowhile do
if sizeresult==0 then
dowhile = false
else
if result[sizeresult]<>" " then
dowhile = false
else
result = REMOVE(result, sizeresult, 1)
sizeresult = SIZE(result)
endif
endif
endwhile
return result
}
}