-- Demo OHS injury and absence integration
-- Example incident with restricted duties
INSERT INTO ohs_incidents (
  id, injury_date, injury_time, classification, nature, location,
  activity, how_sustained, days_lost, resumption_date, outcome, status,
  tenant_id, branch_id
) VALUES
  (1, '2025-05-15', '09:30', 'Injury', 'Back strain', 'Warehouse',
   'Lifting boxes', 'Overexertion while lifting', 3, '2025-05-19',
   'Under treatment', 'reported', 1, 1);

INSERT INTO ohs_medicals (
  id, incident_id, first_name, surname, job_title,
  incident_date, incident_time, medical_treatment,
  employment_status, tenant_id, branch_id
) VALUES
  (1, 1, 'Bob', 'Smith', 'Software Engineer',
   '2025-05-15', '09:30', 'Physiotherapy',
   'Full-Time', 1, 1);

UPDATE employees
  SET medical_restrictions = 'No heavy lifting until 2025-05-20'
  WHERE id = 2;

INSERT INTO leave_requests (
  id, employeeName, leaveType, startDate, endDate,
  reason, status, createdBy, approvedAt, approvedBy
) VALUES
  (3, 'Bob Smith', 'Work-Related Injury', '2025-05-15', '2025-05-18',
   'Back strain while lifting', 'Approved', 1, '2025-05-15', 1);

INSERT INTO attendance (
  id, employee, date, restricted_start, restricted_end,
  hours_worked, overtime, injury_flag, restricted_duty, pay_code
) VALUES
  (1, 'Bob Smith', '2025-05-15', NULL, NULL, 0, 0, 1, 0, 'INJ'),
  (2, 'Bob Smith', '2025-05-19', '09:00', '13:00', 4, 0, 0, 1, 'REST'),
  (3, 'Bob Smith', '2025-05-20', '09:00', '13:00', 4, 0, 0, 1, 'REST');
