{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://publicschema.org/metrics/Stratifier.schema.json",
  "title": "Stratifier",
  "description": "A disaggregation expression evaluated against the populations of a MetricCalculation. Stratifiers may nest via components, allowing cross-cutting disaggregations such as by-sex-and-age.\n",
  "type": "object",
  "properties": {
    "stratifier_code": {
      "type": "string",
      "description": "A short identifier for a stratifier, used when emitting per-stratum rates (for example, 'by-sex', 'by-age-band')."
    },
    "language": {
      "type": "string",
      "description": "The IANA media type identifying the language of a criteria expression: application/sql, application/vtl, text/cql, text/fhirpath. PublicSchema pins the media type so consumers know which engine to invoke; it does not pick a winner.\n"
    },
    "criteria": {
      "type": "string",
      "description": "A criteria expression in the language identified by the paired language slot. May be inline source code or a reference of the form @ref:LibraryName.Symbol resolved against the calculation's libraries list.\n"
    },
    "components": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "$ref": "https://publicschema.org/metrics/Stratifier.schema.json"
          },
          {
            "type": "string",
            "description": "URI or identifier reference"
          }
        ],
        "description": "Nested stratifiers that compose with their parent (for example, by-sex-and-age nests inside by-sex)."
      }
    }
  }
}
