openapi: 3.1.0
info:
  title: OHN-57 Research, Insurance Analytics and Workforce Statistics
  version: 1.0.0
  description: |
    Module key `research`. Every route except `GET /health/ohn-57` needs a gateway-issued Bearer token (ES256, issuer `ohn-platform-gateway`, audience `ohn-57`; subject, `jurisdiction` and `organization_id` are UUIDs) whose role uses its
    purpose of use (researcher/research, dac_member/research_governance, research_admin/research_administration,
    treating_clinician/treatment, insurer_analyst/insurance_analytics, fraud_reviewer/fraud_review,
    employer_analyst/workforce_statistics). Default deny: unknown route 404 (after authentication), role not listed 403 (audited), role used with another purpose 403. Every disclosure threshold (k, minimum cell, minimum group, maximum suppression) is configuration (`/config`, deployment defaults); nothing in the contract fixes one. Every write needs an
    `Idempotency-Key` header. Synthetic data only.
servers: [{ url: https://opeshealthnetwork.com }]
security: [{ bearer: [] }]
components:
  securitySchemes:
    bearer: { type: http, scheme: bearer, bearerFormat: JWT }
  parameters:
    Id: { name: id, in: path, required: true, schema: { type: string, format: uuid } }
    IdempotencyKey: { name: Idempotency-Key, in: header, required: true, schema: { type: string, maxLength: 255 } }
  responses:
    Error:
      description: Error
      content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } }
  schemas:
    Error:
      type: object
      required: [error]
      properties: { type: { type: string }, title: { type: string }, status: { type: integer }, detail: { type: string }, error: { type: string }, message: { type: string }, trace_id: { type: string }, setting: { type: string }, dependency: { type: string }, current_version: { type: integer }, k_required: { type: integer }, receipt_id: { type: string, format: uuid }, details: { description: 'For a 422: the first failing check per top-level field as a zod issue code (invalid_type, too_small, too_big, invalid_string, invalid_enum_value, invalid_literal); unknown keys under _ as unrecognized_keys.' } }
    Receipt:
      type: object
      properties: { receipt_id: { type: string, format: uuid }, committed_at: { type: string, format: date-time }, aggregate_id: { type: [string, 'null'] }, aggregate_type: { type: string }, status: { enum: [committed, denied, refused] } }
    Published:
      type: object
      required: [count, suppressed]
      properties: { count: { type: [integer, 'null'] }, suppressed: { type: boolean }, below: { type: integer } }
    Cell:
      type: object
      required: [key, count, suppressed]
      properties: { key: { type: object, additionalProperties: { type: string } }, count: { type: [integer, 'null'] }, suppressed: { type: boolean } }
    Criteria:
      type: object
      additionalProperties: false
      properties:
        sex: { enum: [female, male, other, unknown] }
        age_min: { type: integer, minimum: 0, maximum: 120 }
        age_max: { type: integer, minimum: 0, maximum: 120 }
        regions: { type: array, items: { type: string, minLength: 1, maxLength: 64 }, maxItems: 50 }
        conditions_any: { type: array, items: { type: string, pattern: '^[A-Za-z0-9._-]{1,16}$' }, maxItems: 50 }
        conditions_all: { type: array, items: { type: string, pattern: '^[A-Za-z0-9._-]{1,16}$' }, maxItems: 20 }
        conditions_none: { type: array, items: { type: string, pattern: '^[A-Za-z0-9._-]{1,16}$' }, maxItems: 50 }
    SubjectRecord:
      type: object
      additionalProperties: false
      required: [patient_id, birth_year, sex, region, conditions, treating_clinician_id, treating_org_id, employer_org_id, insurer_org_id]
      properties:
        patient_id: { type: string, format: uuid }
        birth_year: { type: integer, minimum: 1900, maximum: 2100 }
        sex: { enum: [female, male, other, unknown] }
        region: { type: string, minLength: 1, maxLength: 64 }
        conditions: { type: array, maxItems: 50, items: { type: string, pattern: '^[A-Za-z0-9._-]{1,16}$' } }
        treating_clinician_id: { type: [string, 'null'], format: uuid }
        treating_org_id: { type: [string, 'null'], format: uuid }
        employer_org_id: { type: [string, 'null'], format: uuid }
        insurer_org_id: { type: [string, 'null'], format: uuid }
    Config:
      type: object
      description: Disclosure thresholds of the jurisdiction. Until an administrator configures them (version 0, source default) the deployment defaults apply; if a default is not configured the answer is 503 not_configured and nothing is disclosed.
      required: [k_anonymity, min_cell, insurer_min_cell, employer_min_group, max_suppression_pct]
      properties:
        k_anonymity: { type: integer, minimum: 3, maximum: 100 }
        min_cell: { type: integer, minimum: 3, maximum: 100 }
        insurer_min_cell: { type: integer, minimum: 3, maximum: 100 }
        employer_min_group: { type: integer, minimum: 5, maximum: 500 }
        max_suppression_pct: { type: integer, minimum: 0, maximum: 20 }
        version: { type: integer }
        source: { enum: [configured, default] }
    Study:
      type: object
      properties:
        id: { type: string, format: uuid }
        title: { type: string }
        summary: { type: string }
        state: { enum: [registered, suspended, closed] }
        ethics_committee: { type: string }
        ethics_reference: { type: string }
        ethics_approved_on: { type: string, format: date }
        ethics_expires_on: { type: string, format: date }
        ethics_evidence_ref: { type: string }
        ethics_evidence_sha256: { type: string, pattern: '^[0-9a-f]{64}$' }
        ethics_current: { type: boolean }
        version: { type: integer }
    AccessRequest:
      type: object
      properties:
        id: { type: string, format: uuid }
        study_id: { type: string, format: uuid }
        kind: { enum: [extract, workspace] }
        variables: { type: array, items: { enum: [age_band, sex, region, conditions] } }
        justification: { type: string }
        state: { enum: [submitted, approved, rejected, withdrawn] }
        approvals: { type: integer }
        approvals_required: { type: integer }
    Extract:
      type: object
      properties:
        id: { type: string, format: uuid }
        k_required: { type: integer }
        k_achieved: { type: integer }
        generalisation: { type: object, properties: { level: { type: integer }, age_band_width: { type: integer }, region: { enum: [exact, suppressed] }, sex: { enum: [exact, suppressed] } } }
        rows_total: { type: integer }
        rows_released: { type: integer }
        rows_suppressed: { type: integer }
        sha256: { type: string }
    Trial:
      type: object
      properties:
        id: { type: string, format: uuid }
        study_id: { type: string, format: uuid }
        title: { type: string }
        registry_ref: { type: [string, 'null'] }
        criteria: { $ref: '#/components/schemas/Criteria' }
        state: { enum: [draft, recruiting, closed] }
        version: { type: integer }
    ContactRequest:
      type: object
      description: Returned only to the treating clinician named on the request.
      properties:
        id: { type: string, format: uuid }
        state: { enum: [awaiting_clinician, contacted, patient_interested, patient_declined, not_appropriate, consent_withdrawn] }
        patient_id: { type: string, format: uuid }
        trial_title: { type: string }
        criteria: { $ref: '#/components/schemas/Criteria' }
        version: { type: integer }
    FraudRule:
      type: object
      required: [rule_type, params, enabled, expected_version]
      properties:
        rule_type: { enum: [duplicate_claim, impossible_volume, outlier_provider] }
        params:
          oneOf:
            - { type: object, required: [window_days], properties: { window_days: { type: integer, minimum: 0, maximum: 90 } }, additionalProperties: false }
            - { type: object, required: [max_units_per_provider_day], properties: { max_units_per_provider_day: { type: integer, minimum: 1, maximum: 100000 }, service_codes: { type: array, maxItems: 50, default: [], items: { type: string, minLength: 1, maxLength: 32 } } }, additionalProperties: false }
            - { type: object, required: [z_threshold, min_providers, min_claims_per_provider], properties: { z_threshold: { type: number, minimum: 1, maximum: 10 }, min_providers: { type: integer, minimum: 3, maximum: 1000 }, min_claims_per_provider: { type: integer, minimum: 1, maximum: 1000 } }, additionalProperties: false }
        enabled: { type: boolean }
        expected_version: { type: integer, minimum: 0 }
    FraudFlag:
      type: object
      properties:
        id: { type: string, format: uuid }
        rule_type: { enum: [duplicate_claim, impossible_volume, outlier_provider] }
        claim_id: { type: [string, 'null'], format: uuid }
        claim_number: { type: [string, 'null'] }
        provider_org_id: { type: string, format: uuid }
        summary: { type: string }
        evidence: { type: object }
        score: { type: number }
        state: { enum: [open, under_review, cleared, referred_for_investigation] }
        version: { type: integer }
    Aggregates:
      type: object
      properties:
        group_too_small: { type: boolean }
        dimension: { enum: [age_band, sex, region] }
        members: { $ref: '#/components/schemas/Published' }
        employees: { $ref: '#/components/schemas/Published' }
        groups: { type: array, items: { $ref: '#/components/schemas/Cell' } }
        conditions: { type: array, items: { $ref: '#/components/schemas/Cell' } }
        cells: { type: array, items: { $ref: '#/components/schemas/Cell' } }
        min_cell: { type: integer }
        min_group: { type: integer }
