src: |
  SELECT 'SG'::text || t_secteurs_geographiques.oid::text AS oid,
      t_secteurs_geographiques.texte,
      '1'::text AS level,
      '1'::text || t_secteurs_geographiques.code::text AS tri
     FROM pmsi.t_secteurs_geographiques
  UNION
   SELECT 'DP'::text || t_departements.oid::text AS oid,
      (t_departements.code || ' '::text) || t_departements.texte AS texte,
      '1'::text AS level,
      '3'::text || t_departements.code AS tri
     FROM base.t_departements
    WHERE (t_departements.oid IN ( SELECT p_oids.oid
             FROM pmsi.p_oids
            WHERE p_oids.code_table::text = 'departement'::text))
  UNION
   SELECT 'CP'::text || t_codes_postaux_c.oid::text AS oid,
      t_codes_postaux_c.code AS texte,
      '2'::text AS level,
      '3'::text || t_codes_postaux_c.code AS tri
     FROM pmsi.t_codes_postaux_c
    WHERE (t_codes_postaux_c.oid IN ( SELECT p_oids.oid
             FROM pmsi.p_oids
            WHERE p_oids.code_table::text = 'c_postaux'::text))
  UNION
   SELECT 'GP99999999'::text AS oid,
      'Codes géographiques PMSI'::character varying AS texte,
      '1'::text AS level,
      '4'::text AS tri
  UNION
   SELECT 'GP'::text || t_codes_geographiques_pmsi.oid::text AS oid,
      t_codes_geographiques_pmsi.code AS texte,
      '2'::text AS level,
      '4'::text || t_codes_geographiques_pmsi.code AS tri
     FROM base.t_codes_geographiques_pmsi,
      pmsi.t_codes_postaux_c
    WHERE t_codes_postaux_c.code_geographique_pmsi_id = t_codes_geographiques_pmsi.oid AND (t_codes_postaux_c.oid IN ( SELECT p_oids.oid
             FROM pmsi.p_oids
            WHERE p_oids.code_table::text = 'c_postaux'::text))
    ORDER BY 4;