Admin

Audit Logs

Path/audit-logs
Statuslive
Drill-down pages—
Pop-upsEntry detail
Tabs—
API routes/api/audit-logs
/api/audit-logs/summary
/api/audit-logs/:id

What's on the page

  • Cards: Total Logs (the database's row estimate, shown with ≈), entries in the last 24 hours, number of users, number of record types.
  • Filters: Date Range (default Last 7 Days, the viewer's own days), Record Type, Action, User, and Record ID (exact id). The record types, actions and users come from the log itself, not a fixed list. Filters, sort and page are kept in the link.
  • Table: Time (12-hour, viewer's time zone), User, Action, Record Type, Record ID; every column sorts; 25 / 50 / 100 / 200 per page; newest first by default.
  • The eye button opens one entry: record type and id, user, time, IP, and its old data, new data and metadata. Only that entry's data is loaded (and, on staging, decrypted).

Business rules

Data comes from: audit_logs (see "Audit log & patient-data log" below). API: GET /api/audit-logs (one page), /api/audit-logs/summary (totals and filter choices), /api/audit-logs/:id (one entry).

How it works:

  • Only logins with Audit Logs access (or admins) can use the page and its API; the server checks it.
  • Paging, sorting and filters run in the database. A page lists at most the newest 10,000 matching entries (also with no filter at all); when more match, the page says so and asks to narrow the dates or filters.
  • Record ID search is an exact match over all dates (the date range is ignored and the page says "Searching all dates"), indexed by migration 177, so one record's whole history loads in milliseconds.
  • Dates and filters are checked on the server: a bad date (or a year before 1900) is refused with a clear message, not an error page. A time zone the database doesn't know falls back to UTC days.

Database tables & columns

TableColumns used
audit_logsaction, created_at, entity_id, entity_type, id, user_name

File structure

Its own files

  • apps/
    • web/
      • src/
        • features/
          • audit-logs/
            • pages/
              • AuditLogsPage.tsx
            • api.ts
            • index.ts
    • worker/
      • src/
        • features/
          • audit-logs/
            • __tests__/
              • service.test.ts
            • index.ts
            • queries.ts
            • routes.ts
            • service.ts

Shared code it uses (followed through its imports and the helpers its API calls; sign-in/access plumbing and UI primitives left out)

  • apps/
    • web/
      • src/
        • components/
          • data/
            • DataTable.tsx
          • forms/
            • DatePicker.tsx
          • reports/
            • DentrixSourceNote.tsx
            • FilterSelect.tsx
            • HowItWorksNote.tsx
            • ReportDateRange.tsx
            • ReportHeader.tsx
            • sortable-grid.tsx
          • TablePagination.tsx
        • hooks/
          • usePagedList.ts
        • lib/
          • date-presets.ts
        • services/
          • api.ts
    • worker/
      • src/
        • db/
          • audit.ts
        • lib/
          • dates.ts
          • list-query.ts
        • utils/
          • crypto.ts
          • phi-access.ts
          • phi-crypto.ts