openapi: 3.1.0
info:
  title: OHN-49 Lab and Imaging Orders
  version: 1.1.0
  description: >
    Order entry, routing to a performing laboratory or imaging centre, worklists, specimen and appointment tracking,
    and closing the loop with OHN-11. Every request is scoped by the token's jurisdiction AND organization.
    Every write requires Idempotency-Key; lifecycle steps require expected_version (409 on mismatch).
    Missing configuration => 503 not_configured; unconfigured or failing dependency => 503 dependency_unavailable.
    1.0.1: reconciled with the Java service. Validation errors are 422 domain_validation_failed with zod-style details {field: [messages]}; a route outside the permission table is 403 denied_by_policy; the TypeScript-only synthetic token route is not served (the gateway issues tokens).
    1.1.0 (2026-11-23): role lab_assistant (purpose diagnostic_fulfilment) on lab orders of its own performing organisation: may read orders,
    config, the worklist and results and take the steps accept, specimens, start and result with report_status preliminary only. A final,
    amended or corrected result from it is 403 denied_by_policy with guard result_release_not_permitted (audited); reject, cancel,
    result-link, reports, exports and configuration are refused. Verification and release stay with lab_technologist / lab_verifier (OHN-11).
servers: [{ url: / }]
security: [{ bearer: [] }]
tags: [{ name: orders }, { name: steps }, { name: config }, { name: reports }, { name: ops }]
paths:
  /health/ohn-49:
    get:
      tags: [ops]
      security: []
      summary: Health and dependency modes
      responses:
        '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/Health' } } } }
        '503': { description: Database unavailable }
  /api/ohn/v1/orders:
    get:
      tags: [orders]
      summary: List orders in scope
      parameters:
        - { name: status, in: query, schema: { type: string, description: comma-separated OrderStatus values } }
        - { name: kind, in: query, schema: { $ref: '#/components/schemas/OrderKind' } }
        - { name: priority, in: query, schema: { type: string } }
        - { name: patient_ref, in: query, schema: { type: string, format: uuid } }
        - { name: q, in: query, schema: { type: string, description: order number fragment } }
        - { name: mine, in: query, schema: { enum: ['true'] } }
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
      responses:
        '200': { $ref: '#/components/responses/OrderPage' }
        '401': { $ref: '#/components/responses/Error' }
        '403': { $ref: '#/components/responses/Error' }
    post:
      tags: [orders]
      summary: Create an order (draft, or placed when submit=true) — OHN-49-F001 (ordering_clinician)
      parameters: [{ $ref: '#/components/parameters/idempotency' }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/OrderCreate' } } } }
      responses:
        '201': { $ref: '#/components/responses/OrderReceipt' }
        '403': { $ref: '#/components/responses/Error' }
        '409': { $ref: '#/components/responses/Error' }
        '422': { $ref: '#/components/responses/Validation' }
        '503': { $ref: '#/components/responses/Error' }
  /api/ohn/v1/orders/worklist:
    get:
      tags: [orders]
      summary: Performer worklist (open work ordered by due date); lab roles see lab orders, imaging roles imaging orders
      parameters:
        - { name: status, in: query, schema: { type: string } }
        - { name: q, in: query, schema: { type: string } }
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/offset'
      responses: { '200': { $ref: '#/components/responses/OrderPage' }, '403': { $ref: '#/components/responses/Error' } }
  /api/ohn/v1/orders/dashboard:
    get:
      tags: [orders]
      summary: KPIs in scope
      responses: { '200': { description: OK, content: { application/json: { schema: { type: object, properties: { by_status: { type: object, additionalProperties: { type: integer } }, kpis: { type: object, properties: { open: { type: integer }, awaiting_review: { type: integer }, overdue: { type: integer }, drafts: { type: integer } } } } } } } } }
  /api/ohn/v1/orders/{id}:
    get:
      tags: [orders]
      summary: Order detail with tests, screening, specimens, timeline and allowed_actions
      parameters: [{ $ref: '#/components/parameters/id' }]
      responses:
        '200': { description: OK, content: { application/json: { schema: { $ref: '#/components/schemas/OrderDetail' } } } }
        '404': { $ref: '#/components/responses/Error' }
  /api/ohn/v1/orders/{id}/result:
    get:
      tags: [orders]
      summary: Live read of the linked OHN-11 DiagnosticReport (never cached)
      parameters: [{ $ref: '#/components/parameters/id' }]
      responses:
        '200': { description: OK, content: { application/json: { schema: { type: object, properties: { order_id: { type: string }, result_ref: { type: string }, source: { const: OHN-11 }, report: { type: object, description: OHN-11 reportView } } } } } }
        '404': { $ref: '#/components/responses/Error' }
        '503': { $ref: '#/components/responses/Error' }
    post: { tags: [steps], summary: 'Post result/report to OHN-11 POST /api/ohn/v1/diagnostics/results/ingest and link it (lab staff, radiologist)', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/PostResult' } } } }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/place:
    post: { tags: [steps], summary: 'Place a draft (ordering_clinician)', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { $ref: '#/components/requestBodies/VersionOnly' }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/amend:
    post: { tags: [steps], summary: 'Amend (draft stays draft; placed/rejected become placed after re-running every guard) — OHN-49-F002', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/OrderAmend' } } } }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/accept:
    post: { tags: [steps], summary: 'Accept (performer)', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { $ref: '#/components/requestBodies/VersionOnly' }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/reject:
    post: { tags: [steps], summary: 'Reject with a configured rejection_reason (performer)', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { $ref: '#/components/requestBodies/Reasoned' }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/specimens:
    post: { tags: [steps], summary: 'Record specimen collection (lab)', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/Specimen' } } } }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/start:
    post: { tags: [steps], summary: 'Mark in progress (lab)', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { $ref: '#/components/requestBodies/VersionOnly' }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/schedule:
    post: { tags: [steps], summary: 'Schedule or reschedule (imaging_technologist)', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/Schedule' } } } }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/protocol:
    post: { tags: [steps], summary: 'Protocol (radiologist); screening_reviewed required when screening flagged review', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/Protocol' } } } }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/performed:
    post: { tags: [steps], summary: 'Mark performed (imaging_technologist)', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/Performed' } } } }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/result-link:
    post: { tags: [steps], summary: 'Link an existing OHN-11 report (same patient and source facility)', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { required: true, content: { application/json: { schema: { type: object, required: [expected_version, ohn11_report_id], additionalProperties: false, properties: { expected_version: { type: integer, minimum: 1 }, ohn11_report_id: { type: string, format: uuid } } } } } }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/review:
    post: { tags: [steps], summary: 'Orderer review; refused (409 result_not_final) unless the result is final/amended/corrected', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { $ref: '#/components/requestBodies/VersionOnly' }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/{id}/cancel:
    post: { tags: [steps], summary: 'Cancel with a configured cancel_reason (orderer any open state; performer after accept)', parameters: [{ $ref: '#/components/parameters/id' }, { $ref: '#/components/parameters/idempotency' }], requestBody: { $ref: '#/components/requestBodies/Reasoned' }, responses: { '200': { $ref: '#/components/responses/OrderReceipt' }, '403': { $ref: '#/components/responses/Error' }, '404': { $ref: '#/components/responses/Error' }, '409': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/config:
    get: { tags: [config], summary: 'Configuration and readiness (missing[] lists what blocks ordering)', responses: { '200': { description: OK } } }
  /api/ohn/v1/orders/config/code-lists:
    post: { tags: [config], summary: 'Upsert a code (orders_admin)', parameters: [{ $ref: '#/components/parameters/idempotency' }], requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/CodeListCommand' } } } }, responses: { '201': { description: Saved }, '403': { $ref: '#/components/responses/Error' }, '422': { $ref: '#/components/responses/Validation' } } }
  /api/ohn/v1/orders/config/priority-targets:
    post: { tags: [config], summary: 'Upsert a turnaround target (orders_admin)', parameters: [{ $ref: '#/components/parameters/idempotency' }], requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/PriorityTargetCommand' } } } }, responses: { '201': { description: Saved }, '422': { $ref: '#/components/responses/Validation' }, '503': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/config/screening-questions:
    post: { tags: [config], summary: 'Upsert a screening question (orders_admin)', parameters: [{ $ref: '#/components/parameters/idempotency' }], requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/ScreeningQuestionCommand' } } } }, responses: { '201': { description: Saved } } }
  /api/ohn/v1/orders/config/settings:
    post: { tags: [config], summary: 'Create (expected_version 0) or update settings (orders_admin)', parameters: [{ $ref: '#/components/parameters/idempotency' }], requestBody: { required: true, content: { application/json: { schema: { $ref: '#/components/schemas/SettingsCommand' } } } }, responses: { '200': { description: Saved }, '409': { $ref: '#/components/responses/Error' } } }
  /api/ohn/v1/orders/reports:
    get: { tags: [reports], summary: 'Report catalogue with metric definitions', responses: { '200': { description: OK } } }
  /api/ohn/v1/orders/reports/{rid}:
    get:
      tags: [reports]
      summary: Run OHN-49-R001 (turnaround) or OHN-49-R002 (rejected)
      parameters:
        - { name: rid, in: path, required: true, schema: { enum: [OHN-49-R001, OHN-49-R002] } }
        - { name: from, in: query, schema: { type: string, format: date } }
        - { name: to, in: query, schema: { type: string, format: date } }
        - { name: kind, in: query, schema: { $ref: '#/components/schemas/OrderKind' } }
        - { name: priority, in: query, schema: { type: string } }
        - { name: reason_code, in: query, schema: { type: string } }
      responses: { '200': { description: Report, content: { application/json: { schema: { $ref: '#/components/schemas/Report' } } } } }
  /api/ohn/v1/orders/reports/{rid}/export:
    post:
      tags: [reports]
      summary: Create a signed CSV/PDF export (HMAC-SHA256 with OHN49_EXPORT_SIGNING_KEY)
      parameters: [{ name: rid, in: path, required: true, schema: { enum: [OHN-49-R001, OHN-49-R002] } }, { $ref: '#/components/parameters/idempotency' }]
      requestBody: { required: true, content: { application/json: { schema: { type: object, required: [format], properties: { format: { enum: [csv, pdf] }, filters: { type: object, additionalProperties: { type: string } } } } } } }
      responses: { '201': { description: 'download_token, retrieval.path, signature' }, '503': { $ref: '#/components/responses/Error' } }
  /api/ohn/v1/orders/exports/{token}:
    get: { tags: [reports], summary: 'One-time download by the same principal before expiry; X-OHN49-Signature header', parameters: [{ name: token, in: path, required: true, schema: { type: string } }], responses: { '200': { description: File }, '404': { description: Expired, used or not yours } } }
  /api/ohn/v1/orders/audit:
    get: { tags: [ops], summary: 'Audit receipts for the caller organization (orders_admin)', responses: { '200': { description: OK } } }
  /api/ohn/v1/orders/outbox:
    get: { tags: [ops], summary: 'Outbox delivery state (orders_admin)', responses: { '200': { description: OK } } }
  /api/ohn/v1/orders/outbox/dispatch:
    post: { tags: [ops], summary: 'Relay pending events to OHN-24 (orders_admin)', parameters: [{ $ref: '#/components/parameters/idempotency' }], responses: { '200': { description: 'delivered, failed, pending_after' }, '503': { $ref: '#/components/responses/Error' } } }
components:
  securitySchemes:
    bearer: { type: http, scheme: bearer, bearerFormat: 'JWT HS256, iss ohn-49-orders, aud ohn-49-api; claims sub, role, jurisdiction, organization_id (UUIDs), purpose bound to role' }
  parameters:
    id: { name: id, in: path, required: true, schema: { type: string, format: uuid } }
    idempotency: { name: Idempotency-Key, in: header, required: true, schema: { type: string, maxLength: 255 } }
    limit: { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 25 } }
    offset: { name: offset, in: query, schema: { type: integer, minimum: 0, default: 0 } }
  requestBodies:
    VersionOnly: { required: true, content: { application/json: { schema: { type: object, required: [expected_version], additionalProperties: false, properties: { expected_version: { type: integer, minimum: 1 }, note: { type: string, maxLength: 2000 } } } } } }
    Reasoned: { required: true, content: { application/json: { schema: { type: object, required: [expected_version, reason_code, reason], additionalProperties: false, properties: { expected_version: { type: integer, minimum: 1 }, reason_code: { $ref: '#/components/schemas/Code' }, reason: { type: string, minLength: 10, maxLength: 2000 } } } } } }
  responses:
    Error: { description: 'Typed error (error, message, guard?, setting?, dependency?, receipt?)', content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
    Validation: { description: Field validation, content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
    OrderReceipt: { description: Committed, content: { application/json: { schema: { type: object, properties: { order: { $ref: '#/components/schemas/Order' }, receipt: { $ref: '#/components/schemas/Receipt' }, events: { type: array, items: { type: object, properties: { event_id: { type: string }, event_type: { type: string }, delivery: { const: pending_downstream_confirmation } } } } } } } } }
    OrderPage: { description: Page, content: { application/json: { schema: { type: object, properties: { data: { type: array, items: { $ref: '#/components/schemas/Order' } }, total: { type: integer }, limit: { type: integer }, offset: { type: integer } } } } } }
  schemas:
    Code: { type: string, pattern: '^[a-z][a-z0-9_]{0,63}$' }
    OrderKind: { enum: [lab, imaging] }
    OrderStatus: { enum: [draft, placed, accepted, rejected, specimen_collected, scheduled, protocoled, in_progress, performed, resulted, reviewed, cancelled] }
    Modality: { enum: [XR, CT, MR, US, MG, NM] }
    Contrast: { enum: [none, with, without, with_and_without] }
    Role: { enum: [ordering_clinician, lab_technologist, lab_manager, lab_assistant, imaging_technologist, radiologist, orders_admin, orders_oversight] }
    Purpose: { enum: [diagnostic_ordering, diagnostic_fulfilment, orders_administration, orders_oversight] }
    SyntheticTokenCommand: { type: object, required: [principal_id, role, jurisdiction, organization_id, purpose], additionalProperties: false, properties: { principal_id: { type: string, format: uuid }, role: { $ref: '#/components/schemas/Role' }, jurisdiction: { type: string, format: uuid }, organization_id: { type: string, format: uuid }, purpose: { $ref: '#/components/schemas/Purpose' } } }
    OrderContent:
      type: object
      required: [order_kind, patient_ref, performer_org, priority, clinical_indication]
      properties:
        order_kind: { $ref: '#/components/schemas/OrderKind' }
        patient_ref: { type: string, format: uuid, description: OHN-03 patient id }
        performer_org: { type: string, format: uuid, description: OHN-05 facility id of the performing lab or imaging centre }
        priority: { $ref: '#/components/schemas/Code' }
        clinical_indication: { type: string, minLength: 3, maxLength: 4000 }
        specimen_type: { $ref: '#/components/schemas/Code' }
        tests: { type: array, minItems: 1, maxItems: 20, items: { type: object, required: [code], properties: { code: { type: string, maxLength: 64 }, display: { type: string, maxLength: 256 } } } }
        modality: { $ref: '#/components/schemas/Modality' }
        body_site: { $ref: '#/components/schemas/Code' }
        contrast: { $ref: '#/components/schemas/Contrast' }
        procedure_code: { type: string, maxLength: 64 }
        procedure_display: { type: string, maxLength: 256 }
        screening: { type: array, items: { type: object, required: [question_code, answer], properties: { question_code: { $ref: '#/components/schemas/Code' }, answer: { enum: [yes, no, unknown] }, note: { type: string, maxLength: 1000 } } } }
      description: 'lab requires specimen_type + tests and forbids imaging fields; imaging requires modality, body_site, contrast, procedure_code, screening and forbids lab fields'
    OrderCreate: { allOf: [{ $ref: '#/components/schemas/OrderContent' }, { type: object, properties: { submit: { type: boolean, default: false } } }] }
    OrderAmend: { allOf: [{ $ref: '#/components/schemas/OrderContent' }, { type: object, required: [expected_version, reason], properties: { expected_version: { type: integer, minimum: 1 }, reason: { type: string, minLength: 10 } } }] }
    Specimen: { type: object, required: [expected_version, specimen_type, accession_number, collected_at], additionalProperties: false, properties: { expected_version: { type: integer }, specimen_type: { $ref: '#/components/schemas/Code' }, accession_number: { type: string, pattern: '^[A-Za-z0-9._-]{1,64}$' }, collected_at: { type: string, format: date-time }, note: { type: string } } }
    Schedule: { type: object, required: [expected_version, slot_start, slot_end, location], additionalProperties: false, properties: { expected_version: { type: integer }, slot_start: { type: string, format: date-time }, slot_end: { type: string, format: date-time }, location: { type: string, maxLength: 256 } } }
    Protocol: { type: object, required: [expected_version, protocol, contrast], additionalProperties: false, properties: { expected_version: { type: integer }, protocol: { type: string, minLength: 3, maxLength: 4000 }, contrast: { $ref: '#/components/schemas/Contrast' }, screening_reviewed: { type: boolean, default: false } } }
    Performed: { type: object, required: [expected_version], additionalProperties: false, properties: { expected_version: { type: integer }, performed_at: { type: string, format: date-time }, note: { type: string } } }
    PostResult:
      type: object
      required: [expected_version, report_status, issued_at, file_or_payload]
      additionalProperties: false
      properties:
        expected_version: { type: integer }
        report_status: { enum: [preliminary, final, amended, corrected] }
        issued_at: { type: string, format: date-time }
        file_or_payload: { type: string, format: uuid }
        payload_sha256: { type: string, pattern: '^[a-f0-9]{64}$' }
        source_interpretation: { type: string, maxLength: 8000 }
        critical_declared: { type: boolean, default: false }
        observations: { type: array, maxItems: 500, items: { type: object, description: OHN-11 ObservationInputSchema } }
        imaging_studies: { type: array, maxItems: 50, items: { type: object, description: OHN-11 ImagingInputSchema } }
      description: 'Forwarded to OHN-11 with patient_ref, source_facility=performer_org, specimen_ref, report_type from settings, source_report_id=<order_number>-v<version>, replaces_report_id when re-posting. OHN-11 4xx => 422 ohn11_refused.'
    CodeListCommand: { type: object, required: [list_name, code, label_en, label_fr], properties: { list_name: { enum: [priority, specimen_type, body_site, rejection_reason, cancel_reason] }, code: { $ref: '#/components/schemas/Code' }, label_en: { type: string }, label_fr: { type: string }, active: { type: boolean, default: true } } }
    PriorityTargetCommand: { type: object, required: [order_kind, priority, target_minutes], properties: { order_kind: { $ref: '#/components/schemas/OrderKind' }, priority: { $ref: '#/components/schemas/Code' }, target_minutes: { type: integer, minimum: 1, maximum: 525600 } } }
    ScreeningQuestionCommand: { type: object, required: [modality, code, label_en, label_fr], properties: { modality: { $ref: '#/components/schemas/Modality' }, code: { $ref: '#/components/schemas/Code' }, label_en: { type: string }, label_fr: { type: string }, required: { type: boolean, default: true }, review_on: { type: array, items: { enum: [yes, no, unknown] } }, active: { type: boolean, default: true } } }
    SettingsCommand: { type: object, required: [expected_version, lab_code_system, imaging_code_system, lab_report_type, imaging_report_type, consent_check_required], properties: { expected_version: { type: integer, minimum: 0 }, lab_code_system: { type: string, format: uri }, imaging_code_system: { type: string, format: uri }, lab_report_type: { $ref: '#/components/schemas/Code' }, imaging_report_type: { $ref: '#/components/schemas/Code' }, consent_check_required: { type: boolean }, consent_resource_class: { $ref: '#/components/schemas/Code' }, consent_purpose: { $ref: '#/components/schemas/Code' } } }
    Order:
      type: object
      properties:
        id: { type: string, format: uuid }
        order_number: { type: string }
        order_kind: { $ref: '#/components/schemas/OrderKind' }
        status: { $ref: '#/components/schemas/OrderStatus' }
        version: { type: integer }
        jurisdiction_id: { type: string }
        ordering_org: { type: string }
        performer_org: { type: string }
        patient_ref: { type: string }
        priority: { type: string }
        target_minutes: { type: [integer, 'null'] }
        due_at: { type: [string, 'null'], format: date-time }
        overdue: { type: boolean }
        result_ref: { type: [string, 'null'], description: OHN-11 DiagnosticReport id }
        result_status: { type: [string, 'null'] }
        screening_review_required: { type: boolean }
    OrderDetail: { type: object, properties: { order: { $ref: '#/components/schemas/Order' }, tests: { type: array, items: { type: object } }, screening: { type: array, items: { type: object } }, specimens: { type: array, items: { type: object } }, history: { type: array, items: { type: object } }, allowed_actions: { type: array, items: { type: string } }, lifecycle: { type: array, items: { type: string } } } }
    Report: { type: object, properties: { report_id: { type: string }, title: { type: string }, columns: { type: array, items: { type: string } }, metrics: { type: object }, metric_definitions: { type: object }, data: { type: array, items: { type: object } }, provenance: { type: object } } }
    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 }, version: { type: integer }, status: { enum: [committed, denied, refused] } } }
    Error: { type: object, required: [error], properties: { error: { type: string }, message: { type: string }, guard: { type: string }, setting: { type: string }, dependency: { type: string }, details: { type: object }, receipt: { $ref: '#/components/schemas/Receipt' } } }
    Health: { type: object, properties: { status: { type: string }, module: { const: OHN-49 }, dependencies: { type: object, properties: { OHN-03: { $ref: '#/components/schemas/DepMode' }, OHN-05: { $ref: '#/components/schemas/DepMode' }, OHN-11: { $ref: '#/components/schemas/DepMode' }, OHN-15: { $ref: '#/components/schemas/DepMode' }, OHN-23: { $ref: '#/components/schemas/DepMode' }, OHN-24: { $ref: '#/components/schemas/DepMode' } } }, writes_enabled: { type: boolean }, export_signing_configured: { type: boolean }, jwt_configured: { type: boolean }, synthetic_auth: { type: boolean } } }
    DepMode: { enum: [live, unconfigured, test_fake, test_failing] }
