pour déploiement auto v2 via gitlab
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

190 lines
10 KiB

dep:
- v_codes_postaux_2
- 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,
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 = 'CODEPOST'::text AND v_listes_1.lvl <> '0'::text
UNION ALL
SELECT ('LC'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes.oid::text AS oid,
t_classes.texte,
''::text AS code,
'1'::text AS level,
'5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text)) AS tri,
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 = 'CODEPOST'::text
UNION ALL
SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || t_classes_sections.oid::text AS oid,
t_classes_sections.texte,
''::text AS code,
'2'::text AS level,
'5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || t_classes_sections.code) AS tri,
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 = 'CODEPOST'::text
UNION ALL
SELECT ('LS'::text || lpad(t_classes.sequence::text, 2, '0'::text)) || '0'::text AS oid,
'Section non attribuée'::character varying AS texte,
''::text AS code,
'2'::text AS level,
'5'::text || btrim(rpad(lpad(t_classes.sequence::text, 2, '0'::text), 10, ' '::text) || chr(255)) AS tri,
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 = 'CODEPOST'::text
UNION ALL
SELECT '-8'::text AS oid,
'Codes postaux'::character varying AS texte,
'A'::text AS code,
'1'::text AS level,
'7'::text AS tri,
'0'::character(1) AS is_cti
UNION ALL
( SELECT DISTINCT 'DP'::text || v_codes_postaux_2.departement_id::text AS oid,
(v_codes_postaux_2.departement_code || ' '::text) || v_codes_postaux_2.departement_texte AS texte,
v_codes_postaux_2.departement_code AS code,
'2'::text AS level,
'7'::text || substr(v_codes_postaux_2.departement_code || ' '::text, 1, 5) AS tri,
'0'::character(1) AS is_cti
FROM pmsi.v_codes_postaux_2
WHERE (v_codes_postaux_2.code_postal_id IN ( SELECT p_oids.oid
FROM pmsi.p_oids
WHERE p_oids.code_table::text = 'c_postaux'::text))
ORDER BY ('DP'::text || v_codes_postaux_2.departement_id::text), ((v_codes_postaux_2.departement_code || ' '::text) || v_codes_postaux_2.departement_texte), v_codes_postaux_2.departement_code, '2'::text, ('7'::text || substr(v_codes_postaux_2.departement_code || ' '::text, 1, 5)))
UNION ALL
( SELECT DISTINCT 'CP'::text || v_codes_postaux_2.code_postal_id::text AS oid,
(v_codes_postaux_2.code_postal_code || ' '::text) || v_codes_postaux_2.code_postal_texte AS texte,
v_codes_postaux_2.code_postal_code AS code,
'3'::text AS level,
(('7'::text || substr(v_codes_postaux_2.departement_code || ' '::text, 1, 5)) || 'P'::text) || v_codes_postaux_2.code_postal_code AS tri,
'0'::character(1) AS is_cti
FROM pmsi.v_codes_postaux_2
WHERE (v_codes_postaux_2.code_postal_id IN ( SELECT p_oids.oid
FROM pmsi.p_oids
WHERE p_oids.code_table::text = 'c_postaux'::text))
ORDER BY ('CP'::text || v_codes_postaux_2.code_postal_id::text), ((v_codes_postaux_2.code_postal_code || ' '::text) || v_codes_postaux_2.code_postal_texte), v_codes_postaux_2.code_postal_code, '3'::text, ((('7'::text || substr(v_codes_postaux_2.departement_code || ' '::text, 1, 5)) || 'P'::text) || v_codes_postaux_2.code_postal_code))
UNION ALL
SELECT '-8'::text AS oid,
'Secteurs géographiques PMSI'::character varying AS texte,
'A'::text AS code,
'1'::text AS level,
'8'::text AS tri,
'0'::character(1) AS is_cti
UNION ALL
( SELECT DISTINCT 'DG'::text || v_codes_postaux_2.departement_id::text AS oid,
(v_codes_postaux_2.departement_code || ' '::text) || v_codes_postaux_2.departement_texte AS texte,
v_codes_postaux_2.departement_code AS code,
'2'::text AS level,
'8'::text || substr(v_codes_postaux_2.departement_code || ' '::text, 1, 5) AS tri,
'0'::character(1) AS is_cti
FROM pmsi.v_codes_postaux_2
WHERE (v_codes_postaux_2.code_postal_id IN ( SELECT p_oids.oid
FROM pmsi.p_oids
WHERE p_oids.code_table::text = 'c_postaux'::text))
ORDER BY ('DG'::text || v_codes_postaux_2.departement_id::text), ((v_codes_postaux_2.departement_code || ' '::text) || v_codes_postaux_2.departement_texte), v_codes_postaux_2.departement_code, '2'::text, ('8'::text || substr(v_codes_postaux_2.departement_code || ' '::text, 1, 5)))
UNION ALL
( SELECT DISTINCT 'GP'::text || v_codes_postaux_2.code_geographique_pmsi_id::text AS oid,
(v_codes_postaux_2.code_geographique_pmsi_code || ' '::text) || v_codes_postaux_2.code_geographique_pmsi_texte AS texte,
v_codes_postaux_2.code_geographique_pmsi_code AS code,
'3'::text AS level,
(('8'::text || substr(v_codes_postaux_2.departement_code || ' '::text, 1, 5)) || 'P'::text) || v_codes_postaux_2.code_geographique_pmsi_code AS tri,
'0'::character(1) AS is_cti
FROM pmsi.v_codes_postaux_2
WHERE (v_codes_postaux_2.code_postal_id IN ( SELECT p_oids.oid
FROM pmsi.p_oids
WHERE p_oids.code_table::text = 'c_postaux'::text))
ORDER BY ('GP'::text || v_codes_postaux_2.code_geographique_pmsi_id::text), ((v_codes_postaux_2.code_geographique_pmsi_code || ' '::text) || v_codes_postaux_2.code_geographique_pmsi_texte), v_codes_postaux_2.code_geographique_pmsi_code, '3'::text, ((('8'::text || substr(v_codes_postaux_2.departement_code || ' '::text, 1, 5)) || 'P'::text) || v_codes_postaux_2.code_geographique_pmsi_code))
UNION ALL
SELECT '-8'::text AS oid,
'Régions'::character varying AS texte,
'R'::text AS code,
'1'::text AS level,
'10'::text AS tri,
'0'::character(1) AS is_cti
UNION ALL
( SELECT DISTINCT 'RG'::text || v_codes_postaux_2.region_id::text AS oid,
(v_codes_postaux_2.region_code || ' '::text) || v_codes_postaux_2.region_texte AS texte,
v_codes_postaux_2.region_code AS code,
'2'::text AS level,
'10'::text || substr(v_codes_postaux_2.region_code || ' '::text, 1, 5) AS tri,
'0'::character(1) AS is_cti
FROM pmsi.v_codes_postaux_2
WHERE (v_codes_postaux_2.code_postal_id IN ( SELECT p_oids.oid
FROM pmsi.p_oids
WHERE p_oids.code_table::text = 'c_postaux'::text))
ORDER BY ('RG'::text || v_codes_postaux_2.region_id::text), ((v_codes_postaux_2.region_code || ' '::text) || v_codes_postaux_2.region_texte), v_codes_postaux_2.region_code, '2'::text, ('10'::text || substr(v_codes_postaux_2.region_code || ' '::text, 1, 5)))
UNION ALL
SELECT '-8'::text AS oid,
'Territoires de santé'::character varying AS texte,
'A'::text AS code,
'1'::text AS level,
'9'::text AS tri,
'0'::character(1) AS is_cti
UNION ALL
( SELECT DISTINCT 'TS'::text || v_codes_postaux_2.territoire_sante_id::text AS oid,
CASE
WHEN v_codes_postaux_2.territoire_sante_texte = ''::text THEN 'Non renseigné'::text::character varying::text
ELSE v_codes_postaux_2.territoire_sante_texte
END AS texte,
CASE
WHEN v_codes_postaux_2.territoire_sante_code = ''::text THEN ((chr(127) || '*******'::text)::character varying)::text
ELSE v_codes_postaux_2.territoire_sante_code
END AS code,
'2'::text AS level,
CASE
WHEN v_codes_postaux_2.territoire_sante_texte = ''::text THEN '9 '::text || 'Non renseigné'::text
ELSE '9'::text || v_codes_postaux_2.territoire_sante_texte
END AS tri,
'0'::character(1) AS is_cti
FROM pmsi.v_codes_postaux_2
WHERE (v_codes_postaux_2.code_postal_id IN ( SELECT p_oids.oid
FROM pmsi.p_oids
WHERE p_oids.code_table::text = 'c_postaux'::text))
GROUP BY ('TS'::text || v_codes_postaux_2.territoire_sante_id::text), (
CASE
WHEN v_codes_postaux_2.territoire_sante_texte = ''::text THEN 'Non renseigné'::text::character varying::text
ELSE v_codes_postaux_2.territoire_sante_texte
END), (
CASE
WHEN v_codes_postaux_2.territoire_sante_code = ''::text THEN ((chr(127) || '*******'::text)::character varying)::text
ELSE v_codes_postaux_2.territoire_sante_code
END), '2'::text, (
CASE
WHEN v_codes_postaux_2.territoire_sante_texte = ''::text THEN '9 '::text || 'Non renseigné'::text
ELSE '9'::text || v_codes_postaux_2.territoire_sante_texte
END)
ORDER BY ('TS'::text || v_codes_postaux_2.territoire_sante_id::text), (
CASE
WHEN v_codes_postaux_2.territoire_sante_texte = ''::text THEN 'Non renseigné'::text::character varying::text
ELSE v_codes_postaux_2.territoire_sante_texte
END), (
CASE
WHEN v_codes_postaux_2.territoire_sante_code = ''::text THEN ((chr(127) || '*******'::text)::character varying)::text
ELSE v_codes_postaux_2.territoire_sante_code
END), '2'::text, (
CASE
WHEN v_codes_postaux_2.territoire_sante_texte = ''::text THEN '9 '::text || 'Non renseigné'::text
ELSE '9'::text || v_codes_postaux_2.territoire_sante_texte
END))
ORDER BY 5;