{
  "openapi": "3.1.0",
  "info": {
    "title": "OHN-59 Medication Safety Knowledge",
    "version": "1.1.0",
    "description": "Server paths are under /api/ohn/v1/medication-safety. Reconciled to the observed TypeScript behaviour (docs/program/java/ohn-59-contract-changes.md). Default deny: role AND purpose of use must match. Request bodies are strict (unknown fields are 422); the service validates them and answers 422 domain_validation_failed with details."
  },
  "servers": [
    {
      "url": "/api/ohn/v1/medication-safety"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/knowledge/active": {
      "get": {
        "operationId": "getActiveKnowledge",
        "summary": "Active knowledge version of the jurisdiction (configured:false when none)",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver",
          "clinician",
          "cds_service"
        ],
        "x-purposes": [
          "medication_safety_check",
          "decision_support",
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/versions": {
      "get": {
        "operationId": "listVersions",
        "summary": "Knowledge versions, newest first",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "in_review",
                "active",
                "retired"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      },
      "post": {
        "operationId": "createVersion",
        "summary": "Create a draft knowledge version from a document (F001)",
        "x-roles": [
          "knowledge_admin"
        ],
        "x-purposes": [
          "knowledge_management"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Strict JSON object, documented by components.schemas.CreateVersionCommand; validated by the service (unknown fields are 422).",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/versions/load-demo": {
      "post": {
        "operationId": "loadDemoKnowledge",
        "summary": "Load the labelled synthetic demo set as a draft (non-production only, OHN59_ALLOW_DEMO_KNOWLEDGE)",
        "x-roles": [
          "knowledge_admin"
        ],
        "x-purposes": [
          "knowledge_management"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Strict JSON object, documented by components.schemas.EmptyCommand; validated by the service (unknown fields are 422).",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/versions/{id}": {
      "get": {
        "operationId": "getVersion",
        "summary": "One version with settings and next actions",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/versions/{id}/entries": {
      "get": {
        "operationId": "listEntries",
        "summary": "Browse and search a section of a version",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "section",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "medications",
                "classes",
                "memberships",
                "allergy_cross_reactivity",
                "interactions",
                "dose_ranges",
                "pregnancy",
                "duplicate_groups",
                "lab_contraindications"
              ]
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/versions/{id}/diff": {
      "get": {
        "operationId": "diffVersion",
        "summary": "Difference to the previous (or a chosen) version",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "against",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/versions/{id}/history": {
      "get": {
        "operationId": "versionHistory",
        "summary": "State change history of a version",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/versions/{id}/submit": {
      "post": {
        "operationId": "submitVersion",
        "summary": "Submit a draft for review (needs a clean validation report)",
        "x-roles": [
          "knowledge_admin"
        ],
        "x-purposes": [
          "knowledge_management"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Strict JSON object, documented by components.schemas.SubmitCommand; validated by the service (unknown fields are 422).",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/versions/{id}/approve": {
      "post": {
        "operationId": "approveVersion",
        "summary": "Second-person approval and activation",
        "x-roles": [
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Strict JSON object, documented by components.schemas.ApproveCommand; validated by the service (unknown fields are 422).",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/versions/{id}/reject": {
      "post": {
        "operationId": "rejectVersion",
        "summary": "Send an in-review version back to draft",
        "x-roles": [
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Strict JSON object, documented by components.schemas.ReasonCommand; validated by the service (unknown fields are 422).",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/versions/{id}/retire": {
      "post": {
        "operationId": "retireVersion",
        "summary": "Retire the active version",
        "x-roles": [
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Strict JSON object, documented by components.schemas.ReasonCommand; validated by the service (unknown fields are 422).",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/importers": {
      "get": {
        "operationId": "listImporters",
        "summary": "Import formats and the CSV column contract",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/imports": {
      "get": {
        "operationId": "listImports",
        "summary": "Imports of the jurisdiction (latest 100)",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      },
      "post": {
        "operationId": "runImport",
        "summary": "Import a licensed knowledge export as a draft version",
        "x-roles": [
          "knowledge_admin"
        ],
        "x-purposes": [
          "knowledge_management"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Strict JSON object, documented by components.schemas.ImportCommand; validated by the service (unknown fields are 422).",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/knowledge/imports/{id}": {
      "get": {
        "operationId": "getImport",
        "summary": "One import with its validation report",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/checks/evaluate": {
      "post": {
        "operationId": "evaluateCheck",
        "summary": "Medication safety check for a patient (live)",
        "x-roles": [
          "clinician",
          "cds_service",
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "medication_safety_check",
          "decision_support",
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Strict JSON object, documented by components.schemas.EvaluateCommand; validated by the service (unknown fields are 422).",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/checks/simulate": {
      "post": {
        "operationId": "simulateCheck",
        "summary": "Check with typed hypothetical facts on any version (no patient read)",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Strict JSON object, documented by components.schemas.SimulateCommand; validated by the service (unknown fields are 422).",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/checks/evaluations": {
      "get": {
        "operationId": "listEvaluations",
        "summary": "Stored evaluations of the jurisdiction",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "live",
                "simulation"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/checks/evaluations/{id}": {
      "get": {
        "operationId": "getEvaluation",
        "summary": "One stored evaluation and its outcome",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/checks/evaluations/{id}/outcome": {
      "post": {
        "operationId": "recordOutcome",
        "summary": "Record what the prescriber did with a live evaluation (once)",
        "x-roles": [
          "clinician",
          "cds_service"
        ],
        "x-purposes": [
          "medication_safety_check",
          "decision_support"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Strict JSON object, documented by components.schemas.OutcomeCommand; validated by the service (unknown fields are 422).",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/reports": {
      "get": {
        "operationId": "listReports",
        "summary": "Report catalog",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/reports/{reportId}": {
      "get": {
        "operationId": "runReport",
        "summary": "Run a report (R001 coverage, R002 warnings, R003 change ledger)",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "reportId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "OHN-59-R001",
                "OHN-59-R002",
                "OHN-59-R003"
              ]
            }
          },
          {
            "name": "version_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/reports/{reportId}/export": {
      "get": {
        "operationId": "exportReport",
        "summary": "Signed CSV export (HMAC-SHA256 in X-OHN59-Signature)",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "name": "reportId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "OHN-59-R001",
                "OHN-59-R002",
                "OHN-59-R003"
              ]
            }
          },
          {
            "name": "version_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/audit": {
      "get": {
        "operationId": "listAudit",
        "summary": "Latest 200 audit records of the jurisdiction",
        "x-roles": [
          "knowledge_admin",
          "knowledge_approver"
        ],
        "x-purposes": [
          "knowledge_management",
          "knowledge_governance"
        ],
        "tags": [
          "OHN-59"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    },
    "/admin/outbox/relay": {
      "post": {
        "operationId": "relayOutbox",
        "summary": "Report the pending outbox (delivery is done by the platform relay)",
        "x-roles": [
          "knowledge_admin"
        ],
        "x-purposes": [
          "knowledge_management"
        ],
        "tags": [
          "OHN-59"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": false,
          "description": "Strict JSON object, documented by components.schemas.EmptyCommand; validated by the service (unknown fields are 422).",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Result"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy (role, purpose, second person, test checks disabled)"
          },
          "404": {
            "description": "Not found in the caller's jurisdiction"
          },
          "409": {
            "description": "Version conflict, invalid transition, validation failed or idempotency mismatch"
          },
          "413": {
            "description": "Payload too large"
          },
          "422": {
            "description": "Domain validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Not configured or dependency unavailable (fail closed)"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        }
      }
    },
    "schemas": {
      "Result": {
        "type": "object",
        "additionalProperties": true
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "EmptyCommand": {
        "type": "object",
        "additionalProperties": false,
        "properties": {}
      },
      "CreateVersionCommand": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "document": {
            "$ref": "#/components/schemas/KnowledgeDocument"
          }
        },
        "required": [
          "document"
        ]
      },
      "KnowledgeDocument": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "label",
          "notice",
          "source",
          "settings",
          "medications",
          "classes",
          "memberships",
          "allergy_cross_reactivity",
          "interactions",
          "dose_ranges",
          "pregnancy",
          "duplicate_groups",
          "lab_contraindications"
        ],
        "description": "Sections are arrays of strict objects, validated by the service (see docs/program/java/ohn-59-analysis.md and modules/OHN-59/docs/import-contract.md). source.kind synthetic_demo is refused here.",
        "properties": {
          "label": {
            "type": "string"
          },
          "notice": {
            "type": "string"
          },
          "source": {
            "type": "object",
            "additionalProperties": true
          },
          "settings": {
            "type": "object",
            "additionalProperties": true
          },
          "medications": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "classes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "memberships": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "allergy_cross_reactivity": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "interactions": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "dose_ranges": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "pregnancy": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "duplicate_groups": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "lab_contraindications": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "SubmitCommand": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "expected_row_version": {
            "type": "integer",
            "minimum": 1
          },
          "note": {
            "type": "string",
            "minLength": 0,
            "maxLength": 1000
          }
        },
        "required": [
          "expected_row_version"
        ]
      },
      "ApproveCommand": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "expected_row_version": {
            "type": "integer",
            "minimum": 1
          },
          "approval_ref": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "note": {
            "type": "string",
            "minLength": 0,
            "maxLength": 1000
          }
        },
        "required": [
          "expected_row_version",
          "approval_ref"
        ]
      },
      "ReasonCommand": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "expected_row_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 1000
          }
        },
        "required": [
          "expected_row_version",
          "reason"
        ]
      },
      "ImportCommand": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "ohn59.csv.v1",
              "ohn59.json.v1"
            ]
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "notice": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "source": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "version": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "licence_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              }
            },
            "required": [
              "name",
              "version",
              "licence_ref"
            ]
          },
          "settings": {
            "type": "object",
            "additionalProperties": true
          },
          "files": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 20000000
            },
            "description": "ohn59.csv.v1: one CSV text per section"
          },
          "document": {
            "description": "ohn59.json.v1: knowledge sections"
          }
        },
        "required": [
          "format",
          "label",
          "source"
        ]
      },
      "EvaluateCommand": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "patient_id": {
            "type": "string",
            "format": "uuid"
          },
          "proposed": {
            "type": "array",
            "minItems": 1,
            "maxItems": 30,
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "context": {
            "type": "object",
            "additionalProperties": true
          },
          "checks": {
            "type": "array",
            "minItems": 1,
            "maxItems": 8,
            "items": {
              "type": "string",
              "enum": [
                "knowledge_coverage",
                "allergy",
                "interaction",
                "dose",
                "pregnancy",
                "breastfeeding",
                "duplicate_therapy",
                "lab_contraindication"
              ]
            }
          },
          "caller": {
            "type": "object",
            "additionalProperties": true
          },
          "acting_for": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "principal_id": {
                "type": "string",
                "format": "uuid"
              },
              "organization_id": {
                "type": "string",
                "format": "uuid"
              }
            },
            "required": [
              "principal_id",
              "organization_id"
            ]
          }
        },
        "required": [
          "patient_id",
          "proposed"
        ]
      },
      "SimulateCommand": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "version_id": {
            "type": "string",
            "format": "uuid"
          },
          "facts": {
            "type": "object",
            "additionalProperties": true
          },
          "proposed": {
            "type": "array",
            "minItems": 1,
            "maxItems": 30,
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "version_id",
          "facts",
          "proposed"
        ]
      },
      "OutcomeCommand": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "signed",
              "abandoned",
              "changed"
            ]
          },
          "overrides": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "warning_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 300
                },
                "reason": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 1000
                }
              },
              "required": [
                "warning_id",
                "reason"
              ]
            }
          }
        },
        "required": [
          "action"
        ]
      }
    }
  }
}