dep:
  - v_listes_1
src: |
  (
           SELECT v_listes_1.liste_id_combo AS oid,
              v_listes_1.texte,
              v_listes_1.lvl AS level,
              ('0'::text || v_listes_1.sort) || chr(1) AS sort,
                  CASE
                      WHEN v_listes_1.is_cti = '1'::text OR v_listes_1.code ~~ 'CTI_%'::text THEN '1'::character(1)
                      ELSE '0'::character(1)
                  END AS is_cti
             FROM activite.v_listes_1
            WHERE v_listes_1.table_code = 'MEDECIN'::text AND v_listes_1.lvl <> '0'::text
          UNION ALL (
                   SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid,
                      t_classes.texte,
                      '1'::text AS level,
                      '4'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS sort,
                          CASE
                              WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1)
                              ELSE '0'::character(1)
                          END AS is_cti
                     FROM activite.t_classes,
                      activite.t_listes_tables
                    WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MEDECIN'::text
                  UNION ALL
                   SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid,
                      t_classes_sections.texte,
                      '2'::text AS level,
                      '4'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS sort,
                          CASE
                              WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1)
                              ELSE '0'::character(1)
                          END AS is_cti
                     FROM activite.t_classes,
                      activite.t_classes_sections,
                      activite.t_listes_tables
                    WHERE t_classes.table_id = t_listes_tables.oid AND t_classes_sections.classe_id = t_classes.oid AND t_listes_tables.code = 'MEDECIN'::text
          )
          UNION ALL
           SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid,
              'Section non attribuée'::character varying AS texte,
              '2'::text AS level,
              '4'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS sort,
                  CASE
                      WHEN t_classes.is_cti = '1'::bpchar OR t_classes.code ~~ 'CTI_%'::text THEN '1'::character(1)
                      ELSE '0'::character(1)
                  END AS is_cti
             FROM activite.t_classes,
              activite.t_listes_tables
            WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'MEDECIN'::text
  ) UNION
   SELECT '-8'::text AS oid,
      'Spécialités'::character varying AS texte,
      '1'::text AS level,
      '5'::text AS sort,
      '0'::character(1) AS is_cti
  UNION
   SELECT 'SP'::text || t_specialites_medecin.oid::text AS oid,
      (t_specialites_medecin.code || ' '::text) || t_specialites_medecin.texte AS texte,
      '2'::text AS level,
      '6'::text || t_specialites_medecin.code AS sort,
      '0'::character(1) AS is_cti
     FROM base.t_specialites_medecin
    WHERE (t_specialites_medecin.oid IN ( SELECT DISTINCT t_medecins.specialite_id
             FROM base.t_medecins
            ORDER BY t_medecins.specialite_id))
  UNION
   SELECT 'MD'::text || t_medecins.oid::text AS oid,
          CASE
              WHEN t_medecins.oid <> 0 THEN (t_medecins.nom || ' '::text) || t_medecins.prenom
              ELSE 'Non saisi'::text
          END AS texte,
      '1'::text AS level,
      (('7'::text || t_medecins.nom) || t_medecins.prenom) || t_medecins.oid::text AS sort,
      '0'::character(1) AS is_cti
     FROM activite.t_medecins_administratifs,
      base.t_medecins
    WHERE (t_medecins_administratifs.oid IN ( SELECT p_oids.oid
             FROM activite.p_oids
            WHERE p_oids.code_table = 'medecin_s'::text)) AND t_medecins_administratifs.medecin_id = t_medecins.oid
  UNION
   SELECT 'MA'::text || t_medecins_administratifs.oid::text AS oid,
          CASE
              WHEN t_medecins_administratifs.oid <> 0 THEN ((((t_medecins_administratifs.nom || ' '::text) || t_medecins_administratifs.prenom) || ' ('::text) || t_medecins_administratifs.code) || ')'::text
              ELSE 'Non saisi'::text
          END AS texte,
      '2'::text AS level,
      (((('7'::text || t_medecins.nom) || t_medecins.prenom) || t_medecins.oid::text) || '1'::text) || t_medecins_administratifs.code AS sort,
      '0'::character(1) AS is_cti
     FROM activite.t_medecins_administratifs,
      base.t_medecins
    WHERE (t_medecins_administratifs.oid IN ( SELECT p_oids.oid
             FROM activite.p_oids
            WHERE p_oids.code_table = 'medecin_s'::text)) AND t_medecins_administratifs.medecin_id = t_medecins.oid
    ORDER BY 4;