src: |
  SELECT '-8'::text AS oid,
      '-8'::text AS code,
      'Localisation'::text AS texte,
      1 AS lvl,
      0::text AS tri
  UNION ALL
   SELECT 'SC1'::text || t_actes.topographie_1_id::text AS oid,
      t_actes.topographie_1_code AS code,
      (t_actes.topographie_1_code || '. '::text) || t_actes.topographie_1_texte AS texte,
      2 AS lvl,
      '1'::text || t_actes.topographie_1_code AS tri
     FROM pmsi.t_actes
       JOIN pmsi.p_oids ON p_oids.code_table::text = 'actes'::text AND p_oids.oid = t_actes.oid
    WHERE t_actes.topographie_1_id::text IS DISTINCT FROM NULL::text AND t_actes.topographie_1_id::text > 0::text
    GROUP BY 'SC1'::text || t_actes.topographie_1_id::text, t_actes.topographie_1_code, (t_actes.topographie_1_code || '. '::text) || t_actes.topographie_1_texte
  UNION ALL
   SELECT 'SC2'::text || t_actes.topographie_2_id::text AS oid,
      t_actes.topographie_2_code AS code,
      (t_actes.topographie_2_code || '. '::text) || t_actes.topographie_2_texte AS texte,
      3 AS lvl,
      '1'::text || t_actes.topographie_2_code AS tri
     FROM pmsi.t_actes
       JOIN pmsi.p_oids ON p_oids.code_table::text = 'actes'::text AND p_oids.oid = t_actes.oid
    WHERE t_actes.topographie_2_id::text IS DISTINCT FROM NULL::text AND t_actes.topographie_2_id::text > 0::text
    GROUP BY t_actes.topographie_2_id, t_actes.topographie_2_code, t_actes.topographie_2_texte
  UNION ALL
   SELECT '-8'::text AS oid,
      '-8'::text AS code,
      'Action'::text AS texte,
      1 AS lvl,
      2::text AS tri
  UNION ALL
   SELECT 'SC3'::text || t_actes.action_id::text AS oid,
      t_actes.action_code AS code,
      (t_actes.action_code || '. '::text) || t_actes.action_texte AS texte,
      2 AS lvl,
      '2'::text || t_actes.action_code AS tri
     FROM pmsi.t_actes
       JOIN pmsi.p_oids ON p_oids.code_table::text = 'actes'::text AND p_oids.oid = t_actes.oid
    WHERE t_actes.action_id::text IS DISTINCT FROM NULL::text AND t_actes.action_id::text > 0::text
    GROUP BY t_actes.action_id, t_actes.action_code, t_actes.action_texte
  UNION ALL
   SELECT '-8'::text AS oid,
      '-8'::text AS code,
      'Technique'::text AS texte,
      1 AS lvl,
      3::text AS tri
  UNION ALL
   SELECT 'SC4'::text || t_actes.technique_id::text AS oid,
      t_actes.technique_code AS code,
      (t_actes.technique_code || '. '::text) || t_actes.technique_texte AS texte,
      2 AS lvl,
      '3'::text || t_actes.technique_code AS tri
     FROM pmsi.t_actes
       JOIN pmsi.p_oids ON p_oids.code_table::text = 'actes'::text AND p_oids.oid = t_actes.oid
    WHERE t_actes.technique_id::text IS DISTINCT FROM NULL::text AND t_actes.technique_id::text > 0::text
    GROUP BY t_actes.technique_id, t_actes.technique_code, t_actes.technique_texte
    ORDER BY 5;