/api/audit-logs:
  get:
    tags: [Audit]
    summary: Retrieve audit log entries for a table
    security:
      - bearerAuth: []
    parameters:
      - name: table
        in: query
        required: true
        schema:
          type: string
        description: Table alias for the audit data (logpatient, logorder, logmaster, logsystem)
      - name: rec_id
        in: query
        schema:
          type: string
        description: Primary record identifier (RecID) to filter audit rows
      - name: event_id
        in: query
        schema:
          type: string
        description: Canonical EventID (case insensitive)
      - name: activity_id
        in: query
        schema:
          type: string
        description: Canonical ActivityID (case insensitive)
      - name: from
        in: query
        schema:
          type: string
          format: date-time
        description: Lower bound for LogDate inclusive
      - name: to
        in: query
        schema:
          type: string
          format: date-time
        description: Upper bound for LogDate inclusive
      - name: search
        in: query
        schema:
          type: string
        description: Search term that matches user, reason, field names, or values
      - name: page
        in: query
        schema:
          type: integer
          default: 1
        description: Page number
      - name: perPage
        in: query
        schema:
          type: integer
          default: 20
        description: Items per page (max 100)
    responses:
      '200':
        description: Audit log results
        content:
          application/json:
            schema:
              $ref: '../components/schemas/audit-logs.yaml#/AuditLogsEnvelope'
      '400':
        description: Validation failure (missing table or invalid filters)
        content:
          application/json:
            schema:
              $ref: '../components/schemas/audit-logs.yaml#/AuditLogsErrorResponse'
      '500':
        description: Internal error when retrieving audit logs
        content:
          application/json:
            schema:
              $ref: '../components/schemas/audit-logs.yaml#/AuditLogsErrorResponse'
