ProductOpener::Nutrition - functions related to nutrition facts of food products
ProductOpener::Nutrition
contains functions specific to food products,
in particular related to the new schema of nutrition facts.
This module provides functions It does not contain functions related to ingredients which are in the ProductOpener::Ingredients
module.
..
Generates and returns a hash reference of the preferred nutrient set from the given list of nutrient sets.
The generated set is a combined set of nutrients with the preferred sources, per references and preparation states and with normalized units.
Array of nutrients sets used to generate the preferred set
The generated preferred nutrient set
Sorts hashes of nutrient sets in a given array based on a custom priority.
The priority is based on the sources, the per references and the preparation states present in the nutrient sets.
Unsorted array nutrient sets hashes
Sorted array nutrient sets hashes
For each nutrient appearing in the nutrient sets array, sets its values in the preferred set.
The units of the nutrients quantities are normalized (g, kJ or kcal).
Each nutrient is only added once. Its value is the one in the set with the highest priority.
If the preparation value in a set is different from the one in the preferred set, the nutrient is not added to the preferred set.
The generated preferred nutrient set.
The sorted array of nutrient set hashes used to generate the preferred set.
Normalizes the unit of the nutrient value if necessary.
The normalized units are g, kJ or kcal based on the nutrient.
Hash of the nutrient to normalize
Name of the nutrient to normalize
Converts the value of the amount of the nutrient based on the wanted per reference if necessary.
Hash of the nutrient set with the value to convert
Current per amount of the nutrient
Current per unit of the nutrient
Wanted per amount of the nutrient
Wanted per unit of the nutrient