{
  "openapi": "3.1.0",
  "info": {
    "title": "OHN-23 Clinical Terminology Service",
    "version": "1.0.0",
    "description": "Code systems, concept maps, value sets, licences, FHIR-style terminology operations and reports. Default deny; bearer authentication; every mutating request needs an Idempotency-Key header. Terminology content is served only for an exact published version whose licence is valid in the caller's country. No licensed terminology content ships with this module."
  },
  "servers": [
    {
      "url": "/api/ohn/v1/terminology"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/codes": {
      "get": {
        "operationId": "ohn-23_get_codes",
        "x-inventory-id": "OHN-23-API-001",
        "summary": "Browse concepts of one exact published version",
        "parameters": [
          {
            "name": "system",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Required when several versions are published (422 ambiguous_version)"
          },
          {
            "name": "code",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "language",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_deprecated",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          }
        ],
        "responses": {
          "200": {
            "description": "Page of concepts"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/validate-code": {
      "post": {
        "operationId": "ohn-23_post_validate-code",
        "x-inventory-id": "OHN-23-API-002",
        "summary": "Validate a code (and optionally its display)",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidateCodeCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "result true/false with reason, deprecation and display warnings"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/expand": {
      "post": {
        "operationId": "ohn-23_post_expand",
        "x-inventory-id": "OHN-23-API-003",
        "summary": "Expand an ACTIVE value set (pinned versions; licence re-checked at serve time)",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExpandCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Expansion with hash and drift flag"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/conceptmap/translate": {
      "post": {
        "operationId": "ohn-23_post_conceptmap-translate",
        "x-inventory-id": "OHN-23-API-004",
        "summary": "Translate through current, accepted, undisputed mappings only",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TranslateCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "matches, with counts withheld for disputed and licence-restricted targets"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/deprecation-impact": {
      "get": {
        "operationId": "ohn-23_get_deprecation-impact",
        "summary": "Dependants of deprecated concepts in one version",
        "parameters": [
          {
            "name": "system",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "deprecated codes, value sets, current mappings"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/artifacts": {
      "post": {
        "operationId": "ohn-23_post_artifacts",
        "summary": "Stage a terminology or evidence artifact (malware-scanned, content-referenced)",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "201": {
            "description": "Staged"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/licenses": {
      "post": {
        "operationId": "ohn-23_post_licenses",
        "summary": "Register licence evidence (F004; steward)",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LicenseCommand"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "operationId": "ohn-23_get_licenses",
        "parameters": [
          {
            "name": "license_state",
            "in": "query",
            "schema": {
              "enum": [
                "valid",
                "revoked",
                "expired",
                "country_out_of_scope"
              ]
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          }
        ],
        "responses": {
          "200": {
            "description": "Page"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/licenses/{id}": {
      "get": {
        "operationId": "ohn-23_get_licenses-id",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Licence with editions and history"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/licenses/{id}/revoke": {
      "post": {
        "operationId": "ohn-23_post_licenses-id-revoke",
        "summary": "Revoke: content under this licence is withheld immediately",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Revoked"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/licenses/{id}/renew": {
      "post": {
        "operationId": "ohn-23_post_licenses-id-renew",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Renewed"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/code-systems": {
      "post": {
        "operationId": "ohn-23_post_code-systems",
        "summary": "Register a code set import (F001; steward). State: uploaded",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CodeSystemImportCommand"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "operationId": "ohn-23_get_code-systems",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          }
        ],
        "responses": {
          "200": {
            "description": "Page"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/code-systems/{id}": {
      "get": {
        "operationId": "ohn-23_get_code-systems-id",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Version with history"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/code-systems/{id}/transitions": {
      "post": {
        "operationId": "ohn-23_post_code-systems-id-transitions",
        "summary": "W001 one gate at a time: checksum_verified, license_validated, concepts_indexed, published (emits terminology.version.published)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransitionCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Advanced"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/concept-maps": {
      "post": {
        "operationId": "ohn-23_post_concept-maps",
        "summary": "Propose a mapping (F002). The reviewer must differ from the proposer",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConceptMapCommand"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Candidate"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "operationId": "ohn-23_get_concept-maps",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "disputed",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          }
        ],
        "responses": {
          "200": {
            "description": "Page"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/concept-maps/{id}": {
      "get": {
        "operationId": "ohn-23_get_concept-maps-id",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Mapping with reviews and history"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/concept-maps/{id}/transitions": {
      "post": {
        "operationId": "ohn-23_post_concept-maps-id-transitions",
        "summary": "W002: clinical_review, accepted_or_rejected (named reviewer only; rejected is final), versioned (supersedes the previous mapping)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransitionCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Advanced"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/concept-maps/{id}/dispute": {
      "post": {
        "operationId": "ohn-23_post_concept-maps-id-dispute",
        "summary": "Dispute a versioned mapping (emits terminology.mapping.disputed; withheld from translation)",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Disputed"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/value-sets": {
      "post": {
        "operationId": "ohn-23_post_value-sets",
        "summary": "Submit a value set (F003; steward). The approver must differ from the author",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValueSetCommand"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Draft"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "operationId": "ohn-23_get_value-sets",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          }
        ],
        "responses": {
          "200": {
            "description": "Page"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/value-sets/{id}": {
      "get": {
        "operationId": "ohn-23_get_value-sets-id",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Value set with history"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/value-sets/{id}/transitions": {
      "post": {
        "operationId": "ohn-23_post_value-sets-id-transitions",
        "summary": "W003: expanded, tested (drift, empty and deprecated gates), approved (named approver), active",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransitionCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Advanced"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/reports/{reportId}": {
      "get": {
        "operationId": "ohn-23_get_reports-reportid",
        "parameters": [
          {
            "name": "reportId",
            "in": "path",
            "required": true,
            "schema": {
              "enum": [
                "OHN-23-R001",
                "OHN-23-R002",
                "OHN-23-R003"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Report"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/reports/{reportId}/export": {
      "post": {
        "operationId": "ohn-23_post_reports-reportid-export",
        "summary": "Signed, owner-only, single-use, five-minute export (csv|pdf)",
        "parameters": [
          {
            "name": "reportId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "201": {
            "description": "download_path"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/exports/{id}/download": {
      "get": {
        "operationId": "ohn-23_get_exports-id-download",
        "parameters": [
          {
            "$ref": "#/components/parameters/Id"
          }
        ],
        "responses": {
          "200": {
            "description": "File"
          },
          "410": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "parameters": {
      "Id": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "Page": {
        "name": "page",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1
        }
      },
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "maxLength": 255
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Typed error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "e.g. unknown_system, unknown_version, ambiguous_version, license_restricted, checksum_mismatch, expansion_drift, rejected_is_final"
          },
          "message": {
            "type": "string"
          },
          "fields": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "form": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Validation messages that belong to no single field (unrecognized keys, a body that is not an object)."
          },
          "current_version": {
            "type": "integer",
            "description": "On stale_version: the version now stored."
          },
          "candidates": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "On ambiguous_version: the published versions to choose from."
          },
          "details": {
            "type": "object",
            "description": "On expansion refusals: the system, version and unknown codes."
          },
          "state": {
            "type": "string"
          },
          "next_state": {
            "type": [
              "string",
              "null"
            ]
          },
          "codes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "trace_id": {
            "type": "string"
          }
        }
      },
      "ValidateCodeCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "system",
          "code"
        ],
        "properties": {
          "system": {
            "type": "string",
            "format": "uri"
          },
          "code": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "display": {
            "type": "string"
          },
          "language": {
            "type": "string"
          }
        }
      },
      "ExpandCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "value_set_uri"
        ],
        "properties": {
          "value_set_uri": {
            "type": "string",
            "format": "uri"
          },
          "version": {
            "type": "string"
          },
          "filter": {
            "type": "string"
          },
          "offset": {
            "type": "integer",
            "minimum": 0,
            "default": 0
          },
          "count": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1000,
            "default": 100
          }
        }
      },
      "TranslateCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source_system",
          "source_code",
          "target_system"
        ],
        "properties": {
          "source_system": {
            "type": "string",
            "format": "uri"
          },
          "source_code": {
            "type": "string"
          },
          "source_version": {
            "type": "string"
          },
          "target_system": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "LicenseCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "licensor",
          "license_scope",
          "country_scope",
          "evidence"
        ],
        "properties": {
          "licensor": {
            "type": "string",
            "format": "uuid"
          },
          "license_scope": {
            "type": "string"
          },
          "country_scope": {
            "type": "string",
            "description": "ISO 3166-1 alpha-2 codes separated by commas or spaces"
          },
          "expires_at": {
            "type": "string",
            "format": "date"
          },
          "evidence": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "CodeSystemImportCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code_system_uri",
          "version",
          "licensed_source",
          "effective_at",
          "artifact",
          "checksum"
        ],
        "properties": {
          "code_system_uri": {
            "type": "string",
            "format": "uri"
          },
          "version": {
            "type": "string"
          },
          "licensed_source": {
            "type": "string",
            "format": "uuid"
          },
          "effective_at": {
            "type": "string",
            "format": "date"
          },
          "artifact": {
            "type": "string",
            "format": "uuid"
          },
          "checksum": {
            "type": "string",
            "description": "SHA-256 hex, optional sha256: prefix"
          }
        }
      },
      "ConceptMapCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source_code",
          "source_system",
          "target_code",
          "target_system",
          "equivalence",
          "reviewer",
          "clinical_rationale"
        ],
        "properties": {
          "source_code": {
            "type": "string"
          },
          "source_system": {
            "type": "string",
            "format": "uri"
          },
          "source_version": {
            "type": "string"
          },
          "target_code": {
            "type": "string"
          },
          "target_system": {
            "type": "string",
            "format": "uri"
          },
          "target_version": {
            "type": "string"
          },
          "equivalence": {
            "enum": [
              "equivalent",
              "equal",
              "wider",
              "subsumes",
              "narrower",
              "specializes",
              "inexact",
              "relatedto",
              "disjoint"
            ]
          },
          "reviewer": {
            "type": "string",
            "format": "uuid"
          },
          "clinical_rationale": {
            "type": "string"
          }
        }
      },
      "ValueSetCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "value_set_uri",
          "version",
          "expansion_policy",
          "effective_at",
          "approver",
          "compose"
        ],
        "properties": {
          "value_set_uri": {
            "type": "string",
            "format": "uri"
          },
          "version": {
            "type": "string"
          },
          "expansion_policy": {
            "enum": [
              "pinned_snapshot",
              "pinned_recompute"
            ]
          },
          "effective_at": {
            "type": "string",
            "format": "date"
          },
          "approver": {
            "type": "string",
            "format": "uuid"
          },
          "compose": {
            "type": "array",
            "minItems": 1,
            "maxItems": 50,
            "items": {
              "type": "object",
              "required": [
                "system",
                "version"
              ],
              "properties": {
                "system": {
                  "type": "string"
                },
                "version": {
                  "type": "string"
                },
                "codes": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "descendants_of": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "TransitionCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expected_version",
          "to_state"
        ],
        "properties": {
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "to_state": {
            "type": "string"
          },
          "decision": {
            "enum": [
              "accepted",
              "rejected"
            ]
          },
          "reason": {
            "type": "string"
          }
        }
      },
      "ArtifactCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "kind",
          "media_type",
          "content_base64"
        ],
        "properties": {
          "kind": {
            "enum": [
              "terminology",
              "evidence"
            ]
          },
          "media_type": {
            "type": "string",
            "maxLength": 128
          },
          "content_base64": {
            "type": "string",
            "maxLength": 2600000
          }
        }
      },
      "LicenseRevokeCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expected_version",
          "reason"
        ],
        "properties": {
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string",
            "maxLength": 4096
          }
        }
      },
      "LicenseRenewCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expected_version",
          "expires_at",
          "evidence"
        ],
        "properties": {
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "evidence": {
            "type": "string",
            "format": "uuid"
          }
        }
      },
      "DisputeCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expected_version",
          "reason"
        ],
        "properties": {
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string",
            "maxLength": 4096
          }
        }
      },
      "ExportCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "format"
        ],
        "properties": {
          "format": {
            "enum": [
              "csv",
              "pdf"
            ]
          },
          "filters": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 2048
            }
          }
        }
      }
    }
  }
}
