src: |
  SELECT t_expert_controle.oid AS expert_controle_id,
      t_expert_controle.code AS expert_controle_code,
      t_expert_controle.texte_court AS expert_controle_texte,
      COALESCE(t_expert_controle.texte_abrege, t_expert_controle.texte_court) AS expert_controle_texte_abrege,
      t_expert_controle.gravite_id AS expert_controle_gravite_id,
      to_char(t_expert_controle.gravite_id, 'FM0'::text) AS expert_controle_gravite_code,
          CASE
              WHEN t_expert_controle.gravite_id = 0 THEN 'INFO'::text
              WHEN t_expert_controle.gravite_id >= 1 AND t_expert_controle.gravite_id <= 5 THEN 'ATT'::text
              WHEN t_expert_controle.gravite_id >= 6 AND t_expert_controle.gravite_id <= 9 THEN 'ERREUR'::text
              ELSE 'ATT'::text
          END AS expert_controle_gravite_texte,
      t_expert_controle.date_validite_debut AS expert_controle_date_validite_debut,
      t_expert_controle.date_validite_fin AS expert_controle_date_validite_fin,
      t_expert_controle.section_id AS expert_controle_section_id,
      t_expert_controle.section_code AS expert_controle_section_code,
      t_expert_controle.section_texte AS expert_controle_section_texte,
      t_expert_controle.alert_exp,
      p_expert_sejour_controle.date_signalement,
      date_part('epoch'::text, p_expert_sejour_controle.date_signalement) AS date_signalement_id,
      p_expert_sejour_controle.date_signalement::text AS date_signalement_code,
      p_calendrier_s.texte_court AS date_signalement_texte,
      p_calendrier_s.mois AS date_signalement_mois_id,
      to_char(p_calendrier_s.mois, 'FM000000'::text) AS date_signalement_mois_code,
      (p_calendrier_s.mois_texte || ' '::text) || to_char(p_calendrier_s.iso_annee, 'FM0000'::text) AS date_signalement_mois_texte,
      p_calendrier_s.semaine AS date_signalement_semaine_id,
      to_char(p_calendrier_s.semaine, 'FM000000'::text) AS date_signalement_semaine_code,
      (('Semaine '::text || to_char(p_calendrier_s.iso_semaine, 'FM00'::text)) || ' '::text) || to_char(p_calendrier_s.iso_annee, 'FM0000'::text) AS date_signalement_semaine_texte,
      p_expert_sejour_controle.sejour_id,
      p_expert_sejour_controle.no_sejour,
      p_expert_sejour_controle.code_justificatif,
      t_expert_controle.is_active AS expert_controle_is_active
     FROM activite.t_expert_controle
       JOIN activite.p_expert_sejour_controle ON p_expert_sejour_controle.controle_id = t_expert_controle.oid
       JOIN base.p_calendrier p_calendrier_s ON p_expert_sejour_controle.date_signalement = p_calendrier_s.date
    WHERE t_expert_controle.is_hide IS DISTINCT FROM '1'::bpchar AND t_expert_controle.is_global IS DISTINCT FROM '1'::bpchar;