|
|
return: SETOF record
|
|
|
lang: plpgsql
|
|
|
parameters:
|
|
|
p0:
|
|
|
type: bigint
|
|
|
name: i_rapport_id
|
|
|
src: |
|
|
|
DECLARE
|
|
|
sqlcmd text;
|
|
|
|
|
|
temp_cursor refcursor;
|
|
|
_oid integer;
|
|
|
_maxind integer;
|
|
|
|
|
|
row RECORD;
|
|
|
BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
FOR row IN
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rss_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rss_rum_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rsf_detail_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rsf_detail_6', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rss_lpp_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rss_ucd_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rss_actes_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rss_diagnostics_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rss_cancero_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_expert_rss_controle_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rss_src_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rsf_detail_rum_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT * FROM pmsi.cti_prepare_rapport_indicateurs(i_rapport_id, 'v_rss_sae_1', '') AS (name text, value text)
|
|
|
UNION
|
|
|
SELECT 'RUBRIQUES_RAPPORT',
|
|
|
base.cti_group_concat(
|
|
|
CASE WHEN table_name <> '*CALC' THEN 'SUM(indicateurs[000' || indicateur_id || '])'
|
|
|
ELSE
|
|
|
replace(
|
|
|
replace(
|
|
|
replace(
|
|
|
column_name,
|
|
|
'[1]',
|
|
|
'SUM(indicateurs[000' || indicateur_associe_1_id || '])'
|
|
|
),
|
|
|
'[2]',
|
|
|
'SUM(indicateurs[000' || indicateur_associe_2_id || '])'
|
|
|
),
|
|
|
'[3]',
|
|
|
'SUM(indicateurs[000' || indicateur_associe_2_id || '])'
|
|
|
)
|
|
|
END)
|
|
|
FROM (SELECT * FROM pmsi.t_rapports_rubriques
|
|
|
JOIN pmsi.t_indicateurs ON t_rapports_rubriques.indicateur_id = t_indicateurs.oid
|
|
|
WHERE rapport_id = i_rapport_id ORDER BY numero_rubrique
|
|
|
) subview
|
|
|
UNION
|
|
|
|
|
|
|
|
|
SELECT 'IC' || numero_rubrique, t_indicateurs.oid::text FROM pmsi.t_rapports_rubriques, pmsi.t_indicateurs
|
|
|
WHERE t_rapports_rubriques.rapport_id = i_rapport_id AND t_rapports_rubriques.indicateur_id = t_indicateurs.oid
|
|
|
|
|
|
UNION
|
|
|
|
|
|
SELECT 'IH' || numero_rubrique, CASE WHEN t_rapports_rubriques.entete <> '' THEN t_rapports_rubriques.entete ELSE t_indicateurs.entete END FROM pmsi.t_rapports_rubriques, pmsi.t_indicateurs
|
|
|
WHERE t_rapports_rubriques.rapport_id = i_rapport_id AND t_rapports_rubriques.indicateur_id = t_indicateurs.oid
|
|
|
|
|
|
UNION
|
|
|
|
|
|
SELECT 'IW' || numero_rubrique,
|
|
|
CASE
|
|
|
WHEN t_indicateurs.table_name = 'SEP' THEN '2'
|
|
|
WHEN t_rapports_rubriques.width > 0 THEN t_rapports_rubriques.width::text
|
|
|
WHEN t_indicateurs.width > 0 THEN t_indicateurs.width::text
|
|
|
ELSE '80'
|
|
|
END
|
|
|
FROM pmsi.t_rapports_rubriques, pmsi.t_indicateurs
|
|
|
WHERE t_rapports_rubriques.rapport_id = i_rapport_id AND t_rapports_rubriques.indicateur_id = t_indicateurs.oid
|
|
|
|
|
|
UNION
|
|
|
|
|
|
SELECT 'IO' || numero_rubrique,
|
|
|
CASE WHEN t_rapports_rubriques.output_format <> '' THEN t_rapports_rubriques.output_format
|
|
|
WHEN t_indicateurs.output_format <> '' THEN t_indicateurs.output_format
|
|
|
ELSE '#' END
|
|
|
FROM pmsi.t_rapports_rubriques, pmsi.t_indicateurs
|
|
|
WHERE t_rapports_rubriques.rapport_id = i_rapport_id AND t_rapports_rubriques.indicateur_id = t_indicateurs.oid
|
|
|
|
|
|
UNION
|
|
|
|
|
|
SELECT 'IT' || numero_rubrique, t_indicateurs.table_name::text FROM pmsi.t_rapports_rubriques, pmsi.t_indicateurs
|
|
|
WHERE t_rapports_rubriques.rapport_id = i_rapport_id AND t_rapports_rubriques.indicateur_id = t_indicateurs.oid
|
|
|
LOOP
|
|
|
|
|
|
|
|
|
RETURN NEXT row;
|
|
|
END LOOP;
|
|
|
RETURN ;
|
|
|
END;
|