|
|
dep:
|
|
|
- v_unites_medicales_2
|
|
|
src: |
|
|
|
SELECT DISTINCT p_rss_rum.rss_id,
|
|
|
p_rss_rum.finess,
|
|
|
p_rss_rum.no_rss,
|
|
|
p_rss_rum.no_rum,
|
|
|
p_rss_rum.date_entree AS date_entree_rum,
|
|
|
p_rss_rum.date_sortie AS date_sortie_rum,
|
|
|
p_rss_rum.mode_entree AS mode_entree_rum,
|
|
|
t_modes_entree.texte AS mode_entree_rum_texte,
|
|
|
t_modes_entree.texte_court AS mode_entree_rum_texte_court,
|
|
|
p_rss_rum.provenance AS provenance_rum,
|
|
|
t_provenances_entree.texte AS provenance_rum_texte,
|
|
|
t_provenances_entree.texte_court AS provenance_rum_texte_court,
|
|
|
p_rss_rum.mode_sortie AS mode_sortie_rum,
|
|
|
t_modes_sortie.texte AS mode_sortie_rum_texte,
|
|
|
t_modes_sortie.texte_court AS mode_sortie_rum_texte_court,
|
|
|
p_rss_rum.destination AS destination_rum,
|
|
|
t_destinations_sortie.texte AS destination_rum_texte,
|
|
|
t_destinations_sortie.texte_court AS destination_rum_texte_court,
|
|
|
p_rss_rum.unite_medicale_id,
|
|
|
v_unites_medicales_2.code AS unite_medicale_code,
|
|
|
v_unites_medicales_2.texte AS unite_medicale_texte,
|
|
|
v_unites_medicales_2.type_autorisation,
|
|
|
v_unites_medicales_2.type_autorisation_texte,
|
|
|
v_unites_medicales_2.section_id AS unite_medicale_section_id,
|
|
|
v_unites_medicales_2.section_code AS unite_medicale_section_code,
|
|
|
v_unites_medicales_2.section_texte AS unite_medicale_section_texte,
|
|
|
p_rss_rum.type_autorisation_lit_dedie,
|
|
|
p_rss_rum.pole_id AS pole_rum_id,
|
|
|
t_pole.code AS pole_rum_code,
|
|
|
t_pole.texte AS pole_rum_texte,
|
|
|
t_pole.section_id AS pole_rum_section_id,
|
|
|
t_pole.section_code AS pole_rum_section_code,
|
|
|
t_pole.section_texte AS pole_rum_section_texte,
|
|
|
p_rss_rum.diagnostic_principal_id AS diagnostic_principal_rum_id,
|
|
|
t_diagnostics_principaux.code AS diagnostic_principal_rum_code,
|
|
|
t_diagnostics_principaux.texte AS diagnostic_principal_rum_texte,
|
|
|
t_diagnostics_principaux.racine_id AS diagnostic_principal_rum_racine_id,
|
|
|
t_diagnostics_principaux.racine_code AS diagnostic_principal_rum_racine_code,
|
|
|
t_diagnostics_principaux.racine_texte AS diagnostic_principal_rum_racine_texte,
|
|
|
p_rss_rum.diagnostic_relie_id AS diagnostic_relie_rum_id,
|
|
|
t_diagnostics_relies.code AS diagnostic_relie_rum_code,
|
|
|
t_diagnostics_relies.texte AS diagnostic_relie_rum_texte,
|
|
|
1 AS nb_rum_rum,
|
|
|
CASE
|
|
|
WHEN v_unites_medicales_2.type_autorisation <> ''::text THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_avec_autorisation,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.mode_entree = '0'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_mode_entree_0,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.mode_entree = '6'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_mode_entree_6,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.mode_entree = '7'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_mode_entree_7,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.mode_entree = '8'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_mode_entree_8,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.mode_sortie = '0'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_mode_sortie_0,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.mode_sortie = '6'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_mode_sortie_6,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.mode_sortie = '7'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_mode_sortie_7,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.mode_sortie = '8'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_mode_sortie_8,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.mode_sortie = '9'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_mode_sortie_9,
|
|
|
p_rss_rum.duree_sejour AS duree_sejour_rum,
|
|
|
p_rss_rum.igs2 AS igs2_rum,
|
|
|
p_rss_rum.nb_seances AS nb_seances_rum,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.provenance = '1'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_provenance_1,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.provenance = '2'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_provenance_2,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.provenance = '3'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_provenance_3,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.provenance = '4'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_provenance_4,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.provenance = '5'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_provenance_5,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.provenance = '6'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_provenance_6,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.provenance = '7'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_provenance_7,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.provenance = '8'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_provenance_8,
|
|
|
CASE
|
|
|
WHEN lower(p_rss_rum.provenance::text) = 'r'::text THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_provenance_r,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.destination = '1'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_destination_1,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.destination = '2'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_destination_2,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.destination = '3'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_destination_3,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.destination = '4'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_destination_4,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.destination = '5'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_destination_5,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.destination = '6'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_destination_6,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.destination = '7'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_destination_7,
|
|
|
CASE
|
|
|
WHEN p_rss_rum.destination = '8'::bpchar THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_destination_8,
|
|
|
CASE
|
|
|
WHEN lower(p_rss_rum.destination::text) = 'r'::text THEN 1
|
|
|
ELSE 0
|
|
|
END AS nb_rum_destination_r,
|
|
|
COALESCE(v_unites_medicales_2.finess_geographique, p_rss_rum.finess::text) AS finess_geographique,
|
|
|
t_modes_hospitalisation.oid AS mode_hospitalisation_id,
|
|
|
t_modes_hospitalisation.code AS mode_hospitalisation_code,
|
|
|
t_modes_hospitalisation.texte AS mode_hospitalisation_texte,
|
|
|
t_disciplines_sae.oid AS discipline_sae_id,
|
|
|
t_disciplines_sae.code AS discipline_sae_code,
|
|
|
t_disciplines_sae.texte AS discipline_sae_texte,
|
|
|
t_conversion_hp_hc.oid AS conversion_hp_hc_id,
|
|
|
t_conversion_hp_hc.code AS conversion_hp_hc_code,
|
|
|
t_conversion_hp_hc.texte AS conversion_hp_hc_texte,
|
|
|
p_rss_rum.medecin_rum_id,
|
|
|
t_medecins_c.code AS medecin_rum_code,
|
|
|
t_medecins_c.nom_prenom AS medecin_rum_nom,
|
|
|
t_medecins_c.specialite_medecin_reference_id AS specialite_medecin_reference_rum_id,
|
|
|
t_medecins_c.specialite_medecin_reference_code AS specialite_medecin_reference_rum_code,
|
|
|
t_medecins_c.specialite_medecin_reference_texte AS specialite_medecin_reference_rum_texte,
|
|
|
t_medecins_c.section_id AS medecin_rum_section_id,
|
|
|
t_medecins_c.section_code AS medecin_rum_section_code,
|
|
|
t_medecins_c.section_texte AS medecin_rum_section_texte,
|
|
|
t_passage_urgences.oid AS passage_urgences_id,
|
|
|
t_passage_urgences.code AS passage_urgences_code,
|
|
|
t_passage_urgences.texte AS passage_urgences_texte
|
|
|
FROM pmsi.p_rss_rum
|
|
|
JOIN pmsi.v_unites_medicales_2 ON p_rss_rum.unite_medicale_id = v_unites_medicales_2.oid
|
|
|
JOIN pmsi.t_diagnostics t_diagnostics_principaux ON p_rss_rum.diagnostic_principal_id = t_diagnostics_principaux.oid
|
|
|
JOIN pmsi.t_types_autorisations ON v_unites_medicales_2.type_autorisation = t_types_autorisations.code
|
|
|
JOIN pmsi.t_modes_hospitalisation ON t_types_autorisations.mode_hospitalisation_id = t_modes_hospitalisation.oid
|
|
|
JOIN pmsi.t_disciplines_sae ON t_types_autorisations.discipline_sae_id = t_disciplines_sae.oid
|
|
|
JOIN pmsi.t_modes_entree ON p_rss_rum.mode_entree = t_modes_entree.code
|
|
|
JOIN pmsi.t_provenances_entree ON p_rss_rum.provenance = t_provenances_entree.code
|
|
|
JOIN pmsi.t_modes_sortie ON p_rss_rum.mode_sortie = t_modes_sortie.code
|
|
|
JOIN pmsi.t_destinations_sortie ON p_rss_rum.destination = t_destinations_sortie.code
|
|
|
JOIN pmsi.t_diagnostics t_diagnostics_relies ON p_rss_rum.diagnostic_relie_id = t_diagnostics_relies.oid
|
|
|
JOIN pmsi.t_conversion_hp_hc ON t_conversion_hp_hc.oid = p_rss_rum.conversion_hp_hc_id
|
|
|
JOIN pmsi.t_passage_urgences ON t_passage_urgences.code = p_rss_rum.passage_urgences_code
|
|
|
LEFT JOIN pmsi.t_pole ON p_rss_rum.pole_id = t_pole.oid
|
|
|
JOIN pmsi.t_medecins_c ON p_rss_rum.medecin_rum_id = t_medecins_c.oid
|
|
|
;
|