DEV Community

eth shihao
eth shihao

Posted on

Track OSHA forklift pre-shift coverage and defect lockouts in JavaScript

Three forklifts across four shifts give a warehouse 12 scheduled truck-shifts. Eleven have on-time checklists, for 91.67% coverage. One of those eleven checklists records a leaking hydraulic hose on FL-02. The shift has its check on file and the truck stays out of service.

Record change Coverage Open lockouts
Eleven on-time checks, including the hose finding 11/12 1
Late checklist for the uncovered shift 11/12 1
Repair entered for the hose with sign-off pending 11/12 1
Supervisor sign-off entered after repair 11/12 0

Count scheduled checks and track defects separately

Key coverage by (truckId, shiftId) and include only shifts that have started by the audit cutoff. An on-time checklist falls between the configured opening time and shift start, inclusive. Multiple checklists on one shift count once toward coverage and raise a duplicate flag. An early, late, or unmatched checklist can still carry a safety finding.

Key a finding by (truckId, defectId). The closeout records a repair at or after the latest blocking finding and a named supervisor's sign-off between the repair and the audit cutoff. A passing recheck leaves the original finding in the report. The employer's workflow supplies the authorized signer and the actual return-to-service decision.

Reproduce the 11-of-12 handoff

Run this from the repo root with Node.js 20 or later. This recreates the demo's roster and adds a late checklist to the missing shift. MIT source repository

node --input-type=module <<'JS'
import assert from 'node:assert/strict'
import { reconcileInspections } from './src/index.js'

const day = '2026-11-28'
const schedule = ['FL-01', 'FL-02', 'FL-03'].flatMap((truckId) =>
  ['00', '06', '12', '18'].map((hour) => {
    const startsAt = `${day}T${hour}:00:00Z`
    const opensAt = new Date(Date.parse(startsAt) - 30 * 60_000).toISOString()
    return { truckId, shiftId: `${day}/${hour}`, opensAt, startsAt }
  })
)
const checklists = schedule.slice(0, -1).map(({ truckId, shiftId, opensAt }) => ({
  truckId, shiftId, operator: 'J. Lee', checkedAt: opensAt,
  defects: truckId === 'FL-02' && shiftId.endsWith('/18')
    ? [{ defectId: 'hose', severity: 'safety', description: 'Hydraulic hose leaking' }]
    : [],
}))
const input = { asOf: `${day}T23:59:59Z`, schedule, checklists }
const first = reconcileInspections(input)
assert.equal(first.coverage.basisPoints, 9167)
assert.equal(first.coverage.covered, 11)
assert.equal(first.coverage.scheduled, 12)
assert.deepEqual(first.lockedOutTruckIds, ['FL-02'])

const late = { truckId: 'FL-03', shiftId: `${day}/18`, operator: 'J. Lee',
  checkedAt: `${day}T18:05:00Z` }
const repair = { truckId: 'FL-02', defectId: 'hose', repairedAt: `${day}T18:30:00Z` }
const withLateCheck = { ...input, checklists: [...checklists, late] }
const awaiting = reconcileInspections({ ...withLateCheck, closeouts: [repair] })
const signed = reconcileInspections({ ...withLateCheck, closeouts: [
  { ...repair, signedAt: `${day}T18:45:00Z`, supervisor: 'M. Rivera' },
] })

assert.deepEqual(awaiting.coverage, first.coverage)
assert.deepEqual(awaiting.lockedOutTruckIds, ['FL-02'])
assert.equal(signed.safetyDefects[0].status, 'closed')
assert.equal(signed.lockouts.length, 0)
assert.equal(signed.audit.blockers.missingShifts, 1)
assert.equal(signed.audit.ready, false)

console.log(`Coverage: ${first.coverage.covered}/${first.coverage.scheduled} (${first.coverage.percent}%)`)
console.log(`After repair: ${awaiting.lockouts.length} open lockout`)
console.log(`After sign-off: ${signed.lockouts.length} open lockouts, ${signed.coverage.missing} uncovered shift`)
JS
Enter fullscreen mode Exit fullscreen mode
Coverage: 11/12 (91.67%)
After repair: 1 open lockout
After sign-off: 0 open lockouts, 1 uncovered shift
Enter fullscreen mode Exit fullscreen mode

Federal OSHA § 1910.178(q)(7) requires examinations before trucks enter service and at least daily, with an examination after each shift for round-the-clock operations. Unsafe trucks stay out of service, and identified defects must be reported immediately and corrected. The roster, timestamp window, and supervisor sign-off are employer workflow controls. OSHA leaves exam documentation to the employer under this provision. OSHA powered industrial truck standard · OSHA interpretation on examination documentation

Toggle supervisor sign-off in the demo. The hose finding closes while the missing check remains visible in the coverage grid. Interactive GitHub Pages demo · Companion Gist

ForkliftCheck's $9.00 One-Time Fleet Period Pass unlocks clean PDFs and CSVs for one fleet and review window. Use LAUNCH20 at checkout for $7.20. Warehouse Fleet Yearly is $59/yr. ForkliftCheck · Forklift pre-shift inspection checklist guide

For invoice reconciliation after freight has moved, see FreightAudit.

Top comments (0)