dep:
  - v_listes_1
src: |
  (
          (
                   SELECT v_listes_1.liste_id_combo AS oid,
                      v_listes_1.texte,
                      v_listes_1.liste_id_combo AS code,
                      v_listes_1.lvl AS level,
                      ('0'::text || v_listes_1.sort) || chr(1) AS tri
                     FROM pmsi.v_listes_1
                    WHERE v_listes_1.table_code = 'FINESS'::text AND v_listes_1.lvl <> '0'::text
                  UNION
                   SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid,
                      t_classes.texte,
                      ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS code,
                      '1'::text AS level,
                      '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri
                     FROM base.t_classes,
                      base.t_listes_tables
                    WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::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,
              ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS code,
              '2'::text AS level,
              '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri
             FROM base.t_classes,
              base.t_classes_sections,
              base.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 = 'FINESS'::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,
              ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS code,
              '2'::text AS level,
              '5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri
             FROM base.t_classes,
              base.t_listes_tables
            WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'FINESS'::text
  ) UNION
   SELECT 'FI'::text || t_finess.oid::text AS oid,
      ((t_finess.texte || ' ('::text) || t_finess.code) || ')'::text AS texte,
      t_finess.code,
      '1'::text AS level,
      '9'::text || t_finess.code AS tri
     FROM base.t_finess
    WHERE t_finess.oid > 0
    ORDER BY 5;