paths:
  /health/ohn-57:
    get: { security: [], summary: 'Public liveness: status, module, dependencies (OHN-15, OHN-24, OHN-51: live or unconfigured), keys (pseudonym_key, link_key, export_signing_key: configured or not), writes_enabled, auth_configured, synthetic_auth (always false in Java), data (synthetic_only, or governed_release_only in production)', responses: { '200': { description: OK }, '503': { description: Database unavailable } } }
  /api/ohn/v1/research/context:
    get: { summary: Role, areas and configuration for the caller, responses: { '200': { description: OK } } }
  /api/ohn/v1/research/config:
    get: { summary: Disclosure configuration, responses: { '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/Config' } } } } } }
    put:
      summary: Update disclosure configuration (research_admin)
      parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { allOf: [{ $ref: '#/components/schemas/Config' }, { type: object, required: [expected_version], properties: { expected_version: { type: integer, minimum: 0 } } }], unevaluatedProperties: false } } } }
      responses: { '200': { description: Saved }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Error' } }
  /api/ohn/v1/research/studies:
    get: { summary: Studies (own organisation; committee sees all), responses: { '200': { description: OK } } }
    post:
      summary: Register a study with ethics evidence (researcher)
      parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [title, summary, ethics]
              additionalProperties: false
              properties:
                title: { type: string, minLength: 1, maxLength: 200 }
                summary: { type: string, minLength: 1, maxLength: 4000 }
                ethics: { type: object, additionalProperties: false, required: [committee, reference, approved_on, expires_on, evidence_ref, evidence_sha256], properties: { committee: { type: string, minLength: 1, maxLength: 200 }, reference: { type: string, minLength: 1, maxLength: 100 }, approved_on: { type: string, format: date }, expires_on: { type: string, format: date }, evidence_ref: { type: string, minLength: 1, maxLength: 200 }, evidence_sha256: { type: string, pattern: '^[0-9a-f]{64}$' } } }
      responses: { '201': { description: Registered }, '409': { $ref: '#/components/responses/Error' }, '422': { description: Invalid or ethics not current } }
  /api/ohn/v1/research/studies/{id}:
    get: { parameters: [{ $ref: '#/components/parameters/Id' }], summary: Study detail with requests, extracts and trials, responses: { '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/Study' } } } }, '404': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/research/studies/{id}/state:
    post:
      summary: Suspend, reinstate or close (dac_member, research_admin)
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, required: [state, reason, expected_version], properties: { state: { enum: [registered, suspended, closed] }, reason: { type: string, minLength: 1, maxLength: 1000 }, expected_version: { type: integer, minimum: 1 } } } } } }
      responses: { '200': { description: Changed }, '409': { $ref: '#/components/responses/Error' } }
  /api/ohn/v1/research/studies/{id}/access-requests:
    post:
      summary: Ask the data access committee (researcher)
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, required: [kind, variables, justification], properties: { kind: { enum: [extract, workspace] }, variables: { type: array, minItems: 1, maxItems: 4, items: { enum: [age_band, sex, region, conditions] } }, justification: { type: string, minLength: 1, maxLength: 4000 } } } } } }
      responses: { '201': { description: Submitted }, '409': { description: Study not active or ethics not current } }
  /api/ohn/v1/research/access-requests:
    get:
      summary: Access requests with votes
      parameters: [{ name: state, in: query, schema: { enum: [submitted, approved, rejected, withdrawn] } }]
      responses: { '200': { description: OK, content: { application/json: { schema: { type: object, properties: { items: { type: array, items: { $ref: '#/components/schemas/AccessRequest' } } } } } } } }
  /api/ohn/v1/research/access-requests/{id}/withdraw:
    post: { summary: Withdraw a waiting request (researcher), parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }], responses: { '200': { description: Withdrawn }, '409': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/research/access-requests/{id}/decisions:
    post:
      summary: Committee vote (dac_member). N distinct approvals approve; one rejection rejects; requester cannot vote.
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, required: [decision, reason], properties: { decision: { enum: [approve, reject] }, reason: { type: string, minLength: 1, maxLength: 2000 } } } } } }
      responses: { '200': { description: Recorded }, '403': { description: Conflict of interest }, '409': { description: Already decided or not waiting } }
  /api/ohn/v1/research/studies/{id}/extracts:
    post:
      summary: Prepare a de-identified k-anonymous extract (researcher, approved extract request)
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, required: [request_id], properties: { request_id: { type: string, format: uuid }, criteria: { $ref: '#/components/schemas/Criteria' } } } } } }
      responses: { '201': { description: Released, content: { application/json: { schema: { type: object, properties: { extract: { $ref: '#/components/schemas/Extract' }, receipt: { $ref: '#/components/schemas/Receipt' } } } } } }, '403': { description: Not approved }, '422': { description: empty_cohort or k_anonymity_not_reachable }, '503': { description: Signing key not configured } }
  /api/ohn/v1/research/extracts/{id}/download:
    get:
      summary: Signed CSV (pid, generalised approved variables only)
      parameters: [{ $ref: '#/components/parameters/Id' }]
      responses: { '200': { description: CSV, headers: { X-OHN57-Signature: { schema: { type: string } }, X-Content-SHA256: { schema: { type: string } } }, content: { text/csv: { schema: { type: string } } } }, '409': { description: Study no longer active } }
  /api/ohn/v1/research/studies/{id}/workspace/queries:
    get: { summary: Query log (append-only), parameters: [{ $ref: '#/components/parameters/Id' }], responses: { '200': { description: OK } } }
    post:
      summary: Aggregate-only workspace query over approved variables; logged
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, required: [request_id], properties: { request_id: { type: string, format: uuid }, criteria: { $ref: '#/components/schemas/Criteria' }, dimensions: { type: array, maxItems: 2, default: [], items: { enum: [age_band, sex, region, condition] } } } } } } }
      responses: { '200': { description: Suppressed aggregates, content: { application/json: { schema: { type: object, properties: { total: { $ref: '#/components/schemas/Published' }, cells: { type: array, items: { $ref: '#/components/schemas/Cell' } }, min_cell: { type: integer } } } } } }, '403': { description: Not approved or variable not approved } }
  /api/ohn/v1/research/cohort-counts:
    post:
      summary: Suppressed feasibility count (researcher); logged
      parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, properties: { criteria: { $ref: '#/components/schemas/Criteria' } } } } } }
      responses: { '200': { description: Count, content: { application/json: { schema: { $ref: '#/components/schemas/Published' } } } } }
  /api/ohn/v1/research/trials:
    get: { summary: Trials, responses: { '200': { description: OK } } }
    post:
      summary: Configure a trial (researcher, study registered with current approval)
      parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, required: [study_id, title, criteria], properties: { study_id: { type: string, format: uuid }, title: { type: string, minLength: 1, maxLength: 200 }, registry_ref: { type: string, minLength: 1, maxLength: 100 }, criteria: { $ref: '#/components/schemas/Criteria' } } } } } }
      responses: { '201': { description: Draft created } }
  /api/ohn/v1/research/trials/{id}:
    get: { parameters: [{ $ref: '#/components/parameters/Id' }], summary: Trial with suppressed outcome counts, responses: { '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/Trial' } } } } } }
  /api/ohn/v1/research/trials/{id}/state:
    post:
      summary: draft -> recruiting -> closed (researcher)
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, required: [state, expected_version], properties: { state: { enum: [recruiting, closed] }, expected_version: { type: integer, minimum: 1 } } } } } }
      responses: { '200': { description: Changed }, '409': { $ref: '#/components/responses/Error' } }
  /api/ohn/v1/research/trials/{id}/eligibility:
    get: { summary: Eligibility counts only (suppressed), parameters: [{ $ref: '#/components/parameters/Id' }], responses: { '200': { description: OK, content: { application/json: { schema: { type: object, properties: { eligible: { $ref: '#/components/schemas/Published' }, with_treating_clinician: { $ref: '#/components/schemas/Published' } } } } } } } }
  /api/ohn/v1/research/trials/{id}/contact-requests:
    post:
      summary: Route contact requests to treating clinicians for patients with OHN-15 research_contact permit (researcher)
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false } } } }
      responses: { '200': { description: Suppressed counts, content: { application/json: { schema: { type: object, properties: { routed_to_clinicians: { $ref: '#/components/schemas/Published' }, without_research_contact_consent: { $ref: '#/components/schemas/Published' }, remaining: { $ref: '#/components/schemas/Published' } } } } } }, '409': { description: Trial not recruiting }, '503': { description: OHN-15 unavailable; nothing stored } }
  /api/ohn/v1/research/contact-requests:
    get:
      summary: The treating clinician's own contact requests (only place a patient is named)
      parameters: [{ name: state, in: query, schema: { enum: [awaiting_clinician, contacted, patient_interested, patient_declined, not_appropriate, consent_withdrawn] } }]
      responses: { '200': { description: OK, content: { application/json: { schema: { type: object, properties: { items: { type: array, items: { $ref: '#/components/schemas/ContactRequest' } } } } } } } }
  /api/ohn/v1/research/contact-requests/{id}/outcome:
    post:
      summary: Record contact outcome (treating_clinician); consent rechecked before 'contacted'
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, required: [outcome, expected_version], properties: { outcome: { enum: [contacted, patient_interested, patient_declined, not_appropriate] }, note: { type: string, maxLength: 1000 }, expected_version: { type: integer, minimum: 1 } } } } } }
      responses: { '200': { description: Recorded }, '409': { description: invalid_transition, version_conflict or consent_withdrawn }, '503': { description: OHN-15 unavailable } }
  /api/ohn/v1/research/fraud/rules:
    get: { summary: Insurer fraud rules, responses: { '200': { description: OK } } }
    put:
      summary: Create or update one rule (insurer_analyst)
      parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/FraudRule' } } } }
      responses: { '200': { description: Saved }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Error' } }
  /api/ohn/v1/research/fraud/scans:
    get: { summary: Recent scans, responses: { '200': { description: OK } } }
    post:
      summary: Scan the insurer's OHN-51 claims with enabled rules (insurer_analyst). Never changes a claim.
      parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false } } } }
      responses: { '200': { description: Scan result }, '409': { description: No rules configured }, '503': { description: OHN-51 unavailable } }
  /api/ohn/v1/research/fraud/flags:
    get:
      summary: Reviewer queue
      parameters: [{ name: state, in: query, schema: { enum: [open, under_review, cleared, referred_for_investigation] } }, { name: rule_type, in: query, schema: { enum: [duplicate_claim, impossible_volume, outlier_provider] } }]
      responses: { '200': { description: OK, content: { application/json: { schema: { type: object, properties: { items: { type: array, items: { $ref: '#/components/schemas/FraudFlag' } }, note: { type: string } } } } } } }
  /api/ohn/v1/research/fraud/flags/{id}:
    get: { summary: Flag with history, parameters: [{ $ref: '#/components/parameters/Id' }], responses: { '200': { description: OK } } }
  /api/ohn/v1/research/fraud/flags/{id}/transition:
    post:
      summary: Review a flag (fraud_reviewer)
      parameters: [{ $ref: '#/components/parameters/Id' }, { $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, required: [to, note, expected_version], properties: { to: { enum: [under_review, cleared, referred_for_investigation] }, note: { type: string, minLength: 1, maxLength: 2000 }, expected_version: { type: integer, minimum: 1 } } } } } }
      responses: { '200': { description: Changed }, '409': { $ref: '#/components/responses/Error' } }
  /api/ohn/v1/research/insights/population-risk:
    get:
      summary: Anonymous aggregates of the insurer's own members (insurer_analyst)
      parameters: [{ name: dimension, in: query, schema: { enum: [age_band, sex, region], default: age_band } }]
      responses: { '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/Aggregates' } } } } }
  /api/ohn/v1/research/insights/workforce:
    get:
      summary: Anonymous workforce statistics for the employer's own workforce (employer_analyst)
      parameters: [{ name: dimension, in: query, schema: { enum: [age_band, sex, region], default: age_band } }]
      responses: { '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/Aggregates' } } } } }
  /api/ohn/v1/research/mart/subjects:
    post:
      summary: Ingest synthetic subject records (research_admin)
      parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, required: [source, synthetic, records], properties: { source: { type: string, minLength: 1, maxLength: 64 }, synthetic: { const: true }, records: { type: array, minItems: 1, maxItems: 1000, items: { $ref: '#/components/schemas/SubjectRecord' } } } } } } }
      responses: { '200': { description: Upserted } }
  /api/ohn/v1/research/admin/synthetic-load:
    post:
      summary: Generate synthetic subjects (research_admin, non-production only)
      parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, additionalProperties: false, required: [count, seed, treating], properties: { count: { type: integer, minimum: 1, maximum: 2000 }, seed: { type: integer, minimum: 1, maximum: 2147483647 }, treating: { type: array, minItems: 1, maxItems: 50, items: { type: object, additionalProperties: false, required: [clinician_id, org_id], properties: { clinician_id: { type: string, format: uuid }, org_id: { type: string, format: uuid } } } }, employer_org_ids: { type: array, maxItems: 20, default: [], items: { type: string, format: uuid } }, insurer_org_ids: { type: array, maxItems: 20, default: [], items: { type: string, format: uuid } } } } } } }
      responses: { '200': { description: Loaded }, '404': { description: Not available in production or unless ohn.m57.synthetic-load-enabled is true } }
  /api/ohn/v1/research/mart/summary:
    get: { summary: Data mart counts (dac_member, research_admin), responses: { '200': { description: OK } } }
  /api/ohn/v1/research/audit:
    get: { summary: Audit records (research_admin, dac_member), responses: { '200': { description: OK } } }
  /api/ohn/v1/research/admin/outbox/relay:
    post: { summary: Relay pending events to OHN-24 (research_admin), parameters: [{ $ref: '#/components/parameters/IdempotencyKey' }], responses: { '200': { description: Relay result } } }
