jevrecipes

Recipe catalog / safety-incident-kind

Classify a safety event

What kind of safety event does report describe: a near miss, a first-aid injury, a medical-treatment injury, property damage, an environmental release, or an unsafe condition?

You need to sort free-text safety reports from workers, supervisors, or contractors into a fixed set of event kinds so each can be routed to the right investigation, form, or notification path.

Explore this recipe interactively ยท Source and implementation guide

Use safety-incident-kind in TypeScript

Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.

import { safetyIncidentKind } from 'jev-recipes/safety-incident-kind';

const result = await safetyIncidentKind({
  "report": "Warehouse B, 14:20. A forklift reversing out of aisle 7 came within about a metre of a contractor walking through the marked pedestrian crossing. The driver stopped when the spotter shouted. No contact, no injuries, nothing damaged. The contractor was not wearing a high-visibility vest and the mirror at the aisle end is missing.",
  "minConfidence": 0.8
});
console.log(result);

Input contract

FieldTypeNeeded
reportstringRequired
minConfidencenumberOptional
Full input and result schemas
{
  "input": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "report": {
        "type": "string"
      },
      "minConfidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      }
    },
    "required": [
      "report"
    ]
  },
  "result": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "model": {
        "type": "string"
      },
      "usage": {
        "type": "object",
        "properties": {
          "input_tokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "output_tokens": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "input_tokens",
          "output_tokens"
        ],
        "additionalProperties": false
      },
      "status": {
        "type": "string",
        "enum": [
          "ready",
          "review"
        ]
      },
      "verdict": {
        "type": "string",
        "enum": [
          "near_miss",
          "first_aid",
          "medical_treatment",
          "property_damage",
          "environmental_release",
          "unsafe_condition",
          "unclear"
        ]
      },
      "confidence": {
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "probabilities": {
        "type": "object",
        "propertyNames": {
          "type": "string",
          "enum": [
            "near_miss",
            "first_aid",
            "medical_treatment",
            "property_damage",
            "environmental_release",
            "unsafe_condition",
            "unclear"
          ]
        },
        "additionalProperties": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "required": [
          "near_miss",
          "first_aid",
          "medical_treatment",
          "property_damage",
          "environmental_release",
          "unsafe_condition",
          "unclear"
        ]
      }
    },
    "required": [
      "model",
      "usage",
      "status",
      "verdict",
      "confidence",
      "probabilities"
    ],
    "additionalProperties": false
  }
}

Saved example result

This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo safety-incident-kind.

{
  "model": "demo-fixture",
  "usage": {
    "input_tokens": 0,
    "output_tokens": 0
  },
  "status": "ready",
  "verdict": "near_miss",
  "confidence": 0.87,
  "probabilities": {
    "near_miss": 0.87,
    "first_aid": 0.01,
    "medical_treatment": 0.01,
    "property_damage": 0.01,
    "environmental_release": 0.01,
    "unsafe_condition": 0.07,
    "unclear": 0.02
  }
}

Evaluation evidence

Fixture only

No verified live accuracy measurement is available. Evaluate representative cases before using this decision in your workflow.

Use the evaluation guide to measure this decision on your own labeled cases.

Limitations

Related recipes