{
  "openapi": "3.1.0",
  "info": {
    "title": "OHN-14 International Patient Summary and Emergency View",
    "version": "1.0.0",
    "description": "Server paths are under /api/ohn/v1/ips. Default deny: role AND purpose must match. Inventory paths OHN-14-API-001..003 are mapped to this disjoint prefix (see ADR-0001)."
  },
  "servers": [
    {
      "url": "/api/ohn/v1/ips"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/patients/{id}/ips": {
      "get": {
        "operationId": "getCurrentIps",
        "summary": "Current released International Patient Summary",
        "x-inventory-id": "OHN-14-API-001",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/patients/{id}/critical-info": {
      "get": {
        "operationId": "getCriticalInfo",
        "summary": "Critical health information (blood group, Rh, haemoglobin genotype, allergies, active problems) read live from OHN-10; also embedded in the emergency view",
        "x-inventory-id": "OHN-14-API-006",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/patients/{id}/ips/generate": {
      "post": {
        "operationId": "generateIps",
        "summary": "Compose and validate a summary snapshot (F001, W001)",
        "x-inventory-id": "OHN-14-API-002",
        "x-roles": [
          "licensed_clinician"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateCommand"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/documents": {
      "get": {
        "operationId": "listDocuments",
        "summary": "Summary documents",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 32
            }
          },
          {
            "name": "patient_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/documents/{id}": {
      "get": {
        "operationId": "getDocument",
        "summary": "Document with completeness, validation and gap acknowledgments",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/documents/{id}/release": {
      "post": {
        "operationId": "releaseDocument",
        "summary": "Release (and optionally sign) a validated summary",
        "x-roles": [
          "licensed_clinician"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReleaseCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/documents/{id}/gap-acknowledgments": {
      "post": {
        "operationId": "acknowledgeGap",
        "summary": "Acknowledge a missing required section (F003)",
        "x-roles": [
          "licensed_clinician"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GapCommand"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/exports": {
      "post": {
        "operationId": "createExport",
        "summary": "Export the current summary to a recipient (F002)",
        "x-roles": [
          "licensed_clinician"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExportRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      },
      "get": {
        "operationId": "listExports",
        "summary": "Export access history",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "patient_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "recipient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/exports/{id}/package": {
      "get": {
        "operationId": "readExportPackage",
        "summary": "Read an export package (counted and audited)",
        "x-roles": [
          "licensed_clinician"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/emergency-requests": {
      "post": {
        "operationId": "requestEmergencyView",
        "summary": "Issue a limited emergency view (W002)",
        "x-roles": [
          "licensed_clinician"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmergencyCommand"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      },
      "get": {
        "operationId": "listEmergency",
        "summary": "Emergency accesses (own, or the review queue for reviewers)",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "review",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "pending"
              ]
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/emergency-records/{id}": {
      "get": {
        "operationId": "getEmergencyRecord",
        "summary": "Emergency record; the limited view only to the requester inside the window",
        "x-inventory-id": "OHN-14-API-003",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          },
          "410": {
            "description": "Expired or already consumed"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/emergency-records/{id}/review": {
      "post": {
        "operationId": "reviewEmergency",
        "summary": "Review an emergency disclosure",
        "x-roles": [
          "emergency_reviewer"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReviewCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/propagations": {
      "post": {
        "operationId": "openPropagation",
        "summary": "Open an amendment propagation case (W003)",
        "x-roles": [
          "licensed_clinician",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PropagationOpenCommand"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      },
      "get": {
        "operationId": "listPropagations",
        "summary": "Propagation cases",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 32
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/propagations/{id}/transitions": {
      "post": {
        "operationId": "stepPropagation",
        "summary": "Advance a propagation case",
        "x-roles": [
          "licensed_clinician",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PropagationStepCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/policy": {
      "get": {
        "operationId": "getPolicy",
        "summary": "Jurisdiction IPS and emergency policy",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      },
      "post": {
        "operationId": "setPolicy",
        "summary": "Set the jurisdiction policy",
        "x-roles": [
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PolicyCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/maintenance/drain-outbox": {
      "post": {
        "operationId": "drainOutbox",
        "summary": "Report pending outbox events (no sink: nothing claimed delivered)",
        "x-roles": [
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/report-catalog": {
      "get": {
        "operationId": "reportCatalog",
        "summary": "Available reports",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/reports/{reportId}": {
      "get": {
        "operationId": "runReport",
        "summary": "Run report R001..R003",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer",
          "ips_steward"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "reportId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "OHN-14-R001",
                "OHN-14-R002",
                "OHN-14-R003"
              ]
            }
          },
          {
            "name": "profile",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 16
            }
          },
          {
            "name": "recipient",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 36
            }
          },
          {
            "name": "jurisdiction",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 36
            }
          },
          {
            "name": "organization",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 36
            }
          },
          {
            "name": "period_from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 10
            }
          },
          {
            "name": "period_to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 10
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/reports/{reportId}/export": {
      "post": {
        "operationId": "exportReport",
        "summary": "Create a signed single-use report export",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "reportId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "OHN-14-R001",
                "OHN-14-R002",
                "OHN-14-R003"
              ]
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExportCommand"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    },
    "/report-exports/{token}": {
      "get": {
        "operationId": "downloadReportExport",
        "summary": "Download a report export once",
        "x-roles": [
          "licensed_clinician",
          "emergency_reviewer"
        ],
        "x-purpose": "international_patient_summary",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{20,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "CSV or PDF, once",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or missing Idempotency-Key"
          },
          "401": {
            "description": "Unauthenticated"
          },
          "403": {
            "description": "Denied by policy"
          },
          "404": {
            "description": "Not found / not disclosed"
          },
          "409": {
            "description": "Version conflict, illegal transition or idempotency mismatch"
          },
          "422": {
            "description": "Domain validation failed or domain refusal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Dependency unavailable (fail closed)"
          },
          "410": {
            "description": "Expired or already consumed"
          }
        },
        "tags": [
          "OHN-14"
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 8,
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9_.:-]+$"
        }
      }
    },
    "schemas": {
      "GenerateCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "clinical_context",
          "purpose",
          "language",
          "include_sections"
        ],
        "properties": {
          "clinical_context": {
            "type": "string",
            "format": "uuid"
          },
          "purpose": {
            "type": "string",
            "enum": [
              "continuity_of_care",
              "emergency_preparedness",
              "cross_border",
              "referral"
            ]
          },
          "language": {
            "type": "string",
            "enum": [
              "en",
              "fr"
            ]
          },
          "include_sections": {
            "type": "array",
            "minItems": 1,
            "maxItems": 14,
            "items": {
              "type": "string",
              "enum": [
                "allergies",
                "medications",
                "problems",
                "immunizations",
                "results",
                "procedures",
                "devices",
                "vital_signs",
                "plan_of_care",
                "history_of_illness",
                "pregnancy",
                "social_history",
                "functional_status",
                "advance_directives"
              ]
            }
          }
        }
      },
      "ReleaseCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "expected_version",
          "reason"
        ],
        "properties": {
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 2000
          },
          "sign": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "GapCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "patient_ref",
          "missing_section",
          "responsible_clinician",
          "acknowledgment"
        ],
        "properties": {
          "patient_ref": {
            "type": "string",
            "format": "uuid"
          },
          "missing_section": {
            "type": "string",
            "enum": [
              "allergies",
              "medications",
              "problems",
              "immunizations",
              "results",
              "procedures",
              "devices",
              "vital_signs",
              "plan_of_care",
              "history_of_illness",
              "pregnancy",
              "social_history",
              "functional_status",
              "advance_directives"
            ]
          },
          "responsible_clinician": {
            "type": "string",
            "format": "uuid"
          },
          "acknowledgment": {
            "type": "string",
            "minLength": 10,
            "maxLength": 2000
          }
        }
      },
      "ExportRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "patient_id",
          "recipient_org",
          "export_profile_version",
          "consent_or_basis_ref",
          "reason"
        ],
        "properties": {
          "patient_id": {
            "type": "string",
            "format": "uuid"
          },
          "recipient_org": {
            "type": "string",
            "format": "uuid"
          },
          "export_profile_version": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "consent_or_basis_ref": {
            "type": "string",
            "format": "uuid"
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 2000
          }
        }
      },
      "EmergencyCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "patient_id",
          "reason"
        ],
        "properties": {
          "patient_id": {
            "type": "string",
            "format": "uuid"
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 2000
          }
        }
      },
      "ReviewCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "outcome",
          "expected_version",
          "reason"
        ],
        "properties": {
          "outcome": {
            "type": "string",
            "enum": [
              "appropriate",
              "inappropriate"
            ]
          },
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 2000
          }
        }
      },
      "PropagationOpenCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "document_id",
          "source_ref",
          "reason"
        ],
        "properties": {
          "document_id": {
            "type": "string",
            "format": "uuid"
          },
          "source_ref": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 2000
          }
        }
      },
      "PropagationStepCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "to_state",
          "expected_version",
          "reason"
        ],
        "properties": {
          "to_state": {
            "type": "string",
            "enum": [
              "snapshot_expired",
              "new_snapshot_built",
              "recipient_notice"
            ]
          },
          "expected_version": {
            "type": "integer",
            "minimum": 1
          },
          "reason": {
            "type": "string",
            "minLength": 10,
            "maxLength": 2000
          }
        }
      },
      "PolicyCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "required_sections",
          "emergency_sections",
          "emergency_window_minutes",
          "export_profile_version",
          "require_signature",
          "approval_reference"
        ],
        "properties": {
          "required_sections": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "enum": [
                "allergies",
                "medications",
                "problems",
                "immunizations",
                "results",
                "procedures",
                "devices",
                "vital_signs",
                "plan_of_care",
                "history_of_illness",
                "pregnancy",
                "social_history",
                "functional_status",
                "advance_directives"
              ]
            }
          },
          "emergency_sections": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "enum": [
                "allergies",
                "medications",
                "problems",
                "immunizations",
                "results",
                "procedures",
                "devices",
                "vital_signs",
                "plan_of_care",
                "history_of_illness",
                "pregnancy",
                "social_history",
                "functional_status",
                "advance_directives"
              ]
            }
          },
          "emergency_window_minutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 1440
          },
          "export_profile_version": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "require_signature": {
            "type": "boolean"
          },
          "approval_reference": {
            "type": "string",
            "minLength": 3,
            "maxLength": 256
          },
          "expected_version": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "ExportCommand": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "format"
        ],
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "csv",
              "pdf"
            ]
          },
          "filters": {
            "type": "object",
            "description": "Report filters (profile, status, recipient, jurisdiction, organization, period_from, period_to); unknown keys are refused with 422"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "details": {
            "type": "object"
          }
        }
      }
    }
  }
}
