How menstrual-cycle and health tracking (days, months, or years — up to 10,000 days, bounded naturally by QR capacity; typically 250 KB–1 MB+ of FHIR JSON) fits inside a single offline phone-scannable QR code (300–1,960 bytes), what each component does, and where every clinical safety boundary sits.
Six core pieces
1. Input model
A small, typed JSON structure (CycleLog) representing only the clinical facts—days, bleeding, pain, BBT, medication doses, exclusions, custom series—stripped of FHIR boilerplate.
2. Lifting (FHIR → model)
Translates an arbitrary real-world FHIR R4 Bundle (EHR, wearable, portal export) into the input model while reporting every item kept, reshaped, dropped, or blocked on safety modifiers (lift.ts).
3. Planning (fit to QR budget)
When a model is too big for a target QR size (e.g. Version 22-L = 949 B with viewer link), tries named omission-only steps (drop times, thin repeats, omit low-priority series, trim oldest cycles) without ever altering a recorded value.
4. Codec (model ↔ bytes)
Compresses the normalized input model into a minimal canonical binary stream in a zero-import, zero-float, zero-panic 345 KB Rust WebAssembly module (cycle-log.wasm), and expands bytes back into a standard FHIR R4 Bundle on the receiver.
5. Transport (bytes ↔ QR)
Wraps payload bytes as [codec id][payload][2B SHA-256 check], then packs every 7 bytes into 17 decimal digits so the QR uses high-density Numeric Mode (98.8% of raw binary capacity).
6. Reduced flag (SUBSETTED)
A 1-bit flag on the card (emitted as FHIR Bundle tag SUBSETTED) telling receivers that something from the original source was omitted during lifting or planning; everything present is still verbatim.
Diagram 1: End-to-end architecture & data flow
There are two ways onto a card: an app can fill in the input model directly (never constructing FHIR), or an existing FHIR R4 Bundle can be lifted into the input model. On the receiving phone, no server is contacted—the codec deterministically reconstructs a standard FHIR R4 Bundle locally.
Diagram 2: Deep dive — lifting, input model, and omission-only planning
These three stages all touch clinical meaning, so each has a strict, separate boundary: Lifting safely ingests messy FHIR without dropping modifiers, the Input model defines the exact clinical vocabulary, and Planning shrinks a valid model to fit a QR budget using omissions only.
Diagram 3: Inside the codec — outlier-resilient & simple by design
The codec replaces multi-level Bayesian mixtures and cycle-phase prediction with three small integer primitives (2-level KT probability chains, Elias-style signed/unsigned integer coding, and script-neutral LZ77 UTF-8 text coding) plus four structural fixes that eliminate single-entry outlier cliffs.
Diagram 4: Measured card sizes across sample records & stress tests
Exact card bytes (codec output + 1B codec id + 2B SHA-256 check). Vertical dashed lines mark the comfortable phone-scan threshold (Version 22-L, 983 B bare) and stretch line (Version 30-L, 1,703 B bare).