dep:
  - v_chapitres_ccam_1
  - v_listes_1
  - v_structure_code_ccam_1
src: |
  (
           SELECT
                  CASE
                      WHEN v_listes_1.liste_id = 0 THEN '-8'::text
                      WHEN v_listes_1.liste_is_omit = '1'::text THEN 'SL'::text || v_listes_1.liste_id::text
                      ELSE 'LI'::text || v_listes_1.liste_id::text
                  END AS oid,
              v_listes_1.code,
              v_listes_1.texte,
              v_listes_1.lvl AS level,
              ('0'::text || v_listes_1.sort) || chr(1) AS tri,
              v_listes_1.liste_alias_combo AS alias,
                  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 pmsi.v_listes_1
            WHERE v_listes_1.table_code = 'ACTE'::text AND v_listes_1.lvl <> '0'::text
          UNION ALL (
                  (
                          (
                                  ( SELECT DISTINCT '-8'::text AS oid,
                                      ''::text AS code,
                                      'Compatibilité V10'::text AS texte,
                                      '1'::text AS level,
                                      '8'::text AS tri,
                                      ''::text AS alias,
                                      '0'::character(1) AS is_cti
                                    ORDER BY '-8'::text, 'Compatibilité V10'::text, '1'::text, '8'::text, ''::text)
                                  UNION
                                  ( SELECT DISTINCT 'GX'::text AS oid,
                                      ''::text AS code,
                                      'Gestes marqueurs (2008)'::text AS texte,
                                      '2'::text AS level,
                                      '9'::text AS tri,
                                      ''::text AS alias,
                                      '0'::character(1) AS is_cti
                                    ORDER BY 'GX'::text, 'Gestes marqueurs (2008)'::text, '2'::text, '9'::text, ''::text)
                                  UNION
                                  ( SELECT DISTINCT 'GM'::text || t_gestes_marqueurs.oid::text AS oid,
                                      ''::text AS code,
                                      (t_gestes_marqueurs.code::text || ' '::text) || t_gestes_marqueurs.texte_court::text AS texte,
                                      '3'::text AS level,
                                      '9'::text || t_gestes_marqueurs.code::text AS tri,
                                      ''::text AS alias,
                                      '0'::character(1) AS is_cti
                                     FROM pmsi.t_gestes_marqueurs
                                    WHERE t_gestes_marqueurs.oid > 0
                                    ORDER BY 'GM'::text || t_gestes_marqueurs.oid::text, (t_gestes_marqueurs.code::text || ' '::text) || t_gestes_marqueurs.texte_court::text, '3'::text, '9'::text || t_gestes_marqueurs.code::text, ''::text)
                                  UNION
                                   SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid,
                                      t_classes.code,
                                      t_classes.texte,
                                      '1'::text AS level,
                                      '6'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri,
                                      ''::text AS alias,
  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 pmsi.t_classes,
                                      pmsi.t_listes_tables
                                    WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ACTE'::text
                          ) UNION ALL
                           SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid,
                              t_classes_sections.code,
                              t_classes_sections.texte,
                              '2'::text AS level,
                              '6'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri,
                              ''::text AS alias,
                                  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 pmsi.t_classes,
                              pmsi.t_classes_sections,
                              pmsi.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 = 'ACTE'::text
                          UNION ALL
                           SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid,
                              'N/A'::text AS code,
                              'Section non attribuée'::text AS texte,
                              '2'::text AS level,
                              '6'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri,
                              ''::text AS alias,
                                  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 pmsi.t_classes,
                              pmsi.t_listes_tables
                            WHERE t_classes.table_id = t_listes_tables.oid AND t_listes_tables.code = 'ACTE'::text
                  ) UNION
                  ( SELECT DISTINCT 'NO'::text || t_actes.nomenclature AS oid,
                      t_actes.nomenclature AS code,
                      t_actes.nomenclature AS texte,
                      '1'::text AS level,
                      '7'::text || t_actes.nomenclature AS tri,
                      ''::text AS alias,
                      '0'::character(1) AS is_cti
                     FROM pmsi.t_actes
                    WHERE t_actes.oid > 0 AND (t_actes.oid IN ( SELECT p_oids.oid
                             FROM pmsi.p_oids
                            WHERE p_oids.code_table::text = 'actes'::text))
                    ORDER BY 'NO'::text || t_actes.nomenclature, t_actes.nomenclature, '1'::text, '7'::text || t_actes.nomenclature, ''::text)
                  UNION
                   SELECT 'RC'::text || t_ccam_regroupements.oid::text AS oid,
                      t_ccam_regroupements.code,
                      (t_ccam_regroupements.code::text || ' '::text) || t_ccam_regroupements.texte::text AS texte,
                      '2'::text AS level,
                      ('7'::text || 'CCAM0'::text) || t_ccam_regroupements.code::text AS tri,
                      ''::text AS alias,
                      '0'::character(1) AS is_cti
                     FROM pmsi.t_ccam_regroupements
                    WHERE t_ccam_regroupements.oid > 0 AND (t_ccam_regroupements.code::text <> ALL (ARRAY['NGAP'::character varying::text, 'CDAM'::character varying::text]))
                  UNION
                   SELECT 'AC'::text || t_actes.oid::text AS oid,
                      t_actes.code,
                      (t_actes.code || ' '::text) || t_actes.texte AS texte,
                      '2'::text AS level,
                      (('7'::text || t_actes.nomenclature) || '1'::text) || t_actes.code AS tri,
                      ''::text AS alias,
                      '0'::character(1) AS is_cti
                     FROM pmsi.t_actes
                    WHERE t_actes.oid > 0 AND (t_actes.oid IN ( SELECT p_oids.oid
                             FROM pmsi.p_oids
                            WHERE p_oids.code_table::text = 'actes'::text))
                  UNION
                   SELECT '-8'::text AS oid,
                      ''::text AS code,
                      'Chapitres CCAM'::text AS texte,
                      '1'::text AS level,
                      '9H'::text || chr(1) AS tri,
                      ''::text AS alias,
                      '0'::character(1) AS is_cti
                  UNION
                   SELECT v_chapitres_ccam_1.oid,
                      v_chapitres_ccam_1.code,
                          CASE
                              WHEN length(v_chapitres_ccam_1.texte) > 77 THEN ((substr(v_chapitres_ccam_1.texte, 1, 77) || '...'::text)::character varying)::text
                              ELSE v_chapitres_ccam_1.texte
                          END AS texte,
                      (v_chapitres_ccam_1.lvl + 1)::text AS level,
                      '9H'::text || v_chapitres_ccam_1.code AS tri,
                      ''::text AS alias,
                      '0'::character(1) AS is_cti
                     FROM pmsi.v_chapitres_ccam_1
                  UNION
                   SELECT '-8'::text AS oid,
                      ''::text AS code,
                      'Types d''acte CCAM'::text AS texte,
                      '1'::text AS level,
                      '9I'::text || chr(1) AS tri,
                      ''::text AS alias,
                      '0'::character(1) AS is_cti
                  UNION
                   SELECT 'TA1'::text AS oid,
                      ''::text AS code,
                      'Actes Diagnostiques'::text AS texte,
                      '2'::text AS level,
                      '9I'::text || chr(1) AS tri,
                      ''::text AS alias,
                      '0'::character(1) AS is_cti
                  UNION
                   SELECT 'TA2'::text AS oid,
                      ''::text AS code,
                      'Actes Thérapeutiques'::text AS texte,
                      '2'::text AS level,
                      '9I'::text || chr(2) AS tri,
                      ''::text AS alias,
                      '0'::character(1) AS is_cti
                  UNION
                   SELECT 'TA0'::text AS oid,
                      ''::text AS code,
                      'Autres types d''acte'::text AS texte,
                      '2'::text AS level,
                      '9I'::text || chr(3) AS tri,
                      ''::text AS alias,
                      '0'::character(1) AS is_cti
                  UNION
                   SELECT '-8'::text AS oid,
                      ''::text AS code,
                      'Structure du code CCAM'::text AS texte,
                      '1'::text AS level,
                      '9J'::text || chr(4) AS tri,
                      ''::text AS alias,
                      '0'::character(1) AS is_cti
          )
  ) UNION
   SELECT v_structure_code_ccam_1.oid,
      v_structure_code_ccam_1.code,
          CASE
              WHEN length(v_structure_code_ccam_1.texte) > 77 THEN ((substr(v_structure_code_ccam_1.texte, 1, 77) || '...'::text)::character varying)::text
              ELSE v_structure_code_ccam_1.texte
          END AS texte,
      (v_structure_code_ccam_1.lvl + 1)::text AS level,
      '9J'::text || v_structure_code_ccam_1.tri AS tri,
      ''::text AS alias,
      '0'::character(1) AS is_cti
     FROM pmsi.v_structure_code_ccam_1
    ORDER BY 5;