Querying Regulation Checks and Alerts

How to query regulation checks and alerts for an employee

Regulation related data are available only to the user himself or his company's managers

API call example

query {
  user(id: Int!) {
    regulationComputationsByDay(fromDate: Date, toDate: Date) {
      day
      regulationComputations {
        submitterType
        regulationChecks(unit: "day" | "week") {
          type
          label
          description
          unit
          alert {
            extra
          }
        }
      }
    }
  }
}

API will send back a list with an entry for every day between fromDate and toDate where regulation checks data are present.

Each item will contain a list of RegulationComputation describing results for the relevant day.

A RegulationComputation has

  • a submitterType with value in admin|employee . It indicates whether the computation was based on employee's version or admin's version of the data.

  • a list of RegulationCheck describing which regulation rules have been computed for the day and the results.

A RegulationCheck has

  • a type to uniquely identify the rule

  • a label

  • a description

  • a unit with value in day|week indicating if it's a daily rule or a weekly rule

  • an alert object. It is null if no breach was detected. Otherwise the rule is breached and an extra JSON field will contain additional information

API response example

user: {
  regulationComputationsByDay: [
    { 
      # list contains one item per day
      day: 2023-03-15,
      regulationComputations: [
        {
          day: 2023-03-15,
          # this computation was based on employee's version of the data
          submitterType: employee, 
          regulationChecks: [
            {
              # unique id for the rule
              type: minimumDailyRest,
              label: Non-respect(s) du repos quotidien,
              description: La dur\u00e9e du repos quotidien ...,
              # this is a daily rule
              unit: day,
              # no breach was detected
              alert: null,
            },
            {
              type: maximumWorkDayTime,
              label: D\u00e9passement(s) de la dur\u00e9e maximale du travail quotidien,
              description: La dur\u00e9e du travail ...,
              unit: day,
              # rule is breached
              alert: {
                # extra is a JSON containing context information
                extra: {\night_work\: true, \max_time_in_hours\: 10},
              },
            },
            {
              type: maximumUninterruptedWorkTime,
              label: D\u00e9passement(s) de la dur\u00e9e maximale du travail ininterrompu,
              description: Lorsque le temps de travail ...,
              regulationRule: dailyRest,
              unit: day,
              # rule is breached, even though we don't have any context information
              alert: {
                extra: null,
              },
            },
            {
              # weekly rule example
              type: maximumWorkedDaysInWeek,
              label: Non-respect(s) du repos hebdomadaire,
              description: Il est interdit de travailler plus ...,
              unit: week,
              alert: null,
            }         
          ],
        }
      ],
    }
  ],
}

'Extra' field explanation

The extra field contains some context information based on the alert type

minimumDailyRest

  • min_daily_break_in_hours Minimum duration in hours of mandatory daily rest for the worker

  • breach_period_start and breach_period_end Start and end of the 24h period where a breach has been detected

  • breach_period_max_break_in_seconds Longest rest duration in seconds on this 24h period. It is shorter than the minimum mandatory duration and this is why an alert has been raised

  • sanction_code NATINF code of the sanction

Example

{
  min_daily_break_in_hours: 10,
  breach_period_start: 2023-02-18T05:10:00,
  breach_period_end: 2023-02-19T05:10:00,
  breach_period_max_break_in_seconds: 31380,
  sanction_code: NATINF 20525
}
# 10h daily rest was mandatory on this 24h period 
# but longest rest was only 8h 43m

maximumWorkDayTime

  • night_work indicates if the worker is considered a night worker in the context of this computation

  • max_work_range_in_hours maximum work range for the worker. This value will differ for a night worker

  • work_range_in_seconds work range computed, which is above legal limit

  • work_range_start and work_range_end start and end of the work range

  • sanction_code NATINF code of the sanction

Example

{
  night_work: false, 
  max_work_range_in_hours: 12, 
  work_range_in_seconds: 46260, 
  work_range_start: 2022-12-12T06:59:00, 
  work_range_end: 2022-12-12T20:45:00, 
  sanction_code: NATINF 11292
}
# Maximum work range is 12h
# Observed work range is 12h51m

minimumWorkDayBreak

  • work_range_start, work_range_end and work_range_in_seconds Start, end and duration of the work range considered

  • min_break_time_in_minutes minimum break time the worker should have taken

  • total_break_time_in_seconds observed break time in seconds. this break is too short and that's why an alert is raised

  • sanction_code sanction name

Example

{
  total_break_time_in_seconds: 900.0,
  work_range_in_seconds: 30060,
  work_range_start: 2022-04-12T09:45:00,
  sanction_code: Sanction du Code du Travail,
  work_range_end: 2022-04-12T18:36:00,
  min_break_time_in_minutes: 30
}
# if a worker has a 8h21m work range, he sould have a 30 minutes break
# Observed break time was only 15 minutes

maximumUninterruptedWorkTime

  • longest_uninterrupted_work_start and longest_uninterrupted_work_end start and end of the longest uninterrumpted work range

  • longest_uninterrupted_work_in_seconds duration in seconds of this work range, which is above legal limit

  • max_uninterrupted_work_in_hours maximum uninterrumpted work range duration in hours allowed by legislation

  • sanction_code NATINF code of the sanction

Example

{
  max_uninterrupted_work_in_hours: 6,
  longest_uninterrupted_work_in_seconds: 22200.0,
  longest_uninterrupted_work_start: 2023-01-06T09:00:00,
  longest_uninterrupted_work_end: 2023-01-06T15:10:00,
  sanction_code: Sanction du Code du Travail
}
# Maximum uninterrumpted work range: 6h
# 6h10m observed

maximumWorkedDaysInWeek

  • max_nb_days_worked_by_week maximum number of worked days in a week according to legislation

  • min_weekly_break_in_hours each week, a break of this duration should be observed

  • too_many_days boolean indicates if the worker has worked too many days and breached the first rule

  • rest_duration_s maximum but insufficient break observed by the worker. This field is only present if the second rule has been breached

  • sanction_code NATINF code of the sanction

Exemple

{
  max_nb_days_worked_by_week: 6,
  min_weekly_break_in_hours: 34,
  too_many_days: false,
  rest_duration_s: 111240.0,
  sanction_code: NATINF 13152
}
# Longest break of the week: 30h54m versus 34h mandatory

Last updated