for which selects those attributes in a group or list of attributes that satisfy some predicate expression in which the term “$x” is used to denote a variable attribute.
There are two variants of this expression:
- for which currently evaluates the predicate against the current episode
- for which evaluates the predicate on a per-episode basis
The syntax is:
{ names } for which (expression)
or
{ names } for which currently (expression)
where:
names is a comma separated list of attribute or group attribute names,
expression is the condition that must also be satisfied for an attribute to be included in the final result.
A typical use of this function would be to select from a list of group attributes those primary attributes that have had several abnormal values. For example, given group attributes electrolytes, lipids and glucose we could define a calculated value attribute Abnormals as
{electrolytes, lipids, glucose} for which currently at least 2 $x are high
Suppose that na, cl and li are in the electrolytes group, that ldl, hdl and trig are in the lipids group, and that gluc is in the glucose group. For these primary attribute values:
na 5.1* 5.5* 5.5* cl 10.8* 9.0* 8.8 li 60 100 200* ldl 7.0* 6.5* hdl 5.2* 5.1* 5.2* trig 6.7* 4.0 6.6* gluc 4.5 4.4 4.0
the expression would produce a sample sequence in which each sample was a Values object, and each of these Values objects contained the same set of attributes, namely na, cl, ldl, hdl and trig. The first sample would be
{na (5.1), cl (10.8), ldl (7.0), hdl (5.2) and trig (6.7)}
The second sample would be
{na (5.5), cl (9.0), ldl (6.5), hdl (5.1) and trig (4.0)}
The third (current) sample would be
{na (5.5), cl (8.8), ldl (), hdl (5.2) and trig (6.6)}
A per-episode variant is
{electrolytes, lipids} for which $x is high
For the same case as above, this expression would produce a sample sequence in which each sample was a Values object, and each of these Values contained the set of attributes that were high for that episode. The first sample would be
{na (5.1), cl (10.8), ldl (7.0), hdl (5.2) and trig (6.7)}
The second sample would be
{na (5.5), cl (9.0), ldl (6.5) and hdl (5.1)}
The third (current) sample would be
{na (5.5), li (200), hdl (5.2) and trig (6.6)}
The for which syntax can be used in conjuction with the {attributes} function. For example with the case above, the expression
{attributes} for which currently at least 2 $x are high
would produce the same output as the earlier expression involving groups.