dep:
|
|
- v_listes_1
|
|
src: |
|
|
(
|
|
(
|
|
SELECT v_listes_1.liste_id_combo 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 = 'GHM'::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.code,
|
|
t_classes.texte,
|
|
'1'::text AS level,
|
|
'5'::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 = 'GHM'::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.code || ' '::text) || t_classes_sections.texte AS texte,
|
|
'2'::text AS level,
|
|
'5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri,
|
|
(('#LS'::text || t_classes.code) || ':'::text) || t_classes_sections.code 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 = 'GHM'::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'::character varying AS texte,
|
|
'2'::text AS level,
|
|
'5'::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 = 'GHM'::text
|
|
) UNION
|
|
SELECT 'CM'::text || t_cmd.oid::text AS oid,
|
|
t_cmd.code,
|
|
(t_cmd.code::text || ' '::text) || t_cmd.texte_court::text AS texte,
|
|
'1'::text AS level,
|
|
'6'::text || t_cmd.code::text AS tri,
|
|
''::text AS alias,
|
|
'0'::character(1) AS is_cti
|
|
FROM pmsi.t_cmd,
|
|
pmsi.t_ghm
|
|
WHERE t_ghm.cmd_id = t_cmd.oid AND (t_ghm.oid IN ( SELECT p_oids.oid
|
|
FROM pmsi.p_oids
|
|
WHERE p_oids.code_table::text = 'ghm'::text))
|
|
UNION
|
|
SELECT 'GH'::text || t_ghm.oid::text AS oid,
|
|
t_ghm.code,
|
|
(t_ghm.code::text || ' '::text) || t_ghm.texte::text AS texte,
|
|
'2'::text AS level,
|
|
'6'::text || t_ghm.code::text AS tri,
|
|
''::text AS alias,
|
|
'0'::character(1) AS is_cti
|
|
FROM pmsi.t_ghm
|
|
WHERE (t_ghm.oid IN ( SELECT p_oids.oid
|
|
FROM pmsi.p_oids
|
|
WHERE p_oids.code_table::text = 'ghm'::text))
|
|
UNION
|
|
SELECT 'SV'::text AS oid,
|
|
'SV'::text AS code,
|
|
'Sévérités'::text AS texte,
|
|
'1'::text AS level,
|
|
'7'::text AS tri,
|
|
''::text AS alias,
|
|
'0'::character(1) AS is_cti
|
|
UNION
|
|
SELECT 'SV'::text || t_severites_ghm.code::text AS oid,
|
|
t_severites_ghm.code,
|
|
(t_severites_ghm.code::text || ' '::text) || t_severites_ghm.texte::text AS texte,
|
|
'2'::text AS level,
|
|
'7'::text || t_severites_ghm.code::text AS tri,
|
|
''::text AS alias,
|
|
'0'::character(1) AS is_cti
|
|
FROM pmsi.t_severites_ghm
|
|
UNION
|
|
( SELECT DISTINCT 'CA'::text AS oid,
|
|
'CMA_V10'::text AS code,
|
|
'CMA V10'::text AS texte,
|
|
'1'::text AS level,
|
|
'8'::text AS tri,
|
|
''::text AS alias,
|
|
'0'::character(1) AS is_cti
|
|
FROM pmsi.t_ghm
|
|
ORDER BY 'CA'::text, 'CMA V10'::text, '1'::text, '8'::text, ''::text)
|
|
UNION
|
|
SELECT 'GH'::text || t_ghm.oid::text AS oid,
|
|
t_ghm.code,
|
|
(t_ghm.code::text || ' '::text) || t_ghm.texte::text AS texte,
|
|
'2'::text AS level,
|
|
'8'::text || t_ghm.code::text AS tri,
|
|
''::text AS alias,
|
|
'0'::character(1) AS is_cti
|
|
FROM pmsi.t_ghm
|
|
WHERE substr(t_ghm.code::text, 6, 1) = 'W'::text AND (t_ghm.oid IN ( SELECT p_oids.oid
|
|
FROM pmsi.p_oids
|
|
WHERE p_oids.code_table::text = 'ghm'::text))
|
|
UNION
|
|
SELECT 'CW'::text || t_ghm.oid::text AS oid,
|
|
t_ghm.code::text || '+V '::text AS code,
|
|
(t_ghm.code::text || '+V '::text) || t_ghm.texte::text AS texte,
|
|
'2'::text AS level,
|
|
'8'::text || t_ghm.code::text AS tri,
|
|
''::text AS alias,
|
|
'0'::character(1) AS is_cti
|
|
FROM pmsi.t_ghm
|
|
WHERE substr(t_ghm.code::text, 6, 1) = 'W'::text AND (t_ghm.oid IN ( SELECT p_oids.oid
|
|
FROM pmsi.p_oids
|
|
WHERE p_oids.code_table::text = 'ghm'::text))
|
|
UNION
|
|
( SELECT DISTINCT 'CS'::text AS oid,
|
|
'CMA_V10'::text AS code,
|
|
'CMA V10 (sévère)'::text AS texte,
|
|
'1'::text AS level,
|
|
'9'::text AS tri,
|
|
''::text AS alias,
|
|
'0'::character(1) AS is_cti
|
|
FROM pmsi.t_ghm
|
|
ORDER BY 'CS'::text, 'CMA V10 (sévère)'::text, '1'::text, '9'::text, ''::text)
|
|
UNION
|
|
SELECT 'GH'::text || t_ghm.oid::text AS oid,
|
|
t_ghm.code,
|
|
(t_ghm.code::text || ' '::text) || t_ghm.texte::text AS texte,
|
|
'2'::text AS level,
|
|
'9'::text || t_ghm.code::text AS tri,
|
|
''::text AS alias,
|
|
'0'::character(1) AS is_cti
|
|
FROM pmsi.t_ghm
|
|
WHERE substr(t_ghm.code::text, 6, 1) = 'S'::text AND (t_ghm.oid IN ( SELECT p_oids.oid
|
|
FROM pmsi.p_oids
|
|
WHERE p_oids.code_table::text = 'ghm'::text))
|
|
ORDER BY 5;
|