openapi: 3.1.0
info:
  title: OHN-37 Patient Identity Proofing and Assurance
  version: 1.1.0
  description: >
    Identity proofing cases, evidence review, identity disputes, impersonation investigation and assurance management.
    Reconciled with the observed behaviour of the TypeScript reference (20 operations; the legacy dev token endpoint is not part of the contract).
    Base path /api/ohn/v1/proofing. Every mutation requires an Idempotency-Key (1-255 characters). Routes default-deny on role.
    Assurance policy (which evidence and channels may reach which level) is configuration and fails closed to the claimed level.
    Synthetic-ready; real-patient use requires accepted OHN-01/OHN-38/OHN-45/OHN-16 integrations and legal authorization.
servers:
  - url: /api/ohn/v1/proofing
security:
  - bearer: []
paths:
  /cases:
    post:
      operationId: createCase
      summary: Register a proofing case (OHN-37-F001, API-001).
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/ProofingCaseCommand' } } } }
      responses:
        '201': { $ref: '#/components/responses/Created' }
        '400': { $ref: '#/components/responses/Error' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '409': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
        '503': { $ref: '#/components/responses/Error' }
    get:
      operationId: listCases
      summary: Proofing cases of the caller's jurisdiction and organization, cursor paged.
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters:
        - { name: page_size, in: query, required: false, schema: { type: string } }
        - { name: cursor, in: query, required: false, schema: { type: string } }
        - { name: state, in: query, required: false, schema: { type: string } }
        - { name: channel, in: query, required: false, schema: { type: string } }
        - { name: evidence_type, in: query, required: false, schema: { type: string } }
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
  /cases/{id}:
    get:
      operationId: getCase
      summary: One case with its evidence (redacted unless an identity supervisor reveals it) and history.
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters:
        - { $ref: '#/components/parameters/Id' }
        - { name: reveal, in: query, required: false, schema: { type: string } }
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '404': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
  /cases/{id}/evidence:
    post:
      operationId: submitEvidence
      summary: Add an evidence artifact to an undecided case (OHN-37-F002).
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/EvidenceArtifactCommand' } } } }
      responses:
        '201': { $ref: '#/components/responses/Created' }
        '400': { $ref: '#/components/responses/Error' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '404': { $ref: '#/components/responses/Error' }
        '409': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
  /cases/{id}/decide:
    post:
      operationId: decideCase
      summary: Approve, reject or send a case to manual review; approval issues the assurance badge and events.
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/DecideCaseCommand' } } } }
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '400': { $ref: '#/components/responses/Error' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '404': { $ref: '#/components/responses/Error' }
        '409': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
  /cases/{id}/transitions:
    post:
      operationId: transitionCase
      summary: Move a case one step along its lifecycle (claim_created -> evidence_collected -> fraud_screened -> verified_or_rejected -> assurance_recorded).
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/CaseTransitionCommand' } } } }
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '400': { $ref: '#/components/responses/Error' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '404': { $ref: '#/components/responses/Error' }
        '409': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
  /policy:
    get:
      operationId: getAssurancePolicy
      summary: The active assurance policy, or the fail-closed notice (status not_configured, cap claimed).
      x-required-roles: [proofing_officer, identity_supervisor]
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
  /evidence-review:
    get:
      operationId: evidenceReview
      summary: Undecided cases with their evidence; text is redacted unless an identity supervisor passes reveal=1.
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters: [{ name: reveal, in: query, required: false, schema: { type: string } }]
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
  /disputes:
    get:
      operationId: listDisputes
      summary: Identity disputes of the caller's scope, newest first.
      x-required-roles: [proofing_officer, identity_supervisor]
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
    post:
      operationId: submitDispute
      summary: Submit an identity dispute; fraudulent use opens an impersonation investigation (OHN-37-F003).
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/DisputeCommand' } } } }
      responses:
        '201': { $ref: '#/components/responses/Created' }
        '400': { $ref: '#/components/responses/Error' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
  /disputes/{id}:
    get:
      operationId: getDispute
      summary: One dispute with its full description, the investigation it opened and its steps.
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters: [{ $ref: '#/components/parameters/Id' }]
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '404': { $ref: '#/components/responses/Error' }
  /disputes/{id}/transitions:
    post:
      operationId: transitionDispute
      summary: Take a dispute into review (open -> under_review) or resolve it (under_review -> resolved, supervisor only, resolution required).
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/DisputeTransitionCommand' } } } }
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '400': { $ref: '#/components/responses/Error' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '404': { $ref: '#/components/responses/Error' }
        '409': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
  /assurance-reviews:
    get:
      operationId: listAssuranceReviews
      summary: Assurance escalation and downgrade reviews, newest first.
      x-required-roles: [proofing_officer, identity_supervisor]
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
    post:
      operationId: submitAssuranceReview
      summary: Register an assurance review (identity supervisor only; OHN-37-F004).
      x-required-roles: [identity_supervisor]
      parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/AssuranceReviewCommand' } } } }
      responses:
        '201': { $ref: '#/components/responses/Created' }
        '400': { $ref: '#/components/responses/Error' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
  /assurance-badges:
    get:
      operationId: listAssuranceBadges
      summary: Issued assurance badges, cursor paged.
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters:
        - { name: page_size, in: query, required: false, schema: { type: string } }
        - { name: cursor, in: query, required: false, schema: { type: string } }
        - { name: assurance_level, in: query, required: false, schema: { type: string } }
        - { name: channel, in: query, required: false, schema: { type: string } }
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Error' }
  /workflows:
    get:
      operationId: listWorkflows
      summary: Proofing, impersonation and escalation workflows with the latest 250 history rows.
      x-required-roles: [proofing_officer, identity_supervisor]
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
  /workflows/{id}/transitions:
    post:
      operationId: transitionWorkflow
      summary: Move an impersonation case or an assurance review one step (identity supervisor only).
      x-required-roles: [identity_supervisor]
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/WorkflowTransitionCommand' } } } }
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '400': { $ref: '#/components/responses/Error' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '404': { $ref: '#/components/responses/Error' }
        '409': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
  /reports/{id}:
    get:
      operationId: runReport
      summary: Run report OHN-37-R001 (proofing outcomes), R002 (impersonation and disputes) or R003 (evidence retention).
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters:
        - { $ref: '#/components/parameters/ReportId' }
        - { name: period_from, in: query, required: false, schema: { type: string } }
        - { name: period_to, in: query, required: false, schema: { type: string } }
        - { name: channel, in: query, required: false, schema: { type: string } }
        - { name: evidence_type, in: query, required: false, schema: { type: string } }
        - { name: severity, in: query, required: false, schema: { type: string } }
        - { name: source, in: query, required: false, schema: { type: string } }
      responses:
        '200': { $ref: '#/components/responses/Ok' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '404': { $ref: '#/components/responses/Error' }
  /reports/{id}/export:
    post:
      operationId: exportReport
      summary: Export a report as a signed, single-use, five-minute CSV or PDF.
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters: [{ $ref: '#/components/parameters/ReportId' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/ExportCommand' } } } }
      responses:
        '201': { $ref: '#/components/responses/Created' }
        '400': { $ref: '#/components/responses/Error' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '404': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Error' }
        '429': { $ref: '#/components/responses/Error' }
        '503': { $ref: '#/components/responses/Error' }
  /exports/{token}:
    get:
      operationId: downloadExport
      summary: Download an export once (bound to the requesting principal).
      x-required-roles: [proofing_officer, identity_supervisor]
      parameters: [{ name: token, in: path, required: true, schema: { type: string } }]
      responses:
        '200':
          description: The export bytes once; Content-Type is text/csv or application/pdf, with X-OHN-Export-Signature and X-OHN-Receipt-Id headers
          content: { application/octet-stream: { schema: { type: string, format: binary } } }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
        '404': { $ref: '#/components/responses/Error' }
        '503': { $ref: '#/components/responses/Error' }
components:
  securitySchemes:
    bearer: { type: http, scheme: bearer, bearerFormat: JWT }
  parameters:
    IdempotencyKey: { name: Idempotency-Key, in: header, required: true, schema: { type: string, minLength: 1, maxLength: 255 }, description: One key per user intent. Same key and payload replays the original answer; same key with another payload is 409 idempotency_conflict. }
    Id: { name: id, in: path, required: true, schema: { type: string, format: uuid } }
    ReportId: { name: id, in: path, required: true, schema: { type: string } }
  responses:
    Ok: { description: OK, content: { application/json: { schema: { type: object } } } }
    Created: { description: Created; the body carries the committed receipt, content: { application/json: { schema: { type: object } } } }
    Error: { description: 'Problem document: error, message, details', content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
  schemas:
    Error:
      type: object
      required: [error]
      properties:
        error: { type: string }
        message: { type: string }
        details: {}
    ProofingChannel: { type: string, enum: [in_person, remote_video, remote_document, assisted_enrollment] }
    EvidenceType: { type: string, enum: [national_id, passport, birth_certificate, residence_permit, driving_license, biometric_collection, community_attestation, guardian_attestation] }
    AssuranceLevel: { type: string, enum: [claimed, partial, verified, high] }
    BiographicMatch: { type: string, enum: [match, partial_match, mismatch, not_checked] }
    LivenessResult: { type: string, enum: [passed, failed, inconclusive, not_performed] }
    ReviewDecision: { type: string, enum: [approve, reject, manual_review] }
    ProofingCaseCommand:
      type: object
      additionalProperties: false
      required: [jurisdiction_id, person_claim_ref, proofing_channel, evidence_type, evidence_reference, assurance_target]
      properties:
        jurisdiction_id: { type: string, format: uuid }
        person_claim_ref: { type: string, format: uuid }
        proofing_channel: { $ref: '#/components/schemas/ProofingChannel' }
        evidence_type: { $ref: '#/components/schemas/EvidenceType' }
        evidence_reference: { type: string, format: uuid }
        assurance_target: { $ref: '#/components/schemas/AssuranceLevel' }
    EvidenceArtifactCommand:
      type: object
      additionalProperties: false
      required: [case_id, document_checks, biographic_match, review_decision, reviewer]
      properties:
        case_id: { type: string, format: uuid }
        document_checks: { type: string, minLength: 1, maxLength: 8192 }
        biographic_match: { $ref: '#/components/schemas/BiographicMatch' }
        liveness_result: { $ref: '#/components/schemas/LivenessResult' }
        review_decision: { $ref: '#/components/schemas/ReviewDecision' }
        reviewer: { type: string, format: uuid }
    DecideCaseCommand:
      type: object
      additionalProperties: false
      required: [expected_version, review_decision, document_checks, biographic_match, reason]
      properties:
        expected_version: { type: integer, minimum: 1 }
        review_decision: { $ref: '#/components/schemas/ReviewDecision' }
        document_checks: { type: string, minLength: 1, maxLength: 8192 }
        biographic_match: { $ref: '#/components/schemas/BiographicMatch' }
        liveness_result: { $ref: '#/components/schemas/LivenessResult' }
        reason: { type: string, minLength: 10, maxLength: 4096 }
    CaseTransitionCommand:
      type: object
      additionalProperties: false
      required: [expected_version, to_state, evidence_ref, reason]
      properties:
        expected_version: { type: integer, minimum: 1 }
        to_state: { type: string, minLength: 1, maxLength: 64 }
        evidence_ref: { type: string, format: uuid }
        reason: { type: string, minLength: 10, maxLength: 4096 }
    DisputeCommand:
      type: object
      additionalProperties: false
      required: [person_ref, dispute_type, claim_description, supporting_evidence_ref, contact_channel]
      properties:
        person_ref: { type: string, format: uuid }
        dispute_type: { type: string, enum: [not_my_record, duplicate_record, wrong_demographics, fraudulent_use, other] }
        claim_description: { type: string, minLength: 1, maxLength: 8192 }
        supporting_evidence_ref: { type: string, format: uuid }
        contact_channel: { type: string, enum: [phone, email, sms, in_person, guardian] }
    DisputeTransitionCommand:
      type: object
      additionalProperties: false
      required: [expected_version, to_state, reason]
      properties:
        expected_version: { type: integer, minimum: 1 }
        to_state: { type: string, enum: [under_review, resolved] }
        reason: { type: string, minLength: 10, maxLength: 4096 }
        resolution: { type: string, enum: [upheld_record_corrected, upheld_referred, not_upheld, withdrawn] }
    AssuranceReviewCommand:
      type: object
      additionalProperties: false
      description: current_assurance and target_assurance must differ (422, detail on target_assurance).
      required: [patient_ref, current_assurance, target_assurance, evidence_refs, reviewer]
      properties:
        patient_ref: { type: string, format: uuid }
        current_assurance: { $ref: '#/components/schemas/AssuranceLevel' }
        target_assurance: { $ref: '#/components/schemas/AssuranceLevel' }
        evidence_refs: { type: string, minLength: 1, maxLength: 8192 }
        reviewer: { type: string, format: uuid }
    WorkflowTransitionCommand:
      type: object
      additionalProperties: false
      required: [expected_version, to_state, evidence_ref, reason]
      properties:
        expected_version: { type: integer, minimum: 1 }
        to_state: { type: string, minLength: 1, maxLength: 64 }
        evidence_ref: { type: string, format: uuid }
        reason: { type: string, minLength: 10, maxLength: 4096 }
        resolution: { type: string, enum: [confirmed_impersonation, cleared, inconclusive] }
    ExportCommand:
      type: object
      additionalProperties: false
      required: [format]
      properties:
        format: { type: string, enum: [csv, pdf] }
        period_from: { type: string, format: date-time }
        period_to: { type: string, format: date-time }
        channel: { $ref: '#/components/schemas/ProofingChannel' }
        country: { type: string, format: uuid }
        jurisdiction_id: { type: string, format: uuid }
        evidence_type: { $ref: '#/components/schemas/EvidenceType' }
        severity: { type: string, enum: [low, medium, high, critical] }
        source: { type: string, maxLength: 128 }
