src: |
  SELECT p_rss_ucd.rss_id,
      p_rss_ucd.finess,
      p_rss_ucd.no_rss,
      p_rss_ucd.rang,
      p_rss_ucd.date_ucd,
      p_rss_ucd.ucd_id,
      t_ucd.code AS ucd_code,
      t_ucd.texte_court::text ||
          CASE
              WHEN t_ucd.conditionnement_texte::text <> ''::text THEN (' ('::text || t_ucd.conditionnement_texte::text) || ')'::text
              ELSE ''::text
          END AS ucd_texte,
      t_ucd.section_id AS ucd_section_id,
      t_ucd.section_code AS ucd_section_code,
      t_ucd.section_texte AS ucd_section_texte,
      t_ucd.laboratoire_texte,
      t_ucd.conditionnement_texte,
      t_ucd.atc_code,
      t_ucd.atc_texte,
      t_ucd.ephmra_code,
      t_ucd.ephmra_texte,
      p_rss_ucd.nombre,
      p_rss_ucd.prix_unitaire_achat,
      p_rss_ucd.coefficient_fractionnement,
          CASE
              WHEN (p_rss_ucd.nombre * p_rss_ucd.coefficient_fractionnement) <> 0::numeric THEN p_rss_ucd.montant_facture / p_rss_ucd.nombre / p_rss_ucd.coefficient_fractionnement
              WHEN p_rss_ucd.nombre <> 0::numeric THEN p_rss_ucd.montant_facture / p_rss_ucd.nombre
              ELSE 0::numeric
          END AS prix_unitaire,
      p_rss_ucd.montant_facture,
      p_rss_ucd.montant_ecart_indemnisable,
      p_rss_ucd.prix_unitaire_tr,
      p_rss_ucd.montant_tr,
      p_rss_ucd.montant_t2a_accorde,
      p_rss_ucd.non_pris_en_compte,
      t_type_ucd.oid AS type_ucd_id,
      t_type_ucd.code AS type_ucd_code,
      t_type_ucd.texte AS type_ucd_texte,
      t_indication.oid AS indication_id,
      t_indication.code AS indication_code,
      t_indication.texte AS indication_texte,
      p_rss_ucd.from_eco,
      p_rss_ucd.montant_consommation,
      t_indication.section_id AS iucd_section_id,
      t_indication.section_code AS iucd_section_code,
      t_indication.section_texte AS iucd_section_texte
     FROM pmsi.p_rss_ucd
       JOIN pmsi.t_ucd ON p_rss_ucd.ucd_id = t_ucd.oid
       JOIN pmsi.t_type_ucd ON t_type_ucd.oid = p_rss_ucd.type_ucd_id
       JOIN pmsi.t_indication ON t_indication.oid = p_rss_ucd.indication_id;