A codec built around one set of samples could fail on the first dataset that differs from them. This file checks that field by field: for what real apps store and export, it says what the card can carry and what it cannot.
The design rule is that built-in tables and scales are shortcuts that make expected content cheap; they are never the limit of what can be said.
1. How the model carries something it has no built-in for
There are four mechanisms, all defined in model.ts and vocab.ts.
- Readable built-in keywords + FHIR R4
CodeableConceptescapes. Built-in slots accept readable string keywords (SymptomKind35,MedicationKind7,ConditionKind15, plusMucus,Sex,Mood,Energy,ProcedureKind,IntervalKind,ExcludeReason, codedAnswervalues) that expand on decode to canonical SNOMED CT / LOINC /cycle-logcodings. Any escape or custom concept is a standard FHIR R4CodeableConcept: either{ coding: [{ system, code, display? }], text? }(e.g.{ "coding": [{ "system": "http://www.nlm.nih.gov/research/umls/rxnorm", "code": "314076", "display": "Lisinopril 10 MG Oral Tablet" }], "text": "Blood pressure pill" }) or text-only{ text }(e.g.{ "text": "Brain fog" }).- Any
CodeableConceptis accepted wherever the model takes a concept: symptoms, medications, conditions, the value of every built-in coded series (mucus, tests, sex, mood, energy), temperature exclusion reasons, coded screening answers, custom series, custom state intervals, and procedures. - Eight well-known systems can be named in a few bits: SNOMED CT, LOINC, RxNorm, UCUM, cycle-log (this codec's proposed concepts), ATC, ICD-10-CM and NDC. Any other absolute URI is spelled out once per card, and text-only
{ text }concepts require no system URI at all. - Bounds:
- system: absolute URI, printable ASCII without spaces or
|, at most 255 characters; - code: FHIR
codesyntax, 1–128 characters, any Unicode except control characters and unpaired surrogates; - SNOMED CT: 6–18 digits, valid Verhoeff check digit, concept partition.
- system: absolute URI, printable ASCII without spaces or
- Any
- Inline
Coding.display,CodeableConcept.text, and text-only{ text }. For any non-built-in escape concept — whether in SNOMED CT, LOINC, RxNorm, ICD-10-CM, ATC, NDC, or an app URI — bothcoding[0].displayandtext(at most 128 characters each) are preserved on the card and emitted verbatim in the FHIR Bundle (all occurrences of the same(system, code)must agree on the samedisplayand the sametext). Text-only{ text }concepts carry user or app tags without inventing a synthetic code-system URI (demonstrated intext-tags), and offline displays on standard escape codes keep records human-readable without a terminology server (demonstrated inoffline-displays). Up to 512 distinct escape labels (displays, coded texts, and text-only concepts) may appear on a card. On built-in concepts,displayis optional on input and stripped canonically, andtextis forbidden. - Custom series (
valueType). Up to 32 per card. Each has an Observationcode: CodeableConcept(not a built-in series code), one of four FHIRObservation.value[x]valueTypekinds, and a flatentriesarray of{ date, ... }objects. A code that is an R4 vital-sign LOINC code (heart rate, weight, blood pressure, fever, …) makes the series a vital sign, written with the vital-signs category (MAPPING.md §1):
valueType | FHIR Observation.value[x] | per entry / day | limits | covers |
|---|---|---|---|---|
"boolean" | valueBoolean | { date, value: true | false } | – | yes/no logs; events (true only) |
"coded" | valueCodeableConcept, one fact per entry | { date, value: CodeableConcept } (up to 64 distinct concepts per day) | any CodeableConcept (coded with optional display/text, or text-only { text }) | categorical and ordinal scales, multi-select tags, per-symptom severity |
"quantity" | valueQuantity {value, unit = code, UCUM system} | { date, value: number } | natural decimal below 10^9 in magnitude with up to 6 decimal places, UCUM unit ≤ 64 chars | any measured or counted daily value |
"components" | component[] [{code, value[x]}], no top-level value | { date, components: [{ code, value }] } | 1–16 components, each declaring valueType: "boolean", "coded", or "quantity" | readings of several parts: blood pressure (systolic, diastolic) |
Every fact has the shape of the built-in facts: status final, effectiveDateTime from the entry's FHIR DateTime (YYYY-MM-DD or full timestamp; multiple entries on the same date are simply more array elements), exactly one value (a reading: its components). The custom code becomes Observation.code, carrying its display and/or text if present.
4. Custom states and procedures.
- A custom state span is
{ code: CodeableConcept, value: CodeableConcept, start, end }, emitted as an Observation witheffectivePeriod. Example: contraception LOINC 8659-5 = "Diaphragm or cervical cap", which is not a built-in kind. - A procedure is
{ date: FhirDateTime, code: ProcedureKind | CodeableConcept }, emitted as a Procedure resource with any procedure concept ascode, dated with a partial date (YYYY,YYYY-MM), full calendar date (YYYY-MM-DD), or full timestamp. Any medicationCodeableConceptgoes into a MedicationStatement; any conditionCodeableConceptinto a Condition.
Built-ins are cheaper spellings of the same thing. Pain, sleep and measured volume are quantity series. Symptoms, mucus, the tests, sex, mood and energy are coded series. The pill log is a boolean series. Each is rendered by the same three renderers as a custom series, so its facts are identical apart from Observation.code. A test checks this for pain, sleep, mood, mucus, symptoms and the pill log.
These built-ins are special and cannot be spelled as custom series:
| built-in | why it is special |
|---|---|
| bleeding/flow | Two paired facts (a boolean bleeding fact and a flow fact) with consistency rules. |
| BBT | Uses proposed code basal-body-temperature (separate from LOINC 8310-5 clinical body temperature) and supports optional reading-excluded / reading-exclusion-reason components. |
| wearable skin temperature | One series whose code says deviation or absolute, with optional reading-excluded / reading-exclusion-reason components. |
| conditions, screening answers, the source Device | Not per-day series: a Condition resource, question-coded answers, one Device. |
| medications, procedures | They are MedicationStatement (with optional dose) and Procedure resources, not Observations. They are open to any concept, so they never need a custom series. |
| the three built-in interval codes | Each is a (code, value) pair over a start..end date range. |
Ordering rule. A built-in's code is reserved: anything with that Observation code goes into the built-in. That is always possible, because each built-in coded series accepts any concept as an escape value. The exceptions are pain values outside 0–10 (LOINC 72514-3 is a 0–10 scale by definition) and a second value on the same day.
What a declaration costs
These are estimates from conceptsBits in report.ts, the same coder model as the entropy estimate:
| what | bytes |
|---|---|
| a SNOMED CT escape | ≈ 4.5 |
| an RxNorm code | ≈ 3.8 |
| a LOINC code (as text; a LOINC-aware codec could do ≈ 3) | ≈ 8.6 |
| an app's own code system: first concept, including the 46-character system URI | ≈ 57 |
| each further concept in that system | ≈ 10 |
| a label | 1 + its UTF-8 length |
a custom series header (valueType, plus unit for "quantity") | < 1, or ≈ 2–4 with a unit |
2. Field-by-field audit
Legend:
- B — built-in slot (cheapest).
- E — built-in slot with an escape value or escape concept.
- C — custom series, interval or procedure.
- X — not representable.
The cost column is the extra declaration cost per card, not per day; per-day data costs are in MODEL.md §13.
2.1 Apple HealthKit
Source: Apple's HealthKit documentation (developer.apple.com/documentation/healthkit/…, DocC JSON fetched 2026-12-03), and a real iOS 17.6.1 export.xml (github.com/ipekaksoy/DSA210_project_ipek). In that export, Health-app entries are timestamped 12:00 local, which is date-only in practice. Symptoms logged from the cycle UI carry …SeverityUnspecified.
| type / value set | carried by | notes, cost |
|---|---|---|
menstrualFlow: unspecified / none / light / medium / heavy | B | bleeding / flow-none / light / moderate / heavy. |
HKMetadataKeyMenstrualCycleStart | X (derived) | The start of a bleeding run; a viewer recomputes it. An app whose user marked a start that is not a run start loses that. |
intermenstrualBleeding (presence) | B | spotting. |
cervicalMucusQuality: dry / sticky / creamy / watery / eggWhite | B | |
ovulationTestResult: negative / luteinizingHormoneSurge / estrogenSurge / indeterminate | B | |
progesteroneTestResult, pregnancyTestResult: positive / negative / indeterminate | B | |
sexualActivity + HKMetadataKeySexualActivityProtectionUsed (true / false / absent) | B | protected / unprotected / unspecified. |
contraceptive: implant / injection / intrauterineDevice / intravaginalRing / oral / patch / unspecified | B, E | implant, injection, iud-unspecified, ring, combined-pill or progestin-pill, patch. oral without the pill type → custom interval 8659-5 = LA6524-8 "Oral contraceptive pill" (≈ 9 B). unspecified → SNOMED 13197004 "Uses contraception" as a custom interval value (≈ 4.5 B). |
pregnancy, breastfeeding intervals | B | pregnant, breastfeeding intervals. |
menopausalState: none / perimenopause / menopause | B | Built-in conditions "perimenopause" (161541000119104) and "postmenopause" (76498008, about 2 B each). none is not stated. |
bleedingDuringPregnancy, bleedingAfterPregnancy, bleedingAfterMenopause (unspecified / none / light / medium / heavy) | B or C | Normally reported as ordinary bleeding facts. To keep the distinction, use a custom coded series with an app code or text-only { text } (≈ 20–60 B). |
basalBodyTemperature (timestamped) | B | Each reading as a TempEntry in bbt.entries with its FHIR DateTime; several readings a day are simply several entries. |
appleSleepingWristTemperature | B | Built-in skinTemp, kind absolute, Cel. Oura temperature_deviation and Fitbit nightlyRelative are kind deviation. |
40 symptom types with HKCategoryValueSeverity (notPresent / mild / moderate / severe / unspecified) | B or E for presence; C for severity | Presence: 18 of the 40 are built-in SymptomKind keywords, the others are SNOMED escapes (≈ 4.5 B each). Severity: one custom coded series per symptom, with the symptom as code and SNOMED Mild / Moderate / Severe as values (sample h). Explicit notPresent: a custom boolean series per symptom (false), ≈ 1 B each plus data. |
moodChanges, sleepChanges (present / notPresent) | B or C | Present → "mood-swings" / "insomnia" (or an escape). notPresent → custom boolean. |
appetiteChanges: noChange / decreased / increased | C | Custom coded series with SNOMED values (increased appetite 72405004; decreased 64379006 or app/text-only concepts). |
sleepAnalysis stages (inBed / awake / core / deep / REM) | B (total) / C | Total sleep → sleep. Per-stage minutes → custom quantity series (LOINC 93831-6 deep, 93829-0 REM, 93830-8 light). Stage intervals within the night: X. |
HKStateOfMind: valence −1…+1, 7-class valence, 38 labels, 18 associations, kind daily / momentary | B, C | Daily valence class → mood. Labels → custom coded set (sample h). Associations → custom coded set. Continuous valence → custom quantity (up to 2 decimal places). Several momentary entries per day: X (§3). |
| Cycle-deviation types (irregular, infrequent, prolonged, persistent intermenstrual bleeding) | X (derived) | Apple computes these. A viewer recomputes from the facts. |
2.2 Clue (measurements.json)
Source: Clue help article 17320910724125, and the open-source converters forcegk/clue2drip, fabfabretti/clue-to-drip, avandekleut/cycle-export-visualizer, FSchiltz/Helse and EmmaTellblom/Mensinator. Records are {date, type, value}: date only, multi-select types hold lists.
| type | carried by | notes |
|---|---|---|
period: light / medium / heavy / very_heavy | B, E | very_heavy has no built-in flow level. Map it to heavy and lose the distinction, or add a custom coded series "very heavy" (≈ 60 B). The flow fact's five values are fixed, so they are not widened. |
spotting: red / brown | B + C | spotting; the colour goes in a custom coded series. |
pain (period_cramps, headache, migraine, lower_back, breast_tenderness, ovulation…, pain_free) | B, E | pain_free → explicit pain 0, if the app means "no pain". |
severity per option (extent.severity mild / moderate / severe, partly verified) | C | As for HealthKit. |
discharge: none / sticky / creamy / egg_white / atypical | B, E, C | Maps to the mucus categories. none → dry. atypical → escape (no exact SNOMED concept) or custom. |
feelings, mind, energy, pms, craving, digestion, stool, skin, hair, hot_flashes, breasts_and_chest, vulva_and_vagina, urine, ailments, social_life, exercise, leisure | B, E, C | Symptom-like options → symptoms or escapes. Everything else → one custom coded series per category with app codes and labels (≈ 60 B for the first, ≈ 10 B per further option). |
sex_life: protected / unprotected / withdrawal / high_sex_drive | B, E | withdrawal → escape value under the sex code (SNOMED 169513000 is a uses withdrawal method finding, so an app code is better). high_sex_drive → symptom 58436003. |
medication: painkillers, cold_or_flu_meds, hormone_therapy, GLP-1… | E | Medication escapes. "painkillers" is a class, not a product, so it is an app code with a label. |
birth_control_pill (taken; 2017 also late / missed / double) | B, C | taken / missed → pill. late and double → custom coded series. |
birth_control_ring | B | ring interval. |
tests: ovulation_positive, … | B | |
bbt {celsius, excluded} | B | Built-in bbt supports TempEntry with excluded: true and optional excludeReason directly on each reading. |
weight {kilograms} | C | Custom quantity with LOINC 29463-7 in kg (a vital sign: written with the vital-signs category, conforms to R4 bodyweight). |
sleep_duration {minutes} | B | |
sleep_quality | C | |
notes {text} | X | Free text (§3). |
tags (user-typed strings) | C | Custom coded set (or symptom/sex escapes) using text-only CodeableConcept { text } — no fake app URI needed (see text-tags). Costs about the tag length per distinct tag. |
profile.json (cycle_length, period_length, predictions) | X | Settings and predictions. |
2.3 Flo (JSON export on request)
Source: Flo help article 360054973811, and a real export seen through github.com/yinimini/Menstrual-Symptoms-Analysis-, flo2dinks and Mensinator FloImport.kt. Date and category are per point event.
| field | carried by | notes |
|---|---|---|
cycles[].period_intensity per day: light / medium / heavy / blood clots | B, E | Clots → symptom 289532003 on the same day, plus the day's flow. |
point_events_manual_v2 Symptom (DrawingPain, Headache, … VaginalItching, VaginalDryness) | B, E | Each is a built-in or a SNOMED escape (VaginalItching 34363003). |
| Mood (Panic, Swings, VerySelfCritical, Happy, Sad, Angry, Playful, FeelGood…) | B, E, C | Depressed, Swings and Anxious map to symptoms. The rest go in a custom coded multi-select. |
| Fluid (Dry, Sticky, Creamy, Watery, Eggwhite, ClumpyWhite, Bloody) | B, E | ClumpyWhite → mucus escape value with a label. Bloody → spotting. |
| Sex (Protected, Unprotected, Masturbation, Oral, SensualTouch, Orgasm, High/Low drive, None) | B, E, C | Protected / Unprotected / None → sex. Masturbation and the like → escape values or a custom coded set. Drive → symptoms. |
| Disturber (Stress, Alcohol, Disease…) and Sport | C | |
| OvulationTest / Positive | B | |
| Oral contraceptives "Taken on time" | B | |
notes[] {date, text} | X | Free text. |
symptomCheckerData severity strings, wearablesData | C / X | Severity → custom coded. Wearable streams → daily aggregates as custom quantity, or X if sub-daily. |
cycles[].pregnant | B | pregnant interval. |
additional_fields (predictions), aggregates, user_patterns | X | Predictions and derived data. |
2.4 Natural Cycles (Daily Entries.csv)
Source: NC help article 360006693938, and the column list from github.com/Amnesthesia/sanguine (partly verified against AmeliaMN/NaturalCyclesToDrip).
| column | carried by | notes |
|---|---|---|
| Temperature (user's unit, 2 decimals) | B | |
| Menstruation: MENSTRUATION / SPOTTING / MISCARRIAGE_BLEEDING; Quantity LIGHT / MEDIUM / HEAVY | B, C | Miscarriage bleeding → bleeding facts plus a custom boolean or coded series. It is sensitive, and the app should ask the user before including it. |
| LH test, Pregnancy test YES / NO | B | |
| Had sex / Sex Type (YES / PROTECTED / UNPROTECTED / NO) | B | |
| Cervical Mucus Consistency (DRY…EGGWHITE), Quantity | B, C | Quantity → custom coded. |
| Libido LOW / MEDIUM / HIGH / NORMAL | E, C | |
| Data Flag (PAIN_CRAMPS, SKIN_ACNE, MOOD_TIRED…, DEVIATION_REASON_*) | B, E, C | Temperature deviation reasons (fever, alcohol, poor-sleep, late-wake, travel, stress, medication, other, or any escape) attach directly via TempEntry.excluded + excludeReason. |
| Covid Test | C | |
| Skipped, Source | X / C | "Skipped" is app bookkeeping. Source (wearable or thermometer) per reading cannot be attached to a BBT value: X. |
| Notes | X | Free text. |
2.5 Fitbit (Google Takeout "Menstrual Health") and Samsung Health
Sources: the README inside Fitbit's export (copy at github.com/vic-goncalves/t1d_data), and real Samsung Health CSVs (github.com/ahemed-haneen/pro_runner).
| field | carried by | notes |
|---|---|---|
Fitbit fluids, flow, conditions (multi), sex (protected / unprotected), ovulation_test, mood (multi) | B, E, C | |
Fitbit cycle_altering_event (morning-after pill, pregnancy) | B | emergency-contraception procedure, pregnant interval. |
Fitbit menstrual_health_settings (pregnancy_history, birth_control_history, avg_cycle_days) | B / X | Histories → conditions, prior procedures and intervals where dated. Average cycle length is computed, so X; the person's own statement → the usual-cycle-length answer. |
Fitbit birth_control (type, event_date, has_started) | B, C | Intervals. |
Fitbit cycles.csv fertile window / ovulation, source Computed | X | Predictions. Manual ovulation entries → custom boolean. |
Samsung cycle.flow (spotting 0/1, amount) | B | |
Samsung cycle.daily_temperature.raw (per-minute skin temperature) | X / B | The nightly aggregate → built-in skinTemp (absolute). The per-minute series cannot be carried. |
Samsung cycle.prediction | X | Predictions. |
2.6 drip (open source; src/db/schemas/4.js)
| field | carried by |
|---|---|
| bleeding 0–3, temperature (value, time, exclude) | B (time, excluded, and optional excludeReason per reading) |
| mucus feeling × texture | C, or collapse to B |
| cervix opening / firmness / position | C (sample h has cervix position) |
| desire low / medium / high | E / C |
| sex flags incl. contraceptive flags, pain flags, mood flags | B, E, C |
| note | X |
3. Not representable: the honest boundary
These are the only things a card cannot say. For each, the table gives what an exporting app should do.
| what | why | what the app should do |
|---|---|---|
| Free text (diary notes, long narrative sentences) | Privacy: free text from the source app can say anything. Also size, and a receiver cannot interpret it. | Drop diary notes with the user's knowledge; short user-defined tags or plain-text labels work cleanly as text-only CodeableConcept { text } (up to 128 chars, see text-tags), without fake app URIs. If long narrative notes must travel, use a SMART Health Link with the full record. |
| Streams of many values a day (thousands of readings of one series on one day) | Nothing in the model limits entries per day (the 20,000-fact limit is the only bound), but every entry costs card bytes, so a dense stream does not fit a QR code. | Send the readings that matter, or an aggregate per day; the full stream: SMART Health Link. |
| Sub-daily streams (per-minute skin temperature, heart rate, sleep stages as intervals) | They are timestamped series, not day facts. | Send nightly or daily aggregates: skinTemp for skin temperature, custom quantity series for the rest. |
| Predictions and derived values (fertile window, predicted period, cycle-deviation flags, "cycle start" marks the app inferred) | They are not things the person observed; exported as facts they would read as observations. | Omit them. Viewers recompute. |
| Attributes attached to one fact (per-reading device or source, a note on a reading) | A fact is one value (except built-in TempEntry excluded/excludeReason and MedEntry dose). Adding arbitrary per-fact modifiers would turn the model into a second FHIR. | Drop them, or carry a parallel custom series. |
| Values outside a built-in's definition (pain on a 0–5 or 0–100 scale under LOINC 72514-3, which is 0–10; flow levels beyond the five, e.g. Clue very_heavy) | The built-in codes have fixed definitions. | Use a custom series with a different code (e.g. a 0–5 pain score as a custom quantity, or "very heavy" as a custom coded series). Never rescale silently. |
| The order of an ordinal scale | FHIR has no element for the order of codes in a value without a CodeSystem or an extension. The card carries the levels, not their ranking. | Choose codes and labels that state the rank ("3 of 5"), as sample (h) does. |
| More than 32 custom series, 64 distinct concepts per day per coded series, 512 escape labels, 256 intervals, 512 procedures, 20,000 facts (a bound on work); and finally the QR | These are limits of the format. The QR itself holds at most about 2.9 KB at Version 40-L. | Coarsen or drop low-value series. Sample (h) needs about 2 KB (QR Version 33-L) and (i) about 2.5 KB (QR Version 37-L, does not fit at M). |
| **Codes in a system with ` | ` in its URI, or with control characters or non-FHIR whitespace** | Syntax. |
| Patient identifiers, address, contact and gender; more than one source device | Only a name and a birth date are carried (optional), and one source app (Device). | The host supplies further identity. With several apps, name the exporting one. |
| Dates outside 2000–2099 or spanning more than 10,000 days | Date-span limit of the codec. | Trim older cycles or split across cards / use a SMART Health Link. |
4. The cost of leaving the built-ins
From bun report.ts. "Declarations" are bytes spent on escape concepts, labels and custom-series headers. The rest of the estimate is per-day data.
| sample | entropy estimate B | of which declarations B | QR (1 + payload) L / M |
|---|---|---|---|
| (a) power-tracker (built-ins only) | 1,231 | 6 | 25 / 29 |
| (e) perimenopause (one proposed-code symptom, one SNOMED escape) | 675 | 6 | 18 / 21 |
(h) own-vocabulary: 5 custom series, about 30 app concepts with labels, RxNorm meds, SNOMED escapes, a custom interval, minute-precision sleep (its wrist temperature now uses the built-in skinTemp) | 1,943 (incl. 25 B identity) | 591 | 33 / 37 |
| (i) wellness-diary: 5 custom series (migraine yes/no, triggers, caffeine, steps, resting HR), RxNorm meds | 2,498 | 366 | 37 / – |
What that shows:
- Declarations are a one-off fixed cost, dominated by labels and app system URIs. In (h), about 270 of the 660 bytes are 22 labels and the rest are about 35 app codes plus their one system URI. In (i), 129 of the 366 bytes are 10 labels. SNOMED, RxNorm and LOINC escapes cost 4–9 bytes each.
- A deployment would shrink this by giving common app vocabularies well-known system slots, or by using standard codes so that no label is needed.
- The data itself does not get more expensive.
- Daily numeric wearable streams are what is expensive, built-in or not. In (i), steps and resting heart rate are each about 0.4–0.5 KB a year, because a day's step count carries about 11 bits of real information. In (h), minute-precision sleep (351 B) costs about twice as much as 15-minute sleep.
- Nothing in (h) or (i) needed a model change. Both round-trip losslessly, and both validate (MAPPING.md §6).