{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://fhir.chelseakr.com/capabilities.schema.json",
  "title": "Declared FHIR capabilities, one file per endpoint",
  "description": "An observation of what this endpoint's CapabilityStatement declared when it was retrieved. Nothing listed here was requested or exercised, so none of it is a claim that the declared interaction works.",
  "type": "object",
  "required": [
    "schema_version",
    "endpoint_id",
    "name",
    "generated_at",
    "state",
    "state_detail",
    "retrieved_on",
    "document_sha256",
    "fhir_version",
    "unreadable_declarations",
    "counts",
    "rows",
    "note"
  ],
  "properties": {
    "schema_version": {
      "type": "integer",
      "enum": [
        1
      ]
    },
    "endpoint_id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "generated_at": {
      "type": "string"
    },
    "state": {
      "type": "string",
      "enum": [
        "not_retrieved",
        "unreadable",
        "declares_nothing",
        "declared"
      ],
      "description": "not_retrieved: no vantage retrieved a CapabilityStatement on this run; unreadable: a document was retrieved and could not be read as a CapabilityStatement; declares_nothing: a CapabilityStatement was read and declares nothing this project can list; declared: a CapabilityStatement was read and its declarations are listed"
    },
    "state_detail": {
      "type": "string"
    },
    "retrieved_on": {
      "type": [
        "string",
        "null"
      ],
      "description": "Date of the run that retrieved the document; null when nothing was retrieved"
    },
    "document_sha256": {
      "type": [
        "string",
        "null"
      ],
      "description": "SHA-256 of the retrieved bytes, including a document that could not be read; null when nothing was retrieved"
    },
    "fhir_version": {
      "type": [
        "string",
        "null"
      ]
    },
    "unreadable_declarations": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Entries in the server block that could not be read, counted and not listed; null when there was no declaration to read"
    },
    "counts": {
      "type": [
        "object",
        "null"
      ],
      "description": "Null, never zeros, when there is no declaration to count",
      "required": [
        "resources",
        "interaction_entries_declared",
        "interaction_rows",
        "search_parameters",
        "operations",
        "profiles",
        "rows"
      ],
      "properties": {
        "resources": {
          "type": "integer"
        },
        "interaction_entries_declared": {
          "type": "integer"
        },
        "interaction_rows": {
          "type": "integer"
        },
        "search_parameters": {
          "type": "integer"
        },
        "operations": {
          "type": "integer"
        },
        "profiles": {
          "type": "integer"
        },
        "rows": {
          "type": "integer"
        }
      }
    },
    "rows": {
      "type": [
        "array",
        "null"
      ],
      "description": "Every declaration, flat. Null when nothing could be read; an empty list only for a CapabilityStatement that declares nothing",
      "items": {
        "type": "object",
        "required": [
          "kind",
          "resource",
          "name",
          "type",
          "definition"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "resource",
              "interaction",
              "search_parameter",
              "operation",
              "profile"
            ]
          },
          "resource": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null for a declaration made on the whole server"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": [
              "string",
              "null"
            ]
          },
          "definition": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "note": {
      "type": "string"
    }
  }
}