# OHN-62 OpenAPI 3.1 contract (W28 triage contracts, 2026-11-23). Source of truth for W30 (server/modules/ohn-62) and W31 (frontend).
openapi: 3.1.0
info:
  title: OHN-62 Pre-consultation Questionnaires
  version: 1.3.0
  description: 'Department- and complaint-specific questionnaires supplied as versioned configuration by the jurisdiction or facility; patient capture before arrival (portal, phone /p, SMS link, USSD) or
    at check-in (kiosk, staff-assisted) in EN and FR; configured red-flag rules signalled to OHN-61; responses filed in OHN-13 as FHIR QuestionnaireResponse. No clinical question bank is part of this contract.
    Deployable: care-exchange. Module key: preconsult. Tables: ohn62_*. Every write needs Idempotency-Key; strict bodies (unknown keys 422).'
servers:
- url: https://opeshealthnetwork.com
security:
- bearer: []
paths:
  /api/ohn/v1/pre-consult/definitions:
    get:
      operationId: OHN_62_API_001
      summary: List questionnaire definitions (jurisdiction scope, or the caller's facility)
      x-roles:
      - preconsult_governance_admin
      - preconsult_admin
      x-purpose: preconsult_configuration
      security:
      - bearer: []
      parameters:
      - name: jurisdiction_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
      - name: facility_id
        in: query
        required: false
        schema:
          type: string
          format: uuid
      - name: department_kind
        in: query
        required: false
        schema:
          type: string
          enum:
          - emergency
          - opd_general
          - eye
          - dental
          - maternity
          - paediatrics
          - cardiology
          - diabetes
          - ent
          - dermatology
          - mental_health
          - surgery
          - orthopaedics
          - anc_pnc
          - obgyn
          - neurology
          - nephrology
          - gastroenterology
          - respiratory
          - urology
          - hiv_art
          - oncology
          - immunization
          - laboratory
          - imaging
          - pharmacy
          - family_planning
          - other
      - name: state
        in: query
        required: false
        schema:
          type: string
          enum:
          - draft
          - active
          - retired
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Definition'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    post:
      operationId: OHN_62_API_002
      summary: 'Load a definition as draft. Validates: unique link_ids, enable_when refers to an earlier item with a compatible answer type, options for choice items, unit for quantity, EN and FR text everywhere,
        red-flag conditions refer to existing items, complaint and body-site codes valid in OHN-23'
      x-roles:
      - preconsult_governance_admin
      - preconsult_admin
      x-purpose: preconsult_configuration
      security:
      - bearer: []
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      - name: scope
        in: query
        required: true
        schema:
          type: string
          enum:
          - jurisdiction
          - facility
      - name: jurisdiction_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
      - name: facility_id
        in: query
        required: false
        schema:
          type: string
          format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QuestionnaireDocument'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Definition'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: preconsult_admin may only create facility scope for their own facility
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: upstream_unavailable (OHN-23 or OHN-61 department check)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/definitions/{definition_id}:
    get:
      operationId: OHN_62_API_003
      summary: Get one definition (full, with red-flag rules)
      x-roles:
      - preconsult_governance_admin
      - preconsult_admin
      x-purpose: preconsult_configuration
      security:
      - bearer: []
      parameters:
      - name: definition_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Definition'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/definitions/{definition_id}/activate:
    post:
      operationId: OHN_62_API_004
      summary: Activate an approved definition (state in_review with decision approved); retires the previous active version with the same key
      x-roles:
      - preconsult_governance_admin
      - preconsult_admin
      x-purpose: preconsult_configuration
      security:
      - bearer: []
      parameters:
      - name: definition_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Activate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Definition'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed or definition_not_approved (a real definition cannot use the demo approval_ref); review_required (no approved review), definition_expired; translation_not_reviewed
            (EN and FR must be reviewed for a non-demo definition); candidate_bank_not_activatable (a candidate-bank definition needs review, approval_ref and reviewed translations like any other)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/definitions/{definition_id}/retire:
    post:
      operationId: OHN_62_API_005
      summary: Retire a definition (open responses keep their version)
      x-roles:
      - preconsult_governance_admin
      - preconsult_admin
      x-purpose: preconsult_configuration
      security:
      - bearer: []
      parameters:
      - name: definition_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Reasoned'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Definition'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/definitions/load-demo:
    post:
      operationId: OHN_62_API_006
      summary: Load and activate the SYNTHETIC demo questionnaires (eye, dental, general consultation, diabetes, cardiology). NOT clinically approved. Only when OHN62_ALLOW_DEMO_CONFIG=true and not production
      x-roles:
      - preconsult_governance_admin
      x-purpose: preconsult_configuration
      security:
      - bearer: []
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      - name: jurisdiction_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Definition'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: demo_config_disabled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/complaints:
    get:
      operationId: OHN_62_API_007
      summary: Presenting complaints that have a questionnaire for a department (for the check-in picker)
      x-roles:
      - receptionist
      - triage_officer
      - clinician
      - patient
      - kiosk_device
      x-purpose: preconsult_capture
      security:
      - bearer: []
      parameters:
      - name: department_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Complaint'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/departments/{department_id}/questionnaire:
    get:
      operationId: OHN_62_API_008
      summary: 'Resolve the active questionnaire: facility+department+complaint, then facility+department, then jurisdiction+department kind+complaint, then jurisdiction+department kind. 404 no_questionnaire
        when none (check-in continues without one)'
      x-roles:
      - receptionist
      - triage_officer
      - clinician
      - patient
      - kiosk_device
      x-purpose: preconsult_capture
      security:
      - bearer: []
      parameters:
      - name: department_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: complaint_system
        in: query
        required: false
        schema:
          type: string
          enum:
          - snomed_ct
          - local
      - name: complaint_code
        in: query
        required: false
        schema:
          type: string
      - name: language
        in: query
        required: false
        schema:
          type: string
          enum:
          - en
          - fr
      - name: visit_type
        in: query
        required: false
        schema:
          type: string
          enum:
          - new
          - follow_up
          - review
      - name: age_months
        in: query
        required: false
        schema:
          type: integer
          minimum: 0
      - name: pregnancy_context
        in: query
        required: false
        schema:
          type: string
          enum:
          - anc
          - pnc
      - name: audience
        in: query
        required: false
        schema:
          type: string
          enum:
          - patient
          - nurse
          - clinician
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Resolved'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: no_questionnaire, or department not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/responses:
    post:
      operationId: OHN_62_API_009
      summary: Start a response at check-in (kiosk or staff-assisted) or in the portal
      x-roles:
      - receptionist
      - triage_officer
      - patient
      - kiosk_device
      x-purpose: preconsult_capture
      security:
      - bearer: []
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponseStart'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: patient may start only for themselves (or an OHN-19 representative)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: no_questionnaire
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: an in-progress response exists for this patient and department (details.response_id)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed, private_capture_required (a private definition started on a kiosk), definition_not_applicable (ResponseStart.definition_id not active or not for this department)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    get:
      operationId: OHN_62_API_010
      summary: 'List responses: by ticket, by patient, or by appointment (staff; OHN-16 evaluated with purpose treatment, every read audited)'
      x-roles:
      - receptionist
      - triage_officer
      - clinician
      x-purpose: preconsult_review
      security:
      - bearer: []
      parameters:
      - name: ticket_id
        in: query
        required: false
        schema:
          type: string
          format: uuid
      - name: patient_id
        in: query
        required: false
        schema:
          type: string
          format: uuid
      - name: appointment_id
        in: query
        required: false
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Response'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: exactly one filter is required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/responses/{response_id}:
    get:
      operationId: OHN_62_API_011
      summary: Get a response (staff; patient sees own without red_flags)
      x-roles:
      - receptionist
      - triage_officer
      - clinician
      - patient
      x-purpose: preconsult_review
      security:
      - bearer: []
      parameters:
      - name: response_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/responses/{response_id}/answers:
    put:
      operationId: OHN_62_API_012
      summary: Save answers (partial saves allowed while in_progress). Answers to items hidden by enable_when are dropped
      x-roles:
      - receptionist
      - triage_officer
      - patient
      - kiosk_device
      x-purpose: preconsult_capture
      security:
      - bearer: []
      parameters:
      - name: response_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnswersPut'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: 'answer_invalid: wrong type, option not in list, number outside configured min/max, text too long, unknown link_id; decline_not_allowed'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/responses/{response_id}/submit:
    post:
      operationId: OHN_62_API_013
      summary: 'Submit: checks required visible items, evaluates the configured red-flag rules, files a FHIR QuestionnaireResponse in OHN-13, and signals OHN-61 when linked to a ticket'
      x-roles:
      - receptionist
      - triage_officer
      - patient
      - kiosk_device
      x-purpose: preconsult_capture
      security:
      - bearer: []
      parameters:
      - name: response_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Versioned'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: 'validation_failed: details.missing lists required visible link_ids'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/responses/{response_id}/amend:
    post:
      operationId: OHN_62_API_014
      summary: Staff amend after submission with reason (new OHN-13 document version; previous kept)
      x-roles:
      - triage_officer
      - clinician
      x-purpose: preconsult_review
      security:
      - bearer: []
      parameters:
      - name: response_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AmendRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/responses/{response_id}/entered-in-error:
    post:
      operationId: OHN_62_API_015
      summary: Mark a response entered in error (wrong patient); OHN-13 document is marked too
      x-roles:
      - triage_officer
      - clinician
      x-purpose: preconsult_review
      security:
      - bearer: []
      parameters:
      - name: response_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Reasoned'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/invitations:
    post:
      operationId: OHN_62_API_016
      summary: Invite the patient to answer before arrival via OHN-53 (SMS link, USSD session or portal notice) for an OHN-54 appointment or an open ticket
      x-roles:
      - receptionist
      - triage_officer
      - appointments_service
      x-purpose: preconsult_invitation
      security:
      - bearer: []
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvitationCreate'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invitation'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: no_questionnaire
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed or channel_not_supported (ussd needs an ussd_compatible definition); department_id missing for an appointment invitation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: upstream_unavailable (OHN-53 or OHN-54)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/invitations/{invitation_id}/revoke:
    post:
      operationId: OHN_62_API_017
      summary: Revoke an invitation
      x-roles:
      - receptionist
      - triage_officer
      x-purpose: preconsult_invitation
      security:
      - bearer: []
      parameters:
      - name: invitation_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Reasoned'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invitation'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/me/pending:
    get:
      operationId: OHN_62_API_018
      summary: 'Patient portal (OHN-31): my open invitations and drafts'
      x-roles:
      - patient
      x-purpose: patient_access
      security:
      - bearer: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PendingForMe'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/public/sessions/{token}:
    get:
      operationId: OHN_62_API_019
      summary: 'Phone /p page or SMS link: open the questionnaire by one-time token (no login). Rate-limited; token hashed at rest; no name or Health ID in the reply beyond the facility name'
      x-roles: []
      x-purpose: preconsult_capture
      security: []
      parameters:
      - name: token
        in: path
        required: true
        schema:
          type: string
          minLength: 20
          maxLength: 64
      - name: language
        in: query
        required: false
        schema:
          type: string
          enum:
          - en
          - fr
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenSession'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '410':
          description: invitation_expired or invitation_used
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/public/sessions/{token}/answers:
    put:
      operationId: OHN_62_API_020
      summary: Save answers by token
      x-roles: []
      x-purpose: preconsult_capture
      security: []
      parameters:
      - name: token
        in: path
        required: true
        schema:
          type: string
          minLength: 20
          maxLength: 64
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnswersPut'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '410':
          description: invitation_expired or invitation_used
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/public/sessions/{token}/submit:
    post:
      operationId: OHN_62_API_021
      summary: Submit by token (the token is spent)
      x-roles: []
      x-purpose: preconsult_capture
      security: []
      parameters:
      - name: token
        in: path
        required: true
        schema:
          type: string
          minLength: 20
          maxLength: 64
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Versioned'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '410':
          description: invitation_expired or invitation_used
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/ussd/sessions:
    post:
      operationId: OHN_62_API_022
      summary: 'OHN-53 USSD gateway relay: next question/answer step of an ussd_compatible questionnaire'
      x-roles:
      - notifications_service
      x-purpose: preconsult_capture
      security:
      - bearer: []
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UssdStep'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UssdReply'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '410':
          description: invitation_expired or invitation_used
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/tickets/{ticket_id}/attach:
    post:
      operationId: OHN_62_API_023
      summary: 'Service call from OHN-61 at check-in: link the patient''s submitted/in-progress response (same appointment, or same department within the configured window) to the ticket and return its
        red flags'
      x-roles:
      - triage_service
      x-purpose: triage_signals
      security:
      - bearer: []
      parameters:
      - name: ticket_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Attach'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AttachResult'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: 'never returned for a missing questionnaire: none_configured is a 200'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/reports/completion:
    get:
      operationId: OHN_62_API_024
      summary: 'Completion report OHN-62-R001: invited/started/submitted by department, definition and channel'
      x-roles:
      - preconsult_admin
      - triage_admin
      x-purpose: preconsult_reporting
      security:
      - bearer: []
      parameters:
      - name: facility_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
      - name: from
        in: query
        required: true
        schema:
          type: string
          format: date
      - name: to
        in: query
        required: true
        schema:
          type: string
          format: date
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompletionReport'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/reports/completion/export:
    post:
      operationId: OHN_62_API_025
      summary: Export OHN-62-R001 as CSV/PDF watermarked via OHN-16 marks; counts under 5 suppressed
      x-roles:
      - preconsult_admin
      - triage_admin
      x-purpose: preconsult_reporting
      security:
      - bearer: []
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExportRequest'
      responses:
        '200':
          description: File with X-OHN-Mark-Id header
          content:
            text/csv:
              schema:
                type: string
            application/pdf:
              schema:
                type: string
                format: binary
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: upstream_unavailable (OHN-16 mark)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/pre-consult/definitions/{definition_id}/request-review:
    post:
      operationId: OHN_62_API_026
      summary: draft -> in_review (author)
      x-roles:
      - preconsult_governance_admin
      - preconsult_admin
      x-purpose: preconsult_configuration
      security:
      - bearer: []
      parameters:
      - name: definition_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Versioned'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Definition'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-since: 1.1.0
  /api/ohn/v1/pre-consult/definitions/{definition_id}/review:
    post:
      operationId: OHN_62_API_027
      summary: Review decision by a reviewer who is not the author (approved, or changes_requested -> back to draft)
      x-roles:
      - preconsult_reviewer
      x-purpose: preconsult_configuration
      security:
      - bearer: []
      parameters:
      - name: definition_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Review'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Definition'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: self_review_forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-since: 1.1.0
  /api/ohn/v1/pre-consult/reports/questionnaire_versions:
    get:
      operationId: OHN_62_API_028
      summary: 'Report questionnaire_versions: usage_count, completion_rate, declined_questions, draft_or_expired by department, version and language'
      x-roles:
      - preconsult_admin
      - triage_admin
      - triage_manager
      x-purpose: preconsult_reporting
      security:
      - bearer: []
      parameters:
      - name: facility_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
      - name: from
        in: query
        required: true
        schema:
          type: string
          format: date
      - name: to
        in: query
        required: true
        schema:
          type: string
          format: date
      - name: department_id
        in: query
        required: false
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VersionsReport'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-since: 1.1.0
  /api/ohn/v1/pre-consult/safety-screen:
    get:
      operationId: OHN_62_API_029
      summary: 'Resolve the active universal danger-sign screen (facility, then jurisdiction). 404 no_questionnaire when none is configured: check-in continues and the ticket shows safety_screen not_configured'
      x-roles:
      - receptionist
      - triage_officer
      - clinician
      - patient
      - kiosk_device
      x-purpose: preconsult_capture
      security:
      - bearer: []
      parameters:
      - name: facility_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
      - name: language
        in: query
        required: false
        schema:
          type: string
          enum:
          - en
          - fr
      - name: age_months
        in: query
        required: false
        schema:
          type: integer
          minimum: 0
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Resolved'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: no_questionnaire
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-since: 1.2.0
  /api/ohn/v1/pre-consult/definitions/{definition_id}/suspend:
    post:
      operationId: OHN_62_API_030
      summary: 'Emergency stop: an active definition stops resolving at once (next resolution level applies); reason required; resume = activate again'
      x-roles:
      - preconsult_governance_admin
      - preconsult_admin
      - preconsult_reviewer
      x-purpose: preconsult_configuration
      security:
      - bearer: []
      parameters:
      - name: definition_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Reasoned'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Definition'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-since: 1.3.0
  /api/ohn/v1/pre-consult/responses/{response_id}/staff-review:
    post:
      operationId: OHN_62_API_031
      summary: Staff marks a submitted response accepted_for_triage or staff_review_required (shown to the triage officer)
      x-roles:
      - triage_officer
      - triage_lead
      x-purpose: preconsult_review
      security:
      - bearer: []
      parameters:
      - name: response_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StaffReview'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Response'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-since: 1.3.0
  /api/ohn/v1/pre-consult/definitions/load-candidate-bank:
    post:
      operationId: OHN_62_API_032
      summary: 'DEV/DEMO only (OHN62_ALLOW_DEMO_CONFIG): load the owner''s 26-department candidate question bank as DRAFT definitions marked candidate_bank and NOT_CLINICALLY_APPROVED; nothing is activated'
      x-roles:
      - preconsult_governance_admin
      x-purpose: preconsult_configuration
      security:
      - bearer: []
      parameters:
      - $ref: '#/components/parameters/IdempotencyKey'
      - name: jurisdiction_id
        in: query
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Definition'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: demo_config_disabled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: version_conflict, invalid_transition or idempotency_mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (details per field)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-since: 1.3.0
  /api/ohn/v1/pre-consult/fhir/R4/Questionnaire:
    get:
      operationId: OHN_62_API_033
      summary: 'FHIR R4 search Questionnaire (Questionnaire: active approved definitions only; QuestionnaireResponse: patient, encounter, authored; OHN-16 evaluated)'
      x-roles:
      - clinician
      - triage_officer
      - fhir_client
      - external_triage_system
      x-purpose: preconsult_interop
      security:
      - bearer: []
      parameters:
      - name: patient
        in: query
        required: false
        schema:
          type: string
      - name: url
        in: query
        required: false
        schema:
          type: string
      - name: status
        in: query
        required: false
        schema:
          type: string
      - name: _count
        in: query
        required: false
        schema:
          type: integer
          maximum: 200
      responses:
        '200':
          description: FHIR R4 resource or searchset Bundle
          content:
            application/fhir+json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-since: 1.3.0
  /api/ohn/v1/pre-consult/fhir/R4/Questionnaire/{resource_id}:
    get:
      operationId: OHN_62_API_034
      summary: FHIR R4 read Questionnaire
      x-roles:
      - clinician
      - triage_officer
      - fhir_client
      - external_triage_system
      x-purpose: preconsult_interop
      security:
      - bearer: []
      parameters:
      - name: resource_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^[A-Za-z0-9\-\.]{1,64}$
      responses:
        '200':
          description: FHIR R4 resource or searchset Bundle
          content:
            application/fhir+json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-since: 1.3.0
  /api/ohn/v1/pre-consult/fhir/R4/QuestionnaireResponse:
    get:
      operationId: OHN_62_API_035
      summary: 'FHIR R4 search QuestionnaireResponse (Questionnaire: active approved definitions only; QuestionnaireResponse: patient, encounter, authored; OHN-16 evaluated)'
      x-roles:
      - clinician
      - triage_officer
      - fhir_client
      x-purpose: preconsult_interop
      security:
      - bearer: []
      parameters:
      - name: patient
        in: query
        required: false
        schema:
          type: string
      - name: url
        in: query
        required: false
        schema:
          type: string
      - name: status
        in: query
        required: false
        schema:
          type: string
      - name: _count
        in: query
        required: false
        schema:
          type: integer
          maximum: 200
      responses:
        '200':
          description: FHIR R4 resource or searchset Bundle
          content:
            application/fhir+json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-since: 1.3.0
  /api/ohn/v1/pre-consult/fhir/R4/QuestionnaireResponse/{resource_id}:
    get:
      operationId: OHN_62_API_036
      summary: FHIR R4 read QuestionnaireResponse
      x-roles:
      - clinician
      - triage_officer
      - fhir_client
      x-purpose: preconsult_interop
      security:
      - bearer: []
      parameters:
      - name: resource_id
        in: path
        required: true
        schema:
          type: string
          pattern: ^[A-Za-z0-9\-\.]{1,64}$
      responses:
        '200':
          description: FHIR R4 resource or searchset Bundle
          content:
            application/fhir+json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role or OHN-16 policy denies (consent_required when an OHN-15 consent is missing)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found or outside scope (never discloses existence)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: validation_failed (bad query)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-since: 1.3.0
  /health/ohn-62:
    get:
      operationId: OHN_62_HEALTH
      summary: Liveness/readiness of the module
      security: []
      responses:
        '200':
          description: OK
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      schema:
        type: string
        minLength: 8
        maxLength: 255
  schemas:
    Error:
      type: object
      additionalProperties: true
      properties:
        error:
          type: string
          description: 'Stable code: unauthenticated, forbidden, not_found, validation_failed, idempotency_key_required, idempotency_mismatch, version_conflict, invalid_transition, not_configured, no_questionnaire,
            demo_config_disabled, definition_not_approved, invitation_expired, invitation_used, answer_invalid, channel_not_supported, upstream_unavailable, consent_required, review_required, self_review_forbidden,
            definition_expired, decline_not_allowed, translation_not_reviewed, private_capture_required, definition_suspended, candidate_bank_not_activatable'
        message:
          type: string
        details: {}
      required:
      - error
    I18nText:
      type: object
      additionalProperties: false
      properties:
        en:
          type: string
          minLength: 1
          maxLength: 2000
        fr:
          type: string
          minLength: 1
          maxLength: 2000
      required:
      - en
      - fr
    Coding:
      type: object
      additionalProperties: false
      properties:
        system:
          type: string
          enum:
          - snomed_ct
          - loinc
          - local
        code:
          type: string
          minLength: 1
          maxLength: 64
        display:
          type: string
          minLength: 1
          maxLength: 256
      required:
      - system
      - code
    AnswerOption:
      type: object
      additionalProperties: false
      properties:
        code:
          type: string
          pattern: ^[a-z0-9_.-]{1,64}$
        display:
          $ref: '#/components/schemas/I18nText'
        coding:
          $ref: '#/components/schemas/Coding'
      required:
      - code
      - display
    EnableWhen:
      type: object
      additionalProperties: false
      properties:
        question:
          type: string
          description: link_id of an earlier item
        operator:
          type: string
          enum:
          - exists
          - eq
          - neq
          - gt
          - gte
          - lt
          - lte
          - includes
        answer:
          description: boolean, option code, number or date, matching the question's type
      required:
      - question
      - operator
    Item:
      type: object
      additionalProperties: false
      properties:
        link_id:
          type: string
          pattern: ^[a-z0-9_.-]{1,64}$
        type:
          type: string
          enum:
          - boolean
          - single_choice
          - multiple_choice
          - quantity
          - date
          - scale
          - text
          - body_site
          - group
          - display
        text:
          $ref: '#/components/schemas/I18nText'
        help:
          $ref: '#/components/schemas/I18nText'
        required:
          type: boolean
        options:
          type: array
          items:
            $ref: '#/components/schemas/AnswerOption'
          maxItems: 100
          description: single_choice and multiple_choice
        unit:
          type: string
          description: UCUM unit for quantity, e.g. mm[Hg], kg, mmol/L
        min:
          type: number
        max:
          type: number
        decimals:
          type: integer
          minimum: 0
          maximum: 3
        scale:
          type: object
          additionalProperties: false
          properties:
            min:
              type: integer
            max:
              type: integer
            step:
              type: integer
              minimum: 1
            min_label:
              $ref: '#/components/schemas/I18nText'
            max_label:
              $ref: '#/components/schemas/I18nText'
          required:
          - min
          - max
        body_sites:
          type: array
          items:
            $ref: '#/components/schemas/AnswerOption'
          maxItems: 200
          description: 'body_site: configured site list (SNOMED body structure codes validated with OHN-23 at load)'
        max_length:
          type: integer
          minimum: 1
          maximum: 4000
        date_range:
          type: object
          additionalProperties: false
          properties:
            not_after_today:
              type: boolean
            not_before_years:
              type: integer
        enable_when:
          type: array
          items:
            $ref: '#/components/schemas/EnableWhen'
          maxItems: 10
        enable_behavior:
          type: string
          enum:
          - all
          - any
        items:
          type: array
          items:
            $ref: '#/components/schemas/Item'
          maxItems: 100
          description: children of a group
        coding:
          $ref: '#/components/schemas/Coding'
        ussd_compatible:
          type: boolean
          readOnly: true
          description: 'computed: boolean, single_choice (<=9 options), scale, quantity'
        allow_decline:
          type: boolean
          description: default true; false means a required item cannot be declined
      required:
      - link_id
      - type
      - text
    RedFlagRule:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          pattern: ^[a-z0-9_.-]{1,64}$
        when:
          type: array
          items:
            $ref: '#/components/schemas/EnableWhen'
          minItems: 1
          maxItems: 10
        match:
          type: string
          enum:
          - all
          - any
        effect:
          type: string
          enum:
          - flag_officer
          - raise_priority
          - urgent_review
          description: 'urgent_review: immediate staff review; OHN-61 raises an escalation (trigger danger_screen). Configured only; never a diagnosis or reassurance shown to the patient'
        message:
          $ref: '#/components/schemas/I18nText'
        suggest_discriminator:
          type: string
          description: optional OHN-61 scale discriminator id pre-selected for the officer to confirm; never assigns acuity
        on_unknown:
          type: string
          enum:
          - ignore
          - screen_incomplete
          description: 'safety screens default to screen_incomplete: an unknown or declined answer to a referenced item is never read as ''no''; OHN-61 shows ''screen incomplete'' to staff'
      required:
      - id
      - when
      - effect
      - message
    QuestionnaireDocument:
      type: object
      additionalProperties: false
      properties:
        title:
          $ref: '#/components/schemas/I18nText'
        department_kind:
          type: string
          enum:
          - emergency
          - opd_general
          - eye
          - dental
          - maternity
          - paediatrics
          - cardiology
          - diabetes
          - ent
          - dermatology
          - mental_health
          - surgery
          - orthopaedics
          - anc_pnc
          - obgyn
          - neurology
          - nephrology
          - gastroenterology
          - respiratory
          - urology
          - hiv_art
          - oncology
          - immunization
          - laboratory
          - imaging
          - pharmacy
          - family_planning
          - other
        department_id:
          type: string
          format: uuid
          description: 'facility scope only: bind to one OHN-61 department'
        complaint:
          $ref: '#/components/schemas/Coding'
        complaint_label:
          $ref: '#/components/schemas/I18nText'
        estimated_minutes:
          type: integer
          minimum: 1
          maximum: 60
        items:
          type: array
          items:
            $ref: '#/components/schemas/Item'
          minItems: 1
          maxItems: 200
        red_flag_rules:
          type: array
          items:
            $ref: '#/components/schemas/RedFlagRule'
          maxItems: 100
        source_reference:
          type: string
          minLength: 1
          maxLength: 500
        valid_until:
          type: string
          format: date
        kind:
          type: string
          enum:
          - department
          - safety_screen
          description: 'safety_screen: the universal danger-sign screen asked of every patient before department questions (department_kind is ignored); department: the default'
        audience:
          type: string
          enum:
          - patient
          - nurse
          - clinician
          description: patient (pre-consultation, shown on patient channels), nurse (triage stage, staff views only) or clinician (consultation prompts, clinician view only); default patient
        visit_type:
          type: string
          enum:
          - new
          - follow_up
          - review
        age_band:
          type: object
          additionalProperties: false
          properties:
            min_months:
              type: integer
              minimum: 0
            max_months:
              type: integer
              minimum: 0
        pregnancy_context:
          type: string
          enum:
          - anc
          - pnc
        capture_privacy:
          type: string
          enum:
          - standard
          - private
          description: 'private: never offered on a shared kiosk; staff-assisted only in a private room, or on the patient''s own device'
        translation_status:
          type: object
          additionalProperties: false
          properties:
            en:
              type: string
              enum:
              - draft
              - reviewed
            fr:
              type: string
              enum:
              - draft
              - reviewed
          required:
          - en
          - fr
        source_topic_tags:
          type: array
          items:
            type: string
          maxItems: 20
          description: guideline topics the content was derived from (e.g. who_iitt, imci, who_pen); provenance only, not a claim of validation
      required:
      - title
      - department_kind
      - items
      - red_flag_rules
    Definition:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          format: uuid
        scope:
          type: string
          enum:
          - jurisdiction
          - facility
        jurisdiction_id:
          type: string
          format: uuid
        facility_id:
          type:
          - string
          - 'null'
          format: uuid
        key:
          type: string
          readOnly: true
          description: department_kind[/department_id][/complaint system|code]
        version:
          type: integer
        state:
          type: string
          enum:
          - draft
          - in_review
          - active
          - retired
          - expired
          - suspended
        approval_ref:
          type:
          - string
          - 'null'
        synthetic_demo:
          type: boolean
        clinically_approved:
          type: boolean
        activated_at:
          type:
          - string
          - 'null'
          format: date-time
        document:
          $ref: '#/components/schemas/QuestionnaireDocument'
        row_version:
          type: integer
        valid_until:
          type:
          - string
          - 'null'
          format: date
          description: after this date the definition is expired and no longer resolves
        review:
          oneOf:
          - type: object
            additionalProperties: false
            properties:
              requested_by:
                type: string
              requested_at:
                type: string
                format: date-time
              decision:
                type:
                - string
                - 'null'
                enum:
                - approved
                - changes_requested
                - null
              reviewed_by:
                type:
                - string
                - 'null'
              reviewed_at:
                type:
                - string
                - 'null'
                format: date-time
              comment:
                type:
                - string
                - 'null'
            required:
            - requested_by
            - requested_at
          - type: 'null'
        created_by:
          type: string
        warnings:
          type: array
          items:
            type: string
          description: non-blocking load warnings, e.g. patient questionnaire with more than 7 items visible by default
        candidate_bank:
          type: boolean
          description: loaded from the owner's candidate question bank (v1.1); always NOT_CLINICALLY_APPROVED, draft only, can never be activated without review, approval_ref and reviewed translations
      required:
      - id
      - scope
      - version
      - state
      - synthetic_demo
      - document
    Activate:
      type: object
      additionalProperties: false
      properties:
        approval_ref:
          type: string
          minLength: 3
          maxLength: 128
        expected_version:
          type: integer
      required:
      - approval_ref
      - expected_version
    Reasoned:
      type: object
      additionalProperties: false
      properties:
        expected_version:
          type: integer
        reason:
          type: string
          minLength: 5
          maxLength: 1000
      required:
      - expected_version
      - reason
    Resolved:
      type: object
      additionalProperties: false
      properties:
        definition:
          $ref: '#/components/schemas/RenderedDefinition'
        matched_on:
          type: string
          enum:
          - facility_department_complaint
          - facility_department
          - jurisdiction_kind_complaint
          - jurisdiction_kind
      required:
      - definition
    RenderedDefinition:
      type: object
      additionalProperties: false
      properties:
        definition_id:
          type: string
          format: uuid
        version:
          type: integer
        language:
          type: string
          enum:
          - en
          - fr
        title:
          type: string
        items:
          type: array
          items:
            type: object
          description: Item with text/help/labels resolved to the language; red_flag_rules are never sent to patients
        synthetic_demo:
          type: boolean
        disclaimer:
          type:
          - string
          - 'null'
      required:
      - definition_id
      - version
      - language
      - title
      - items
      - synthetic_demo
    Complaint:
      type: object
      additionalProperties: false
      properties:
        coding:
          $ref: '#/components/schemas/Coding'
        label:
          $ref: '#/components/schemas/I18nText'
      required:
      - coding
      - label
    Answer:
      type: object
      additionalProperties: false
      properties:
        link_id:
          type: string
        value_boolean:
          type: boolean
        value_code:
          type: string
        value_codes:
          type: array
          items:
            type: string
        value_number:
          type: number
        value_date:
          type: string
          format: date
        value_text:
          type: string
          minLength: 0
          maxLength: 4000
        declined:
          type: boolean
          description: the patient chose not to answer; no value field allowed
        decline_reason:
          type: string
          enum:
          - prefer_not_to_say
          - do_not_know
          - not_applicable
      required:
      - link_id
    ResponseStart:
      type: object
      additionalProperties: false
      properties:
        patient_id:
          type: string
          format: uuid
        department_id:
          type: string
          format: uuid
        complaint:
          $ref: '#/components/schemas/Coding'
        ticket_id:
          type: string
          format: uuid
        appointment_id:
          type: string
          format: uuid
        channel:
          type: string
          enum:
          - kiosk
          - staff_assisted
          - portal
        language:
          type: string
          enum:
          - en
          - fr
        definition_id:
          type: string
          format: uuid
          description: 'optional (1.2.0): the definition the client resolved, e.g. GET /safety-screen Resolved.definition.definition_id to start the safety screen for a ticket, or a department
            definition resolved with visit_type/age_months/pregnancy_context. It must be active and apply to the department (the safety screen applies everywhere), else 422 definition_not_applicable.
            Without it the department questionnaire is resolved. A safety-screen response and a department response may be open together for the same patient and department.'
          x-since: 1.2.0
      required:
      - patient_id
      - department_id
      - channel
      - language
    AnswersPut:
      type: object
      additionalProperties: false
      properties:
        answers:
          type: array
          items:
            $ref: '#/components/schemas/Answer'
          maxItems: 300
        expected_version:
          type: integer
      required:
      - answers
      - expected_version
    Response:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          format: uuid
        definition_id:
          type: string
          format: uuid
        definition_version:
          type: integer
        patient_id:
          type: string
          format: uuid
        department_id:
          type: string
          format: uuid
        facility_id:
          type: string
          format: uuid
        complaint:
          oneOf:
          - $ref: '#/components/schemas/Coding'
          - type: 'null'
        ticket_id:
          type:
          - string
          - 'null'
          format: uuid
        appointment_id:
          type:
          - string
          - 'null'
          format: uuid
        channel:
          type: string
          enum:
          - portal
          - phone_web
          - sms_link
          - ussd
          - kiosk
          - staff_assisted
        language:
          type: string
          enum:
          - en
          - fr
        entered_by:
          type: string
          description: patient, representative or staff user id (staff_assisted/kiosk)
        status:
          type: string
          enum:
          - in_progress
          - submitted
          - amended
          - entered_in_error
          - expired
          - staff_review_required
          - accepted_for_triage
        answers:
          type: array
          items:
            $ref: '#/components/schemas/Answer'
        red_flags:
          type: array
          items:
            type: object
            additionalProperties: false
            properties:
              rule_id:
                type: string
              effect:
                type: string
              message:
                $ref: '#/components/schemas/I18nText'
              suggest_discriminator:
                type:
                - string
                - 'null'
            required:
            - rule_id
            - effect
            - message
          description: staff views only; never returned on patient channels
        submitted_at:
          type:
          - string
          - 'null'
          format: date-time
        document_id:
          type:
          - string
          - 'null'
          format: uuid
          description: OHN-13 document holding the FHIR QuestionnaireResponse
        record_sync:
          type: string
          enum:
          - not_submitted
          - pending_upstream
          - filed
          - failed
        synthetic_demo:
          type: boolean
        version:
          type: integer
        declined_link_ids:
          type: array
          items:
            type: string
          description: shown to staff as 'declined', never as a missing answer
        amendments:
          type: array
          items:
            type: object
            additionalProperties: false
            properties:
              at:
                type: string
                format: date-time
              by:
                type: string
              reason:
                type: string
              document_version:
                type:
                - integer
                - 'null'
            required:
            - at
            - by
            - reason
          description: append-only; the original answers are never overwritten
      required:
      - id
      - definition_id
      - definition_version
      - patient_id
      - department_id
      - channel
      - language
      - status
      - answers
      - version
    Invitation:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          format: uuid
        patient_id:
          type: string
          format: uuid
        appointment_id:
          type:
          - string
          - 'null'
          format: uuid
        ticket_id:
          type:
          - string
          - 'null'
          format: uuid
        department_id:
          type: string
          format: uuid
        channel:
          type: string
          enum:
          - sms_link
          - ussd
          - portal
        language:
          type: string
          enum:
          - en
          - fr
        expires_at:
          type: string
          format: date-time
        state:
          type: string
          enum:
          - sent
          - opened
          - submitted
          - expired
          - revoked
          - delivery_failed
      required:
      - id
      - patient_id
      - channel
      - expires_at
      - state
    InvitationCreate:
      type: object
      additionalProperties: false
      properties:
        appointment_id:
          type: string
          format: uuid
        ticket_id:
          type: string
          format: uuid
        channel:
          type: string
          enum:
          - sms_link
          - ussd
          - portal
        language:
          type: string
          enum:
          - en
          - fr
        department_id:
          type: string
          format: uuid
          description: required with appointment_id unless ticket_id is given (an OHN-54 appointment has no OHN-61 department); must belong to the appointment's facility
      required:
      - channel
      - language
    TokenSession:
      type: object
      additionalProperties: false
      properties:
        definition:
          $ref: '#/components/schemas/RenderedDefinition'
        response:
          type: object
          additionalProperties: false
          properties:
            id:
              type: string
              format: uuid
            status:
              type: string
            answers:
              type: array
              items:
                $ref: '#/components/schemas/Answer'
            version:
              type: integer
          required:
          - id
          - status
          - answers
          - version
        facility_name:
          type: string
        appointment_at:
          type:
          - string
          - 'null'
          format: date-time
      required:
      - definition
      - response
    Attach:
      type: object
      additionalProperties: false
      properties:
        patient_id:
          type: string
          format: uuid
        department_id:
          type: string
          format: uuid
        facility_id:
          type: string
          format: uuid
        appointment_id:
          type: string
          format: uuid
        complaint:
          $ref: '#/components/schemas/Coding'
      required:
      - patient_id
      - department_id
      - facility_id
    AttachResult:
      type: object
      additionalProperties: false
      properties:
        questionnaire_available:
          type: boolean
        state:
          type: string
          enum:
          - none_configured
          - not_started
          - in_progress
          - submitted
        response_ids:
          type: array
          items:
            type: string
            format: uuid
        red_flags:
          type: array
          items:
            type: object
            additionalProperties: false
            properties:
              rule_id:
                type: string
              effect:
                type: string
              message:
                $ref: '#/components/schemas/I18nText'
            required:
            - rule_id
            - effect
      required:
      - questionnaire_available
      - state
      - response_ids
      - red_flags
    PendingForMe:
      type: object
      additionalProperties: false
      properties:
        items:
          type: array
          items:
            type: object
            additionalProperties: false
            properties:
              invitation_id:
                type: string
                format: uuid
              response_id:
                type:
                - string
                - 'null'
                format: uuid
              appointment_id:
                type:
                - string
                - 'null'
                format: uuid
              appointment_at:
                type:
                - string
                - 'null'
                format: date-time
              facility_name:
                type: string
              department_name:
                type: string
              status:
                type: string
            required:
            - invitation_id
            - department_name
            - status
      required:
      - items
    ExportRequest:
      type: object
      additionalProperties: false
      properties:
        facility_id:
          type: string
          format: uuid
        from:
          type: string
          format: date
        to:
          type: string
          format: date
        format:
          type: string
          enum:
          - csv
          - pdf
      required:
      - facility_id
      - from
      - to
      - format
    CompletionReport:
      type: object
      additionalProperties: false
      properties:
        from:
          type: string
          format: date
        to:
          type: string
          format: date
        rows:
          type: array
          items:
            type: object
            additionalProperties: true
            properties:
              department_id:
                type: string
                format: uuid
              definition_id:
                type: string
                format: uuid
              invited:
                type: integer
              started:
                type: integer
              submitted:
                type: integer
              submitted_before_arrival:
                type: integer
              by_channel:
                type: object
                additionalProperties:
                  type: integer
              red_flags_raised:
                type: integer
            required:
            - department_id
            - invited
            - started
            - submitted
      required:
      - from
      - to
      - rows
    Versioned:
      type: object
      additionalProperties: false
      properties:
        expected_version:
          type: integer
      required:
      - expected_version
    AmendRequest:
      type: object
      additionalProperties: false
      properties:
        answers:
          type: array
          items:
            $ref: '#/components/schemas/Answer'
          maxItems: 300
        reason:
          type: string
          minLength: 5
          maxLength: 1000
        expected_version:
          type: integer
      required:
      - answers
      - reason
      - expected_version
    UssdStep:
      type: object
      additionalProperties: false
      properties:
        session_ref:
          type: string
          minLength: 1
          maxLength: 64
        msisdn_hash:
          type: string
          minLength: 16
          maxLength: 128
        invitation_code:
          type: string
          minLength: 4
          maxLength: 16
        input:
          type: string
          minLength: 0
          maxLength: 182
      required:
      - session_ref
      - msisdn_hash
      - input
    UssdReply:
      type: object
      additionalProperties: false
      properties:
        text:
          type: string
          minLength: 0
          maxLength: 182
        end:
          type: boolean
      required:
      - text
      - end
    Review:
      type: object
      additionalProperties: false
      properties:
        decision:
          type: string
          enum:
          - approved
          - changes_requested
        comment:
          type: string
          minLength: 0
          maxLength: 2000
        expected_version:
          type: integer
      required:
      - decision
      - expected_version
    VersionsReport:
      type: object
      additionalProperties: false
      properties:
        from:
          type: string
          format: date
        to:
          type: string
          format: date
        rows:
          type: array
          items:
            type: object
            additionalProperties: true
            properties:
              department_id:
                type: string
                format: uuid
              definition_id:
                type: string
                format: uuid
              version:
                type: integer
              language:
                type: string
                enum:
                - en
                - fr
              state:
                type: string
              usage_count:
                type: integer
                description: responses started
              completion_rate:
                type:
                - number
                - 'null'
                description: submitted / started
              declined_questions:
                type: integer
                description: declined answers in submitted responses
              declined_by_item:
                type: object
                additionalProperties:
                  type: integer
              draft_or_expired:
                type: boolean
            required:
            - department_id
            - definition_id
            - version
            - language
      required:
      - from
      - to
      - rows
    StaffReview:
      type: object
      additionalProperties: false
      properties:
        decision:
          type: string
          enum:
          - accepted_for_triage
          - staff_review_required
        note:
          type: string
          minLength: 0
          maxLength: 1000
        expected_version:
          type: integer
      required:
      - decision
      - expected_version
