The goal is a whole year of rich menstrual-cycle tracking in one small QR code. This directory defines what such a card can say (model.ts, vocab.ts) and the FHIR Bundle it stands for (to-bundle.ts, MAPPING.md). It also provides fourteen synthetic years (sample.ts), their sizes with an entropy target (report.ts), an audit of what real apps store against what the card can carry (EXPRESSIVENESS.md), and the tests (bun test). A codec (Rust → WebAssembly) and a viewer build on this contract.
Design rule. Built-in series, tables and scales are shortcuts that make expected content cheap. They never limit what can be said:
- every coded value accepts any concept from any code system as an escape;
- concepts outside the built-ins may carry a label;
- anything without a built-in slot goes into one of three custom-series shapes, or a custom interval or procedure.
What remains unrepresentable is listed, with the reason, in EXPRESSIVENESS.md §3.
Files
| file | what |
|---|---|
vocab.ts | code systems, the concept-key syntax and its limits, all built-in tables and codes |
model.d.ts | the normative definition of the model: TypeScript types only, every field documented, the built-in tables as documented literal unions |
model.ts | validate, validateJson, normalize and the limits (with vocab.ts, the source of truth for what is accepted); its types come from model.d.ts |
model.schema.json | JSON Schema 2020-12 derived from model.d.ts and the constants (written by make-schema.ts, with the generated sections of this file) |
examples/ | every persona's normalized model (<persona>.model.json, generated) and the hand-written minimal-teaching.model.json with its line-by-line explanation |
make-schema.ts | derives model.schema.json, examples/<persona>.model.json and the generated sections of this file from model.d.ts and the constants (bun make-schema.ts --write) |
json-schema-lite.ts | test support: a validator for the JSON Schema keywords the schema uses |
to-bundle.ts | toBundle, stringify (canonical bytes), fromBundle |
MAPPING.md | FHIR representation, entry order, canonical form, code evidence, validation status |
EXPRESSIVENESS.md | field-by-field audit of HealthKit, Clue, Flo, Natural Cycles, Fitbit, Samsung and drip; the "not representable" list |
CodeSystem-cycle-log.json | the proposed concepts, https://joshuamandel.com/shc2-poc/CodeSystem/cycle-log (CYCLE_LOG_CS in vocab.ts), with definitions (written by make-codesystem.ts) |
codes-verified.json | tx.fhir.org $lookup evidence for every standard code (bun verify-codes.ts) |
sample.ts | generate(options), SAMPLES (14 personas); re-exports coarsen |
coarsen.ts | coarsen(model, options): a coarser grid for sleep, mood, BBT, skin temperature and volume |
import-ics.ts | importIcs(text, options): bleeding days from an iCalendar export (tested in import-ics.test.ts, fixtures in fixtures/ics/) |
calendar-sample.ts | the synthetic year-long calendar persona (j) is imported from (also fixtures/ics/calendar-year.ics) |
report.ts | measurement tables (bun report.ts) |
golden.json | SHA-256 of every sample's model and canonical Bundle (bun golden.ts --write) |
r4-structure.ts, hl7-validate/ | offline R4 structural checker; HL7 validator runner |
cycle-log.test.ts, model-schema.test.ts, import-ics.test.ts | the model, schema and importer tests |
1. Writing an exporter: the smallest valid model
The model is one JSON object. The smallest valid model is a window and nothing in it:
{"start": "2026-01-05", "days": 90}
It is valid but says nothing. The smallest useful model adds one per-day series. examples/minimal-teaching.model.json is three months of bleeding days and nothing else, explained line by line in examples/minimal-teaching.model.md. Every persona in §12 is published as a full example in examples/<persona>.model.json.
To write an exporter:
- Pick the window:
startis the first day,daysits length (at most 10,000). Day i isstart+ i. - For each thing the app logged, find its field in §2. Write per-day values at their day index,
nullwhere nothing was logged. A day with several entries, or entries with times of day, is written as entries (§8). - Write only what the person logged. Leave out what they did not; never fill in a negative (§3).
- For a value without a built-in name, write a concept (§4). For a whole kind of data without a field, add a custom series (§5).
- Check the result with
validateJson(or the codec's encoder, which refuses exactly what it rejects). The JSON Schema catches shape errors in any language; the rules in §6 needvalidate.
2. Field reference
Generated from model.schema.json, which is derived from model.d.ts; the types file has the same text as TSDoc. "Required" means the field must be present; every other field may be absent or null. A per-day array has one entry per day from day 0; a type such as array (≤ 10000) of Bleeding | null means the entries are Bleeding values or null.
Shared shapes
| name | type | meaning |
|---|---|---|
CalendarDate | string (pattern) | A calendar date YYYY-MM-DD from 2000-01-01 to 2099-12-31 (real Gregorian date). Used for interval start and end bounds. |
DateTime | string (pattern) | A FHIR dateTime on the daily tracking timeline (2000-01-01 to 2099-12-31): either a calendar date YYYY-MM-DD (day precision) or a date with local time and quarter-hour UTC offset YYYY-MM-DDTHH:MM(:SS)?(Z|±HH:MM). "Z" is accepted and normalized to "+00:00"; ":00" seconds are accepted and omitted canonically; "-00:00" is rejected. |
FhirDate | string (pattern) | A FHIR date of year, month or day precision: YYYY, YYYY-MM or YYYY-MM-DD, from 1900 to 2150. Used for patient birth date and condition onset. |
FhirDateTime | string (pattern) | A FHIR dateTime for procedures (year 1900 to 2150): YYYY, YYYY-MM, YYYY-MM-DD, or YYYY-MM-DDTHH:MM(:SS)?(Z|±HH:MM). "Z" is accepted and normalized to "+00:00"; ":00" seconds are omitted canonically; "-00:00" is rejected. |
FhirInstant | string (pattern) | A FHIR instant with calendar date (2000-01-01 to 2099-12-31), time of day, optional seconds and quarter-hour UTC offset: YYYY-MM-DDTHH:MM(:SS)?(Z|±HH:MM). "Z" is accepted and normalized to "+00:00"; ":00" seconds are omitted canonically; "-00:00" is rejected. FHIR Bundle.timestamp always emits seconds. |
The model object
One card: consumer cycle tracking as uniform dated arrays. An empty object {} is valid.
| field | required | type | meaning |
|---|---|---|---|
patient | PatientInfo, or null | Who the card is about, kept deliberately small. Not recorded: absent or empty; the card then carries no identity at all. | |
source | Source, or null | The source app: its name and optional version. Not recorded: absent. | |
exportedAt | FhirInstant, or null | When the card was exported, as a FHIR instant with UTC offset (mapped to FHIR Bundle.timestamp). Not recorded: absent. | |
reduced | boolean, or null | The sender deliberately left out data to fit a size: a series, time of day, or display that is absent may have been tracked; recorded values are never altered. It says nothing about what was left out. Not reduced: false or absent (omitted canonically). Written as the Bundle tag SUBSETTED. | |
conditions | array of ConditionEntry, or null | Conditions the person reports having (background context such as PCOS or fibroids). Not recorded: [] or absent. Explicit negative: status "resolved". A condition stated more than once (even differently) is carried as stated. | |
bleeding | array of {date: DateTime, value: Bleeding}, or null | Menstrual bleeding entries. Omitted dates: not recorded. Explicit negative: "no-bleeding" (or "flow-none"). | |
volume | array of {date: DateTime, value: integer 0..500}, or null | Collected menstrual fluid entries, whole mL (a smart or graduated cup). Fluid, not blood: the blood fraction varies widely between people, so a fluid volume does not establish a blood loss. Independent of bleeding: neither implies the other. Omitted dates: not recorded. Explicit negative: 0. | |
pain | array of {date: DateTime, value: integer 0..10}, or null | Pain entries on a 0-10 numeric rating scale (LOINC 72514-3). Omitted dates: not recorded. Explicit negative: 0 ("no pain"). Another scale goes in a custom series. | |
symptoms | array of ({date: DateTime, value: SymptomKind | CodeableConcept}), or null | Symptoms present on each date: a built-in keyword (SymptomKind) or any FHIR CodeableConcept as an escape (presence only; for severity use a custom coded series). Omitted dates: not recorded. There is no explicit "symptom absent". | |
bbt | Bbt, or null | Basal body temperature (waking readings). Not recorded: absent. | |
skinTemp | SkinTemp, or null | Nightly skin or wrist temperature from a wearable (one device per card). Never pooled with BBT. Not recorded: absent. | |
mucus | array of ({date: DateTime, value: Mucus | CodeableConcept}), or null | Cervical mucus entries. Omitted dates: not recorded. "dry" is a value. | |
ovulationTest | array of ({date: DateTime, value: OvulationTest | CodeableConcept}), or null | LH (ovulation) test result entries. Omitted dates: not recorded. Explicit negative: "negative". | |
progesteroneTest | array of ({date: DateTime, value: TestResult | CodeableConcept}), or null | Progesterone (PdG) urine test result entries. Omitted dates: not recorded. Explicit negative: "negative". | |
pregnancyTest | array of ({date: DateTime, value: TestResult | CodeableConcept}), or null | Pregnancy test result entries. Omitted dates: not recorded. Explicit negative: "negative". | |
sex | array of ({date: DateTime, value: Sex | CodeableConcept}), or null | Sexual intercourse entries. Omitted dates: not recorded. Explicit negative: "none". | |
mood | array of ({date: DateTime, value: Mood | CodeableConcept}), or null | Mood entries on a 7-point valence scale. Omitted dates: not recorded. Other mood scales or multi-select moods go in a custom series. | |
energy | array of ({date: DateTime, value: Energy | CodeableConcept}), or null | Energy entries on a 4-point scale. Omitted dates: not recorded. | |
sleep | array of {date: DateTime, value: integer 0..1440}, or null | Minutes of sleep ending on each date (attributed to the wake day). Omitted dates: not recorded. 0 is a value (no sleep). | |
pill | array of {date: DateTime, value: PillLog}, or null | Contraceptive pill log entries. Which pill is named by the contraception interval covering the date. Omitted dates: not recorded. Explicit negative: "missed". | |
medications | array of MedEntry, or null | Medication entries (a dose taken twice is two entries with their timestamps). Built-in keywords: MedicationKind; any other product (RxNorm, SNOMED CT, text-only, ...) is an escape CodeableConcept. Omitted dates: not recorded. Explicit negative: status "not-taken" (a missed dose). | |
intervals | array (≤ 256) of (BuiltinInterval | CodedInterval), or null | States that last over a range of calendar dates: contraception, pregnancy, breastfeeding, or any other coded or text-only state. Not recorded: [] or absent. Explicit negative for contraception: kind "none". Intervals of one state that overlap or touch are one interval: normalize merges them. | |
procedures | array (≤ 512) of Procedure, or null | Procedures: partial date (YYYY, YYYY-MM), full date (YYYY-MM-DD), or full date with time (YYYY-MM-DDTHH:MM(:SS)?(Z|±HH:MM)), year 1900-2150. Not recorded: [] or absent. A procedure listed twice is two procedures. | |
answers | array of Answer, or null | Screening questions the person answered, each with the date (and optional time) they answered it. What they said, never a value computed from the log. Not recorded: [] or absent. A question answered more than once (even differently, at one time) is carried as answered. | |
custom | array (≤ 32) of (CustomBooleanSeries | CustomCodedSeries | CustomQuantitySeries | CustomComponentsSeries), or null | Series without a built-in slot, each with its own Observation CodeableConcept and one of four valueType kinds ("boolean", "coded", "quantity", or "components" for multi-component readings like blood pressure). Not recorded: [] or absent. One series per distinct code. |
Answer
A screening question answered on a date or timestamp.
| field | required | type | meaning |
|---|---|---|---|
date | yes | DateTime | When the person answered: calendar date or date with time and UTC offset. |
question | yes | Question | Which question. |
value | yes | string | integer | CodeableConcept | The answer: for a coded question its built-in answer name or any FHIR CodeableConcept as an escape; for a numeric question an integer in the question's range. See Question. |
Exactly one of: usual-cycle-length → UsualCycleLength | CodeableConcept; periods-per-year → integer 0..100; missed-periods-3-months → integer 0..3; period-in-last-year → YesNo | CodeableConcept; periods-stopped → PeriodsStopped | CodeableConcept; age-periods-stopped → integer 0..100; age-at-menarche → integer 0..100.
Bbt
Basal body temperature readings (0.01 °C / 0.01 °F precision, distinct from LOINC 8310-5 general body temperature).
| field | required | type | meaning |
|---|---|---|---|
unit | yes | TemperatureUnit | Unit of every reading. |
entries | yes | array of TempEntry | Readings in natural degrees of unit (at most 2 decimal places, e.g. 36.52). Cel 34-42, [degF] 93-107.6. |
Exactly one of: readings in Cel (34..42); readings in [degF] (93..107.6).
BuiltinInterval
A built-in state over a range of calendar dates.
| field | required | type | meaning |
|---|---|---|---|
kind | yes | IntervalKind | Which state. |
start | yes | CalendarDate | First calendar date. |
end | yes | CalendarDate | Last calendar date (inclusive), not before start. |
CodeableConcept
A FHIR R4 CodeableConcept: either a single Coding with optional plain-text text, or a text-only concept { text } with no coding (no synthetic URI required). For built-in concepts, coding[0].display is optional on input and stripped in canonical form, and text is not allowed. For any non-built-in escape coding, both coding[0].display and text are preserved and must agree across all occurrences of the same (system, code).
| field | required | type | meaning |
|---|---|---|---|
coding | array (≤ 1) of Coding, or null | At most one standard FHIR Coding { system, code, display? }. Required unless text is given. | |
text | string (1–128 chars), or null | Plain-text label (1-128 characters, no control characters or leading/trailing whitespace). Required when coding is absent; optional on non-built-in escape codings; not allowed on built-in concepts. |
CodedInterval
Any other state: an observation code and a coded or text-only value, over a range of calendar dates.
| field | required | type | meaning |
|---|---|---|---|
code | yes | CodeableConcept (restricted) | What is observed (an Observation CodeableConcept), e.g. LOINC 8659-5 "Birth control method". Not a built-in per-day series code and not an R4 vital-sign code. |
value | yes | CodeableConcept | The state, e.g. LOINC LA27913-5 (diaphragm or cervical cap) or a text-only concept. |
start | yes | CalendarDate | First calendar date. |
end | yes | CalendarDate | Last calendar date (inclusive), not before start. |
Coding
A standard FHIR Coding from any code system. For built-in concepts, display is optional on input and stripped in canonical form. For any non-built-in escape concept (including SNOMED CT, LOINC, RxNorm, ICD-10-CM, ATC, NDC, or app URIs), display is carried and all occurrences of the same (system, code) must agree on the same display text.
| field | required | type | meaning |
|---|---|---|---|
system | yes | string (1–255 chars) | Code system URI: absolute URI of printable ASCII without spaces or "|", 1-255 characters. |
code | yes | string (1–128 chars) | Concept code within system: 1-128 characters, no control characters, no leading/trailing/repeated spaces. SNOMED CT codes must be valid 6-18 digit concept ids (Verhoeff check digit, partition 00 or 10). |
display | string (1–128 chars), or null | Optional human-readable display text (1-128 characters, no control characters or leading/trailing whitespace). Carried for any non-built-in escape concept; optional on input and stripped in canonical form for built-in concepts. |
ConditionEntry
A condition the person reports.
| field | required | type | meaning |
|---|---|---|---|
code | yes | ConditionKind | CodeableConcept | The condition: a built-in keyword (ConditionKind) or any FHIR CodeableConcept as an escape. |
status | ConditionStatus, or null | What the person says about it now. Not stated: absent. | |
onset | FhirDate, or null | When it started, as precisely as the person says (1900-2150). Not stated: absent. |
CustomBooleanComponent
A yes / no component (component.valueBoolean).
| field | required | type | meaning |
|---|---|---|---|
code | yes | CodeableConcept | The component CodeableConcept. |
valueType | yes | "boolean" | FHIR Observation component value type: boolean (component.valueBoolean). |
CustomBooleanSeries
Yes / no entries (also events: only true).
| field | required | type | meaning |
|---|---|---|---|
code | yes | CodeableConcept (restricted) | The Observation CodeableConcept. Not a built-in series code. An R4 vital-sign code makes the series a vital sign (category vital-signs); a code with its own R4 profile needs that profile's valueType and unit (VITAL_SIGN_PROFILES). |
valueType | yes | "boolean" | FHIR Observation value type: boolean (Observation.valueBoolean). |
entries | yes | array of {date: DateTime, value: boolean} | Entries with boolean values (false is an explicit negative). |
CustomCodedComponent
A coded or text-only component: one CodeableConcept per reading (component.valueCodeableConcept).
| field | required | type | meaning |
|---|---|---|---|
code | yes | CodeableConcept | The component CodeableConcept. |
valueType | yes | "coded" | FHIR Observation component value type: coded or text-only (component.valueCodeableConcept). |
CustomCodedSeries
Coded or text-only entries: categorical, ordinal or multi-select alike (each entry is one fact).
| field | required | type | meaning |
|---|---|---|---|
code | yes | CodeableConcept (restricted) | The Observation CodeableConcept. Not a built-in series code. An R4 vital-sign code makes the series a vital sign (category vital-signs); a code with its own R4 profile needs that profile's valueType and unit (VITAL_SIGN_PROFILES). |
valueType | yes | "coded" | FHIR Observation value type: coded or text-only (Observation.valueCodeableConcept). |
entries | yes | array of {date: DateTime, value: CodeableConcept} | Entries with FHIR CodeableConcept values (each one fact). Level order is not carried, so displays or text should state the rank ("3 of 5"). |
CustomComponentValue
One recorded component value inside a CustomComponentsEntry.
| field | required | type | meaning |
|---|---|---|---|
code | yes | CodeableConcept | The component CodeableConcept (must match one of series.components). |
value | yes | boolean | CodeableConcept | number -999999999.999999..999999999.999999 | The component's value: boolean, CodeableConcept, or decimal number matching the component's valueType. |
CustomComponentsEntry
One multi-component reading entry on a date or timestamp.
| field | required | type | meaning |
|---|---|---|---|
date | yes | DateTime | When the reading was taken: calendar date or date with time and UTC offset. |
components | yes | array (≤ 16) of CustomComponentValue | Recorded component values (1..16). Each code must match a declared component of the series, with no duplicate component code in one entry. |
CustomComponentsSeries
A reading of several components, written as one Observation with a component per recorded value and no top-level value (blood pressure: LOINC 85354-9 with 8480-6 and 8462-4 in mm[Hg]). Nothing here is specific to blood pressure: any code may have components.
| field | required | type | meaning |
|---|---|---|---|
code | yes | CodeableConcept (restricted) | The Observation CodeableConcept. Not a built-in series code. An R4 vital-sign code makes the series a vital sign (category vital-signs); 85354-9 must be a components series whose 8480-6 and 8462-4 components are quantities in mm[Hg]. |
valueType | yes | "components" | FHIR Observation value type: multi-component reading with no top-level value (Observation.component[]). |
components | yes | array (≤ 16) of (CustomBooleanComponent | CustomCodedComponent | CustomQuantityComponent) | The declared components, each with its own code and valueType. Codes differ. Canonical order is the concepts' canonical order; a component never recorded in any entry is dropped. |
entries | yes | array of CustomComponentsEntry | The readings, each carrying its date/time and at least one recorded component value. |
CustomQuantityComponent
A decimal quantity component in a UCUM unit (component.valueQuantity, at most 6 decimal places).
| field | required | type | meaning |
|---|---|---|---|
code | yes | CodeableConcept | The component CodeableConcept. |
valueType | yes | "quantity" | FHIR Observation component value type: decimal quantity in UCUM unit (component.valueQuantity). |
unit | yes | string (1–64 chars) | UCUM unit code (printable ASCII, no spaces). In a vital-sign series, one of the units the R4 vital-signs profile allows for components (UCUM_VITALS_COMMON). |
CustomQuantitySeries
Natural decimal quantity entries in a UCUM unit (at most 6 decimal places).
| field | required | type | meaning |
|---|---|---|---|
code | yes | CodeableConcept (restricted) | The Observation CodeableConcept. Not a built-in series code. An R4 vital-sign code makes the series a vital sign (category vital-signs); a code with its own R4 profile needs that profile's valueType and unit (VITAL_SIGN_PROFILES). |
valueType | yes | "quantity" | FHIR Observation value type: decimal quantity in UCUM unit (Observation.valueQuantity). |
unit | yes | string (1–64 chars) | UCUM unit code (printable ASCII, no spaces). |
entries | yes | array of {date: DateTime, value: number -999999999.999999..999999999.999999} | Entries with natural decimal numbers below 1,000,000,000 in magnitude and at most 6 decimal places. 0 is a value. |
MedDose
Exact positive decimal medication dose in a UCUM unit.
| field | required | type | meaning |
|---|---|---|---|
value | yes | number 0.000001..999999999.999999 | Strictly positive decimal dose below 1,000,000,000, with at most 6 decimal places (e.g. 400, 12.5). |
unit | yes | string (1–64 chars) | UCUM unit code (printable ASCII, no spaces, e.g. "mg", "ug", "mL", "[iU]"). |
MedEntry
One medication entry on a date or timestamp.
| field | required | type | meaning |
|---|---|---|---|
date | yes | DateTime | When the medication was taken (or missed): calendar date or date with time and UTC offset. |
code | yes | MedicationKind | CodeableConcept | The product: a built-in keyword (MedicationKind) or any FHIR CodeableConcept as an escape. |
status | yes | MedStatus | Whether it was taken. |
dose | MedDose, or null | Optional exact dose taken (maps to MedicationStatement.dosage[0].doseAndRate[0].doseQuantity). |
PatientInfo
Optional identity: deliberately small. An empty object means no identity.
| field | required | type | meaning |
|---|---|---|---|
family | string (1–64 chars), or null | Family name. Not recorded: absent. | |
given | array (≤ 3) of string (1–64 chars), or null | Given names, in order. Not recorded: absent or []. Each 1-64 characters. | |
birthDate | FhirDate, or null | Birth date, from 1900 to 2150. A year alone is enough to give age without identity. Not recorded: absent. |
Procedure
A completed procedure on a date or dateTime.
| field | required | type | meaning |
|---|---|---|---|
date | yes | FhirDateTime | When: YYYY, YYYY-MM, YYYY-MM-DD, or YYYY-MM-DDTHH:MM(:SS)?(Z|±HH:MM) (year 1900-2150). |
code | yes | ProcedureKind | CodeableConcept | Which procedure: a built-in keyword (ProcedureKind) or any FHIR CodeableConcept. |
SkinTemp
Wearable nightly temperature from one device.
| field | required | type | meaning |
|---|---|---|---|
kind | yes | SkinTempKind | Whether values are deviations from the device's baseline or absolute temperatures. |
unit | yes | TemperatureUnit | Unit of every value. For a deviation, a temperature difference in this unit. |
entries | yes | array of TempEntry | Readings by wake date, in natural degrees of unit (at most 2 decimal places, e.g. -0.31). Deviation: Cel -5..5, [degF] -9..9. Absolute: Cel 25..40, [degF] 77..104. |
Exactly one of: deviation in Cel (-5..5); deviation in [degF] (-9..9); absolute in Cel (25..40); absolute in [degF] (77..104).
Source
The exporting app, shown as the source device of every observation.
| field | required | type | meaning |
|---|---|---|---|
name | yes | string (1–64 chars) | The app's name as users know it, 1-64 characters. |
version | string (1–32 chars), or null | The app's version, 1-32 characters. Not recorded: absent. |
TempEntry
One temperature reading with date/time and optional disturbance/exclusion flag.
| field | required | type | meaning |
|---|---|---|---|
date | yes | DateTime | When the reading was taken: calendar date or date with time and UTC offset. |
value | yes | number | Temperature in natural degrees of the series unit, at most 2 decimal places (e.g. 36.52). |
excluded | boolean, or null | True when the user or app marked this reading disturbed/excluded from thermal-shift interpretation. | |
excludeReason | ExcludeReason | CodeableConcept, or null | Optional coded or text-only reason for exclusion (only allowed when excluded is true). |
Enumerations and built-in tables
Each built-in value is a short name for a concept. A coded field accepts the names below or, as an escape, any concept. The built-in tables of symptoms, medications and conditions are the concepts that are cheap to encode; any other concept is allowed in the same field.
Bleeding
Menstrual bleeding on one day: the legal combinations of bleeding and flow.
| value | meaning |
|---|---|
no-bleeding | Explicitly no bleeding. |
flow-none | Explicitly no bleeding, logged on a flow scale's "none" option. |
bleeding | Bleeding, amount not recorded. |
spotting | Bleeding, flow category spotting (also bleeding between periods with no amount). |
light | Bleeding, flow category light. |
moderate | Bleeding, flow category moderate (medium). |
heavy | Bleeding, flow category heavy. |
ConditionKind
Built-in condition keywords (SNOMED CT), pending clinical review: the main explanations of a bleeding pattern. Any other condition is passed as a FHIR CodeableConcept.
| value | meaning |
|---|---|
pcos | Polycystic ovary syndrome. (237055002) |
uterine-fibroids | Uterine leiomyoma (fibroids). (95315005) |
adenomyosis | Uterine adenomyosis. (784314006) |
endometrial-polyp | Endometrial polyp. (1237359009) |
endometriosis | Endometriosis. (129103003) |
von-willebrand-disorder | von Willebrand disorder. (128105004) |
coagulation-disorder | Blood coagulation disorder. (64779008) |
iron-deficiency-anemia | Iron deficiency anemia. (87522002) |
hypothyroidism | Hypothyroidism. (40930008) |
hyperthyroidism | Hyperthyroidism. (34486009) |
hyperprolactinemia | Hyperprolactinemia. (237662005) |
premature-ovarian-insufficiency | Premature ovarian insufficiency. (237788002) |
hypothalamic-amenorrhea | Hypothalamic amenorrhea. (237120002) |
perimenopause | Perimenopausal state. (161541000119104) |
postmenopause | Postmenopausal state. (76498008) |
ConditionStatus
A reported condition's status, as the person states it.
| value | meaning |
|---|---|
active | The person has it now. |
resolved | The person had it and it is over (explicit negative for now). |
Energy
Energy, 4 points (Clue).
| value | meaning |
|---|---|
exhausted | 1 of 4. |
low | 2 of 4. |
high | 3 of 4. |
energized | 4 of 4. |
ExcludeReason
Built-in disturbance/exclusion reason on a BBT or skinTemp reading.
| value | meaning |
|---|---|
fever | Fever or acute febrile illness. |
alcohol | Alcohol consumption the previous evening. |
poor-sleep | Poor, broken, or unusually short sleep. |
late-wake | Woke significantly later (or earlier) than usual. |
travel | Travel or time-zone shift. |
stress | Acute stress. |
medication | Medication affecting basal temperature. |
other | Other unspecified disturbance. |
IntervalKind
Built-in states over a range of days. Contraception values are LOINC answers to 8659-5.
| value | meaning |
|---|---|
none | Not using contraception (explicit negative). (http://loinc.org |
combined-pill | Combined oral contraceptive pill. (http://loinc.org |
progestin-pill | Progestin-only pill. (http://loinc.org |
patch | Contraceptive patch. (http://loinc.org |
ring | Vaginal ring. (http://loinc.org |
injection | Injectable contraceptive. (http://loinc.org |
implant | Contraceptive implant. (http://loinc.org |
hormonal-iud | Hormonal (progestin) IUD. (http://loinc.org |
copper-iud | Copper IUD. (http://loinc.org |
iud-unspecified | IUD, type not recorded. (http://loinc.org |
condom | Male condom. (http://loinc.org |
fertility-awareness | Fertility awareness-based method. (http://loinc.org |
lactational-amenorrhea | Lactational amenorrhea method. (http://loinc.org |
pregnant | Pregnant (LOINC 82810-3). (http://loinc.org |
breastfeeding | Breastfeeding (LOINC 63895-7). (http://loinc.org |
MedStatus
Whether a medication was taken on a day.
| value | meaning |
|---|---|
taken | Taken. |
not-taken | Explicitly not taken (a missed dose). |
MedicationKind
Built-in medication keywords (SNOMED CT medicinal products). Any other product (RxNorm, SNOMED CT, text-only, ...) is passed as a FHIR CodeableConcept.
| value | meaning |
|---|---|
ibuprofen | Ibuprofen-containing product. (38268001) |
naproxen | Naproxen-containing product. (11847009) |
acetaminophen | Acetaminophen-containing product. (90332006) |
mefenamic-acid | Mefenamic acid-containing product. (34364009) |
tranexamic-acid | Tranexamic acid-containing product. (109006003) |
iron | Iron-containing product. (30729008) |
folic-acid | Folic acid-containing product. (6247001) |
Mood
Mood valence, 7 points (Apple HealthKit State of Mind).
| value | meaning |
|---|---|
very-unpleasant | 1 of 7. |
unpleasant | 2 of 7. |
slightly-unpleasant | 3 of 7. |
neutral | 4 of 7, neither pleasant nor unpleasant. |
slightly-pleasant | 5 of 7. |
pleasant | 6 of 7. |
very-pleasant | 7 of 7. |
Mucus
Cervical mucus, as self-observed.
| value | meaning |
|---|---|
dry | No mucus; feels dry. |
sticky | Sticky, tacky or crumbly. |
creamy | Creamy, lotion-like. |
watery | Watery, wet. |
egg-white | Clear and stretchy, like raw egg white. |
OvulationTest
LH (ovulation) urine test result.
| value | meaning |
|---|---|
negative | No surge detected. |
lh-surge | LH surge detected (a positive test). |
estrogen-surge | Estrogen rise detected (high fertility on two-hormone tests). |
indeterminate | The result could not be read. |
PeriodsStopped
Answers to "periods-stopped".
| value | meaning |
|---|---|
yes-no-periods | Yes, no menstrual periods. (http://loinc.org |
yes-hormones | Yes, but has periods now due to female hormones. (http://loinc.org |
no | No. (http://loinc.org |
not-sure | Not sure. (http://loinc.org |
PillLog
Contraceptive pill log for one day.
| value | meaning |
|---|---|
taken | The pill was taken. |
missed | The pill was missed (explicit negative). |
ProcedureKind
Built-in procedures (SNOMED CT).
| value | meaning |
|---|---|
iud-insertion | Insertion of an intrauterine device. (65200003) |
iud-removal | Removal of an intrauterine device. (1263416007) |
implant-insertion | Insertion of a contraceptive implant. (169553002) |
implant-removal | Removal of a contraceptive implant. (301807007) |
emergency-contraception | Emergency contraception taken. (1372819003) |
hysterectomy | Hysterectomy: afterwards absent bleeding is not amenorrhea or menopause. (236886002) |
endometrial-ablation | Endometrial ablation: afterwards little or no bleeding is expected. (265060005) |
oophorectomy | Oophorectomy (one ovary or unspecified). (83152002) |
bilateral-oophorectomy | Bilateral oophorectomy: surgical menopause. (76876009) |
myomectomy | Myomectomy (fibroid removal). (42010004) |
d-and-c | Dilation and curettage. (11401008) |
polypectomy | Endometrial polypectomy. (236884004) |
uterine-artery-embolization | Uterine artery embolization. (312138002) |
Question
Screening questions (LOINC). A coded question's value is one of its answer names (or any CodeableConcept as an escape); a numeric question's value is an integer.
| value | meaning |
|---|---|
usual-cycle-length | Usual cycle length over the last year. Answer: UsualCycleLength. (http://loinc.org |
periods-per-year | Number of periods per year. Answer: integer 0-100 (unit /a). (http://loinc.org |
missed-periods-3-months | Periods missed over the past 3 months. Answer: integer 0-3. (http://loinc.org |
period-in-last-year | Had a period within the last year. Answer: YesNo. (http://loinc.org |
periods-stopped | Periods stopped permanently. Answer: PeriodsStopped. (http://loinc.org |
age-periods-stopped | Age in years when periods stopped. Answer: integer 0-100. (http://loinc.org |
age-at-menarche | Age in years at the first period. Answer: integer 0-100. (http://loinc.org |
Sex
Sexual intercourse on one day.
| value | meaning |
|---|---|
none | Explicitly no intercourse. |
protected | Intercourse with protection (e.g. a condom). |
unprotected | Intercourse without protection. |
unspecified | Intercourse, protection not recorded. |
SkinTempKind
What a wearable temperature value means.
| value | meaning |
|---|---|
deviation | Difference from the device's own baseline (Oura, Fitbit, Garmin); signed. |
absolute | Absolute nightly skin or wrist temperature (Apple Watch, Google, Whoop). |
SymptomKind
Built-in symptom keywords (SNOMED CT, plus hot-flash in cycle-log). The first 14 are the starter set of the Period Tracking guide the design started from. Any other symptom is passed as a FHIR CodeableConcept.
| value | meaning |
|---|---|
menstrual-cramp | Menstrual cramp. (431416001) |
backache | Backache. (161891005) |
headache | Headache. (25064002) |
migraine | Migraine. (37796009) |
stomach-ache | Stomach ache. (271681002) |
nausea | Nausea. (422587007) |
breast-tenderness | Breast tenderness. (55222007) |
ovulation-pain | Ovulation pain. (43548008) |
fatigue | Fatigue. (84229001) |
bloating | Abdominal bloating. (116289008) |
depressed-mood | Depressed mood. (366979004) |
irritable | Feeling irritable. (55929007) |
stress | Stress. (73595000) |
dyspareunia | Dyspareunia. (71315007) |
acne | Acne. (11381005) |
pelvic-pain | Pain in pelvis. (30473006) |
low-back-pain | Low back pain. (279039007) |
breast-pain | Pain of breast. (53430007) |
mood-swings | Mood swings. (18963009) |
anxiety | Anxiety. (48694002) |
diarrhea | Diarrhea. (62315008) |
constipation | Constipation. (14760008) |
dizziness | Dizziness. (404640003) |
food-craving | Craving for food or drink. (248132003) |
vaginal-clots | Passing clots vaginally. (289532003) |
hot-flash | Hot flash (cause not stated); a proposed code. (https://joshuamandel.com/shc2-poc/CodeSystem/cycle-log |
night-sweats | Night sweats. (42984000) |
insomnia | Insomnia. (193462001) |
vaginal-dryness | Vaginal dryness. (31908003) |
palpitations | Palpitations. (80313002) |
urinary-incontinence | Urinary incontinence. (165232002) |
memory-lapses | Memory lapses. (225038006) |
hair-loss | Alopecia (hair loss). (56317004) |
increased-libido | Increased libido. (58436003) |
reduced-libido | Reduced libido. (8357008) |
TemperatureUnit
Temperature unit (UCUM).
| value | meaning |
|---|---|
Cel | Degrees Celsius. |
[degF] | Degrees Fahrenheit. |
TestResult
A urine test result (progesterone or pregnancy).
| value | meaning |
|---|---|
negative | Negative. |
positive | Positive. |
indeterminate | The result could not be read. |
UsualCycleLength
Answers to "usual-cycle-length".
| value | meaning |
|---|---|
<21 | Less than 21 days. (http://loinc.org |
21-25 | 21-25 days. (http://loinc.org |
26-32 | 26-32 days. (http://loinc.org |
33-35 | 33-35 days. (http://loinc.org |
36-90 | 36-90 days. (http://loinc.org |
>90 | More than 90 days. (http://loinc.org |
too-variable | Too variable to say. (http://loinc.org |
dont-know | Don't know. (http://loinc.org |
YesNo
Answers to "period-in-last-year".
| value | meaning |
|---|---|
yes | Yes. (http://loinc.org |
no | No (explicit negative). (http://loinc.org |
3. Not recorded and explicit negatives
The card distinguishes three things for every day and every field:
| the person logged | write | example |
|---|---|---|
| nothing | null, [], or leave the field (or the end of the array) out | "pain": [null, 4]: no pain score on day 0 |
| a positive value | the value | "bleeding": ["heavy"] |
| an explicit "no" | the field's negative value | "bleeding": ["no-bleeding"], "pain": [0], "sex": ["none"], {"code": "38268001", "status": "not-taken"}, a custom boolean false, contraception interval kind "none", condition status "resolved", answer "no" |
- Absence is never a negative. A day with no bleeding entry is "not recorded", not "not bleeding". A viewer must not compute cycle lengths as if unlogged days were negatives.
- Symptoms have no negative. A symptom set lists what was present. "No symptoms today" has no representation; if an app records it explicitly, use a custom boolean series.
- Fields without a negative.
bbt,skinTemp,moodandenergyare measurements or ratings: there is nothing to negate.
4. Concepts and escapes
- Key.
- SNOMED CT is a bare id: 6–18 digits, Verhoeff check digit, concept partition.
"http://snomed.info/sct|…"is normalized to the bare id. - Every other system is
"<system>|<code>":- the system is an absolute URI of printable ASCII without spaces or
|, at most 255 characters; - the code follows FHIR
codesyntax, 1–128 characters, any Unicode except control characters and unpaired surrogates.
- the system is an absolute URI of printable ASCII without spaces or
- SNOMED CT is a bare id: 6–18 digits, Verhoeff check digit, concept partition.
- Well-known systems. These get small indices in a codec: SNOMED CT, LOINC, RxNorm, UCUM, cycle, cycle-log (the proposed concepts), ATC, ICD-10-CM, NDC. Any other system is spelled out once per card.
- Canonical spelling. A concept equal to a built-in level, interval pair or procedure is written as that built-in. For example,
https://joshuamandel.com/shc2-poc/CodeSystem/cycle-log|valence-neutralbecomes"neutral". - Order. Built-in table index first, then SNOMED CT numerically, then code-point order.
- Labels. At most 200 characters, at most 512 per card. Labels are allowed only on concepts in code systems outside the well-known terminologies, so never on built-ins, SNOMED CT, LOINC or RxNorm. Receivers look those displays up, and a label that differs from the official display fails validation. Unused labels are dropped by
normalize, with a warning. App code systems should not be under example.org: the HL7 validator rejects "example URLs" (MAPPING.md §6).
5. Custom series
| shape | model values | FHIR value[x] | limits |
|---|---|---|---|
boolean | true / false / null per day | valueBoolean | – |
coded | a set of concepts per day | valueCodeableConcept, one fact per concept | any number per day |
quantity | integer per day; unit (UCUM), scale | valueQuantity {value = v × 10^−scale, unit = code = unit} | |v / 10^scale| < 10^9; scale 0–6 (canonical: smallest exact); unit ≤ 64 chars |
components | per day a reading: one entry per declared component (boolean, concept or integer by the component's shape, null = that component not recorded), or null | no value; one component per recorded value | 1–16 components with different codes |
- A custom series'
codeis any concept except a built-in series code. - Readings with components. Blood pressure is the motivating case (85354-9 with systolic 8480-6 and diastolic 8462-4 in mm[Hg]), but any code may have components, each with the value shapes above (one value per reading, a coded component one concept).
- A day's reading is
null(nothing measured) or an array with one entry per component; an entry isnullwhen that component was not recorded. A reading whose entries are all null is the same asnulland is not written. - Components are kept in the canonical concept order (the Bundle carries no order), and a component recorded on no day is dropped.
- Each reading counts one fact per recorded component toward the 20,000-fact limit.
- A day's reading is
- Vital signs. A series whose code is an R4 vital-sign LOINC code (
R4_VITAL_SIGN_CODES, about 90) is written with the vital-signs category. A code with its own R4 profile must have that profile's shape (rulevital-sign-profile): heart rate 8867-4 and respiratory rate 9279-1 in/min, oxygen saturation 2708-6 in%, body height 8302-2 and head circumference 9843-4 incmor[in_i], body weight 29463-7 inkg,gor[lb_av], BMI 39156-5 inkg/m2, and blood pressure 85354-9 as a components series. MAPPING.md §1 says exactly which Bundles then conform to the R4 vital-signs profiles; in short, use each measurement's own profile code, and record both blood-pressure values. - Body temperature is BBT. LOINC 8310-5 "Body temperature" is the built-in
bbtseries: waking basal readings, written with the vital-signs category and conforming to R4 bodytemp. A custom series may not use 8310-5. Temperatures that are not basal readings (a fever log) go in a custom quantity series under a site-specific LOINC code such as 8331-1 "Oral temperature"; it is written as a vital sign, but the validator applies bodytemp, which expects the 8310-5 coding, so it does not conform to that profile. - At most 32 series, one per code. Each fact has the shape of every built-in fact (MAPPING.md §1).
- An event is a boolean series with only
true, or a coded series, or a custom procedure. - Ordinal scales. Levels are coded concepts. Their order is not carried, because FHIR has no element for it without a CodeSystem or an extension, so labels should state the rank ("3 of 5").
- Built-ins are cheaper spellings of the same thing. Pain and sleep are quantity series. Symptoms, mucus, the tests, sex, mood and energy are coded series. The pill log is a boolean series. Their facts are identical to the equivalent custom series apart from
Observation.code(tested). - Special built-ins. Bleeding/flow (two paired facts), BBT (category), the window, built-in intervals, and medications and procedures (MedicationStatement and Procedure resources, open to any concept).
6. Cross-field rules and what validate accepts
The JSON Schema is necessary, not sufficient. Any model validate accepts satisfies the schema, and the schema rejects most mistakes: wrong types, unknown fields, values outside an enumeration, integers out of range, strings too long, malformed concepts and dates, reserved codes in custom series, labels on built-in or well-known concepts. These rules involve more than one field, or a computation, and are checked only by validate / validateJson and the codec's encoder:
| rule | what to do |
|---|---|
date-span | Across all daily series, intervals and answers, recorded dates span at most 10,000 days from earliest to latest, and every interval has start ≤ end. |
calendar-date | Every full calendar date (DateTime, CalendarDate, FhirInstant, and full dates in FhirDate / FhirDateTime) is a real Gregorian date (no 2026-02-30; 29 February only in leap years). |
decimal-precision | Temperature readings (bbt, skinTemp) have at most 2 decimal places; medication doses and custom quantities have at most 6 decimal places. |
snomed-check-digit | A SNOMED CT Coding (system: "http://snomed.info/sct") has a 6-18 digit concept id passing the Verhoeff check digit with partition 00 or 10 (not a description or relationship id). |
no-unpaired-surrogates | Codes, displays, texts and names contain no unpaired UTF-16 surrogate (possible only through a \ud800-style escape in JSON text). |
display-consistency | For non-built-in coded concepts, every occurrence of the same (system, code) with a display must agree on the same display, and every occurrence with text must agree on the same text; text is not allowed on built-in concepts; at most 512 distinct escape labels (displays, coded texts, and text-only concepts) may appear on a card. |
unique-custom-code | Each custom series has a different code (distinct (system, code) or distinct text-only text). |
entries | A temperature entry's excludeReason is allowed only when excluded is true (identical entries, and entries that disagree, are all valid: each is its own fact). |
component-reading | A components series declares 1-16 components with distinct codes; each entry records at least one component with no duplicate code, matching a declared component and carrying a value of that component's valueType. A component code has one valueType, and as a quantity one unit, on the whole card. |
vital-sign-profile | A custom series whose code has its own R4 vital-signs profile has that profile's valueType and unit: 8310-5 in Cel or [degF], 8867-4 and 9279-1 in /min, 2708-6 in %, 8302-2 and 9843-4 in cm or [in_i], 29463-7 in kg, g or [lb_av], 39156-5 in kg/m2 (quantity series), and 85354-9 a components series whose 8480-6 and 8462-4 components are quantities in mm[Hg]; in any R4 vital-sign series a quantity component's unit is one of %, cm, [in_i], kg, g, [lb_av], Cel, [degF], mm[Hg], /min, kg/m2, m2. |
fact-limit | The model has at most 20,000 facts in all (a bound on encoder and decoder work, far above real use). |
number-spelling | In JSON text, integer fields (pain, volume, sleep, numeric answers) are spelled -?(0|[1-9][0-9]*); decimal fields are spelled -?(0|[1-9][0-9]*)(\.[0-9]{1,N})? (N = 2 for temperatures, N = 6 for doses and custom quantities); never -0, -0.0 or scientific notation. |
The tests check that every invalid case in the rejection table is either rejected by the schema or named here.
What validate accepts
validate(model) returns a list of problems for any input whatsoever. It never throws, and a fuzz test (3,000 random and mutated models) checks this. validateJson(text) additionally checks how numbers are spelled.
- Fields. Every object carries only the fields in the reference (§2); any other field is an error, so nothing is dropped silently. Every field except
startanddaysmay be absent ornull; an absent series means nothing recorded. - Numbers.
- Every number in the model is an integer within its field's range, and every range lies inside ±2⁵³.
- In JSON text a number must be spelled
-?(0|[1-9][0-9]*), and-0is not allowed.2.0,1e3,1e-400,0.5and-0are all rejected. validateJsonenforces the spelling on the text.validatesees only the parsed value. It rejects non-integers, unsafe integers,-0, NaN and ±Infinity, but cannot see the spelling of a value that parses to an integer (2.0→ 2,1e-400→ 0).- Encoders that read JSON text should apply the spelling rule, as the Rust encoder does.
- Non-canonical spellings are accepted and normalized, uniformly.
validateaccepts them andnormalizecanonicalizes them. An encoder must produce exactlynormalize(model). The accepted non-canonical forms are:http://snomed.info/sct|<id>for a valid SNOMED CT id, in every concept slot, normalized to the bare id;- a concept equal to a built-in level, interval pair, procedure or screening answer, normalized to its name or kind;
- a time of day with
:00seconds, normalized toHH:MM±HH:MM; a day in the entries form that the plain form can say (one untimed entry; a set's untimed, distinct items), written plain; a plain set day with a repeated item (the same concept twice, in any spelling), written in the entries form, one entry per occurrence; entries in any order, normalized to the canonical order; - any order of sets, conditions, intervals, procedures, answers, custom series and label keys;
- series shorter than
days(missing days are not recorded), andnullfor an empty per-day set; - a quantity series at a larger scale than needed, normalized to the smallest exact scale;
- an empty
patient(normalized tonull), unused labels (dropped, with a warning), custom series with no values and emptybbt/skinTemp(dropped). - Everything else must already be canonical. In particular,
-0is an error, not normalized.
- Dates are proleptic-Gregorian
YYYY-MM-DD, checked arithmetically for every year 0000–9999. For example,0099-01-01is a valid date and is reported as outside the window range. - Other limits. At most 20,000 facts (
fact-limitabove), and a card of at most 4,096 bytes, more than any QR code holds, which is the encoder's check. There is no limit on the size of the Bundle; tools warn when a card would be unusually costly to decode or its Bundle unusually large.
7. Published files
| file | what | where |
|---|---|---|
model.d.ts | the normative definition (TypeScript types with TSDoc) | https://joshuamandel.com/shc2-poc/codecs/cycle-log/model.d.ts |
model.schema.json | JSON Schema 2020-12, derived from model.d.ts | its $id, https://joshuamandel.com/shc2-poc/codecs/cycle-log/model.schema.json |
examples/<persona>.model.json | the sixteen personas of §12 as normalized models | examples/ beside the schema |
examples/minimal-teaching.model.json, .md | the hand-written teaching example and its explanation | examples/ |
How the three stay in agreement. model.d.ts holds every description and every enumeration's members and meanings. make-schema.ts reads it (a small reader for that one file) and takes field names, optionality, nullability, descriptions, examples and enumeration members from it. It takes limits, patterns, table order and reserved codes from the constants validate uses. Wherever the two meet it checks them, and any disagreement fails the build:
- every field in the types has a schema and the reverse;
- union members equal the vocab.ts arrays in order;
@minimum,@maximum,@maxLengthand@maxItemstags equal the schema's values;@codetags equal the built-in codes.
The tests regenerate the schema, the examples and the generated sections of this file and fail if any committed file differs. They also check that every persona, every random model and every fuzzed model that validate accepts satisfies the schema.
8. Context and devices
A reduced card (reduced). An exporter that left out data to fit a size sets reduced: true. Then a series, time of day, or label that is absent may have been tracked; recorded values are never altered, and the flag says nothing about which items were omitted. A viewer shows that the card is reduced. In the Bundle it is the R4 tag SUBSETTED (MAPPING.md §1). Not reduced is false (canonical), null or absent; a card without the flag asserts nothing about reduction beyond that. The flag is one bit, not a list of the steps taken.
Reported conditions.
- The 15 built-ins are the main explanations of a bleeding pattern: PALM-COEIN (Munro 2011/2018), endocrine causes, and menopausal status. Evidence for each is in
vocab.tsand EXPRESSIVENESS.md. - The table is pending clinical review.
- Any other condition is an escape.
statusandonsetare only what the person states.
Surgical history.
- Procedures before the window carry a year, a month, or a full date.
- After a hysterectomy or an endometrial ablation, absent bleeding is not amenorrhea and not menopause. A viewer suppresses amenorrhea and cycle-length inferences after the procedure's date.
- Ovarian signals (BBT, LH, skin temperature, cyclic symptoms) continue unless both ovaries were removed. After a bilateral oophorectomy the viewer shows surgical menopause.
- Age without identity is a
patient.birthDateyear alone.
Measured volume (volume).
- What a smart or graduated cup collects per day, in whole mL.
- It is menstrual fluid, not blood. The blood fraction varies widely: 36% on average but from 1.6% to 81.7% between people (Fraser 1985), and about half in heavy losses (Fraser 2001).
- So a measured fluid volume does not establish whether the classic heavy-menstrual-bleeding threshold of 80 mL of blood per period was exceeded.
- A day can have both a flow category and a volume. Neither implies the other, and a volume implies no Layer 0 fact.
Wearable skin temperature (skinTemp).
- One series per card:
deviation: Ouratemperature_deviation, FitbitnightlyRelative, Garmin. The difference from the device's own baseline.absolute: AppleappleSleepingWristTemperature, Google Health nightly temperature, Whoop.
- Attributed to the wake day.
- The unit is
Cel(or[degF]for a Fahrenheit device) in both cases. Fordeviationthe value is a temperature difference in that unit: −0.31 means 0.31 °C below baseline, and the Observation code says it is a deviation. This is the owner's choice over UCUM'sKfor differences. - It is never pooled with BBT.
Source (source). One Device per card, named by the source app (and version). Every Observation references it.
Several entries a day, and times of day. A day of a per-day series normally holds one value (a set series: a set of items), written as today: "pain": [3, null, 5]. When the source app recorded more than that, the day is written as entries instead: an array of {"value": …, "time": …} objects, one per entry (a set series: one per item occurrence), each with its own optional time of day.
- When. A day uses the entries form exactly when the plain form cannot say it: an entry has a time, a single-valued series has more than one entry, or an item of a set repeats. Otherwise it must be plain (
normalizewrites it so), so a set of facts has one spelling. - Times.
HH:MM±HH:MM, orHH:MM:SS±HH:MMwhen seconds were recorded (rare: a device sync). The local time the source app recorded, with its UTC offset; the day is the day the fact belongs to (sleep and skin temperature: the wake day). Optional per entry: a day may mix entries with and without a time. The offset may change from day to day (daylight saving time, travel) and within a day. - Order (canonical): entries without a time first, then by instant (local time minus offset), then by local time; ties by value (the series' value order: levels in table order, then concepts; numbers ascending).
- Repeats are separate facts, never merged. Any number of entries a day (the model's 20,000-fact limit is the only bound), each its own fact: two pain scores, morning and evening blood pressure, a symptom at 09:00 and another at 21:00. Entries are what was recorded: two identical entries (the same value, and the same time or both without one) are two facts, and entries that disagree are all carried as recorded: two different untimed blood-pressure readings, a medication taken and not-taken at one time, two pain scores at one time. Nothing is deduplicated, merged or refused for disagreeing; a reader that wants one value per day chooses its own rule.
- Bleeding is no exception: a day may hold any bleeding entries, timed or not, including states that disagree at one time ("light" and "heavy" at 09:00) or an untimed "no-bleeding" beside a timed "light". Each entry is its bleeding fact and, for a flow state, its flow fact (MAPPING.md §1); the states are recovered from those facts exactly, as a multiset per time.
- Not recorded and negatives keep their per-day meaning: an absent day or
nullis not recorded; "no-bleeding", pain 0, a medication "not-taken" are entries like any other. - Screening answers and procedures inside the window carry their own
time. The same question may be answered more than once on a day, even at one time and differently; a procedure listed twice is two procedures; a condition stated more than once (even with different statuses or onsets) is carried as stated. Intervals, conditions and the window have no time. - In the Bundle every entry is its own Observation (or MedicationStatement), and a timed one's
effectiveDateTimeisYYYY-MM-DDTHH:MM:SS±HH:MM(MAPPING.md §1).
| what was logged | model |
|---|---|
| one pain score, no time | "pain": [3] (unchanged) |
| two pain scores with times | "pain": [[{"value": 3, "time": "08:00-05:00"}, {"value": 6, "time": "20:30-05:00"}]] |
| headache at 09:00, cramps at 21:00 | "symptoms": [[{"value": "25064002", "time": "09:00-05:00"}, {"value": "431416001", "time": "21:00-05:00"}]] |
| blood pressure morning and evening | "values": [[{"value": [128, 84], "time": "07:10-05:00"}, {"value": [121, 79], "time": "21:40-05:00"}]] in the 85354-9 components series |
| BBT at 06:45 | "bbt": {"unit": "Cel", "values": [[{"value": 3652, "time": "06:45-05:00"}]]} |
| ibuprofen twice | "medications": [[{"value": {"code": "38268001", "status": "taken"}, "time": "08:00-05:00"}, {"value": {"code": "38268001", "status": "taken"}, "time": "20:00-05:00"}]] |
| two identical untimed pain scores | "pain": [[{"value": 3}, {"value": 3}]] (two facts) |
| blood pressure twice, no times | "values": [[{"value": [79, 121]}, {"value": [84, 128]}]] (components in code order: diastolic 8462-4, systolic 8480-6) |
| "light" and "heavy" both logged at 09:00 | "bleeding": [[{"value": "light", "time": "09:00-05:00"}, {"value": "heavy", "time": "09:00-05:00"}]] |
Screening answers (answers).
| question | LOINC | answer |
|---|---|---|
| usual cycle length last year | 64700-8 | <21, 21-25, 26-32, 33-35, 36-90, >90, too-variable, dont-know |
| periods per year | 92656-8 | 0–100, /a |
| periods missed in the last 3 months | 65930-0 | 0–3 |
| period in the last year | 63889-0 | yes, no |
| periods stopped permanently | 64701-6 | yes-no-periods, yes-hormones, no, not-sure |
| age when periods stopped | 64702-4 | 0–100, a |
| age at menarche | 63888-2 | 0–100, a |
- Each answer is what the person said, on the day they said it. The card carries no value computed from the log, so an answer cannot be mistaken for one.
- "Fewer than eight periods a year" is the PCOS guideline threshold (Teede 2023) applied to the periods-per-year answer. A viewer derives it; it is not a question.
9. Design decisions
| decision | why |
|---|---|
days 1..10,000 | Up to ~27 years; QR byte capacity is the natural bound rather than an arbitrary 1-year cap. |
bleeding: 7 values + null | Exactly the legal one-day combinations of the bleeding and flow facts (MAPPING.md §1). HealthKit unspecified → bleeding; intermenstrualBleeding → spotting. |
| symptoms and medications are sets of concepts from any system; the built-in tables only fix short codes and order | One representation for every source: tables are shortcuts, not limits. |
| BBT in integer hundredths of Cel or [degF]; the grid is implied by the values | Real thermometers read to 0.01 in both units (§10). A resolution field would not survive the Bundle round trip (JSON loses trailing zeros); a codec detects the grid. |
| any number of entries a day, each with an optional time of day with UTC offset; the plain per-day value stays the spelling of the common case | Apps log several pain scores, morning and evening readings, symptoms when they happen. One mechanism for times and repeats; a card with one untimed entry per series per day pays about half a bit for it (FORMAT.md §4.11, 4.12). The plain form keeps simple exporters simple; normalize allows exactly one spelling. |
| mood: 7-point valence; energy: 4-point; sleep in any whole minute | HealthKit and Clue scales. A coarser grid is the exporting app's choice and simply compresses better (coarsen, §13). |
| fertility signs: mucus, LH (4 values), PdG and pregnancy tests | HealthKit's value sets exactly. Other values (Flo "ClumpyWhite", Clue "atypical") are escapes. |
a per-day pill log (taken / missed) and an emergency-contraception procedure | The pill's identity is carried by the contraception interval covering the day: a viewer reads a pill fact together with the 8659-5 interval that contains its day. A pill log with no covering interval is allowed and means "a contraceptive pill, kind not recorded". |
an optional, deliberately small patient (name, birth date); a Patient is always resource:0 and every fact references it | Facts are linked to a patient. R4 bodytemp, MedicationStatement and Procedure need a subject. Without identity the Patient is {"resourceType":"Patient","id":"0"}, the least assertive valid Patient (MAPPING.md §1). |
| medications are MedicationStatements, procedures are Procedures | The FHIR resources made for them. |
| custom series, custom intervals and procedures, labels, escapes in every coded slot | Nothing short of a new kind of structure is unrepresentable (§5, EXPRESSIVENESS.md). |
| tracking window carried explicitly | Trailing unrecorded days would otherwise be lost, and the window tells a viewer where "not recorded" applies. |
| reported conditions with a 15-entry table | The main explanations of a bleeding pattern travel with it (§8). |
| procedures carry a date, with partial precision before the window | One list holds in-window events and prior surgical history (§8). |
| measured fluid volume as its own series | The only calibrated amount; flow categories are uncalibrated (§8). |
| wearable skin temperature as its own series, deviation or absolute | What Oura, Fitbit, Apple Watch and others actually provide; not BBT (§8). |
| one Device for the source app | Names where the data came from (§8). |
| seven screening answers with their LOINC questions | What a person says about their cycles, kept apart from anything computed (§8). |
10. Evidence for the built-ins
- Apple HealthKit (developer.apple.com/documentation/healthkit, fetched 2026-12-03):
menstrualFlow: unspecified / none / light / medium / heavy;intermenstrualBleeding;cervicalMucusQuality: dry / sticky / creamy / watery / eggWhite;ovulationTestResult: negative / LH surge / estrogen surge / indeterminate;pregnancyTestResult,progesteroneTestResult;sexualActivitywithProtectionUsed;contraceptive,pregnancy,lactation,basalBodyTemperature;- 40 symptom types;
HKStateOfMind, 7-value valence.
- Clue. Li et al. 2020 (npj Digit Med, Table 3); the
measurements.jsonexport format comes from open-source converters (EXPRESSIVENESS.md §2.2). - Flo. PMC7927251, PMC10956037, and a real export (EXPRESSIVENESS.md §2.3).
- Natural Cycles. Help centre;
Daily Entries.csv(EXPRESSIVENESS.md §2.4). - drip.
src/db/schemas/4.js. - Fitbit and Samsung exports (EXPRESSIVENESS.md §2.5).
Clinical relevance:
- bleeding, flow, clots and pain give the FIGO AUB System 1 parameters;
- BBT, LH, PdG and mucus confirm ovulation and luteal length;
- pregnancy and breastfeeding explain amenorrhea;
- contraception and procedures explain bleeding patterns;
- analgesics, tranexamic acid and iron show treatment burden;
- vasomotor and sleep symptoms matter for perimenopause;
- mood matters for PMS/PMDD.
The wellbeing resolutions are:
- Mood: HealthKit's 7-point valence. Tag-style moods (Clue, Flo, drip) are custom coded sets.
- Energy: Clue's four levels.
- Sleep: minutes. Wearable total-sleep 95% limits of agreement against polysomnography span about ±60–130 min (Schyvens et al. 2025, SLEEP Advances 6(2):zpaf021), so coarsening to 15–30 minutes loses nothing real.
11. Excluded on principle
These are excluded on principle, not for lack of a slot; the full list with handling advice is EXPRESSIVENESS.md §3:
- free text;
- sub-daily streams;
- predictions and derived flags;
- per-fact attributes (an "excluded" BBT, a device per reading);
- values outside a built-in code's definition (pain beyond 0–10, flow beyond the five levels) — use a custom series with its own code instead;
- the order of ordinal levels;
- identifiers, address, contact and gender (only name and birth date are carried), and more than one source device.
Things that only lack a built-in slot are expressible as a custom series or escape: for example symptom severity, multi-select emotions, other energy and mood scales, cervix position, sleep stages, libido scales, app tags and RxNorm medications.
12. Samples
generate({persona, seed?, start?, days?}) is deterministic: mulberry32, no clock. SAMPLES holds the sixteen personas, and golden.json pins them.
12.1 Physiology engine and sources
- Cycles. Each cycle is follicular + luteal. The luteal phase is about 13 ± 1.2 d and the follicular phase carries the variability. Sources: Bull et al. 2019 (612,613 cycles: 29.3 ± 5.2 d; follicular 16.9 ± 5.3; luteal 12.4 ± 2.4; per-user SD 2.6 d; bleed 4.0 ± 1.5 d) and Fehring 2006.
- LH. Positive the day before ovulation, with estrogen-rise results 2–4 days earlier (Su et al. 2017; Ecochard 2001).
- BBT. A rise of 0.32–0.38 °C over days +1..+3, with noise SD 0.06–0.09 °C, 4% disturbed mornings, a premenstrual drop, and a persistent rise in pregnancy. Sources: Barron & Fehring via Fukaya 2017; Natural Cycles 0.2–0.45 °C; Prior 2024. Measured on the power tracker, the rise is 0.34–0.46 °C.
- Mucus. Progresses to egg-white on ovulation −1/0 (Billings/WHO 1978; Fehring).
- Symptoms. Phase-linked, with a shared "bad day" factor (Apple Women's Health Study; Pierson et al. 2021).
- Adherence. Skipped days, paused and abandoned categories, categories started mid-year, and an unlogged period that produces the spurious 60-day cycle Li et al. 2020 had to exclude.
12.2 Personas (all synthetic)
| sample | window | story |
|---|---|---|
(a) power-tracker | 2025-12-01, 365 d | Fertility awareness, then trying to conceive; conceives in month 11. BBT 0.01 °C, LH with estrogen results, mucus, PdG, pregnancy tests, wearable sleep, mood, energy, ibuprofen, folic acid, one SNOMED escape symptom. Source app. |
(b) copper-iud | 2025-12-08, 365 d | The case the design started from, extended to a year. IUD inserted 2026-03-18 (procedure + interval, condoms before). Heavier, longer, more painful periods that improve. Intermenstrual spotting that does not fade (Hubacher 2009). BBT for three cycles at 06:45 −05:00. |
(c) pcos | 2025-10-15, 400 d | Cycles of 34–88 d, mostly anovulatory. Monophasic BBT in °F. LH strips positive without ovulation. Negative pregnancy tests. Hirsutism and metformin as escapes. One condom failure followed by emergency contraception. Reported PCOS (onset 2019); answers: 5 periods a year, usual cycle 36–90 days. |
(d) minimal | 2026-01-01, 365 d | Layer 0 only, with gaps; one period unlogged. |
(e) perimenopause | 2025-11-20, 365 d | STRAW+10 late transition (cycles 20–66 d). Hot flashes and night sweats rising (SWAN). Insomnia, clots, tranexamic acid, iron. Reported perimenopausal state. |
(f) combined-pill | 2026-01-05, 364 d | Combined pill all year. pill log with 4 missed pills and breakthrough spotting. Withdrawal bleeds starting on pill-free day 3–5. |
(g) near-empty | 2026-01-01, 365 d | Breastfeeding, lactational amenorrhea, one 3-day bleed logged. |
(h) own-vocabulary | 2026-02-01, 365 d | Outside the built-ins throughout: 5-level energy and an 8-option emotion multi-select (custom coded, app codes with labels); per-symptom severity for cramps and headache (custom coded, SNOMED Mild / Moderate / Severe); cervix position; wrist-temperature deviation (the built-in skinTemp); RxNorm ibuprofen 400 mg and naproxen sodium 220 mg; SNOMED and app-local symptoms ("Brain fog"); a sex escape value ("Solo sex"); a diaphragm (custom contraception interval); minute-precision sleep. |
(i) wellness-diary | 2026-01-10, 365 d | The same card used mostly for something else: a migraine and wellness diary with migraine yes/no every day (custom boolean, SNOMED 37796009 as code), trigger multi-select, caffeine (mg), steps (LOINC 41950-7), resting heart rate (app code, because LOINC 40443-4 triggers the R4 heart-rate profile), the built-in pain score on attack days, sleep, RxNorm sumatriptan with daily magnesium and riboflavin (explicit missed doses), and only 31 Layer 0 bleeding facts. |
(j) calendar-only | 2026-01-01, 365 d | Built by import-ics.ts from calendar-sample.ts (a Google Calendar-style export): 58 bleeding days, spotting, a "Period due?" reminder skipped, no explicit negatives, nothing logged from mid-June to late August. Answers: usual cycle 26–32 days, 12 periods a year. Birth year only. |
(k) smart-cup-hmb | 2026-01-15, 365 d | Heavy menstrual bleeding measured with a smart cup: 126–244 mL of fluid per period (about 60–120 mL blood) before a myomectomy on day 196, 59–87 mL after. Clots, fatigue, pain; reported fibroids (2023) and iron-deficiency anaemia; tranexamic acid on heavy days; daily iron with missed doses. |
(l) wearable | 2026-03-01, 365 d | A ring: nightly skin temperature deviation (biphasic, about +0.33 °C luteal), minute-precision sleep; light manual logging (bleeding without flow, occasional cramps). Ovulation visible without BBT. |
(m) post-ablation | 2026-02-01, 365 d | Endometrial ablation 2023-05 (before the window), ovaries intact: almost no bleeding (4 spotting days, explicit no-bleeding days), but biphasic BBT and cyclic breast tenderness, bloating and mood continue. Adenomyosis resolved; answers: 0 periods a year, no period in the last year. Absent bleeding is not menopause. |
(n) vitals-follow-up | 2026-01-20, 365 d | Hypertension follow-up while tracking cycles: blood pressure (85354-9, systolic and diastolic components in mm[Hg]) on about half the days, falling from about 146/94 to 130/84 as treatment takes effect; resting heart rate (8867-4) most mornings, a little higher in the luteal phase; weight (29463-7, 0.1 kg) on Mondays; daily lisinopril (RxNorm) with occasional misses; essential hypertension reported (onset 2025-09); ordinary bleeding with cramps; source app. |
(o) timestamped | 2026-01-12, 365 d | An app that timestamps every entry (held out; designed after the time and entry coding, which were tuned on synthetic data added to power-tracker). New York offsets (−05:00, −04:00 from 8 March to 31 October) and ten days in Lisbon (+01:00) in June. BBT on waking (about 06:25 on weekdays, 08:00 at weekends), LH tests in the afternoon, mood and energy at an evening check-in, bleeding whenever the app was opened (on the first day of most periods, spotting in the morning and the flow in the evening). Symptoms at the time each was noticed: cramps in the morning and again in the evening on heavy days, a headache in the afternoon, the rest at the check-in. Pain in the morning and at the check-in in the first days of a period; ibuprofen once or twice on those days. A pregnancy test synced with seconds; two onboarding answers and the removal of a hormonal IUD (day 17) with their times. |
(p) bp-twice-daily | 2026-02-02, 365 d | Home blood pressure morning and evening (held out; a variant of (n)). A reading at about 07:10 on most days and another at about 21:30 on three quarters of those, a little lower; resting heart rate with the morning reading; a daily antihypertensive at about 07:25 with occasional misses; Pacific offsets with daylight saving time; ordinary bleeding with cramps; essential hypertension reported. |
13. Measurements
From bun report.ts. The QR version is what one codec-reference byte plus the estimated payload needs with the dense-qr digit transport (src/transport.ts toQr); "–" means it does not fit version 40.
| sample | entries | JSON B | deflate-raw B | entropy estimate B | of which declarations B | of which identity B | QR L / M |
|---|---|---|---|---|---|---|---|
| power-tracker | 2,842 | 1,175,890 | 31,855 | 1,264 | 6 | 0 | 26 / 30 |
| copper-iud (named) | 695 | 258,998 | 7,615 | 341 | 1 | 14 | 12 / 14 |
| pcos | 495 | 165,991 | 5,787 | 284 | 10 | 0 | 11 / 13 |
| minimal | 62 | 19,804 | 806 | 35 | 1 | 0 | 3 / 4 |
| perimenopause | 1,435 | 500,716 | 14,575 | 679 | 6 | 0 | 18 / 21 |
| combined-pill | 631 | 217,346 | 6,499 | 243 | 1 | 0 | 10 / 12 |
| near-empty | 10 | 3,391 | 493 | 20 | 1 | 0 | 2 / 3 |
| own-vocabulary (named) | 2,226 | 850,452 | 25,844 | 1,944 | 591 | 25 | 33 / 37 |
| wellness-diary | 2,417 | 763,101 | 27,713 | 2,499 | 366 | 0 | 37 / – |
| calendar-only | 73 | 27,675 | 1,215 | 63 | 1 | 3 | 4 / 5 |
| smart-cup-hmb | 820 | 285,961 | 8,430 | 339 | 1 | 0 | 12 / 14 |
| wearable | 745 | 282,794 | 8,081 | 709 | 1 | 0 | 19 / 22 |
| post-ablation | 617 | 263,981 | 7,581 | 473 | 1 | 3 | 15 / 17 |
| vitals-follow-up | 1,046 | 487,189 | 14,356 | 765 | 75 | 0 | 19 / 23 |
| timestamped | 1,286 | 585,575 | 19,903 | 2,400 | 1 | 0 | 37 / – |
| bp-twice-daily | 1,324 | 730,219 | 22,023 | 2,946 | 62 | 0 | – / – |
| power-tracker coarsened: sleep 30 min, mood 5-pt, BBT 0.05 | 1,110 | 6 | 0 | 24 / 28 | |||
| power-tracker coarsened: sleep 60 min, mood 3-pt, BBT 0.1 | 1,017 | 6 | 0 | 23 / 26 | |||
| power-tracker coarsened: sleep 60 min, mood 3-pt, BBT unchanged | 1,160 | 6 | 0 | 25 / 28 | |||
| wearable coarsened: skin temperature 0.05 | 602 | 1 | 0 | 17 / 19 | |||
| wearable coarsened: skin temperature 0.1, sleep 15 min | 370 | 1 | 0 | 13 / 15 |
Identity is estimated as a presence bit, the names as length-prefixed UTF-8, and the birth date as 18 bits (day since 1900 plus precision). An identity-free card spends 1 bit on it.
coarsen maps mood 7→5 points as {1, 2, 2, 4, 6, 6, 7} and 7→3 points as {2, 2, 2, 4, 6, 6, 6}. Sleep, BBT, skin temperature (0.05 / 0.1) and volume (5 / 10 mL) are rounded to the nearest step, ties up. Energy is unchanged.
13.1 The entropy estimate
This is an estimate, not a bound. Each category is coded on its own, day by day, with an adaptive Krichevsky–Trofimov (add-½) estimator, using the cheaper of order 0 and order 1 (context = the previous day's value). That is what an adaptive arithmetic coder achieves, learning cost included.
- Numeric series (BBT, skin temperature, volume, sleep, custom quantities, and each quantity component of a reading over the days it was recorded) are coded on their gcd grid, as the cheaper of direct values and day-to-day deltas. A reading with components adds its presence per day and each component's presence per reading.
- The header is the window and one bit for the reduced flag.
- Context (source name and version as UTF-8; conditions as table index, status, onset; answers; procedure dates as a day offset inside the window or year/month/day before it) at fixed-width cost.
- Further entries: per series with repeats, the count per day (KT over 0..3) and about a byte per entry.
- Times of day: a flag; per timed series one shared time (minutes and offset, 20 bits), or the has-time flags (KT), the minutes as a numeric series, the seconds when any and the offset changes; each timed answer or procedure 18 bits.
- Declarations cover each escape concept once (SNOMED and digit codes as numbers; each unknown system URI once; text codes as UTF-8), labels, and custom-series headers.
- Not exploited: the cycle structure across categories. A cycle-aware codec should land below these numbers.
Per-category bytes are in bun report.ts. For the power tracker:
| category | bytes |
|---|---|
| BBT | 276 |
| symptoms | 205 |
| sleep | 183 |
| source app name | 29 |
| mood | 110 |
| energy | 93 |
| mucus | 82 |
| pain | 64 |
| bleeding | 62 |
| sex | 46 |
| ovulation test | 40 |
| medications | 32 |
| everything else | < 30 |
What this means.
- Years of the core cycle facts alone need 20–330 B (QR versions 2–14).
- The power tracker needs about 1.2 KB (version 25-L). Half of that is irreducible daily numbers: BBT noise at 0.01 resolution, sleep, mood and energy. Coarsening saves at most about 20%.
- Leaving the built-ins costs a fixed declaration overhead (EXPRESSIVENESS.md §4): 659 B for (h), mostly labels and app codes. Rich daily wearable numbers are the other large cost: (i)'s steps and resting heart rate.
- Neither (h) nor (i) fits a small QR. Both are representable and round-trip losslessly.
- The context features are cheap: a calendar-only year with two answers is ~56 B (QR 4-L), a smart-cup year ~332 B. Conditions cost about 2 B each, an answer 1.5 B. The source app's name (about 1 B per character) is the largest of them.
- Nightly wearable temperature is as costly as BBT: about 290 B a year at 0.01 °C, 180 B at 0.05 and 130 B at 0.1.
14. Notes for the codec author
- Encode exactly
normalize(m). Decoding must givestringify(toBundle(m))byte for byte;golden.jsonpins every sample. - Indices of the tables and enumerations in
vocab.tsare the codes. The lists are append-only once shipped. The tables areBLEEDING,MUCUS,OVULATION_TEST,TEST_RESULT,SEX,MOOD,ENERGY,PILL_LOG,MED_STATUS,INTERVAL_KIND,PROCEDURE,CONDITION_STATUS,SKIN_TEMP_KIND,QUESTIONS(key order, and each coded question's answer order),BUILTIN_SYMPTOMS,BUILTIN_MEDICATIONS,BUILTIN_CONDITIONSandWELL_KNOWN_SYSTEMS. - Ranges:
patient: family 1–64 chars, given ≤ 3 × 1–64 chars, birthDate YYYY / YYYY-MM / YYYY-MM-DD from 1900 to the window start;days1..10,000; start 2000-01-01..2099-12-31;- pain 0–10; sleep 0–1440;
- BBT hundredths: Cel 3400–4200, [degF] 9300–10760;
- skin temperature hundredths: deviation Cel −500..500, [degF] −900..900; absolute Cel 2500–4000, [degF] 7700–10400;
- volume 0–500 mL; answers per
QUESTIONS(periods per year and ages 0–100, missed periods 0–3); source.name1–64 andsource.version1–32 characters (label character rules);- condition onsets and procedure dates before the window: YYYY, YYYY-MM or YYYY-MM-DD from 1900; procedure dates inside the window: full dates; nothing after the window;
- quantities: |v / 10^scale| < 10^9 with scale 0–6 (so |v| < 10^15, 15 significant digits);
- a component code has one shape, and as a quantity one unit, on the whole card;
- times of day: hours 00–23, minutes and seconds 00–59, offset ±00:00..±14:00 in quarter hours, never −00:00;
- entries: any number per series per day, identical or disagreeing (each its own fact); a reading entry records at least one component;
- concepts and labels per §4; custom series ≤ 32; intervals ≤ 256; procedures ≤ 512; facts ≤ 20,000 (a bound on work, not on Bundle size).
- Canonical order: MAPPING.md §3. Note the code-point order for non-SNOMED keys and the 100 × series index sub-rank for custom facts.
- Repeats: never deduplicate or merge. Identical entries, a set item that repeats, a condition or procedure listed twice and a question answered twice are each a fact, kept in canonical order with their ties broken by value (conditions: code, then status — none, active, resolved — then onset, unstated first; answers: day, question, time, then value: coded answers in the question's answer order with escapes after, numbers ascending).
- Serialization: MAPPING.md §2.
- The six fixed displays are mandatory.
- Labels become
displayon every coding of the concept. - Every fact carries
subject: {"reference":"resource:0"}; with a source, every Observation also carriesdevice: {"reference":"resource:1"}. - The Patient is
{"resourceType":"Patient","id":"0"}without identity; otherwise it hasnameand/orbirthDateand no id. - Numbers are printed from integers, with no trailing zeros.
- Strings get JSON escaping of
"and\, and are otherwise raw UTF-8.
- Decimals: a custom quantity prints v / 10^scale in shortest form. With |v| < 10^15 and scale ≤ 6 (at most 15 significant digits) this equals the plain decimal literal.
- Validation messages:
validate()reports the field path and, for per-day data, the day and date ("... (day 57, 2026-03-03)"). Encoders should surface them. The accepted set (§6) is the contract an encoder must match exactly.