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.prix_unitaire, p_rsf_detail.base_remboursement, p_rsf_detail.taux_remboursement, 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.sejour_remboursable, 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.sejour_remboursable_2, p_rsf_detail.ghs_id, 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, 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 FROM pmsi.p_rsf_detail JOIN pmsi.t_prestations ON t_prestations.oid = p_rsf_detail.prestation_id JOIN base.t_pec_fj ON t_pec_fj.oid = p_rsf_detail.pec_fj_id WHERE p_rsf_detail.type = 'B'::bpchar AND p_rsf_detail.est_ligne_rss = '1'::bpchar;