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.
 
 
 

203 lines
12 KiB

src: |
SELECT p_couts_patient_shs.exercice_comptable,
p_couts_patient_shs.exercice_comptable::bigint AS exercice_comptable_id,
p_couts_patient_shs.exercice_comptable::text AS exercice_comptable_code,
p_couts_patient_shs.exercice_comptable::text AS exercice_comptable_texte,
p_couts_patient_shs.mois_comptable,
p_couts_patient_shs.mois_comptable::bigint AS mois_comptable_id,
p_couts_patient_shs.mois_comptable::text AS mois_comptable_code,
p_couts_patient_shs.mois_comptable::text AS mois_comptable_texte,
p_couts_patient_shs.no_sejour,
p_couts_patient_shs.no_facture,
p_couts_patient_shs.date_entree,
p_couts_patient_shs.date_sortie,
p_couts_patient_shs.lieu_id,
t_lieux_cout_patient_shs.service_facturation_code_original,
t_lieux_cout_patient_shs.service_facturation_id,
t_lieux_cout_patient_shs.service_facturation_code,
t_lieux_cout_patient_shs.service_facturation_texte,
t_lieux_cout_patient_shs.service_facturation_section1_id,
t_lieux_cout_patient_shs.service_facturation_section1_code,
t_lieux_cout_patient_shs.service_facturation_section1_texte,
t_lieux_cout_patient_shs.service_facturation_section2_id,
t_lieux_cout_patient_shs.service_facturation_section2_code,
t_lieux_cout_patient_shs.service_facturation_section2_texte,
t_lieux_cout_patient_shs.service_facturation_section3_id,
t_lieux_cout_patient_shs.service_facturation_section3_code,
t_lieux_cout_patient_shs.service_facturation_section3_texte,
t_lieux_cout_patient_shs.activite_code_original,
t_lieux_cout_patient_shs.activite_id,
t_lieux_cout_patient_shs.activite_code,
t_lieux_cout_patient_shs.activite_texte,
t_lieux_cout_patient_shs.activite_section1_id,
t_lieux_cout_patient_shs.activite_section1_code,
t_lieux_cout_patient_shs.activite_section1_texte,
t_lieux_cout_patient_shs.activite_section2_id,
t_lieux_cout_patient_shs.activite_section2_code,
t_lieux_cout_patient_shs.activite_section2_texte,
t_lieux_cout_patient_shs.activite_section3_id,
t_lieux_cout_patient_shs.activite_section3_code,
t_lieux_cout_patient_shs.activite_section3_texte,
t_lieux_cout_patient_shs.etage_code_original,
t_lieux_cout_patient_shs.etage_id,
t_lieux_cout_patient_shs.etage_code,
t_lieux_cout_patient_shs.etage_texte,
t_lieux_cout_patient_shs.etage_section1_id,
t_lieux_cout_patient_shs.etage_section1_code,
t_lieux_cout_patient_shs.etage_section1_texte,
t_lieux_cout_patient_shs.etage_section2_id,
t_lieux_cout_patient_shs.etage_section2_code,
t_lieux_cout_patient_shs.etage_section2_texte,
t_lieux_cout_patient_shs.etage_section3_id,
t_lieux_cout_patient_shs.etage_section3_code,
t_lieux_cout_patient_shs.etage_section3_texte,
t_lieux_cout_patient_shs.lit_code_original,
t_lieux_cout_patient_shs.lit_id,
t_lieux_cout_patient_shs.lit_code,
t_lieux_cout_patient_shs.lit_texte,
t_lieux_cout_patient_shs.lit_section1_id,
t_lieux_cout_patient_shs.lit_section1_code,
t_lieux_cout_patient_shs.lit_section1_texte,
t_lieux_cout_patient_shs.lit_section2_id,
t_lieux_cout_patient_shs.lit_section2_code,
t_lieux_cout_patient_shs.lit_section2_texte,
t_lieux_cout_patient_shs.lit_section3_id,
t_lieux_cout_patient_shs.lit_section3_code,
t_lieux_cout_patient_shs.lit_section3_texte,
p_couts_patient_shs.medecin_administratif_id,
t_medecins_cout_patient_shs.code AS medecin_administratif_code,
t_medecins_cout_patient_shs.code_original AS medecin_administratif_code_original,
(t_medecins_cout_patient_shs.nom::text || ' '::text) || t_medecins_cout_patient_shs.prenom::text AS medecin_administratif_texte,
t_medecins_cout_patient_shs.section1_id AS medecin_administratif_section1_id,
t_medecins_cout_patient_shs.section1_code AS medecin_administratif_section1_code,
t_medecins_cout_patient_shs.section1_texte AS medecin_administratif_section1_texte,
t_medecins_cout_patient_shs.section2_id AS medecin_administratif_section2_id,
t_medecins_cout_patient_shs.section2_code AS medecin_administratif_section2_code,
t_medecins_cout_patient_shs.section2_texte AS medecin_administratif_section2_texte,
t_medecins_cout_patient_shs.section3_id AS medecin_administratif_section3_id,
t_medecins_cout_patient_shs.section3_code AS medecin_administratif_section3_code,
t_medecins_cout_patient_shs.section3_texte AS medecin_administratif_section3_texte,
p_couts_patient_shs.ghs_id,
t_ghs_cout_patient_shs.code AS ghs_code,
t_ghs_cout_patient_shs.texte_court AS ghs_texte,
t_ghs_cout_patient_shs.section1_id AS ghs_section1_id,
t_ghs_cout_patient_shs.section1_code AS ghs_section1_code,
t_ghs_cout_patient_shs.section1_texte AS ghs_section1_texte,
t_ghs_cout_patient_shs.section2_id AS ghs_section2_id,
t_ghs_cout_patient_shs.section2_code AS ghs_section2_code,
t_ghs_cout_patient_shs.section2_texte AS ghs_section2_texte,
t_ghs_cout_patient_shs.section3_id AS ghs_section3_id,
t_ghs_cout_patient_shs.section3_code AS ghs_section3_code,
t_ghs_cout_patient_shs.section3_texte AS ghs_section3_texte,
t_ghs_cout_patient_shs.section6_id AS ghs_section6_id,
t_ghs_cout_patient_shs.section6_code AS ghs_section6_code,
t_ghs_cout_patient_shs.section6_texte AS ghs_section6_texte,
t_ghs_cout_patient_shs.section7_id AS ghs_section7_id,
t_ghs_cout_patient_shs.section7_code AS ghs_section7_code,
t_ghs_cout_patient_shs.section7_texte AS ghs_section7_texte,
t_ghs_cout_patient_shs.section8_id AS ghs_section8_id,
t_ghs_cout_patient_shs.section8_code AS ghs_section8_code,
t_ghs_cout_patient_shs.section8_texte AS ghs_section8_texte,
t_ghs_cout_patient_shs.section9_id AS ghs_section9_id,
t_ghs_cout_patient_shs.section9_code AS ghs_section9_code,
t_ghs_cout_patient_shs.section9_texte AS ghs_section9_texte,
p_couts_patient_shs.element_cout_id,
t_elements_cout_patient_shs.code_original AS element_cout_code_original,
t_elements_cout_patient_shs.code AS element_cout_code,
t_elements_cout_patient_shs.texte_court AS element_cout_texte,
t_elements_cout_patient_shs.section1_id AS element_cout_section1_id,
t_elements_cout_patient_shs.section1_code AS element_cout_section1_code,
t_elements_cout_patient_shs.section1_texte AS element_cout_section1_texte,
t_elements_cout_patient_shs.section2_id AS element_cout_section2_id,
t_elements_cout_patient_shs.section2_code AS element_cout_section2_code,
t_elements_cout_patient_shs.section2_texte AS element_cout_section2_texte,
t_elements_cout_patient_shs.section3_id AS element_cout_section3_id,
t_elements_cout_patient_shs.section3_code AS element_cout_section3_code,
t_elements_cout_patient_shs.section3_texte AS element_cout_section3_texte,
p_couts_patient_shs.unite_oeuvre_id,
t_unites_oeuvre_shs.code_original AS unite_oeuvre_code_original,
t_unites_oeuvre_shs.code AS unite_oeuvre_code,
t_unites_oeuvre_shs.texte_court AS unite_oeuvre_texte,
t_unites_oeuvre_shs.section1_id AS unite_oeuvre_section1_id,
t_unites_oeuvre_shs.section1_code AS unite_oeuvre_section1_code,
t_unites_oeuvre_shs.section1_texte AS unite_oeuvre_section1_texte,
t_unites_oeuvre_shs.section2_id AS unite_oeuvre_section2_id,
t_unites_oeuvre_shs.section2_code AS unite_oeuvre_section2_code,
t_unites_oeuvre_shs.section2_texte AS unite_oeuvre_section2_texte,
t_unites_oeuvre_shs.section3_id AS unite_oeuvre_section3_id,
t_unites_oeuvre_shs.section3_code AS unite_oeuvre_section3_code,
t_unites_oeuvre_shs.section3_texte AS unite_oeuvre_section3_texte,
p_couts_patient_shs.quantite_consommee,
p_couts_patient_shs.prix_unitaire,
p_couts_patient_shs.cout,
p_couts_patient_shs.montant_facture,
p_couts_patient_shs.ghm_id,
t_ghm_cout_patient_shs.code AS ghm_code,
t_ghm_cout_patient_shs.texte_court AS ghm_texte,
t_ghm_cout_patient_shs.section1_id AS ghm_section1_id,
t_ghm_cout_patient_shs.section1_code AS ghm_section1_code,
t_ghm_cout_patient_shs.section1_texte AS ghm_section1_texte,
t_ghm_cout_patient_shs.section2_id AS ghm_section2_id,
t_ghm_cout_patient_shs.section2_code AS ghm_section2_code,
t_ghm_cout_patient_shs.section2_texte AS ghm_section2_texte,
t_ghm_cout_patient_shs.section3_id AS ghm_section3_id,
t_ghm_cout_patient_shs.section3_code AS ghm_section3_code,
t_ghm_cout_patient_shs.section3_texte AS ghm_section3_texte,
t_ghm_cout_patient_shs.section6_id AS ghm_section6_id,
t_ghm_cout_patient_shs.section6_code AS ghm_section6_code,
t_ghm_cout_patient_shs.section6_texte AS ghm_section6_texte,
t_ghm_cout_patient_shs.section7_id AS ghm_section7_id,
t_ghm_cout_patient_shs.section7_code AS ghm_section7_code,
t_ghm_cout_patient_shs.section7_texte AS ghm_section7_texte,
t_ghm_cout_patient_shs.section8_id AS ghm_section8_id,
t_ghm_cout_patient_shs.section8_code AS ghm_section8_code,
t_ghm_cout_patient_shs.section8_texte AS ghm_section8_texte,
t_ghm_cout_patient_shs.section9_id AS ghm_section9_id,
t_ghm_cout_patient_shs.section9_code AS ghm_section9_code,
t_ghm_cout_patient_shs.section9_texte AS ghm_section9_texte,
t_ghm_cout_patient_shs.severite_id AS ghm_severite_id,
t_ghm_cout_patient_shs.severite_code AS ghm_severite_code,
t_ghm_cout_patient_shs.severite_texte AS ghm_severite_texte,
t_ghm_cout_patient_shs.ghm5_id,
t_ghm_cout_patient_shs.ghm5_code,
t_ghm_cout_patient_shs.ghm5_texte,
t_ghm_cout_patient_shs.pole_oap_id,
t_ghm_cout_patient_shs.pole_oap_code,
t_ghm_cout_patient_shs.pole_oap_texte,
t_ghm_cout_patient_shs.ligne_oap_id,
t_ghm_cout_patient_shs.ligne_oap_code,
t_ghm_cout_patient_shs.ligne_oap_texte,
t_lieux_cout_patient_shs.service_facturation_section_id,
t_lieux_cout_patient_shs.service_facturation_section_code,
t_lieux_cout_patient_shs.service_facturation_section_texte,
t_lieux_cout_patient_shs.activite_section_id,
t_lieux_cout_patient_shs.activite_section_code,
t_lieux_cout_patient_shs.activite_section_texte,
t_lieux_cout_patient_shs.etage_section_id,
t_lieux_cout_patient_shs.etage_section_code,
t_lieux_cout_patient_shs.etage_section_texte,
t_lieux_cout_patient_shs.lit_section_id,
t_lieux_cout_patient_shs.lit_section_code,
t_lieux_cout_patient_shs.lit_section_texte,
t_medecins_cout_patient_shs.section_id AS medecin_administratif_section_id,
t_medecins_cout_patient_shs.section_code AS medecin_administratif_section_code,
t_medecins_cout_patient_shs.section_texte AS medecin_administratif_section_texte,
t_ghs_cout_patient_shs.section_id AS ghs_section_id,
t_ghs_cout_patient_shs.section_code AS ghs_section_code,
t_ghs_cout_patient_shs.section_texte AS ghs_section_texte,
t_elements_cout_patient_shs.section_id AS element_cout_section_id,
t_elements_cout_patient_shs.section_code AS element_cout_section_code,
t_elements_cout_patient_shs.section_texte AS element_cout_section_texte,
t_unites_oeuvre_shs.section_id AS unite_oeuvre_section_id,
t_unites_oeuvre_shs.section_code AS unite_oeuvre_section_code,
t_unites_oeuvre_shs.section_texte AS unite_oeuvre_section_texte,
t_ghm_cout_patient_shs.section_id AS ghm_section_id,
t_ghm_cout_patient_shs.section_code AS ghm_section_code,
t_ghm_cout_patient_shs.section_texte AS ghm_section_texte
FROM compta.p_couts_patient_shs
JOIN compta.t_lieux_cout_patient_shs ON p_couts_patient_shs.lieu_id = t_lieux_cout_patient_shs.oid
JOIN compta.t_medecins_cout_patient_shs ON p_couts_patient_shs.medecin_administratif_id = t_medecins_cout_patient_shs.oid
JOIN compta.t_elements_cout_patient_shs ON p_couts_patient_shs.element_cout_id = t_elements_cout_patient_shs.oid
JOIN compta.t_unites_oeuvre_shs ON p_couts_patient_shs.unite_oeuvre_id = t_unites_oeuvre_shs.oid
JOIN compta.t_ghm_cout_patient_shs ON p_couts_patient_shs.ghm_id = t_ghm_cout_patient_shs.oid
JOIN compta.t_ghs_cout_patient_shs ON p_couts_patient_shs.ghs_id = t_ghs_cout_patient_shs.oid;