src: | SELECT p_rsf_detail.rss_id, p_rsf_detail.finess, p_rsf_detail.no_rss, p_rsf_detail.nature, p_rsf_detail.mt, p_rsf_detail.dmt, p_rsf_detail.date_debut, p_rsf_detail.date_fin, p_rsf_detail.nombre, p_rsf_detail.coefficient, p_rsf_detail.nombre * p_rsf_detail.coefficient AS nombre_coefficient, p_rsf_detail.prix_unitaire, p_rsf_detail.taux_remboursement, p_rsf_detail.base_remboursement, round((p_rsf_detail.prix_unitaire * p_rsf_detail.nombre * p_rsf_detail.coefficient + COALESCE(p_rsf_detail.montant_supplement_nf, 0::numeric)) * p_rsf_detail.coefficient_geo * p_rsf_detail.coefficient_pacte_resp, 2) AS base_remboursement_sauf_transition, p_rsf_detail.sejour_remboursable, (p_rsf_detail.prix_unitaire * p_rsf_detail.nombre * p_rsf_detail.coefficient + COALESCE(p_rsf_detail.montant_supplement_nf, 0::numeric)) * p_rsf_detail.coefficient_mco AS base_remboursement_sans_arrondi, (p_rsf_detail.prix_unitaire * p_rsf_detail.nombre * p_rsf_detail.coefficient + COALESCE(p_rsf_detail.montant_supplement_nf, 0::numeric)) * p_rsf_detail.coefficient_geo * p_rsf_detail.coefficient_pacte_resp AS base_remboursement_sauf_transition_sans_arrondi, (p_rsf_detail.prix_unitaire * p_rsf_detail.nombre * p_rsf_detail.coefficient + COALESCE(p_rsf_detail.montant_supplement_nf, 0::numeric)) * p_rsf_detail.coefficient_mco * p_rsf_detail.taux_remboursement / 100::numeric AS sejour_remboursable_sans_arrondi, p_rsf_detail.sejour_facture, CASE WHEN t_prestations.compteur_rsf::text = '1'::text OR p_rsf_detail.ligne_t2a = '1'::bpchar THEN p_rsf_detail.sejour_facture ELSE 0::numeric END AS t2a_facture, CASE WHEN t_prestations.compteur_rsf::text = '3'::text THEN p_rsf_detail.sejour_facture ELSE 0::numeric END AS dmi_facture, CASE WHEN t_prestations.compteur_rsf::text = '7'::text THEN p_rsf_detail.sejour_facture ELSE 0::numeric END AS phc_facture, p_rsf_detail.compteur, p_rsf_detail.ligne_t2a, p_rsf_detail.pec_fj, p_rsf_detail.pec_fj_id, t_pec_fj.code AS pec_fj_code, t_pec_fj.texte AS pec_fj_texte, p_rsf_detail.coefficient_mco, p_rsf_detail.coefficient_geo, p_rsf_detail.sejour_remboursable_2, p_rsf_detail.ghs_id, t_ghs.code_text AS ghs_code, t_ghs.texte AS ghs_texte, p_rsf_detail.sejour_rembourse_noemie, p_rsf_detail.nature_noemie, p_rsf_detail.prestation_id, t_prestations.code AS prestation_code, t_prestations.texte_court AS prestation_texte, t_prestations.section_id AS prestation_section_id, t_prestations.section_code AS prestation_section_code, t_prestations.section_texte AS prestation_section_texte, CASE WHEN t_prestations.code::text = 'GHS'::text AND p_rsf_detail.coefficient < 1::numeric THEN 'EXB'::text WHEN t_prestations.code::text = 'EXH'::text THEN 'EXH'::text ELSE ''::text END AS prestation_exb_exh, CASE WHEN p_rsf_detail.base_remboursement_sauf_transition_sauf_ame <> 0::numeric THEN p_rsf_detail.base_remboursement_sauf_transition_sauf_ame ELSE round(p_rsf_detail.prix_unitaire * p_rsf_detail.nombre * p_rsf_detail.coefficient, 2) END AS base_remboursement_sauf_transition_sauf_ame FROM pmsi.p_rsf_detail JOIN pmsi.t_prestations ON t_prestations.oid = p_rsf_detail.prestation_id JOIN pmsi.t_ghs ON t_ghs.oid = p_rsf_detail.ghs_id JOIN base.t_pec_fj ON t_pec_fj.oid = p_rsf_detail.pec_fj_id WHERE p_rsf_detail.type = 'C'::bpchar AND p_rsf_detail.est_ligne_rss = '1'::bpchar;