{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://joshuamandel.com/shc2-poc/codecs/cycle-log/model.schema.json",
  "title": "cycle-log model",
  "description": "The input of the cycle-log codec: consumer menstrual-cycle tracking as uniform dated arrays with readable built-in keywords, FHIR R4 CodeableConcept escapes, and FHIR dateTime, as JSON. Derived from the TypeScript types in model.d.ts (https://joshuamandel.com/shc2-poc/codecs/cycle-log/model.d.ts), which are the normative definition; where this schema and the types or validate() in model.ts differ, the types and validate() win.\nThis schema is necessary, not sufficient. A model that validate() accepts always satisfies it, but these cross-field rules are checked only by validate() / validateJson() and the codec's encoder:\n- 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`.\n- 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).\n- decimal-precision: Temperature readings (`bbt`, `skinTemp`) have at most 2 decimal places; medication doses and custom quantities have at most 6 decimal places.\n- 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).\n- no-unpaired-surrogates: Codes, displays, texts and names contain no unpaired UTF-16 surrogate (possible only through a `\\ud800`-style escape in JSON text).\n- 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.\n- unique-custom-code: Each custom series has a different `code` (distinct `(system, code)` or distinct text-only `text`).\n- 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).\n- 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.\n- 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.\n- fact-limit: The model has at most 20,000 facts in all (a bound on encoder and decoder work, far above real use).\n- 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.\nOrder inside arrays is free, and non-canonical spellings (a CodeableConcept equal to a built-in keyword, Z offset, ':00' seconds, display on a built-in concept) are accepted: the encoder normalizes.\nPatterns are ECMA-262 regular expressions with Unicode (u flag) semantics.",
  "type": "object",
  "properties": {
    "patient": {
      "title": "Who the card is about, kept deliberately small",
      "description": "Who the card is about, kept deliberately small. Not recorded: absent or empty; the card then carries no identity at all.",
      "anyOf": [
        {
          "$ref": "#/$defs/PatientInfo"
        },
        {
          "type": "null"
        }
      ]
    },
    "source": {
      "title": "The source app: its name and optional version",
      "description": "The source app: its name and optional version. Not recorded: absent.",
      "anyOf": [
        {
          "$ref": "#/$defs/Source"
        },
        {
          "type": "null"
        }
      ]
    },
    "exportedAt": {
      "title": "When the card was exported, as a FHIR instant with UTC offset (mapped to FHIR `Bundle.timestamp`)",
      "description": "When the card was exported, as a FHIR instant with UTC offset (mapped to FHIR `Bundle.timestamp`). Not recorded: absent.",
      "anyOf": [
        {
          "$ref": "#/$defs/FhirInstant"
        },
        {
          "type": "null"
        }
      ]
    },
    "reduced": {
      "title": "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",
      "description": "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.",
      "type": [
        "boolean",
        "null"
      ]
    },
    "conditions": {
      "title": "Conditions the person reports having (background context such as PCOS or fibroids)",
      "description": "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.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/ConditionEntry"
      }
    },
    "bleeding": {
      "title": "Menstrual bleeding entries",
      "description": "Menstrual bleeding entries. Omitted dates: not recorded. Explicit negative: \"no-bleeding\" (or \"flow-none\").",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "$ref": "#/$defs/Bleeding"
          }
        }
      }
    },
    "volume": {
      "title": "Collected menstrual fluid entries, whole mL (a smart or graduated cup)",
      "description": "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.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "type": "integer",
            "minimum": 0,
            "maximum": 500
          }
        }
      }
    },
    "pain": {
      "title": "Pain entries on a 0-10 numeric rating scale (LOINC 72514-3)",
      "description": "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.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "type": "integer",
            "minimum": 0,
            "maximum": 10
          }
        }
      }
    },
    "symptoms": {
      "title": "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)",
      "description": "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\".",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "anyOf": [
              {
                "$ref": "#/$defs/SymptomKind"
              },
              {
                "$ref": "#/$defs/CodeableConcept"
              }
            ]
          }
        }
      }
    },
    "bbt": {
      "title": "Basal body temperature (waking readings)",
      "description": "Basal body temperature (waking readings). Not recorded: absent.",
      "anyOf": [
        {
          "$ref": "#/$defs/Bbt"
        },
        {
          "type": "null"
        }
      ]
    },
    "skinTemp": {
      "title": "Nightly skin or wrist temperature from a wearable (one device per card)",
      "description": "Nightly skin or wrist temperature from a wearable (one device per card). Never pooled with BBT. Not recorded: absent.",
      "anyOf": [
        {
          "$ref": "#/$defs/SkinTemp"
        },
        {
          "type": "null"
        }
      ]
    },
    "mucus": {
      "title": "Cervical mucus entries",
      "description": "Cervical mucus entries. Omitted dates: not recorded. \"dry\" is a value.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "anyOf": [
              {
                "$ref": "#/$defs/Mucus"
              },
              {
                "$ref": "#/$defs/CodeableConcept"
              }
            ]
          }
        }
      }
    },
    "ovulationTest": {
      "title": "LH (ovulation) test result entries",
      "description": "LH (ovulation) test result entries. Omitted dates: not recorded. Explicit negative: \"negative\".",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "anyOf": [
              {
                "$ref": "#/$defs/OvulationTest"
              },
              {
                "$ref": "#/$defs/CodeableConcept"
              }
            ]
          }
        }
      }
    },
    "progesteroneTest": {
      "title": "Progesterone (PdG) urine test result entries",
      "description": "Progesterone (PdG) urine test result entries. Omitted dates: not recorded. Explicit negative: \"negative\".",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "anyOf": [
              {
                "$ref": "#/$defs/TestResult"
              },
              {
                "$ref": "#/$defs/CodeableConcept"
              }
            ]
          }
        }
      }
    },
    "pregnancyTest": {
      "title": "Pregnancy test result entries",
      "description": "Pregnancy test result entries. Omitted dates: not recorded. Explicit negative: \"negative\".",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "anyOf": [
              {
                "$ref": "#/$defs/TestResult"
              },
              {
                "$ref": "#/$defs/CodeableConcept"
              }
            ]
          }
        }
      }
    },
    "sex": {
      "title": "Sexual intercourse entries",
      "description": "Sexual intercourse entries. Omitted dates: not recorded. Explicit negative: \"none\".",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "anyOf": [
              {
                "$ref": "#/$defs/Sex"
              },
              {
                "$ref": "#/$defs/CodeableConcept"
              }
            ]
          }
        }
      }
    },
    "mood": {
      "title": "Mood entries on a 7-point valence scale",
      "description": "Mood entries on a 7-point valence scale. Omitted dates: not recorded. Other mood scales or multi-select moods go in a custom series.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "anyOf": [
              {
                "$ref": "#/$defs/Mood"
              },
              {
                "$ref": "#/$defs/CodeableConcept"
              }
            ]
          }
        }
      }
    },
    "energy": {
      "title": "Energy entries on a 4-point scale",
      "description": "Energy entries on a 4-point scale. Omitted dates: not recorded.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "anyOf": [
              {
                "$ref": "#/$defs/Energy"
              },
              {
                "$ref": "#/$defs/CodeableConcept"
              }
            ]
          }
        }
      }
    },
    "sleep": {
      "title": "Minutes of sleep ending on each date (attributed to the wake day)",
      "description": "Minutes of sleep ending on each date (attributed to the wake day). Omitted dates: not recorded. 0 is a value (no sleep).",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "type": "integer",
            "minimum": 0,
            "maximum": 1440
          }
        }
      }
    },
    "pill": {
      "title": "Contraceptive pill log entries",
      "description": "Contraceptive pill log entries. Which pill is named by the contraception interval covering the date. Omitted dates: not recorded. Explicit negative: \"missed\".",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "title": "ObservationEntry",
        "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
        "type": "object",
        "required": [
          "date",
          "value"
        ],
        "additionalProperties": false,
        "properties": {
          "date": {
            "title": "When the observation was recorded: calendar date or date with time and UTC offset",
            "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
            "$ref": "#/$defs/DateTime"
          },
          "value": {
            "title": "The recorded value",
            "description": "The recorded value.",
            "$ref": "#/$defs/PillLog"
          }
        }
      }
    },
    "medications": {
      "title": "Medication entries (a dose taken twice is two entries with their timestamps)",
      "description": "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).",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/MedEntry"
      }
    },
    "intervals": {
      "title": "States that last over a range of calendar dates: contraception, pregnancy, breastfeeding, or any other coded or text-only state",
      "description": "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.",
      "type": [
        "array",
        "null"
      ],
      "maxItems": 256,
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/BuiltinInterval"
          },
          {
            "$ref": "#/$defs/CodedInterval"
          }
        ]
      }
    },
    "procedures": {
      "title": "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",
      "description": "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.",
      "type": [
        "array",
        "null"
      ],
      "maxItems": 512,
      "items": {
        "$ref": "#/$defs/Procedure"
      }
    },
    "answers": {
      "title": "Screening questions the person answered, each with the date (and optional time) they answered it",
      "description": "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.",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/Answer"
      }
    },
    "custom": {
      "title": "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)",
      "description": "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`.",
      "type": [
        "array",
        "null"
      ],
      "maxItems": 32,
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/CustomBooleanSeries"
          },
          {
            "$ref": "#/$defs/CustomCodedSeries"
          },
          {
            "$ref": "#/$defs/CustomQuantitySeries"
          },
          {
            "$ref": "#/$defs/CustomComponentsSeries"
          }
        ]
      }
    }
  },
  "required": [],
  "additionalProperties": false,
  "$defs": {
    "Answer": {
      "title": "A screening question answered on a date or timestamp",
      "description": "A screening question answered on a date or timestamp.",
      "type": "object",
      "oneOf": [
        {
          "title": "usual-cycle-length",
          "properties": {
            "question": {
              "const": "usual-cycle-length"
            },
            "value": {
              "anyOf": [
                {
                  "$ref": "#/$defs/UsualCycleLength"
                },
                {
                  "$ref": "#/$defs/CodeableConcept"
                }
              ]
            }
          }
        },
        {
          "title": "periods-per-year",
          "properties": {
            "question": {
              "const": "periods-per-year"
            },
            "value": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          }
        },
        {
          "title": "missed-periods-3-months",
          "properties": {
            "question": {
              "const": "missed-periods-3-months"
            },
            "value": {
              "type": "integer",
              "minimum": 0,
              "maximum": 3
            }
          }
        },
        {
          "title": "period-in-last-year",
          "properties": {
            "question": {
              "const": "period-in-last-year"
            },
            "value": {
              "anyOf": [
                {
                  "$ref": "#/$defs/YesNo"
                },
                {
                  "$ref": "#/$defs/CodeableConcept"
                }
              ]
            }
          }
        },
        {
          "title": "periods-stopped",
          "properties": {
            "question": {
              "const": "periods-stopped"
            },
            "value": {
              "anyOf": [
                {
                  "$ref": "#/$defs/PeriodsStopped"
                },
                {
                  "$ref": "#/$defs/CodeableConcept"
                }
              ]
            }
          }
        },
        {
          "title": "age-periods-stopped",
          "properties": {
            "question": {
              "const": "age-periods-stopped"
            },
            "value": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          }
        },
        {
          "title": "age-at-menarche",
          "properties": {
            "question": {
              "const": "age-at-menarche"
            },
            "value": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100
            }
          }
        }
      ],
      "properties": {
        "date": {
          "title": "When the person answered: calendar date or date with time and UTC offset",
          "description": "When the person answered: calendar date or date with time and UTC offset.",
          "$ref": "#/$defs/DateTime"
        },
        "question": {
          "title": "Which question",
          "description": "Which question.",
          "$ref": "#/$defs/Question"
        },
        "value": {
          "title": "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",
          "description": "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`.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "integer"
            },
            {
              "$ref": "#/$defs/CodeableConcept"
            }
          ]
        }
      },
      "required": [
        "date",
        "question",
        "value"
      ],
      "additionalProperties": false
    },
    "Bbt": {
      "title": "Basal body temperature readings (0.01 °C / 0.01 °F precision, distinct from LOINC 8310-5 general body temperature)",
      "description": "Basal body temperature readings (0.01 °C / 0.01 °F precision, distinct from LOINC 8310-5 general body temperature).",
      "type": "object",
      "oneOf": [
        {
          "title": "readings in Cel",
          "properties": {
            "unit": {
              "const": "Cel"
            },
            "entries": {
              "items": {
                "properties": {
                  "value": {
                    "type": "number",
                    "minimum": 34,
                    "maximum": 42
                  }
                }
              }
            }
          }
        },
        {
          "title": "readings in [degF]",
          "properties": {
            "unit": {
              "const": "[degF]"
            },
            "entries": {
              "items": {
                "properties": {
                  "value": {
                    "type": "number",
                    "minimum": 93,
                    "maximum": 107.6
                  }
                }
              }
            }
          }
        }
      ],
      "properties": {
        "unit": {
          "title": "Unit of every reading",
          "description": "Unit of every reading.",
          "$ref": "#/$defs/TemperatureUnit"
        },
        "entries": {
          "title": "Readings in natural degrees of `unit` (at most 2 decimal places, e.g",
          "description": "Readings in natural degrees of `unit` (at most 2 decimal places, e.g. 36.52). Cel 34-42, [degF] 93-107.6.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/TempEntry"
          }
        }
      },
      "required": [
        "unit",
        "entries"
      ],
      "additionalProperties": false
    },
    "Bleeding": {
      "title": "Menstrual bleeding on one day: the legal combinations of bleeding and flow",
      "description": "Menstrual bleeding on one day: the legal combinations of bleeding and flow.",
      "type": "string",
      "oneOf": [
        {
          "const": "no-bleeding",
          "description": "Explicitly no bleeding."
        },
        {
          "const": "flow-none",
          "description": "Explicitly no bleeding, logged on a flow scale's \"none\" option."
        },
        {
          "const": "bleeding",
          "description": "Bleeding, amount not recorded."
        },
        {
          "const": "spotting",
          "description": "Bleeding, flow category spotting (also bleeding between periods with no amount)."
        },
        {
          "const": "light",
          "description": "Bleeding, flow category light."
        },
        {
          "const": "moderate",
          "description": "Bleeding, flow category moderate (medium)."
        },
        {
          "const": "heavy",
          "description": "Bleeding, flow category heavy."
        }
      ]
    },
    "BuiltinInterval": {
      "title": "A built-in state over a range of calendar dates",
      "description": "A built-in state over a range of calendar dates.",
      "type": "object",
      "properties": {
        "kind": {
          "title": "Which state",
          "description": "Which state.",
          "$ref": "#/$defs/IntervalKind"
        },
        "start": {
          "title": "First calendar date",
          "description": "First calendar date.",
          "$ref": "#/$defs/CalendarDate"
        },
        "end": {
          "title": "Last calendar date (inclusive), not before `start`",
          "description": "Last calendar date (inclusive), not before `start`.",
          "$ref": "#/$defs/CalendarDate"
        }
      },
      "required": [
        "kind",
        "start",
        "end"
      ],
      "additionalProperties": false
    },
    "CalendarDate": {
      "title": "A calendar date YYYY-MM-DD from 2000-01-01 to 2099-12-31 (real Gregorian date)",
      "description": "A calendar date YYYY-MM-DD from 2000-01-01 to 2099-12-31 (real Gregorian date). Used for interval start and end bounds.",
      "examples": [
        "2026-01-05"
      ],
      "type": "string",
      "pattern": "^20[0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$"
    },
    "CodeableConcept": {
      "title": "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)",
      "description": "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)`.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "coding": {
          "title": "Single-element Coding array",
          "description": "At most one standard FHIR Coding `{ system, code, display? }`. Required unless `text` is given.",
          "type": [
            "array",
            "null"
          ],
          "minItems": 1,
          "maxItems": 1,
          "items": {
            "$ref": "#/$defs/Coding"
          }
        },
        "text": {
          "title": "Plain-text representation",
          "description": "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.",
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[^\\s\\x00-\\x1f\\x7f](?:[^\\x00-\\x1f\\x7f]*[^\\s\\x00-\\x1f\\x7f])?$"
        }
      },
      "anyOf": [
        {
          "required": [
            "coding"
          ],
          "properties": {
            "coding": {
              "type": "array",
              "minItems": 1,
              "maxItems": 1,
              "items": {
                "$ref": "#/$defs/Coding"
              }
            }
          }
        },
        {
          "required": [
            "text"
          ],
          "properties": {
            "text": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[^\\s\\x00-\\x1f\\x7f](?:[^\\x00-\\x1f\\x7f]*[^\\s\\x00-\\x1f\\x7f])?$"
            }
          }
        }
      ]
    },
    "CodedInterval": {
      "title": "Any other state: an observation code and a coded or text-only value, over a range of calendar dates",
      "description": "Any other state: an observation code and a coded or text-only value, over a range of calendar dates.",
      "type": "object",
      "properties": {
        "code": {
          "title": "What is observed (an Observation `CodeableConcept`), e.g",
          "description": "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.",
          "allOf": [
            {
              "$ref": "#/$defs/CodeableConcept"
            },
            {
              "not": {
                "$ref": "#/$defs/IntervalReservedCode"
              }
            },
            {
              "not": {
                "$ref": "#/$defs/R4VitalSignCode"
              }
            }
          ]
        },
        "value": {
          "title": "The state, e.g",
          "description": "The state, e.g. LOINC LA27913-5 (diaphragm or cervical cap) or a text-only concept.",
          "$ref": "#/$defs/CodeableConcept"
        },
        "start": {
          "title": "First calendar date",
          "description": "First calendar date.",
          "$ref": "#/$defs/CalendarDate"
        },
        "end": {
          "title": "Last calendar date (inclusive), not before `start`",
          "description": "Last calendar date (inclusive), not before `start`.",
          "$ref": "#/$defs/CalendarDate"
        }
      },
      "required": [
        "code",
        "value",
        "start",
        "end"
      ],
      "additionalProperties": false
    },
    "Coding": {
      "title": "A standard FHIR Coding from any code system",
      "description": "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.",
      "type": "object",
      "properties": {
        "system": {
          "title": "Code system URI: absolute URI of printable ASCII without spaces or \"|\", 1-255 characters",
          "description": "Code system URI: absolute URI of printable ASCII without spaces or \"|\", 1-255 characters.",
          "examples": [
            "http://snomed.info/sct",
            "http://www.nlm.nih.gov/research/umls/rxnorm"
          ],
          "type": "string",
          "minLength": 1,
          "maxLength": 255,
          "pattern": "^[A-Za-z][A-Za-z0-9+.-]*:[\\x21-\\x7b\\x7d\\x7e]+$"
        },
        "code": {
          "title": "Concept code within `system`: 1-128 characters, no control characters, no leading/trailing/repeated spaces",
          "description": "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).",
          "examples": [
            "25064002",
            "314076"
          ],
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[^\\s\\x00-\\x1f\\x7f]+(?: [^\\s\\x00-\\x1f\\x7f]+)*$"
        },
        "display": {
          "title": "Optional human-readable display text (1-128 characters, no control characters or leading/trailing whitespace)",
          "description": "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.",
          "examples": [
            "Essential hypertension"
          ],
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[^\\s\\x00-\\x1f\\x7f](?:[^\\x00-\\x1f\\x7f]*[^\\s\\x00-\\x1f\\x7f])?$"
        }
      },
      "required": [
        "system",
        "code"
      ],
      "additionalProperties": false
    },
    "ConditionEntry": {
      "title": "A condition the person reports",
      "description": "A condition the person reports.",
      "type": "object",
      "properties": {
        "code": {
          "title": "The condition: a built-in keyword (`ConditionKind`) or any FHIR `CodeableConcept` as an escape",
          "description": "The condition: a built-in keyword (`ConditionKind`) or any FHIR `CodeableConcept` as an escape.",
          "anyOf": [
            {
              "$ref": "#/$defs/ConditionKind"
            },
            {
              "$ref": "#/$defs/CodeableConcept"
            }
          ]
        },
        "status": {
          "title": "What the person says about it now",
          "description": "What the person says about it now. Not stated: absent.",
          "anyOf": [
            {
              "$ref": "#/$defs/ConditionStatus"
            },
            {
              "type": "null"
            }
          ]
        },
        "onset": {
          "title": "When it started, as precisely as the person says (1900-2150)",
          "description": "When it started, as precisely as the person says (1900-2150). Not stated: absent.",
          "anyOf": [
            {
              "$ref": "#/$defs/FhirDate"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "code"
      ],
      "additionalProperties": false
    },
    "ConditionKind": {
      "title": "Built-in condition keywords (SNOMED CT), pending clinical review: the main explanations of a bleeding pattern",
      "description": "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`.",
      "type": "string",
      "oneOf": [
        {
          "const": "pcos",
          "description": "Polycystic ovary syndrome.",
          "$comment": "concept 237055002"
        },
        {
          "const": "uterine-fibroids",
          "description": "Uterine leiomyoma (fibroids).",
          "$comment": "concept 95315005"
        },
        {
          "const": "adenomyosis",
          "description": "Uterine adenomyosis.",
          "$comment": "concept 784314006"
        },
        {
          "const": "endometrial-polyp",
          "description": "Endometrial polyp.",
          "$comment": "concept 1237359009"
        },
        {
          "const": "endometriosis",
          "description": "Endometriosis.",
          "$comment": "concept 129103003"
        },
        {
          "const": "von-willebrand-disorder",
          "description": "von Willebrand disorder.",
          "$comment": "concept 128105004"
        },
        {
          "const": "coagulation-disorder",
          "description": "Blood coagulation disorder.",
          "$comment": "concept 64779008"
        },
        {
          "const": "iron-deficiency-anemia",
          "description": "Iron deficiency anemia.",
          "$comment": "concept 87522002"
        },
        {
          "const": "hypothyroidism",
          "description": "Hypothyroidism.",
          "$comment": "concept 40930008"
        },
        {
          "const": "hyperthyroidism",
          "description": "Hyperthyroidism.",
          "$comment": "concept 34486009"
        },
        {
          "const": "hyperprolactinemia",
          "description": "Hyperprolactinemia.",
          "$comment": "concept 237662005"
        },
        {
          "const": "premature-ovarian-insufficiency",
          "description": "Premature ovarian insufficiency.",
          "$comment": "concept 237788002"
        },
        {
          "const": "hypothalamic-amenorrhea",
          "description": "Hypothalamic amenorrhea.",
          "$comment": "concept 237120002"
        },
        {
          "const": "perimenopause",
          "description": "Perimenopausal state.",
          "$comment": "concept 161541000119104"
        },
        {
          "const": "postmenopause",
          "description": "Postmenopausal state.",
          "$comment": "concept 76498008"
        }
      ]
    },
    "ConditionStatus": {
      "title": "A reported condition's status, as the person states it",
      "description": "A reported condition's status, as the person states it.",
      "type": "string",
      "oneOf": [
        {
          "const": "active",
          "description": "The person has it now."
        },
        {
          "const": "resolved",
          "description": "The person had it and it is over (explicit negative for now)."
        }
      ]
    },
    "CustomBooleanComponent": {
      "title": "A yes / no component (`component.valueBoolean`)",
      "description": "A yes / no component (`component.valueBoolean`).",
      "type": "object",
      "properties": {
        "code": {
          "title": "The component `CodeableConcept`",
          "description": "The component `CodeableConcept`.",
          "$ref": "#/$defs/CodeableConcept"
        },
        "valueType": {
          "title": "FHIR Observation component value type: boolean (`component.valueBoolean`)",
          "description": "FHIR Observation component value type: boolean (`component.valueBoolean`).",
          "const": "boolean"
        }
      },
      "required": [
        "code",
        "valueType"
      ],
      "additionalProperties": false
    },
    "CustomBooleanSeries": {
      "title": "Yes / no entries (also events: only `true`)",
      "description": "Yes / no entries (also events: only `true`).",
      "type": "object",
      "properties": {
        "code": {
          "title": "The Observation `CodeableConcept`",
          "description": "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`).",
          "allOf": [
            {
              "$ref": "#/$defs/CodeableConcept"
            },
            {
              "not": {
                "$ref": "#/$defs/ReservedSeriesCode"
              }
            }
          ]
        },
        "valueType": {
          "title": "FHIR Observation value type: boolean (`Observation.valueBoolean`)",
          "description": "FHIR Observation value type: boolean (`Observation.valueBoolean`).",
          "const": "boolean"
        },
        "entries": {
          "title": "Entries with boolean values (false is an explicit negative)",
          "description": "Entries with boolean values (false is an explicit negative).",
          "type": "array",
          "items": {
            "title": "ObservationEntry",
            "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
            "type": "object",
            "required": [
              "date",
              "value"
            ],
            "additionalProperties": false,
            "properties": {
              "date": {
                "title": "When the observation was recorded: calendar date or date with time and UTC offset",
                "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
                "$ref": "#/$defs/DateTime"
              },
              "value": {
                "title": "The recorded value",
                "description": "The recorded value.",
                "type": "boolean"
              }
            }
          }
        }
      },
      "required": [
        "code",
        "valueType",
        "entries"
      ],
      "additionalProperties": false
    },
    "CustomCodedComponent": {
      "title": "A coded or text-only component: one `CodeableConcept` per reading (`component.valueCodeableConcept`)",
      "description": "A coded or text-only component: one `CodeableConcept` per reading (`component.valueCodeableConcept`).",
      "type": "object",
      "properties": {
        "code": {
          "title": "The component `CodeableConcept`",
          "description": "The component `CodeableConcept`.",
          "$ref": "#/$defs/CodeableConcept"
        },
        "valueType": {
          "title": "FHIR Observation component value type: coded or text-only (`component.valueCodeableConcept`)",
          "description": "FHIR Observation component value type: coded or text-only (`component.valueCodeableConcept`).",
          "const": "coded"
        }
      },
      "required": [
        "code",
        "valueType"
      ],
      "additionalProperties": false
    },
    "CustomCodedSeries": {
      "title": "Coded or text-only entries: categorical, ordinal or multi-select alike (each entry is one fact)",
      "description": "Coded or text-only entries: categorical, ordinal or multi-select alike (each entry is one fact).",
      "type": "object",
      "properties": {
        "code": {
          "title": "The Observation `CodeableConcept`",
          "description": "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`).",
          "allOf": [
            {
              "$ref": "#/$defs/CodeableConcept"
            },
            {
              "not": {
                "$ref": "#/$defs/ReservedSeriesCode"
              }
            }
          ]
        },
        "valueType": {
          "title": "FHIR Observation value type: coded or text-only (`Observation.valueCodeableConcept`)",
          "description": "FHIR Observation value type: coded or text-only (`Observation.valueCodeableConcept`).",
          "const": "coded"
        },
        "entries": {
          "title": "Entries with FHIR `CodeableConcept` values (each one fact)",
          "description": "Entries with FHIR `CodeableConcept` values (each one fact). Level order is not carried, so displays or text should state the rank (\"3 of 5\").",
          "type": "array",
          "items": {
            "title": "ObservationEntry",
            "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
            "type": "object",
            "required": [
              "date",
              "value"
            ],
            "additionalProperties": false,
            "properties": {
              "date": {
                "title": "When the observation was recorded: calendar date or date with time and UTC offset",
                "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
                "$ref": "#/$defs/DateTime"
              },
              "value": {
                "title": "The recorded value",
                "description": "The recorded value.",
                "$ref": "#/$defs/CodeableConcept"
              }
            }
          }
        }
      },
      "required": [
        "code",
        "valueType",
        "entries"
      ],
      "additionalProperties": false
    },
    "CustomComponentValue": {
      "title": "One recorded component value inside a `CustomComponentsEntry`",
      "description": "One recorded component value inside a `CustomComponentsEntry`.",
      "type": "object",
      "properties": {
        "code": {
          "title": "The component `CodeableConcept` (must match one of `series.components`)",
          "description": "The component `CodeableConcept` (must match one of `series.components`).",
          "$ref": "#/$defs/CodeableConcept"
        },
        "value": {
          "title": "The component's value: boolean, `CodeableConcept`, or decimal number matching the component's `valueType`",
          "description": "The component's value: boolean, `CodeableConcept`, or decimal number matching the component's `valueType`.",
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "$ref": "#/$defs/CodeableConcept"
            },
            {
              "type": "number",
              "minimum": -999999999.999999,
              "maximum": 999999999.999999
            }
          ]
        }
      },
      "required": [
        "code",
        "value"
      ],
      "additionalProperties": false
    },
    "CustomComponentsEntry": {
      "title": "One multi-component reading entry on a date or timestamp",
      "description": "One multi-component reading entry on a date or timestamp.",
      "type": "object",
      "properties": {
        "date": {
          "title": "When the reading was taken: calendar date or date with time and UTC offset",
          "description": "When the reading was taken: calendar date or date with time and UTC offset.",
          "$ref": "#/$defs/DateTime"
        },
        "components": {
          "title": "Recorded component values (1..16)",
          "description": "Recorded component values (1..16). Each `code` must match a declared component of the series, with no duplicate component code in one entry.",
          "type": "array",
          "maxItems": 16,
          "items": {
            "$ref": "#/$defs/CustomComponentValue"
          }
        }
      },
      "required": [
        "date",
        "components"
      ],
      "additionalProperties": false
    },
    "CustomComponentsSeries": {
      "title": "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])",
      "description": "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.",
      "type": "object",
      "properties": {
        "code": {
          "title": "The Observation `CodeableConcept`",
          "description": "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].",
          "allOf": [
            {
              "$ref": "#/$defs/CodeableConcept"
            },
            {
              "not": {
                "$ref": "#/$defs/ReservedSeriesCode"
              }
            }
          ]
        },
        "valueType": {
          "title": "FHIR Observation value type: multi-component reading with no top-level value (`Observation.component[]`)",
          "description": "FHIR Observation value type: multi-component reading with no top-level value (`Observation.component[]`).",
          "const": "components"
        },
        "components": {
          "title": "The declared components, each with its own code and `valueType`",
          "description": "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.",
          "type": "array",
          "maxItems": 16,
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/CustomBooleanComponent"
              },
              {
                "$ref": "#/$defs/CustomCodedComponent"
              },
              {
                "$ref": "#/$defs/CustomQuantityComponent"
              }
            ]
          }
        },
        "entries": {
          "title": "The readings, each carrying its date/time and at least one recorded component value",
          "description": "The readings, each carrying its date/time and at least one recorded component value.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/CustomComponentsEntry"
          }
        }
      },
      "required": [
        "code",
        "valueType",
        "components",
        "entries"
      ],
      "additionalProperties": false
    },
    "CustomQuantityComponent": {
      "title": "A decimal quantity component in a UCUM unit (`component.valueQuantity`, at most 6 decimal places)",
      "description": "A decimal quantity component in a UCUM unit (`component.valueQuantity`, at most 6 decimal places).",
      "type": "object",
      "properties": {
        "code": {
          "title": "The component `CodeableConcept`",
          "description": "The component `CodeableConcept`.",
          "$ref": "#/$defs/CodeableConcept"
        },
        "valueType": {
          "title": "FHIR Observation component value type: decimal quantity in UCUM `unit` (`component.valueQuantity`)",
          "description": "FHIR Observation component value type: decimal quantity in UCUM `unit` (`component.valueQuantity`).",
          "const": "quantity"
        },
        "unit": {
          "title": "UCUM unit code (printable ASCII, no spaces)",
          "description": "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`).",
          "examples": [
            "mm[Hg]"
          ],
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[\\x21-\\x7e]+$"
        }
      },
      "required": [
        "code",
        "valueType",
        "unit"
      ],
      "additionalProperties": false
    },
    "CustomQuantitySeries": {
      "title": "Natural decimal quantity entries in a UCUM unit (at most 6 decimal places)",
      "description": "Natural decimal quantity entries in a UCUM unit (at most 6 decimal places).",
      "type": "object",
      "properties": {
        "code": {
          "title": "The Observation `CodeableConcept`",
          "description": "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`).",
          "allOf": [
            {
              "$ref": "#/$defs/CodeableConcept"
            },
            {
              "not": {
                "$ref": "#/$defs/ReservedSeriesCode"
              }
            }
          ]
        },
        "valueType": {
          "title": "FHIR Observation value type: decimal quantity in UCUM `unit` (`Observation.valueQuantity`)",
          "description": "FHIR Observation value type: decimal quantity in UCUM `unit` (`Observation.valueQuantity`).",
          "const": "quantity"
        },
        "unit": {
          "title": "UCUM unit code (printable ASCII, no spaces)",
          "description": "UCUM unit code (printable ASCII, no spaces).",
          "examples": [
            "mg",
            "{steps}"
          ],
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[\\x21-\\x7e]+$"
        },
        "entries": {
          "title": "Entries with natural decimal numbers below 1,000,000,000 in magnitude and at most 6 decimal places",
          "description": "Entries with natural decimal numbers below 1,000,000,000 in magnitude and at most 6 decimal places. 0 is a value.",
          "type": "array",
          "items": {
            "title": "ObservationEntry",
            "description": "One observation entry in a flat series array: a `DateTime` (day or timestamp) and its value. Identical entries and entries that disagree on the same date or time are all carried, each its own fact, never merged.",
            "type": "object",
            "required": [
              "date",
              "value"
            ],
            "additionalProperties": false,
            "properties": {
              "date": {
                "title": "When the observation was recorded: calendar date or date with time and UTC offset",
                "description": "When the observation was recorded: calendar date or date with time and UTC offset.",
                "$ref": "#/$defs/DateTime"
              },
              "value": {
                "title": "The recorded value",
                "description": "The recorded value.",
                "type": "number",
                "minimum": -999999999.999999,
                "maximum": 999999999.999999
              }
            }
          }
        }
      },
      "required": [
        "code",
        "valueType",
        "unit",
        "entries"
      ],
      "additionalProperties": false
    },
    "DateTime": {
      "title": "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)`",
      "description": "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.",
      "examples": [
        "2026-01-05",
        "2026-01-05T07:30-05:00",
        "2026-01-05T22:15:42+01:00"
      ],
      "type": "string",
      "pattern": "^20[0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?(Z|(?!-00:00$)[+-](0[0-9]|1[0-4]):(00|15|30|45)))?$"
    },
    "Energy": {
      "title": "Energy, 4 points (Clue)",
      "description": "Energy, 4 points (Clue).",
      "type": "string",
      "oneOf": [
        {
          "const": "exhausted",
          "description": "1 of 4."
        },
        {
          "const": "low",
          "description": "2 of 4."
        },
        {
          "const": "high",
          "description": "3 of 4."
        },
        {
          "const": "energized",
          "description": "4 of 4."
        }
      ]
    },
    "ExcludeReason": {
      "title": "Built-in disturbance/exclusion reason on a BBT or skinTemp reading",
      "description": "Built-in disturbance/exclusion reason on a BBT or skinTemp reading.",
      "type": "string",
      "oneOf": [
        {
          "const": "fever",
          "description": "Fever or acute febrile illness."
        },
        {
          "const": "alcohol",
          "description": "Alcohol consumption the previous evening."
        },
        {
          "const": "poor-sleep",
          "description": "Poor, broken, or unusually short sleep."
        },
        {
          "const": "late-wake",
          "description": "Woke significantly later (or earlier) than usual."
        },
        {
          "const": "travel",
          "description": "Travel or time-zone shift."
        },
        {
          "const": "stress",
          "description": "Acute stress."
        },
        {
          "const": "medication",
          "description": "Medication affecting basal temperature."
        },
        {
          "const": "other",
          "description": "Other unspecified disturbance."
        }
      ]
    },
    "FhirDate": {
      "title": "A FHIR date of year, month or day precision: YYYY, YYYY-MM or YYYY-MM-DD, from 1900 to 2150",
      "description": "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.",
      "examples": [
        "2019",
        "2023-05",
        "2021-11-30"
      ],
      "type": "string",
      "pattern": "^(19[0-9]{2}|20[0-9]{2}|21[0-4][0-9]|2150)(-(0[1-9]|1[0-2])(-(0[1-9]|[12][0-9]|3[01]))?)?$"
    },
    "FhirDateTime": {
      "title": "A FHIR dateTime for procedures (year 1900 to 2150): `YYYY`, `YYYY-MM`, `YYYY-MM-DD`, or `YYYY-MM-DDTHH:MM(:SS)?(Z|±HH:MM)`",
      "description": "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.",
      "examples": [
        "2021-04",
        "2026-01-29T10:30-05:00"
      ],
      "type": "string",
      "pattern": "^(19[0-9]{2}|20[0-9]{2}|21[0-4][0-9]|2150)(-(0[1-9]|1[0-2])(-(0[1-9]|[12][0-9]|3[01])(T([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?(Z|(?!-00:00$)[+-](0[0-9]|1[0-4]):(00|15|30|45)))?)?)?$"
    },
    "FhirInstant": {
      "title": "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)`",
      "description": "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.",
      "examples": [
        "2026-12-04T14:30-06:00",
        "2026-12-04T14:30:15+00:00"
      ],
      "type": "string",
      "pattern": "^20[0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?(Z|(?!-00:00$)[+-](0[0-9]|1[0-4]):(00|15|30|45))$"
    },
    "IntervalKind": {
      "title": "Built-in states over a range of days",
      "description": "Built-in states over a range of days. Contraception values are LOINC answers to 8659-5.",
      "type": "string",
      "oneOf": [
        {
          "const": "none",
          "description": "Not using contraception (explicit negative).",
          "$comment": "concept http://loinc.org|LA137-2"
        },
        {
          "const": "combined-pill",
          "description": "Combined oral contraceptive pill.",
          "$comment": "concept http://loinc.org|LA27908-5"
        },
        {
          "const": "progestin-pill",
          "description": "Progestin-only pill.",
          "$comment": "concept http://loinc.org|LA27909-3"
        },
        {
          "const": "patch",
          "description": "Contraceptive patch.",
          "$comment": "concept http://loinc.org|LA16581-3"
        },
        {
          "const": "ring",
          "description": "Vaginal ring.",
          "$comment": "concept http://loinc.org|LA27911-9"
        },
        {
          "const": "injection",
          "description": "Injectable contraceptive.",
          "$comment": "concept http://loinc.org|LA27907-7"
        },
        {
          "const": "implant",
          "description": "Contraceptive implant.",
          "$comment": "concept http://loinc.org|LA27901-0"
        },
        {
          "const": "hormonal-iud",
          "description": "Hormonal (progestin) IUD.",
          "$comment": "concept http://loinc.org|LA27902-8"
        },
        {
          "const": "copper-iud",
          "description": "Copper IUD.",
          "$comment": "concept http://loinc.org|LA27903-6"
        },
        {
          "const": "iud-unspecified",
          "description": "IUD, type not recorded.",
          "$comment": "concept http://loinc.org|LA27904-4"
        },
        {
          "const": "condom",
          "description": "Male condom.",
          "$comment": "concept http://loinc.org|LA27912-7"
        },
        {
          "const": "fertility-awareness",
          "description": "Fertility awareness-based method.",
          "$comment": "concept http://loinc.org|LA27918-4"
        },
        {
          "const": "lactational-amenorrhea",
          "description": "Lactational amenorrhea method.",
          "$comment": "concept http://loinc.org|LA27919-2"
        },
        {
          "const": "pregnant",
          "description": "Pregnant (LOINC 82810-3).",
          "$comment": "concept http://loinc.org|LA15173-0"
        },
        {
          "const": "breastfeeding",
          "description": "Breastfeeding (LOINC 63895-7).",
          "$comment": "concept http://loinc.org|LA29252-6"
        }
      ]
    },
    "IntervalReservedCode": {
      "title": "Per-day series code",
      "description": "Built-in per-day series codes, which an interval may not use (the contraception, pregnancy and breastfeeding codes are allowed).",
      "anyOf": [
        {
          "properties": {
            "coding": {
              "type": "array",
              "minItems": 1,
              "items": {
                "properties": {
                  "system": {
                    "const": "http://loinc.org"
                  },
                  "code": {
                    "enum": [
                      "2106-3",
                      "63888-2",
                      "63889-0",
                      "64700-8",
                      "64701-6",
                      "64702-4",
                      "65930-0",
                      "72514-3",
                      "92656-8",
                      "93832-4"
                    ]
                  }
                },
                "required": [
                  "system",
                  "code"
                ]
              }
            }
          },
          "required": [
            "coding"
          ]
        },
        {
          "properties": {
            "coding": {
              "type": "array",
              "minItems": 1,
              "items": {
                "properties": {
                  "system": {
                    "const": "http://snomed.info/sct"
                  },
                  "code": {
                    "enum": [
                      "364316005"
                    ]
                  }
                },
                "required": [
                  "system",
                  "code"
                ]
              }
            }
          },
          "required": [
            "coding"
          ]
        },
        {
          "properties": {
            "coding": {
              "type": "array",
              "minItems": 1,
              "items": {
                "properties": {
                  "system": {
                    "const": "https://joshuamandel.com/shc2-poc/CodeSystem/cycle-log"
                  },
                  "code": {
                    "enum": [
                      "basal-body-temperature",
                      "cervical-mucus",
                      "contraceptive-pill-taken",
                      "energy-level",
                      "menstrual-bleeding",
                      "menstrual-flow",
                      "menstrual-fluid-volume",
                      "mood-valence",
                      "nightly-skin-temperature",
                      "ovulation-test",
                      "pdg-test",
                      "skin-temperature-deviation",
                      "symptom"
                    ]
                  }
                },
                "required": [
                  "system",
                  "code"
                ]
              }
            }
          },
          "required": [
            "coding"
          ]
        }
      ]
    },
    "MedDose": {
      "title": "Exact positive decimal medication dose in a UCUM unit",
      "description": "Exact positive decimal medication dose in a UCUM unit.",
      "type": "object",
      "properties": {
        "value": {
          "title": "Strictly positive decimal dose below 1,000,000,000, with at most 6 decimal places (e.g",
          "description": "Strictly positive decimal dose below 1,000,000,000, with at most 6 decimal places (e.g. 400, 12.5).",
          "type": "number",
          "minimum": 0.000001,
          "maximum": 999999999.999999
        },
        "unit": {
          "title": "UCUM unit code (printable ASCII, no spaces, e.g",
          "description": "UCUM unit code (printable ASCII, no spaces, e.g. \"mg\", \"ug\", \"mL\", \"[iU]\").",
          "examples": [
            "mg"
          ],
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[\\x21-\\x7e]+$"
        }
      },
      "required": [
        "value",
        "unit"
      ],
      "additionalProperties": false
    },
    "MedEntry": {
      "title": "One medication entry on a date or timestamp",
      "description": "One medication entry on a date or timestamp.",
      "type": "object",
      "properties": {
        "date": {
          "title": "When the medication was taken (or missed): calendar date or date with time and UTC offset",
          "description": "When the medication was taken (or missed): calendar date or date with time and UTC offset.",
          "$ref": "#/$defs/DateTime"
        },
        "code": {
          "title": "The product: a built-in keyword (`MedicationKind`) or any FHIR `CodeableConcept` as an escape",
          "description": "The product: a built-in keyword (`MedicationKind`) or any FHIR `CodeableConcept` as an escape.",
          "anyOf": [
            {
              "$ref": "#/$defs/MedicationKind"
            },
            {
              "$ref": "#/$defs/CodeableConcept"
            }
          ]
        },
        "status": {
          "title": "Whether it was taken",
          "description": "Whether it was taken.",
          "$ref": "#/$defs/MedStatus"
        },
        "dose": {
          "title": "Optional exact dose taken (maps to MedicationStatement.dosage[0].doseAndRate[0].doseQuantity)",
          "description": "Optional exact dose taken (maps to MedicationStatement.dosage[0].doseAndRate[0].doseQuantity).",
          "anyOf": [
            {
              "$ref": "#/$defs/MedDose"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "date",
        "code",
        "status"
      ],
      "additionalProperties": false
    },
    "MedStatus": {
      "title": "Whether a medication was taken on a day",
      "description": "Whether a medication was taken on a day.",
      "type": "string",
      "oneOf": [
        {
          "const": "taken",
          "description": "Taken."
        },
        {
          "const": "not-taken",
          "description": "Explicitly not taken (a missed dose)."
        }
      ]
    },
    "MedicationKind": {
      "title": "Built-in medication keywords (SNOMED CT medicinal products)",
      "description": "Built-in medication keywords (SNOMED CT medicinal products). Any other product (RxNorm, SNOMED CT, text-only, ...) is passed as a FHIR `CodeableConcept`.",
      "type": "string",
      "oneOf": [
        {
          "const": "ibuprofen",
          "description": "Ibuprofen-containing product.",
          "$comment": "concept 38268001"
        },
        {
          "const": "naproxen",
          "description": "Naproxen-containing product.",
          "$comment": "concept 11847009"
        },
        {
          "const": "acetaminophen",
          "description": "Acetaminophen-containing product.",
          "$comment": "concept 90332006"
        },
        {
          "const": "mefenamic-acid",
          "description": "Mefenamic acid-containing product.",
          "$comment": "concept 34364009"
        },
        {
          "const": "tranexamic-acid",
          "description": "Tranexamic acid-containing product.",
          "$comment": "concept 109006003"
        },
        {
          "const": "iron",
          "description": "Iron-containing product.",
          "$comment": "concept 30729008"
        },
        {
          "const": "folic-acid",
          "description": "Folic acid-containing product.",
          "$comment": "concept 6247001"
        }
      ]
    },
    "Mood": {
      "title": "Mood valence, 7 points (Apple HealthKit State of Mind)",
      "description": "Mood valence, 7 points (Apple HealthKit State of Mind).",
      "type": "string",
      "oneOf": [
        {
          "const": "very-unpleasant",
          "description": "1 of 7."
        },
        {
          "const": "unpleasant",
          "description": "2 of 7."
        },
        {
          "const": "slightly-unpleasant",
          "description": "3 of 7."
        },
        {
          "const": "neutral",
          "description": "4 of 7, neither pleasant nor unpleasant."
        },
        {
          "const": "slightly-pleasant",
          "description": "5 of 7."
        },
        {
          "const": "pleasant",
          "description": "6 of 7."
        },
        {
          "const": "very-pleasant",
          "description": "7 of 7."
        }
      ]
    },
    "Mucus": {
      "title": "Cervical mucus, as self-observed",
      "description": "Cervical mucus, as self-observed.",
      "type": "string",
      "oneOf": [
        {
          "const": "dry",
          "description": "No mucus; feels dry."
        },
        {
          "const": "sticky",
          "description": "Sticky, tacky or crumbly."
        },
        {
          "const": "creamy",
          "description": "Creamy, lotion-like."
        },
        {
          "const": "watery",
          "description": "Watery, wet."
        },
        {
          "const": "egg-white",
          "description": "Clear and stretchy, like raw egg white."
        }
      ]
    },
    "OvulationTest": {
      "title": "LH (ovulation) urine test result",
      "description": "LH (ovulation) urine test result.",
      "type": "string",
      "oneOf": [
        {
          "const": "negative",
          "description": "No surge detected."
        },
        {
          "const": "lh-surge",
          "description": "LH surge detected (a positive test)."
        },
        {
          "const": "estrogen-surge",
          "description": "Estrogen rise detected (high fertility on two-hormone tests)."
        },
        {
          "const": "indeterminate",
          "description": "The result could not be read."
        }
      ]
    },
    "PatientInfo": {
      "title": "Optional identity: deliberately small",
      "description": "Optional identity: deliberately small. An empty object means no identity.",
      "type": "object",
      "properties": {
        "family": {
          "title": "Family name",
          "description": "Family name. Not recorded: absent.",
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[^\\s\\x00-\\x1f\\x7f](?:[^\\x00-\\x1f\\x7f]*[^\\s\\x00-\\x1f\\x7f])?$"
        },
        "given": {
          "title": "Given names, in order",
          "description": "Given names, in order. Not recorded: absent or []. Each 1-64 characters.",
          "type": [
            "array",
            "null"
          ],
          "maxItems": 3,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[^\\s\\x00-\\x1f\\x7f](?:[^\\x00-\\x1f\\x7f]*[^\\s\\x00-\\x1f\\x7f])?$"
          }
        },
        "birthDate": {
          "title": "Birth date, from 1900 to 2150",
          "description": "Birth date, from 1900 to 2150. A year alone is enough to give age without identity. Not recorded: absent.",
          "anyOf": [
            {
              "$ref": "#/$defs/FhirDate"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "PeriodsStopped": {
      "title": "Answers to \"periods-stopped\"",
      "description": "Answers to \"periods-stopped\".",
      "type": "string",
      "oneOf": [
        {
          "const": "yes-no-periods",
          "description": "Yes, no menstrual periods.",
          "$comment": "concept http://loinc.org|LA14656-5"
        },
        {
          "const": "yes-hormones",
          "description": "Yes, but has periods now due to female hormones.",
          "$comment": "concept http://loinc.org|LA14657-3"
        },
        {
          "const": "no",
          "description": "No.",
          "$comment": "concept http://loinc.org|LA32-8"
        },
        {
          "const": "not-sure",
          "description": "Not sure.",
          "$comment": "concept http://loinc.org|LA12693-0"
        }
      ]
    },
    "PillLog": {
      "title": "Contraceptive pill log for one day",
      "description": "Contraceptive pill log for one day.",
      "type": "string",
      "oneOf": [
        {
          "const": "taken",
          "description": "The pill was taken."
        },
        {
          "const": "missed",
          "description": "The pill was missed (explicit negative)."
        }
      ]
    },
    "Procedure": {
      "title": "A completed procedure on a date or dateTime",
      "description": "A completed procedure on a date or dateTime.",
      "type": "object",
      "properties": {
        "date": {
          "title": "When: YYYY, YYYY-MM, YYYY-MM-DD, or YYYY-MM-DDTHH:MM(:SS)?(Z|±HH:MM) (year 1900-2150)",
          "description": "When: YYYY, YYYY-MM, YYYY-MM-DD, or YYYY-MM-DDTHH:MM(:SS)?(Z|±HH:MM) (year 1900-2150).",
          "$ref": "#/$defs/FhirDateTime"
        },
        "code": {
          "title": "Which procedure: a built-in keyword (`ProcedureKind`) or any FHIR `CodeableConcept`",
          "description": "Which procedure: a built-in keyword (`ProcedureKind`) or any FHIR `CodeableConcept`.",
          "anyOf": [
            {
              "$ref": "#/$defs/ProcedureKind"
            },
            {
              "$ref": "#/$defs/CodeableConcept"
            }
          ]
        }
      },
      "required": [
        "date",
        "code"
      ],
      "additionalProperties": false
    },
    "ProcedureKind": {
      "title": "Built-in procedures (SNOMED CT)",
      "description": "Built-in procedures (SNOMED CT).",
      "type": "string",
      "oneOf": [
        {
          "const": "iud-insertion",
          "description": "Insertion of an intrauterine device.",
          "$comment": "concept 65200003"
        },
        {
          "const": "iud-removal",
          "description": "Removal of an intrauterine device.",
          "$comment": "concept 1263416007"
        },
        {
          "const": "implant-insertion",
          "description": "Insertion of a contraceptive implant.",
          "$comment": "concept 169553002"
        },
        {
          "const": "implant-removal",
          "description": "Removal of a contraceptive implant.",
          "$comment": "concept 301807007"
        },
        {
          "const": "emergency-contraception",
          "description": "Emergency contraception taken.",
          "$comment": "concept 1372819003"
        },
        {
          "const": "hysterectomy",
          "description": "Hysterectomy: afterwards absent bleeding is not amenorrhea or menopause.",
          "$comment": "concept 236886002"
        },
        {
          "const": "endometrial-ablation",
          "description": "Endometrial ablation: afterwards little or no bleeding is expected.",
          "$comment": "concept 265060005"
        },
        {
          "const": "oophorectomy",
          "description": "Oophorectomy (one ovary or unspecified).",
          "$comment": "concept 83152002"
        },
        {
          "const": "bilateral-oophorectomy",
          "description": "Bilateral oophorectomy: surgical menopause.",
          "$comment": "concept 76876009"
        },
        {
          "const": "myomectomy",
          "description": "Myomectomy (fibroid removal).",
          "$comment": "concept 42010004"
        },
        {
          "const": "d-and-c",
          "description": "Dilation and curettage.",
          "$comment": "concept 11401008"
        },
        {
          "const": "polypectomy",
          "description": "Endometrial polypectomy.",
          "$comment": "concept 236884004"
        },
        {
          "const": "uterine-artery-embolization",
          "description": "Uterine artery embolization.",
          "$comment": "concept 312138002"
        }
      ]
    },
    "Question": {
      "title": "Screening questions (LOINC)",
      "description": "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.",
      "type": "string",
      "oneOf": [
        {
          "const": "usual-cycle-length",
          "description": "Usual cycle length over the last year. Answer: `UsualCycleLength`.",
          "$comment": "concept http://loinc.org|64700-8"
        },
        {
          "const": "periods-per-year",
          "description": "Number of periods per year. Answer: integer 0-100 (unit /a).",
          "$comment": "concept http://loinc.org|92656-8"
        },
        {
          "const": "missed-periods-3-months",
          "description": "Periods missed over the past 3 months. Answer: integer 0-3.",
          "$comment": "concept http://loinc.org|65930-0"
        },
        {
          "const": "period-in-last-year",
          "description": "Had a period within the last year. Answer: `YesNo`.",
          "$comment": "concept http://loinc.org|63889-0"
        },
        {
          "const": "periods-stopped",
          "description": "Periods stopped permanently. Answer: `PeriodsStopped`.",
          "$comment": "concept http://loinc.org|64701-6"
        },
        {
          "const": "age-periods-stopped",
          "description": "Age in years when periods stopped. Answer: integer 0-100.",
          "$comment": "concept http://loinc.org|64702-4"
        },
        {
          "const": "age-at-menarche",
          "description": "Age in years at the first period. Answer: integer 0-100.",
          "$comment": "concept http://loinc.org|63888-2"
        }
      ]
    },
    "R4VitalSignCode": {
      "title": "R4 vital-sign code",
      "description": "LOINC codes for which the HL7 validator applies an R4 vital-signs profile (requiring category vital-signs). Custom intervals may not use them; a custom series with one is a vital sign, written with category vital-signs.",
      "properties": {
        "coding": {
          "type": "array",
          "minItems": 1,
          "items": {
            "properties": {
              "system": {
                "const": "http://loinc.org"
              },
              "code": {
                "enum": [
                  "11291-2",
                  "11328-2",
                  "19224-5",
                  "19840-8",
                  "20564-1",
                  "2708-6",
                  "2709-4",
                  "2710-2",
                  "2713-6",
                  "29463-7",
                  "3137-7",
                  "3138-5",
                  "3141-9",
                  "3142-7",
                  "33438-3",
                  "35094-2",
                  "39156-5",
                  "40443-4",
                  "51733-4",
                  "55284-4",
                  "55425-3",
                  "59408-5",
                  "59417-6",
                  "60834-9",
                  "60835-6",
                  "60836-4",
                  "60838-0",
                  "60955-2",
                  "60978-4",
                  "61009-7",
                  "68999-2",
                  "69000-8",
                  "73795-7",
                  "73799-9",
                  "75292-3",
                  "75539-7",
                  "75987-8",
                  "76010-8",
                  "76011-6",
                  "76170-0",
                  "76171-8",
                  "76172-6",
                  "76270-8",
                  "76278-1",
                  "76476-1",
                  "76477-9",
                  "76534-7",
                  "79348-9",
                  "8287-5",
                  "8302-2",
                  "8306-3",
                  "8308-9",
                  "8309-7",
                  "8310-5",
                  "8328-7",
                  "8329-5",
                  "8330-3",
                  "8331-1",
                  "8332-9",
                  "8333-7",
                  "8334-5",
                  "8350-1",
                  "8351-9",
                  "8459-0",
                  "8462-4",
                  "8478-0",
                  "8480-6",
                  "85353-1",
                  "85354-9",
                  "8867-4",
                  "8886-4",
                  "8889-8",
                  "8890-6",
                  "8891-4",
                  "8892-2",
                  "8893-0",
                  "89270-3",
                  "89276-0",
                  "91371-5",
                  "9279-1",
                  "97549-0",
                  "9843-4",
                  "98657-0",
                  "98663-8"
                ]
              }
            },
            "required": [
              "system",
              "code"
            ]
          }
        }
      },
      "required": [
        "coding"
      ]
    },
    "ReservedSeriesCode": {
      "title": "Built-in series code",
      "description": "The Observation codes of the built-in series and screening questions. A custom series may not use them: put the values in the built-in instead (its coded values accept any CodeableConcept).",
      "anyOf": [
        {
          "properties": {
            "coding": {
              "type": "array",
              "minItems": 1,
              "items": {
                "properties": {
                  "system": {
                    "const": "http://loinc.org"
                  },
                  "code": {
                    "enum": [
                      "2106-3",
                      "63888-2",
                      "63889-0",
                      "63895-7",
                      "64700-8",
                      "64701-6",
                      "64702-4",
                      "65930-0",
                      "72514-3",
                      "82810-3",
                      "8659-5",
                      "92656-8",
                      "93832-4"
                    ]
                  }
                },
                "required": [
                  "system",
                  "code"
                ]
              }
            }
          },
          "required": [
            "coding"
          ]
        },
        {
          "properties": {
            "coding": {
              "type": "array",
              "minItems": 1,
              "items": {
                "properties": {
                  "system": {
                    "const": "http://snomed.info/sct"
                  },
                  "code": {
                    "enum": [
                      "364316005"
                    ]
                  }
                },
                "required": [
                  "system",
                  "code"
                ]
              }
            }
          },
          "required": [
            "coding"
          ]
        },
        {
          "properties": {
            "coding": {
              "type": "array",
              "minItems": 1,
              "items": {
                "properties": {
                  "system": {
                    "const": "https://joshuamandel.com/shc2-poc/CodeSystem/cycle-log"
                  },
                  "code": {
                    "enum": [
                      "basal-body-temperature",
                      "cervical-mucus",
                      "contraceptive-pill-taken",
                      "energy-level",
                      "menstrual-bleeding",
                      "menstrual-flow",
                      "menstrual-fluid-volume",
                      "mood-valence",
                      "nightly-skin-temperature",
                      "ovulation-test",
                      "pdg-test",
                      "skin-temperature-deviation",
                      "symptom"
                    ]
                  }
                },
                "required": [
                  "system",
                  "code"
                ]
              }
            }
          },
          "required": [
            "coding"
          ]
        }
      ]
    },
    "Sex": {
      "title": "Sexual intercourse on one day",
      "description": "Sexual intercourse on one day.",
      "type": "string",
      "oneOf": [
        {
          "const": "none",
          "description": "Explicitly no intercourse."
        },
        {
          "const": "protected",
          "description": "Intercourse with protection (e.g. a condom)."
        },
        {
          "const": "unprotected",
          "description": "Intercourse without protection."
        },
        {
          "const": "unspecified",
          "description": "Intercourse, protection not recorded."
        }
      ]
    },
    "SkinTemp": {
      "title": "Wearable nightly temperature from one device",
      "description": "Wearable nightly temperature from one device.",
      "type": "object",
      "oneOf": [
        {
          "title": "deviation in Cel",
          "properties": {
            "kind": {
              "const": "deviation"
            },
            "unit": {
              "const": "Cel"
            },
            "entries": {
              "items": {
                "properties": {
                  "value": {
                    "type": "number",
                    "minimum": -5,
                    "maximum": 5
                  }
                }
              }
            }
          }
        },
        {
          "title": "deviation in [degF]",
          "properties": {
            "kind": {
              "const": "deviation"
            },
            "unit": {
              "const": "[degF]"
            },
            "entries": {
              "items": {
                "properties": {
                  "value": {
                    "type": "number",
                    "minimum": -9,
                    "maximum": 9
                  }
                }
              }
            }
          }
        },
        {
          "title": "absolute in Cel",
          "properties": {
            "kind": {
              "const": "absolute"
            },
            "unit": {
              "const": "Cel"
            },
            "entries": {
              "items": {
                "properties": {
                  "value": {
                    "type": "number",
                    "minimum": 25,
                    "maximum": 40
                  }
                }
              }
            }
          }
        },
        {
          "title": "absolute in [degF]",
          "properties": {
            "kind": {
              "const": "absolute"
            },
            "unit": {
              "const": "[degF]"
            },
            "entries": {
              "items": {
                "properties": {
                  "value": {
                    "type": "number",
                    "minimum": 77,
                    "maximum": 104
                  }
                }
              }
            }
          }
        }
      ],
      "properties": {
        "kind": {
          "title": "Whether values are deviations from the device's baseline or absolute temperatures",
          "description": "Whether values are deviations from the device's baseline or absolute temperatures.",
          "$ref": "#/$defs/SkinTempKind"
        },
        "unit": {
          "title": "Unit of every value",
          "description": "Unit of every value. For a deviation, a temperature difference in this unit.",
          "$ref": "#/$defs/TemperatureUnit"
        },
        "entries": {
          "title": "Readings by wake date, in natural degrees of `unit` (at most 2 decimal places, e.g",
          "description": "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.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/TempEntry"
          }
        }
      },
      "required": [
        "kind",
        "unit",
        "entries"
      ],
      "additionalProperties": false
    },
    "SkinTempKind": {
      "title": "What a wearable temperature value means",
      "description": "What a wearable temperature value means.",
      "type": "string",
      "oneOf": [
        {
          "const": "deviation",
          "description": "Difference from the device's own baseline (Oura, Fitbit, Garmin); signed."
        },
        {
          "const": "absolute",
          "description": "Absolute nightly skin or wrist temperature (Apple Watch, Google, Whoop)."
        }
      ]
    },
    "Source": {
      "title": "The exporting app, shown as the source device of every observation",
      "description": "The exporting app, shown as the source device of every observation.",
      "type": "object",
      "properties": {
        "name": {
          "title": "The app's name as users know it, 1-64 characters",
          "description": "The app's name as users know it, 1-64 characters.",
          "examples": [
            "FertilityApp"
          ],
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[^\\s\\x00-\\x1f\\x7f](?:[^\\x00-\\x1f\\x7f]*[^\\s\\x00-\\x1f\\x7f])?$"
        },
        "version": {
          "title": "The app's version, 1-32 characters",
          "description": "The app's version, 1-32 characters. Not recorded: absent.",
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 32,
          "pattern": "^[^\\s\\x00-\\x1f\\x7f](?:[^\\x00-\\x1f\\x7f]*[^\\s\\x00-\\x1f\\x7f])?$"
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false
    },
    "SymptomKind": {
      "title": "Built-in symptom keywords (SNOMED CT, plus `hot-flash` in `cycle-log`)",
      "description": "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`.",
      "type": "string",
      "oneOf": [
        {
          "const": "menstrual-cramp",
          "description": "Menstrual cramp.",
          "$comment": "concept 431416001"
        },
        {
          "const": "backache",
          "description": "Backache.",
          "$comment": "concept 161891005"
        },
        {
          "const": "headache",
          "description": "Headache.",
          "$comment": "concept 25064002"
        },
        {
          "const": "migraine",
          "description": "Migraine.",
          "$comment": "concept 37796009"
        },
        {
          "const": "stomach-ache",
          "description": "Stomach ache.",
          "$comment": "concept 271681002"
        },
        {
          "const": "nausea",
          "description": "Nausea.",
          "$comment": "concept 422587007"
        },
        {
          "const": "breast-tenderness",
          "description": "Breast tenderness.",
          "$comment": "concept 55222007"
        },
        {
          "const": "ovulation-pain",
          "description": "Ovulation pain.",
          "$comment": "concept 43548008"
        },
        {
          "const": "fatigue",
          "description": "Fatigue.",
          "$comment": "concept 84229001"
        },
        {
          "const": "bloating",
          "description": "Abdominal bloating.",
          "$comment": "concept 116289008"
        },
        {
          "const": "depressed-mood",
          "description": "Depressed mood.",
          "$comment": "concept 366979004"
        },
        {
          "const": "irritable",
          "description": "Feeling irritable.",
          "$comment": "concept 55929007"
        },
        {
          "const": "stress",
          "description": "Stress.",
          "$comment": "concept 73595000"
        },
        {
          "const": "dyspareunia",
          "description": "Dyspareunia.",
          "$comment": "concept 71315007"
        },
        {
          "const": "acne",
          "description": "Acne.",
          "$comment": "concept 11381005"
        },
        {
          "const": "pelvic-pain",
          "description": "Pain in pelvis.",
          "$comment": "concept 30473006"
        },
        {
          "const": "low-back-pain",
          "description": "Low back pain.",
          "$comment": "concept 279039007"
        },
        {
          "const": "breast-pain",
          "description": "Pain of breast.",
          "$comment": "concept 53430007"
        },
        {
          "const": "mood-swings",
          "description": "Mood swings.",
          "$comment": "concept 18963009"
        },
        {
          "const": "anxiety",
          "description": "Anxiety.",
          "$comment": "concept 48694002"
        },
        {
          "const": "diarrhea",
          "description": "Diarrhea.",
          "$comment": "concept 62315008"
        },
        {
          "const": "constipation",
          "description": "Constipation.",
          "$comment": "concept 14760008"
        },
        {
          "const": "dizziness",
          "description": "Dizziness.",
          "$comment": "concept 404640003"
        },
        {
          "const": "food-craving",
          "description": "Craving for food or drink.",
          "$comment": "concept 248132003"
        },
        {
          "const": "vaginal-clots",
          "description": "Passing clots vaginally.",
          "$comment": "concept 289532003"
        },
        {
          "const": "hot-flash",
          "description": "Hot flash (cause not stated); a proposed code.",
          "$comment": "concept https://joshuamandel.com/shc2-poc/CodeSystem/cycle-log|hot-flash"
        },
        {
          "const": "night-sweats",
          "description": "Night sweats.",
          "$comment": "concept 42984000"
        },
        {
          "const": "insomnia",
          "description": "Insomnia.",
          "$comment": "concept 193462001"
        },
        {
          "const": "vaginal-dryness",
          "description": "Vaginal dryness.",
          "$comment": "concept 31908003"
        },
        {
          "const": "palpitations",
          "description": "Palpitations.",
          "$comment": "concept 80313002"
        },
        {
          "const": "urinary-incontinence",
          "description": "Urinary incontinence.",
          "$comment": "concept 165232002"
        },
        {
          "const": "memory-lapses",
          "description": "Memory lapses.",
          "$comment": "concept 225038006"
        },
        {
          "const": "hair-loss",
          "description": "Alopecia (hair loss).",
          "$comment": "concept 56317004"
        },
        {
          "const": "increased-libido",
          "description": "Increased libido.",
          "$comment": "concept 58436003"
        },
        {
          "const": "reduced-libido",
          "description": "Reduced libido.",
          "$comment": "concept 8357008"
        }
      ]
    },
    "TempEntry": {
      "title": "One temperature reading with date/time and optional disturbance/exclusion flag",
      "description": "One temperature reading with date/time and optional disturbance/exclusion flag.",
      "type": "object",
      "properties": {
        "date": {
          "title": "When the reading was taken: calendar date or date with time and UTC offset",
          "description": "When the reading was taken: calendar date or date with time and UTC offset.",
          "$ref": "#/$defs/DateTime"
        },
        "value": {
          "title": "Temperature in natural degrees of the series unit, at most 2 decimal places (e.g",
          "description": "Temperature in natural degrees of the series unit, at most 2 decimal places (e.g. 36.52).",
          "type": "number"
        },
        "excluded": {
          "title": "True when the user or app marked this reading disturbed/excluded from thermal-shift interpretation",
          "description": "True when the user or app marked this reading disturbed/excluded from thermal-shift interpretation.",
          "type": [
            "boolean",
            "null"
          ]
        },
        "excludeReason": {
          "title": "Optional coded or text-only reason for exclusion (only allowed when `excluded` is true)",
          "description": "Optional coded or text-only reason for exclusion (only allowed when `excluded` is true).",
          "anyOf": [
            {
              "anyOf": [
                {
                  "$ref": "#/$defs/ExcludeReason"
                },
                {
                  "$ref": "#/$defs/CodeableConcept"
                }
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "date",
        "value"
      ],
      "additionalProperties": false
    },
    "TemperatureUnit": {
      "title": "Temperature unit (UCUM)",
      "description": "Temperature unit (UCUM).",
      "type": "string",
      "oneOf": [
        {
          "const": "Cel",
          "description": "Degrees Celsius."
        },
        {
          "const": "[degF]",
          "description": "Degrees Fahrenheit."
        }
      ]
    },
    "TestResult": {
      "title": "A urine test result (progesterone or pregnancy)",
      "description": "A urine test result (progesterone or pregnancy).",
      "type": "string",
      "oneOf": [
        {
          "const": "negative",
          "description": "Negative."
        },
        {
          "const": "positive",
          "description": "Positive."
        },
        {
          "const": "indeterminate",
          "description": "The result could not be read."
        }
      ]
    },
    "UsualCycleLength": {
      "title": "Answers to \"usual-cycle-length\"",
      "description": "Answers to \"usual-cycle-length\".",
      "type": "string",
      "oneOf": [
        {
          "const": "<21",
          "description": "Less than 21 days.",
          "$comment": "concept http://loinc.org|LA14649-0"
        },
        {
          "const": "21-25",
          "description": "21-25 days.",
          "$comment": "concept http://loinc.org|LA14650-8"
        },
        {
          "const": "26-32",
          "description": "26-32 days.",
          "$comment": "concept http://loinc.org|LA14651-6"
        },
        {
          "const": "33-35",
          "description": "33-35 days.",
          "$comment": "concept http://loinc.org|LA14652-4"
        },
        {
          "const": "36-90",
          "description": "36-90 days.",
          "$comment": "concept http://loinc.org|LA14653-2"
        },
        {
          "const": ">90",
          "description": "More than 90 days.",
          "$comment": "concept http://loinc.org|LA14654-0"
        },
        {
          "const": "too-variable",
          "description": "Too variable to say.",
          "$comment": "concept http://loinc.org|LA14655-7"
        },
        {
          "const": "dont-know",
          "description": "Don't know.",
          "$comment": "concept http://loinc.org|LA12688-0"
        }
      ]
    },
    "YesNo": {
      "title": "Answers to \"period-in-last-year\"",
      "description": "Answers to \"period-in-last-year\".",
      "type": "string",
      "oneOf": [
        {
          "const": "yes",
          "description": "Yes.",
          "$comment": "concept http://loinc.org|LA33-6"
        },
        {
          "const": "no",
          "description": "No (explicit negative).",
          "$comment": "concept http://loinc.org|LA32-8"
        }
      ]
    }
  }
}
