Skip to content

ADR-0008: Nutrient / form / source as three axes, keyed to EU Annex I and II

  • Status: Accepted
  • Date: 2026-07-25
  • Supersedes: None
  • Superseded by: None

Builds on ADR-0004, which established that supplement composition is captured from labels, parsed deterministically, and always reviewed before saving. That still holds. This ADR decides what the parsed thing is.

Context

Schema 1 recorded a supplement ingredient as a name plus one free-text form. On real labels that single field collects at least four different kinds of thing. A panel row reading Vitamin A (as β-Carotene & Vit A conc.) puts two compounds in it; Vitamin E (Natural) puts a stereochemistry claim in it; Iodine (from Bladderwrack) puts an origin organism in it; Magnesium (as Citrate) puts a bare anion in it that names no substance on its own.

Two consequences, both real:

  • Identity was ambiguous. Vitamin D, Vitamin D3, Vit D and cholecalciferol produced four different names. The duplicate-substance check compares inn ?? name, so they never matched each other.
  • Supplements were invisible to that check anyway. It reads medication_ingredients; supplement composition lived only in the record's JSON. Magnesium in a prescribed Magne-B6 and magnesium in a multivitamin — the exact pair the check exists to find — produced no warning.

A closed vocabulary exists for part of this and does not exist for the rest. Directive 2002/46/EC Annex I lists the vitamins and minerals permitted in food supplements; Annex II lists their permitted chemical forms. Both are closed, transposed in Slovakia, and small. Botanicals, amino acids and probiotics have no harmonised EU positive list (Art. 8 leaves them to member states), so no comparable vocabulary can be had.

Decision

  • An ingredient is recorded on three separate axes: nutrientKey (Annex I), forms[] (Annex II), sourceMaterial (origin, no controlled list).
  • The nutrient is the identity. Vitamin D3 is stored as nutrient vitamin-d with form cholecalciferol, not as its own substance. Lanolin-derived and lichen-derived D3 are one substance differing only in sourceMaterial; natural and synthetic vitamin E are genuinely different Annex II compounds and stay distinct on the form axis.
  • forms is a list, because a label may declare several at once, and the split between them is usually unstated. A provitamin declared alongside a preformed vitamin is flagged for review rather than summed.
  • Blend membership is modelled. A subtotal row (Total Mixed plant Superfoods 250 mg) is marked isBlendTotal and its constituents carry partOf; membership is decided arithmetically, by which following rows still fit inside the declared total. countableIngredients() excludes subtotals so nothing is counted twice.
  • An "of which" breakdown counts the element, not the salt. A panel reading "Magnézium bisglycinát 2000 mg / z toho horčík 240 mg" states the compound's mass and the nutrient it delivers. The compound row is marked isSaltTotal and excluded from intake; the element row carries ofWhich and inherits the compound's Annex II form. Counting the salt would overstate magnesium eightfold.
  • A table flattened to one cell per line is rejoined before parsing. Copying a facts table out of a web page puts the name, the amount, the percentage and each further dose column on separate lines, so no line carries both a name and a number. Value-only cells fold back onto the last line that named something; lines containing words are never moved. Where a panel prints several dose columns ("2 kaps" and "4 kaps"), the first is taken — the others are multiples of the same product.
  • Allergen and claim wording is read for denial, not just for keywords. "Bez laktózy" (lactose-free) must not report milk, and "Vhodné pre vegánov: Nie" must not record a vegan claim. A denied claim is stored as false, which is a different fact from never having been asked.
  • Anything outside Annex I is kept and flagged, never forced into the table. requiresReview with a stated reason is the honest record of "no EU list covers this".
  • The ingredient statement is captured verbatim as ingredientStatement, and used to fill in Annex II forms the panel abbreviated. Only forms of a nutrient the row already resolved to are accepted, so the statement can add detail but never change what a row is.
  • Allergens are detected; dietary claims are only copied. Regulation 1169/2011 Annex II is a closed legal list, so allergens are matched deterministically and reported with the word that triggered them. "Vegan" has no EU legal definition, so it is recorded when the pack asserts it and is never inferred from an ingredient list.
  • Supplement composition is mirrored into medication_ingredients with source = 'label', the Annex I nutrient name in inn. The duplicate check needs no change and now sees supplements.
  • No UNII is hand-entered. scripts/load-unii.mjs resolves Annex II form names against the FDA substance file and writes unii.generated.json, which nutrients.ts merges in. A plausible-looking wrong identifier in a health record cannot be told from a right one by eye, so a test asserts the vocabulary source contains none, and the loader leaves a form unresolved rather than choosing when its aliases point at different substances. The committed artifact is empty until the loader is run; --check fails when it is stale.
  • Composition JSON moves to schemaVersion: 2. Schema 1 documents are migrated on read: the single form string becomes one unclassified form row and the ingredient is flagged for review, because the old model cannot say which of the four things that string was.

Alternatives considered

  • Keep one form string and add aliases. Rejected: the field held four incompatible concepts, so no alias table can disambiguate it. (Natural) and (from Bladderwrack) are not spellings of a compound.
  • Fold source material into identity (lichen-D3 as its own substance). Rejected: it splits one nutrient into several and breaks the duplicate check, to record something that is a dietary preference, not a pharmacological fact.
  • Use DSLD (NIH) as the ingredient vocabulary. Deferred, not rejected: it is a US label database with good coverage of US brands, but it is product-level and carries no legal force in the EU. Worth revisiting for prefill.
  • Open Food Facts as the supplement source. Kept only as a barcode fallback: it is a food index with patchy supplement coverage and no ingredient panel for many products.
  • A parallel supplement-ingredient table. Rejected: it would need a cross-table join in every safety path, which is what made supplements invisible to the duplicate check in the first place.

Consequences

Supplements participate in the duplicate-substance check, and vitamin-D spellings collide correctly within it. Cross-matching a supplement against a registry medicine works through the UNII and only through it: ŠÚKL names the substance ("colecalciferol") while a label names the nutrient ("Vitamin D"), so the names never meet. Until npm run data:unii has been run against an FDA substance file the identifiers are absent and that pair stays invisible — a documented, tested state rather than a silent one. A supplement row that declares no chemical form has no identifier to carry even afterwards, and still matches other supplements by nutrient name alone.

The NRV table is load-bearing beyond display: nrvAgrees() checks a label's own percentage column against the regulation, which catches a misread amount or a swapped unit without asking the user anything.