{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://vaccinedatanavigator.org/schemas/ae_mechanism.schema.json",
  "title": "Adverse Event Mechanism Catalog",
  "description": "Reusable biological mechanism definitions for vaccine-associated adverse events. Referenced by injury table entries via mechanism_id.",
  "type": "object",
  "required": ["_meta", "mechanisms"],
  "additionalProperties": false,
  "properties": {
    "_meta": {
      "type": "object",
      "required": ["description", "lastUpdated", "schemaVersion"],
      "additionalProperties": true,
      "properties": {
        "description": { "type": "string" },
        "lastUpdated": { "type": "string", "format": "date" },
        "schemaVersion": { "type": "string" },
        "sources": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    },
    "mechanisms": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": { "$ref": "#/$defs/mechanism" }
    }
  },
  "$defs": {
    "literatureCitation": {
      "type": "object",
      "required": ["label", "url"],
      "additionalProperties": false,
      "properties": {
        "label": { "type": "string" },
        "url": { "type": "string", "format": "uri" },
        "year": { "type": "integer" },
        "pmid": { "type": "string" },
        "type": {
          "type": "string",
          "enum": [
            "cohort_study",
            "case_series",
            "systematic_review",
            "narrative_review",
            "surveillance",
            "regulatory",
            "mechanism",
            "case_report",
            "iom_report"
          ]
        }
      }
    },
    "mechanism": {
      "type": "object",
      "required": [
        "mechanism_id",
        "name",
        "category",
        "summary",
        "evidence_level"
      ],
      "additionalProperties": false,
      "properties": {
        "mechanism_id": {
          "type": "string",
          "pattern": "^[a-z0-9_]+$"
        },
        "name": { "type": "string" },
        "category": {
          "type": "string",
          "enum": [
            "hypersensitivity",
            "molecular_mimicry",
            "innate_inflammation",
            "live_replication",
            "procedural",
            "vasovagal",
            "immune_complex",
            "toxin_mediated",
            "endothelial",
            "unknown",
            "other"
          ]
        },
        "summary": { "type": "string" },
        "pathway_steps": {
          "type": "array",
          "items": { "type": "string" }
        },
        "evidence_level": {
          "type": "string",
          "enum": ["High", "Moderate", "Low", "Very Low", "Hypothetical"]
        },
        "applies_to_platforms": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "any",
              "live_attenuated",
              "inactivated",
              "subunit",
              "conjugate",
              "toxoid",
              "mrna",
              "viral_vector",
              "adjuvanted",
              "oral",
              "intranasal"
            ]
          }
        },
        "typical_time_window_days": {
          "type": "array",
          "items": { "type": "integer" },
          "minItems": 2,
          "maxItems": 2
        },
        "supporting_literature": {
          "type": "array",
          "items": { "$ref": "#/$defs/literatureCitation" }
        },
        "notes": { "type": "string" }
      }
    }
  }
}