dep:
|
|
- v_listes_1
|
|
src: |
|
|
SELECT v_listes_1.liste_id_combo AS oid,
|
|
v_listes_1.texte,
|
|
''::text AS code,
|
|
v_listes_1.lvl AS level,
|
|
('0'::text || v_listes_1.sort) || chr(1) AS tri,
|
|
v_listes_1.liste_alias_combo AS alias
|
|
FROM pmsi.v_listes_1
|
|
WHERE v_listes_1.table_code = 'GHS'::text AND v_listes_1.lvl <> '0'::text
|
|
UNION ALL
|
|
SELECT 'GS'::text || t_ghs.oid::text AS oid,
|
|
(t_ghs.code_text || ' '::text) || t_ghs.texte::text AS texte,
|
|
t_ghs.code_text AS code,
|
|
'1'::text AS level,
|
|
CASE
|
|
WHEN substr(t_ghs.code_text, 1, 1) = ANY (ARRAY['D'::text, 'I'::text]) THEN '9'::text
|
|
ELSE '8'::text
|
|
END || lpad(t_ghs.code_text, 4, '0'::text) AS tri,
|
|
CASE
|
|
WHEN t_ghs.code_text IS DISTINCT FROM ''::text THEN '#GS'::text || t_ghs.code_text
|
|
ELSE t_ghs.oid::text
|
|
END AS alias
|
|
FROM pmsi.t_ghs
|
|
WHERE (t_ghs.oid IN ( SELECT p_oids.oid
|
|
FROM pmsi.p_oids
|
|
WHERE p_oids.code_table::text = 'ghs'::text))
|
|
ORDER BY 5;
|