nx_allergen.nx
buildroot/runtime/nx_allergen.nx
about
nx_allergen.nx -- FOOD-SCIENCE SUITE / ALLERGEN MANAGEMENT rung. Tracks
the FDA "big 9" allergens (FASTER Act 2021) as a bitmask, rolls a
recipe's ingredients up into its full allergen profile (catching HIDDEN
allergens a naive list misses -- traditional soy sauce carries BOTH soy
AND wheat), checks a recipe against a person's avoid-profile, flags
shared-equipment CROSS-CONTACT ("may contain"), and suggests a
substitution that NEVER reintroduces an avoided allergen.
THE exceed: allergen safety is computed by ROLLUP + personalization +
cross-contact + safe-substitution, not a static "contains nuts" line;
and a substitute is validated against the SAME avoid-profile so it can't
swap one allergen for another (the classic milk->soy-milk mistake for a
soy-allergic person).
Grounded: fda_faster_act_2021_big9_allergens + fda_food_allergen_labeling
genealogy_id: fda_big9_allergens + nishi_food_science_suite
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_allergen_test.nx
structs
| none |
consts
| 22 | const AL_MILK: i64 = 1 |
| 23 | const AL_EGG: i64 = 2 |
| 24 | const AL_FISH: i64 = 4 |
| 25 | const AL_SHELLFISH: i64 = 8 |
| 26 | const AL_TREENUT: i64 = 16 |
| 27 | const AL_PEANUT: i64 = 32 |
| 28 | const AL_WHEAT: i64 = 64 |
| 29 | const AL_SOY: i64 = 128 |
| 30 | const AL_SESAME: i64 = 256 |
| 31 | const AL_N: i64 = 9 // number of allergen bits |
| 35 | const ING_MILK: i64 = 0 |
| 36 | const ING_CHEESE: i64 = 1 |
| 37 | const ING_YOGURT: i64 = 2 |
| 38 | const ING_EGG: i64 = 3 |
| 39 | const ING_WHEAT_FLOUR: i64 = 4 |
| 40 | const ING_BREAD: i64 = 5 |
| 41 | const ING_SOY_SAUCE: i64 = 6 |
| 42 | const ING_TOFU: i64 = 7 |
| 43 | const ING_PEANUT: i64 = 8 |
| 44 | const ING_ALMOND: i64 = 9 |
| 45 | const ING_SHRIMP: i64 = 10 |
| 46 | const ING_SALMON: i64 = 11 |
| 47 | const ING_SESAME_OIL: i64 = 12 |
| 48 | const ING_TAHINI: i64 = 13 |
| 49 | const ING_RICE: i64 = 14 |
| 50 | const ING_CHICKEN: i64 = 15 |
| 51 | const ING_OLIVE_OIL: i64 = 16 |
| 53 | const ING_OAT_MILK: i64 = 17 |
| 54 | const ING_RICE_FLOUR: i64 = 18 |
| 55 | const ING_COCONUT_AMINOS: i64 = 19 |
| 56 | const ING_FLAX_EGG: i64 = 20 |
| 57 | const ING_SUNFLOWER_BUTTER: i64 = 21 |
| 58 | const ING_N: i64 = 22 |
functions
| 61 | func nx_ingredient_allergens(id: i64) -> i64 |
| 82 | func al_mask_add(mask: i64, ing_id: i64) -> i64 |
| 86 | func al_contains(recipe_mask: i64, allergen_bit: i64) -> i64 called by 1: main |
| 92 | func al_safe_for(recipe_mask: i64, avoid_mask: i64) -> i64 called by 1: main |
| 98 | func al_count(recipe_mask: i64) -> i64 called by 1: main |
| 111 | func al_cross_contact_risk(facility_mask: i64, avoid_mask: i64) -> i64 called by 1: main |
| 121 | func al_substitute(ing_id: i64, avoid_mask: i64) -> i64 |