ADR-0004: Supplement-only label capture with estimate-based refill tracking
- Status: Accepted
- Date: 2026-07-19
- Supersedes: None
- Superseded by: None
Context
The app needs to know what is in each supplement (for overlapping-ingredient checks) and when stock runs out (for refill reminders). Supplement packaging is the only authoritative source for supplement composition, while prescription and OTC medication data should come from official registries (NCZI is the planned source) — hand-captured label data must not masquerade as registry data. A full OCR-first pipeline (layout analysis, table reconstruction) was assessed and rejected as over-built for a single-user app.
Decision
- Structured composition applies to
kind = 'supplement'only. It is stored as versioned JSON (schemaVersion: 1) inside the existingmedications.compositiontext column; legacy free text stays valid and parses as unstructured. - Capture is barcode-first (Open Food Facts prefill), then deterministic text
parsing (pasted or OCR'd label text). No language model parses amounts; every
parsed ingredient keeps its source line in
rawText; every capture path ends in an editable confirmation UI — drafts are never saved unreviewed. - Units are normalized to canonical spellings (µg, mg, IU, CFU…) with OCR-confusable-character folding. IU is never auto-converted to mass: the factor is substance- and form-specific.
- OCR is an optional LAN microservice (
services/label-ocr, PaddleOCR) that returns raw lines only; all parsing stays in the app. Barcode and OCR calls happen at ingestion time only — saved records never depend on a network service, and Open Food Facts responses go through the versioned api_cache. - Refill tracking is estimate-based for all medication kinds: the user records units on hand at a date, and the app projects days-left from the dosing rate (parsed from the schedule text or set explicitly). No per-intake logging is required, and no rate is ever guessed for as-needed items.
Alternatives considered
- OCR-first pipeline with layout/table reconstruction (PP-StructureV3): heavier than the problem for a personal record; curved bottle labels defeat table reconstruction anyway.
- VLM as the extraction engine: deferred; the deterministic parser plus confirmation UI covers current volume without a hallucination surface.
- Intake-log-driven supply countdown: rejected as the primary mechanism — logging discipline varies, so projection uses elapsed time; the intake log remains a separate record of what was actually taken.
Consequences
Composition JSON enables later overlapping-ingredient checks across supplements. Medication (prescription/OTC) composition remains free of label-captured data, keeping the path clear for NCZI registry integration.