By Anonymous - January 7, 2022

=== Global User Data ===

We have added global food avoidance questions to both inform us and serve as a filter to reduce the burden of questions asked of the user.

* Question 1: Do you eat any of the following?
* dairy: "Dairy products from cows, sheep, etc. (e.g. yogurt, cheese, milk)"
* egg: "Eggs or egg products such as mayonnaise"
* fish: "Fish or fish products (e.g. tuna, fish cakes)"
* seafood: "Other seafood"
* poultry: "Poultry or poultry products (e.g. chicken breast, turkey deli meat, etc.)"
* red_meat: "Beef, lamb, or other red meat (not including pork)"
* pork: "Pork, ham, or other pork products"
* Question 2: Tell us about your food allergies or sensitivities.
* nut_avoidance
* always: "Yes, always."
* often: "Yes, usually or often."
* no: "Rarely or never."
* nut_avoid_type
* all_nuts: "All nuts."
* tree_nuts: "All tree nuts (not peanuts)."
* peanuts: "Just peanuts."
* almonds: "Just almonds."
* walnuts: "Just walnuts or pistachio."
* other_nuts: "Just other tree nuts not listed."
* gluten_avoidance
* yes: "Yes."
* no: "No."
* sometimes: "Sometimes."

The following global variables can be referenced from any webform (note: case sensitive).

Variable Options Notes
gender male / female
date_of_birth [yyyy-mm-dd] e.g., 1970-07-22
age [number] (e.g., 52)
dairy Yes / No "do you eat dairy?"
egg Yes / No "do you eat eggs?"
fish Yes / No "do you eat fish?"
seafood Yes / No "do you eat other seafood?"
poultry Yes / No "do you eat poultry?"
red_meat Yes / No "do you eat red meat (exl. pork)?"
pork Yes / No "do you eat pork?"
beef_or_pork Yes / No derived variable: "Yes" if either red_meat or pork are "Yes"
meat Yes / No derived variable: "Yes" if red_meat, pork, or chicken are "Yes"
any_meat Yes / No derived variable: "Yes" if any meat, fish, or seafood are "Yes"
nut_avoidance always / often / no "do you avoid nuts?"
nut_avoid_type all_nuts / tree_nuts / peanuts / almonds / walnuts / other_nuts "which do you avoid?"
gluten_avoidance yes / no / sometimes "do you avoid gluten?"

Derived variables

Variable Options Notes
avoid_gluten Yes / No "No" if either "no" or "sometimes" is selected.
avoid_all_nuts Yes / No derived from combination of nut avoidance questions
avoid_tree_nuts Yes / No derived (note that this also gets a value if all_nuts was selected)
avoid_peanuts Yes / No derived (note that this also gets a value if all_nuts was selected)
avoid_almonds Yes / No derived (note that this also gets a value if all_nuts or tree_nuts was selected)
avoid_walnuts Yes / No derived (note that this also gets a value if all_nuts or tree_nuts was selected)
avoid_other_nuts Yes / No derived (note that this also gets a value if all_nuts or tree_nuts was selected)

To utilize these they have to be referenced through the user_data array. i.e. ''%%user_data[peanuts]::no%%'' or ''%%user_data[peanuts]::always%%''. The "values" for the nuts are taken from here https:docs.google.com/spreadsheets/d/1YgmNMt1d9fyrQkxDARYAFA5JOczr6G_ORo6ROCBl9Fw/edit#gid=788072392&range=I26. The gluten_avoidance values are from here https:docs.google.com/spreadsheets/d/1YgmNMt1d9fyrQkxDARYAFA5JOczr6G_ORo6ROCBl9Fw/edit#gid=788072392&range=I28. Values are case-sensitive, so we may want to update those to standardize to the capitalized "Yes/No" options that the webforms modules use.


=== Using the Filters ===

The value for nut avoidance can be accessed like this:
user_data[nut_avoidance]::always

The nut type variable can be similarly used, however, they should only have a value if "always" was selected for nut_avoidance.

The nut type can be used inline for hiding items in a list of checkboxes for example.
[conditional::user_data[nut_avoid_type]::peanuts]

It can also be used to hide a question or an entire page.

user_data[nut_avoid_type]::peanuts::hidden::all::page^^
user_data[nut_avoid_type]::tree_nuts::hidden::all::page^^
user_data[nut_avoid_type]::all_nuts::hidden::all::page^^

user_data[gluten_avoidance]::yes::hidden::all::page^^

grapes::Grapes or Raisins^^
berries::Berries (e.g. strawberries, blueberries, cranberries)^^
stonefruit::Stone Fruits (e.g. Apricots, Plums, Peaches)^^
apple::Apples or Applesauce^^
banana::Bananas^^
watermelon::Watermelon^^
othermelon::Other Melons (e.g. cantaloupe, honeydew)^^
pear::Pears^^
avocado::Avocados^^
persimmon::Persimmons^^
pomegranate::Pomegranate^^
fig::Figs^^
pineapple::Pineapple^^
mango::Mango^^
kiwi::Kiwi^^
cherries::Cherries^^
oranges::Orange citrus (e,g, Oranges, Tangerines)^^
othercitrus::Other Citrus (e.g. Grapefruit, Pomelo)^^

=== More on Conditionals ===
When not expressly stated, all conditionals use AND logic by defaulting to the "all" syntax. Such as: ''%%user_data[all_nuts]::often::visible::all%%''. If you want OR logic then change "all" to "any. Such as:
user_data[all_nuts]::often::visible::any^^
user_data[all_nuts]::no::visible::any

This conditional would make the element visible as long as all_nuts is either "often" or "no". Note "visible" and "all" are defaults if you leave those parameters empty. So ''%%user_data[all_nuts]::often%%'' is the same as ''%%user_data[all_nuts]::often::visible::all%%''.

Note that when someone selects "no" for the nut_avoidance question that user_data[nut_avoid_type] will be "empty". "Sometimes" should also do this, but need to double-check with R+D.