# Rules contexts

Rules are said to run in the context of the item they are evaluating or calculating and all items on whose values the rule script depends. A rule context answers the questions:

- What item does the rule run against?
- What values are substituted in the rule when it runs against this item?
- What other values does the rule need to run, and what items are those values found in?

By separating the definition of a rule from the specification of the item it runs against, contexts give you the flexibility to associate the same rule with many different items.

A rule context consists of:

- The key item—in its section, form, and visit—to which the rule is applied.
- All arguments passed to the rule script.
- Dependencies—Additional items or associations used in the processing of the rule script.

A single rule can have many contexts; for example, a rule that tests for range limits can be applied to different items on multiple forms, passing arguments that are specific to the context each time it is applied. Therefore, a rule that checks for valid ranges on a height item can use arguments that specify minimum and maximum number of inches in the height context; when the same rule is applied to a pulse rate item, it can use a different set of arguments that specify a minimum and maximum number of heartbeats.

Note: Only form rules, calculations, and randomization rules have contexts; conversion rules, which are applied to unit definitions, do not.

Copyright © 2013 Oracle and/or its affiliates. All rights reserved.