# OHN-60 OpenAPI 3.1 contract (W27, owner order 2026-11-23). Generated from the route table of server/modules/ohn-60 (Ohn60Authorization).
openapi: 3.1.0
info:
  title: OHN-60 Outreach Programmes
  version: 1.1.0
  description: 'Health organisation (NGO) partnerships with care sites, jurisdiction-approved screening protocols (configuration, empty by default: 503 not_configured), campaigns with sites and team, on-site
    registration linked to OHN-02/03, consent through OHN-15, screenings written into OHN-09/11, referral to an ACTIVE partner through OHN-27 with follow-up, reports and suppressed public-health figures.
    Deployable: care-exchange. Module key: outreach. Tables: ohn60_*. Every POST needs Idempotency-Key; bodies are strict (unknown keys 422); transitions carry expected_version. Synthetic data only until
    the legal gate.'
servers:
- url: https://opeshealthnetwork.com
security:
- bearer: []
paths:
  /api/ohn/v1/outreach/partnerships:
    get:
      operationId: listPartnerships
      summary: 'Partnerships of the caller (NGO: its own; partner facility: those addressed to it, never drafts)'
      description: 'Partnerships of the caller (NGO: its own; partner facility: those addressed to it, never drafts).'
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      - data_officer
      - partner_facility
      x-purposes:
      - outreach_programmes
      - outreach_referral_receipt
      security:
      - bearer: []
      parameters:
      - name: state
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Partnership'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    post:
      operationId: createPartnership
      summary: Draft a partnership with a registered, active OHN-05 facility (one open agreement per NGO and facility)
      description: Draft a partnership with a registered, active OHN-05 facility (one open agreement per NGO and facility).
      x-roles:
      - facility_administrator
      - programme_manager
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnershipCreate'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Partnership'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/partnerships/{id}:
    get:
      operationId: getPartnership
      summary: One partnership with its append-only history; another organisation answers 404
      description: One partnership with its append-only history; another organisation answers 404.
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      - data_officer
      - partner_facility
      x-purposes:
      - outreach_programmes
      - outreach_referral_receipt
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Partnership'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/partnerships/{id}/transitions:
    post:
      operationId: transitionPartnership
      summary: draft->proposed (NGO) -> accepted|rejected (partner, rejection needs a reason) -> active (NGO); suspend/resume/end by ei
      description: draft->proposed (NGO) -> accepted|rejected (partner, rejection needs a reason) -> active (NGO); suspend/resume/end by either side with a reason. Audited, evented.
      x-roles:
      - facility_administrator
      - programme_manager
      - partner_facility
      x-purposes:
      - outreach_programmes
      - outreach_referral_receipt
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnershipTransition'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Partnership'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/protocols:
    get:
      operationId: listProtocols
      summary: 'Approved protocols of the jurisdiction (steward: all)'
      description: 'Approved protocols of the jurisdiction (steward: all). None approved: 503 not_configured.'
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      - data_officer
      - protocol_steward
      x-purposes:
      - outreach_programmes
      - outreach_protocol_governance
      security:
      - bearer: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Protocol'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    post:
      operationId: createProtocol
      summary: Draft a new version of a protocol (configuration)
      description: Draft a new version of a protocol (configuration). 422 lists every problem of the document.
      x-roles:
      - protocol_steward
      x-purposes:
      - outreach_protocol_governance
      security:
      - bearer: []
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProtocolCreate'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Protocol'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/protocols/load-demo:
    post:
      operationId: loadDemoProtocol
      summary: WHO PEN / HEARTS reference protocol, not clinically approved; 404 unless OHN_M60_ALLOW_DEMO_PROTOCOL=true outside production
      description: WHO PEN / HEARTS reference protocol (cited per rule), not clinically approved; 404 unless OHN_M60_ALLOW_DEMO_PROTOCOL=true outside production.
      x-roles:
      - protocol_steward
      x-purposes:
      - outreach_protocol_governance
      security:
      - bearer: []
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Protocol'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/protocols/{id}:
    get:
      operationId: getProtocol
      summary: One protocol
      description: One protocol.
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      - data_officer
      - protocol_steward
      x-purposes:
      - outreach_programmes
      - outreach_protocol_governance
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Protocol'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/protocols/{id}/approve:
    post:
      operationId: approveProtocol
      summary: A second steward approves with the approval reference (403 separation_of_duties for the drafter)
      description: A second steward approves with the approval reference (403 separation_of_duties for the drafter). Approved versions are immutable.
      x-roles:
      - protocol_steward
      x-purposes:
      - outreach_protocol_governance
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProtocolApprove'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Protocol'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/protocols/{id}/retire:
    post:
      operationId: retireProtocol
      summary: Retire a protocol version
      description: Retire a protocol version.
      x-roles:
      - protocol_steward
      x-purposes:
      - outreach_protocol_governance
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProtocolRetire'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Protocol'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/campaigns:
    get:
      operationId: listCampaigns
      summary: 'The NGO''s campaigns (field workers: only those they are rostered on)'
      description: 'The NGO''s campaigns (field workers: only those they are rostered on).'
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      - data_officer
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Campaign'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    post:
      operationId: createCampaign
      summary: Create a draft campaign on an APPROVED protocol (503 not_configured otherwise)
      description: Create a draft campaign on an APPROVED protocol (503 not_configured otherwise).
      x-roles:
      - facility_administrator
      - programme_manager
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignCreate'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Campaign'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/campaigns/{id}:
    get:
      operationId: getCampaign
      summary: One campaign with sites and team; another NGO answers 404
      description: One campaign with sites and team; another NGO answers 404.
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      - data_officer
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Campaign'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/campaigns/{id}/transitions:
    post:
      operationId: transitionCampaign
      summary: approve (never by the creator) -> activate (needs a site) -> close (reason)
      description: approve (never by the creator) -> activate (needs a site) -> close (reason).
      x-roles:
      - facility_administrator
      - programme_manager
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignTransition'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Campaign'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/campaigns/{id}/sites:
    post:
      operationId: addSite
      summary: Fixed or mobile site, optional GPS
      description: Fixed or mobile site, optional GPS.
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SiteCreate'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Site'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/campaigns/{id}/team:
    post:
      operationId: addTeamMember
      summary: Roster a coordinator, outreach worker or outreach clinician
      description: Roster a coordinator, outreach worker or outreach clinician.
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TeamMember'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/campaigns/{id}/day:
    get:
      operationId: siteDay
      summary: 'Site day view: who was screened, outcome, referral progress (names and Health IDs only)'
      description: 'Site day view: who was screened, outcome, referral progress (names and Health IDs only).'
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: site_id
        in: query
        required: false
        schema:
          type: string
      - name: date
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/persons/lookup:
    post:
      operationId: lookupPerson
      summary: By Health ID (OHN-02) or MPI search (OHN-03)
      description: By Health ID (OHN-02) or MPI search (OHN-03).
      x-roles:
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PersonLookup'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/persons:
    post:
      operationId: registerPerson
      summary: Link an existing record or register through OHN-03 and issue a Health ID through OHN-02
      description: Link an existing record or register through OHN-03 and issue a Health ID through OHN-02. 409 possible_duplicate on an exact MPI match; 200 on a replay or an already-linked person.
      x-roles:
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PersonRegister'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Person'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/persons/{id}/consents:
    post:
      operationId: recordConsent
      summary: Screening or data-sharing consent, recorded in OHN-15 (the latest decision counts)
      description: Screening or data-sharing consent, recorded in OHN-15 (the latest decision counts).
      x-roles:
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Consent'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/persons/{id}/record:
    get:
      operationId: personRecord
      summary: 'The person''s outreach record within this NGO: the licensed outreach clinician only'
      description: 'The person''s outreach record within this NGO: the licensed outreach clinician only.'
      x-roles:
      - outreach_clinician
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/screenings:
    post:
      operationId: recordScreening
      summary: Record a screening (approved protocol, active campaign, rostered performer, allowed role, active licence for the clinici
      description: Record a screening (approved protocol, active campaign, rostered performer, allowed role, active licence for the clinician, screening consent). Written into OHN-09/OHN-11; a positive/refer
        result is referred to an active partner.
      x-roles:
      - outreach_worker
      - outreach_clinician
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScreeningCreate'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Screening'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    get:
      operationId: listScreenings
      summary: 'Screenings of the NGO (a field worker: own only; the outreach worker never sees the answers)'
      description: 'Screenings of the NGO (a field worker: own only; the outreach worker never sees the answers).'
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: campaign_id
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Screening'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/screenings/push-pending:
    post:
      operationId: pushPendingScreenings
      summary: Write pending screenings into the record again after an outage
      description: Write pending screenings into the record again after an outage.
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/referrals:
    post:
      operationId: createReferral
      summary: Refer a positive/refer screening to an ACTIVE partner (422 not_a_partner, 409 partnership_not_active, 403 consent_requir
      description: Refer a positive/refer screening to an ACTIVE partner (422 not_a_partner, 409 partnership_not_active, 403 consent_required, 409 already_referred).
      x-roles:
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      - programme_manager
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReferralCreate'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Referral'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    get:
      operationId: listReferrals
      summary: 'NGO: its referrals; partner facility: incoming referrals under an active partnership'
      description: 'NGO: its referrals; partner facility: incoming referrals under an active partnership.'
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      - outreach_worker
      - outreach_clinician
      - partner_facility
      x-purposes:
      - outreach_programmes
      - outreach_referral_receipt
      security:
      - bearer: []
      parameters:
      - name: state
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Referral'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/referrals/{id}/follow-up:
    post:
      operationId: referralFollowUp
      summary: 'Partner facility: received -> seen -> outcome'
      description: 'Partner facility: received -> seen -> outcome.'
      x-roles:
      - partner_facility
      x-purposes:
      - outreach_referral_receipt
      security:
      - bearer: []
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          format: uuid
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FollowUp'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Referral'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/referrals/sweep:
    post:
      operationId: referralSweep
      summary: Mark open referrals past the follow-up window lost to follow-up and alert the referrer (OHN-53)
      description: Mark open referrals past the follow-up window lost to follow-up and alert the referrer (OHN-53).
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/reports/summary:
    get:
      operationId: reportSummary
      summary: Screened, positive, referred, seen, positivity and follow-up rate by campaign, site, area, age band or sex
      description: Screened, positive, referred, seen, positivity and follow-up rate by campaign, site, area, age band or sex.
      x-roles:
      - facility_administrator
      - programme_manager
      - field_coordinator
      - data_officer
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: campaign_id
        in: query
        required: false
        schema:
          type: string
      - name: group_by
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Report'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/reports/summary/export:
    get:
      operationId: reportExport
      summary: CSV attachment; watermarked by the platform ExportMarkFilter
      description: CSV attachment; watermarked by the platform ExportMarkFilter.
      x-roles:
      - facility_administrator
      - programme_manager
      - data_officer
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: campaign_id
        in: query
        required: false
        schema:
          type: string
      - name: group_by
        in: query
        required: false
        schema:
          type: string
      responses:
        '200':
          description: OK
          content:
            text/csv:
              schema:
                type: string
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/reports/publications:
    post:
      operationId: publishAggregates
      summary: Publish the campaign's figures for public health with small-cell suppression (503 not_configured without OHN_M60_MIN_CEL
      description: Publish the campaign's figures for public health with small-cell suppression (503 not_configured without OHN_M60_MIN_CELL_SIZE).
      x-roles:
      - facility_administrator
      - data_officer
      x-purposes:
      - outreach_programmes
      security:
      - bearer: []
      parameters:
      - name: Idempotency-Key
        in: header
        required: true
        schema:
          type: string
          minLength: 1
          maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Publication'
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/public-health/publications:
    get:
      operationId: publicHealthPublications
      summary: Published, suppressed figures of the jurisdiction
      description: Published, suppressed figures of the jurisdiction.
      x-roles:
      - public_health_reader
      x-purposes:
      - public_health_surveillance
      security:
      - bearer: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/analytics/totals:
    get:
      operationId: nationalTotals
      summary: Ministry analyst - outreach totals by region, campaign or period; every count below 10 is "<10"
      description: 'Owner decision 2026-11-29. Totals of every organisation in the caller''s jurisdiction. No name, no person-level record, no site, age or sex.
        Every count below 10 (zero included) is returned as the string "<10"; a rate is given only when both of its counts are shown. Each read is audited
        (analytics.totals) with its filters.'
      x-roles:
      - ministry_analyst
      x-purposes:
      - national_analytics
      security:
      - bearer: []
      parameters:
      - name: group_by
        in: query
        required: false
        schema:
          enum: [region, campaign, period]
          default: region
      - name: period
        in: query
        required: false
        description: Period bucket when group_by=period.
        schema:
          enum: [month, quarter]
          default: month
      - name: from
        in: query
        required: false
        schema:
          type: string
          format: date
      - name: to
        in: query
        required: false
        schema:
          type: string
          format: date
      - name: region
        in: query
        required: false
        description: One region (district) only.
        schema:
          type: string
          maxLength: 200
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NationalTotals'
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Not the ministry analyst, or the wrong purpose (audited as denied)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/analytics/totals/export:
    get:
      operationId: nationalTotalsExport
      summary: The same totals as a CSV attachment (watermarked); suppressed counts stay "<10"
      description: The same totals as a CSV attachment, watermarked by the platform ExportMarkFilter. Suppressed counts stay "<10" in the file. Each export is audited (analytics.export).
      x-roles:
      - ministry_analyst
      x-purposes:
      - national_analytics
      security:
      - bearer: []
      parameters:
      - name: group_by
        in: query
        required: false
        schema:
          enum: [region, campaign, period]
          default: region
      - name: period
        in: query
        required: false
        description: Period bucket when group_by=period.
        schema:
          enum: [month, quarter]
          default: month
      - name: from
        in: query
        required: false
        schema:
          type: string
          format: date
      - name: to
        in: query
        required: false
        schema:
          type: string
          format: date
      - name: region
        in: query
        required: false
        description: One region (district) only.
        schema:
          type: string
          maxLength: 200
      responses:
        '200':
          description: OK
          content:
            text/csv:
              schema:
                type: string
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Not the ministry analyst, or the wrong purpose (audited as denied)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /api/ohn/v1/outreach/me/screenings:
    get:
      operationId: myScreenings
      summary: The patient's own screening results (portal)
      description: The patient's own screening results (portal).
      x-roles:
      - patient
      x-purposes:
      - patient_access
      security:
      - bearer: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Role, purpose, consent, licence or separation of duties
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found (or another organisation's record)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Version conflict or invalid transition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 'not_configured or dependency_unavailable: nothing stored'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /health/ohn-60:
    get:
      operationId: health
      summary: Liveness and dependency wiring
      security: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    Error:
      type: object
      required:
      - error
      - message
      properties:
        error:
          type: string
        message:
          type: string
        details:
          type: object
        dependency:
          type: string
    PartnershipCreate:
      type: object
      additionalProperties: false
      required:
      - partner_facility_id
      - title
      - services
      - data_shared
      - sharing_purpose
      - start_date
      - end_date
      properties:
        partner_facility_id:
          type: string
          format: uuid
        title:
          type: string
          minLength: 3
          maxLength: 200
        programmes:
          type: array
          maxItems: 20
          items:
            type: string
            pattern: ^[a-z0-9_.-]{2,64}$
        services:
          type: array
          minItems: 1
          items:
            enum:
            - referral_receipt
            - lab_tests
            - follow_up
        data_shared:
          type: array
          minItems: 1
          maxItems: 20
          items:
            type: string
            pattern: ^[a-z0-9_.-]{2,64}$
        sharing_purpose:
          type: string
          minLength: 10
          maxLength: 1000
        start_date:
          type: string
          format: date
        end_date:
          type: string
          format: date
    PartnershipTransition:
      type: object
      additionalProperties: false
      required:
      - action
      - expected_version
      properties:
        action:
          enum:
          - propose
          - accept
          - reject
          - activate
          - suspend
          - resume
          - end
        expected_version:
          type: integer
          minimum: 1
        reason:
          type: string
          minLength: 10
          maxLength: 1000
    Partnership:
      type: object
      properties:
        id:
          type: string
          format: uuid
        ngo_org_id:
          type: string
          format: uuid
        partner_facility_id:
          type: string
          format: uuid
        partner_name:
          type:
          - string
          - 'null'
        partner_code:
          type:
          - string
          - 'null'
        title:
          type: string
        programmes:
          type: array
          items:
            type: string
        services:
          type: array
          items:
            type: string
        data_shared:
          type: array
          items:
            type: string
        sharing_purpose:
          type: string
        start_date:
          type: string
          format: date
        end_date:
          type: string
          format: date
        state:
          enum:
          - draft
          - proposed
          - accepted
          - active
          - suspended
          - ended
          - rejected
        rejection_reason:
          type:
          - string
          - 'null'
        version:
          type: integer
        history:
          type: array
          items:
            type: object
    ProtocolCreate:
      type: object
      additionalProperties: false
      required:
      - code
      - title
      - definition
      properties:
        code:
          type: string
          pattern: ^[a-z0-9_.-]{2,64}$
        title:
          type: string
          minLength: 3
          maxLength: 200
        definition:
          $ref: '#/components/schemas/ProtocolDefinition'
    ProtocolDefinition:
      type: object
      description: 'Jurisdiction-approved configuration. OHN-60 contains no clinical threshold: fields, ranges, performer roles and the positive/refer criteria all come from here. First matching rule wins;
        no match = negative.'
      required:
      - performer_roles
      - fields
      - outcome_rules
      - follow_up_days
      - record
      properties:
        notice:
          type: string
        sources:
          type: array
          description: The publications the rules cite (id, full citation, link).
          items:
            type: object
            properties:
              id:
                type: string
              citation:
                type: string
              url:
                type: string
        performer_roles:
          type: array
          minItems: 1
          items:
            enum:
            - outreach_worker
            - outreach_clinician
        fields:
          type: array
          minItems: 1
          maxItems: 50
          items:
            type: object
            required:
            - key
            - label_en
            - label_fr
            - type
            properties:
              key:
                type: string
                pattern: ^[a-z][a-z0-9_]{0,47}$
              label_en:
                type: string
              label_fr:
                type: string
              type:
                enum:
                - number
                - integer
                - boolean
                - choice
                - text
              unit:
                type: string
              min:
                type: number
              max:
                type: number
              required:
                type: boolean
              max_length:
                type: integer
              options:
                type: array
                items:
                  type: object
                  required:
                  - code
                  - label_en
                  - label_fr
        outcome_rules:
          type: array
          items:
            type: object
            required:
            - id
            - outcome
            - all
            properties:
              id:
                type: string
              outcome:
                enum:
                - positive
                - refer
              priority:
                type: string
                description: Optional OHN-27 priority code for referrals from this rule (e.g. urgent); absent = referral.priority.
              sources:
                type: array
                description: Ids of the definition's sources this rule cites.
                items:
                  type: string
              all:
                type: array
                minItems: 1
                items:
                  type: object
                  required:
                  - field
                  - op
                  - value
                  properties:
                    field:
                      type: string
                    op:
                      enum:
                      - '>'
                      - '>='
                      - <
                      - <=
                      - ==
                      - '!='
                      - in
                    value: {}
        follow_up_days:
          type: integer
          minimum: 1
          maximum: 365
        record:
          type: object
          required:
          - encounter_type
          properties:
            encounter_type:
              type: string
              description: code of the jurisdiction OHN-09 encounter_type list
            as_result:
              type: boolean
            report_type:
              type: string
            observation_codes:
              type: object
        referral:
          type: object
          required:
          - requested_service
          - priority
          properties:
            requested_service:
              type: string
            priority:
              type: string
    ProtocolApprove:
      type: object
      additionalProperties: false
      required:
      - approval_reference
      - expected_version
      properties:
        approval_reference:
          type: string
          minLength: 3
          maxLength: 200
        expected_version:
          type: integer
          minimum: 1
    ProtocolRetire:
      type: object
      additionalProperties: false
      required:
      - reason
      - expected_version
      properties:
        reason:
          type: string
          minLength: 10
          maxLength: 1000
        expected_version:
          type: integer
          minimum: 1
    Protocol:
      type: object
      properties:
        id:
          type: string
          format: uuid
        code:
          type: string
        version:
          type: integer
        title:
          type: string
        status:
          enum:
          - draft
          - approved
          - retired
        demo:
          type: boolean
        clinically_approved:
          type: boolean
        approval_reference:
          type:
          - string
          - 'null'
        expected_version:
          type: integer
        notice:
          type: string
        definition:
          $ref: '#/components/schemas/ProtocolDefinition'
    CampaignCreate:
      type: object
      additionalProperties: false
      required:
      - name
      - programme
      - target_group
      - district
      - start_date
      - end_date
      - protocol_id
      properties:
        name:
          type: string
          minLength: 3
          maxLength: 200
        programme:
          type: string
          pattern: ^[a-z0-9_.-]{2,64}$
        target_group:
          type: string
          minLength: 3
          maxLength: 300
        district:
          type: string
          minLength: 2
          maxLength: 120
        start_date:
          type: string
          format: date
        end_date:
          type: string
          format: date
        protocol_id:
          type: string
          format: uuid
        follow_up_days:
          type: integer
          minimum: 1
          maximum: 365
    CampaignTransition:
      type: object
      additionalProperties: false
      required:
      - action
      - expected_version
      properties:
        action:
          enum:
          - approve
          - activate
          - close
        expected_version:
          type: integer
          minimum: 1
        reason:
          type: string
          minLength: 10
          maxLength: 1000
    Campaign:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        programme:
          type: string
        target_group:
          type: string
        area:
          type: object
          properties:
            jurisdiction_id:
              type: string
              format: uuid
            district:
              type: string
        start_date:
          type: string
          format: date
        end_date:
          type: string
          format: date
        protocol_id:
          type: string
          format: uuid
        protocol:
          type: object
        follow_up_days:
          type: integer
        state:
          enum:
          - draft
          - approved
          - active
          - closed
        version:
          type: integer
        sites:
          type: array
          items:
            $ref: '#/components/schemas/Site'
        team:
          type: array
          items:
            type: object
    SiteCreate:
      type: object
      additionalProperties: false
      required:
      - name
      - kind
      properties:
        name:
          type: string
          minLength: 2
          maxLength: 200
        kind:
          enum:
          - fixed
          - mobile
        latitude:
          type: number
          minimum: -90
          maximum: 90
        longitude:
          type: number
          minimum: -180
          maximum: 180
        site_date:
          type: string
          format: date
    Site:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        kind:
          enum:
          - fixed
          - mobile
        latitude:
          type:
          - number
          - 'null'
        longitude:
          type:
          - number
          - 'null'
        site_date:
          type:
          - string
          - 'null'
    TeamMember:
      type: object
      additionalProperties: false
      required:
      - principal_id
      - role
      - display_name
      properties:
        principal_id:
          type: string
          format: uuid
        role:
          enum:
          - field_coordinator
          - outreach_worker
          - outreach_clinician
        display_name:
          type: string
          minLength: 2
          maxLength: 120
    PersonLookup:
      type: object
      additionalProperties: false
      required: []
      properties:
        health_id:
          type: string
          minLength: 5
          maxLength: 64
        given_name:
          type: string
          minLength: 1
          maxLength: 100
        family_name:
          type: string
          minLength: 2
          maxLength: 100
        birth_date:
          type: string
          format: date
    PersonRegister:
      type: object
      additionalProperties: false
      required:
      - campaign_id
      properties:
        campaign_id:
          type: string
          format: uuid
        existing_patient_id:
          type: string
          format: uuid
        health_id:
          type: string
          minLength: 5
          maxLength: 64
        given_name:
          type: string
          minLength: 1
          maxLength: 100
        family_name:
          type: string
          minLength: 2
          maxLength: 100
        birth_date:
          type: string
          format: date
        sex:
          enum:
          - male
          - female
          - unknown
          - other
        client_ref:
          type: string
          minLength: 8
          maxLength: 100
        on_conflict:
          enum:
          - ask
          - link_exact
          description: 'link_exact (offline sync): link to the single exact MPI match instead of 409 possible_duplicate'
    Person:
      type: object
      properties:
        id:
          type: string
          format: uuid
        patient_id:
          type: string
          format: uuid
        health_id:
          type:
          - string
          - 'null'
        given_name:
          type: string
        family_name:
          type: string
        birth_date:
          type: string
          format: date
        sex:
          type: string
        source:
          enum:
          - existing
          - registered
          - linked_on_sync
        resolution:
          enum:
          - existing
          - registered
          - linked_on_sync
          - replayed
          - already_linked
    Consent:
      type: object
      additionalProperties: false
      required:
      - campaign_id
      - kind
      - granted
      properties:
        campaign_id:
          type: string
          format: uuid
        kind:
          enum:
          - screening
          - data_sharing
        granted:
          type: boolean
        client_ref:
          type: string
          minLength: 8
          maxLength: 100
    ScreeningCreate:
      type: object
      additionalProperties: false
      required:
      - campaign_id
      - site_id
      - person_id
      - answers
      properties:
        campaign_id:
          type: string
          format: uuid
        site_id:
          type: string
          format: uuid
        person_id:
          type: string
          format: uuid
        answers:
          type: object
          description: keys and value types of the protocol fields
        performed_at:
          type: string
          format: date-time
        client_ref:
          type: string
          minLength: 8
          maxLength: 100
        referral_partner_facility_id:
          type: string
          format: uuid
        referral_reason:
          type: string
          minLength: 10
          maxLength: 4000
    Screening:
      type: object
      properties:
        id:
          type: string
          format: uuid
        campaign_id:
          type: string
          format: uuid
        site_id:
          type: string
          format: uuid
        person_id:
          type: string
          format: uuid
        patient_id:
          type: string
          format: uuid
        outcome:
          enum:
          - negative
          - positive
          - refer
        matched_rule:
          type:
          - string
          - 'null'
        answers:
          type: object
        performed_at:
          type: string
          format: date-time
        performed_by:
          type:
          - string
          - 'null'
        performer_role:
          type: string
        record_state:
          enum:
          - pending
          - recorded
          - failed
        encounter_ref:
          type:
          - string
          - 'null'
        result_ref:
          type:
          - string
          - 'null'
        referral:
          oneOf:
          - type: 'null'
          - $ref: '#/components/schemas/Referral'
        referral_required:
          type: boolean
        referral_error:
          $ref: '#/components/schemas/Error'
        replayed:
          type: boolean
    ReferralCreate:
      type: object
      additionalProperties: false
      required:
      - screening_id
      - partner_facility_id
      properties:
        screening_id:
          type: string
          format: uuid
        partner_facility_id:
          type: string
          format: uuid
        reason:
          type: string
          minLength: 10
          maxLength: 4000
    FollowUp:
      type: object
      additionalProperties: false
      required:
      - action
      - expected_version
      properties:
        action:
          enum:
          - receive
          - seen
          - outcome
        expected_version:
          type: integer
          minimum: 1
        outcome:
          type: string
          minLength: 3
          maxLength: 2000
    Referral:
      type: object
      properties:
        id:
          type: string
          format: uuid
        screening_id:
          type: string
          format: uuid
        campaign_id:
          type: string
          format: uuid
        partner_facility_id:
          type: string
          format: uuid
        partnership_id:
          type: string
          format: uuid
        ohn27_referral_id:
          type:
          - string
          - 'null'
        reason:
          type: string
        state:
          enum:
          - referred
          - received
          - seen
          - outcome_recorded
          - lost_to_follow_up
        outcome:
          type:
          - string
          - 'null'
        due_at:
          type: string
          format: date-time
        version:
          type: integer
        person:
          type: object
    NationalTotals:
      type: object
      properties:
        group_by:
          enum: [region, campaign, period]
        period:
          enum: [month, quarter]
        from:
          type: [string, 'null']
        to:
          type: [string, 'null']
        region:
          type: [string, 'null']
        min_count:
          const: 10
        suppressed_as:
          const: '<10'
        generated_at:
          type: string
        rows:
          type: array
          items:
            type: object
            additionalProperties: false
            properties:
              group:
                type: string
              screened:
                oneOf:
                - type: integer
                  minimum: 10
                - const: '<10'
              positive:
                oneOf:
                - type: integer
                  minimum: 10
                - const: '<10'
              referred:
                oneOf:
                - type: integer
                  minimum: 10
                - const: '<10'
              seen:
                oneOf:
                - type: integer
                  minimum: 10
                - const: '<10'
              positivity:
                type: [number, 'null']
              follow_up_rate:
                type: [number, 'null']
              suppressed:
                type: boolean
    Publication:
      type: object
      additionalProperties: false
      required:
      - campaign_id
      properties:
        campaign_id:
          type: string
          format: uuid
    Report:
      type: object
      properties:
        group_by:
          enum:
          - campaign
          - site
          - area
          - age_band
          - sex
        rows:
          type: array
          items:
            type: object
            properties:
              group:
                type: string
              screened:
                type:
                - integer
                - 'null'
              positive:
                type:
                - integer
                - 'null'
              referred:
                type:
                - integer
                - 'null'
              seen:
                type:
                - integer
                - 'null'
              positivity:
                type:
                - number
                - 'null'
              follow_up_rate:
                type:
                - number
                - 'null'
              suppressed:
                type: boolean
