{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://quaa.org/assets/quaa-registry-record.schema.json",
  "title": "QUAA Public Registry Record",
  "description": "Schema for genuine, authorized public decisions only. It contains no sample or invented records.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "record_id",
    "institution",
    "scheme",
    "review_scope",
    "outcome",
    "limitations",
    "validity",
    "panel",
    "decision_authority",
    "report_pdf",
    "evidence_version",
    "publication_timestamp",
    "verification_url",
    "latest_status",
    "status_history"
  ],
  "properties": {
    "record_id": {
      "type": "string",
      "minLength": 1
    },
    "institution": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "legal_name",
        "brand_name",
        "country",
        "related_party"
      ],
      "properties": {
        "legal_name": {
          "type": "string"
        },
        "brand_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "country": {
          "type": "string",
          "description": "ISO 3166-1 alpha-2 code."
        },
        "related_party": {
          "type": "object",
          "required": [
            "is_related",
            "disclosure"
          ],
          "properties": {
            "is_related": {
              "type": "boolean"
            },
            "disclosure": {
              "type": [
                "string",
                "null"
              ]
            },
            "relationship_type": {
              "type": [
                "string",
                "null"
              ]
            },
            "controls_applied": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "scheme": {
      "type": "object",
      "required": [
        "review_scheme",
        "version"
      ],
      "properties": {
        "review_scheme": {
          "type": "string"
        },
        "version": {
          "type": "string"
        }
      }
    },
    "review_scope": {
      "type": "object",
      "required": [
        "scope_statement",
        "entity_type",
        "programme_details",
        "award_granting_body",
        "delivery_sites",
        "delivery_mode"
      ],
      "properties": {
        "scope_statement": {
          "type": "string"
        },
        "entity_type": {
          "type": "string"
        },
        "programme_details": {
          "type": [
            "array",
            "string",
            "null"
          ]
        },
        "award_granting_body": {
          "type": [
            "string",
            "null"
          ]
        },
        "delivery_sites": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "delivery_mode": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "outcome": {
      "type": "string",
      "enum": [
        "positive",
        "positive_with_conditions",
        "negative"
      ]
    },
    "limitations": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "validity": {
      "type": "object",
      "required": [
        "effective_date",
        "expiry_date"
      ],
      "properties": {
        "effective_date": {
          "type": "string",
          "format": "date"
        },
        "expiry_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        }
      }
    },
    "panel": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "role",
          "qualifications",
          "independence_declaration"
        ],
        "properties": {
          "role": {
            "type": "string"
          },
          "qualifications": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "independence_declaration": {
            "type": "string"
          }
        }
      }
    },
    "decision_authority": {
      "type": "object",
      "required": [
        "authority_name",
        "decision_date",
        "independence_controls"
      ],
      "properties": {
        "authority_name": {
          "type": "string"
        },
        "decision_date": {
          "type": "string",
          "format": "date"
        },
        "independence_controls": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "report_pdf": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "evidence_version": {
      "type": "string"
    },
    "publication_timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "verification_url": {
      "type": "string",
      "format": "uri"
    },
    "latest_status": {
      "type": "string",
      "enum": [
        "positive_decision",
        "conditional",
        "negative_decision",
        "expired",
        "suspended",
        "withdrawn"
      ]
    },
    "status_history": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "status",
          "effective_date",
          "reason_category",
          "appeal_status"
        ],
        "properties": {
          "status": {
            "type": "string"
          },
          "effective_date": {
            "type": "string",
            "format": "date"
          },
          "reason_category": {
            "type": [
              "string",
              "null"
            ]
          },
          "appeal_status": {
            "type": [
              "string",
              "null"
            ]
          },
          "public_note": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    }
  }
}
