Пример #1
0
 /**
  * Charge les actes Tarmed codés
  *
  * @param int  $num_facture numéro de la facture concernée
  * @param bool $show_alerte chargement des alertes
  *
  * @return array
  */
 function loadRefsActesTarmed($num_facture = null, $show_alerte = false)
 {
     $this->_ref_actes_tarmed = array();
     $totaux = array("base" => 0, "dh" => 0);
     if (CModule::getActive("tarmed") && CAppUI::conf("tarmed CCodeTarmed use_cotation_tarmed")) {
         $where = array();
         $ljoin = array();
         $order = null;
         $acte_tarmed = new CActeTarmed();
         //Dans le cas d'une consultation
         if ($this->_class == "CConsultation") {
             //Classement des actes par ordre chonologique et par code
             $ljoin["consultation"] = "acte_tarmed.object_id = consultation.consultation_id";
             $ljoin["plageconsult"] = "plageconsult.plageconsult_id = consultation.plageconsult_id";
             $where["acte_tarmed.object_class"] = " = '{$this->_class}'";
             $where["acte_tarmed.object_id"] = " = '{$this->_id}'";
             if ($num_facture) {
                 $where["acte_tarmed.num_facture"] = " = '{$num_facture}'";
             }
             //Dans le cas ou la date est nulle on prend celle de la plage de consultation correspondante
             $order = "IFNULL(acte_tarmed.date, plageconsult.date), acte_tarmed.num_facture, code ASC";
             $this->_ref_actes_tarmed = $acte_tarmed->loadList($where, $order, null, null, $ljoin);
         } else {
             //Dans les cas d'un séjour ou d'une intervention
             $where["object_class"] = " = '{$this->_class}'";
             $where["object_id"] = " = '{$this->_id}'";
             if ($num_facture) {
                 $where["num_facture"] = " = '{$num_facture}'";
             }
             $order = "acte_tarmed.num_facture, code ASC";
             $this->_ref_actes_tarmed = $acte_tarmed->loadList($where, $order);
         }
         if (null === $this->_ref_actes_tarmed) {
             return null;
         }
         $this->_codes_tarmed = array();
         foreach ($this->_ref_actes_tarmed as $_acte_tarmed) {
             /** @var CActeTarmed $_acte_tarmed */
             $this->_codes_tarmed[] = $_acte_tarmed->makeFullCode();
             $_acte_tarmed->loadRefExecutant();
             $_acte_tarmed->loadRefTarmed();
             if ($show_alerte) {
                 $_acte_tarmed->loadAlertes();
             }
             $totaux["base"] += $_acte_tarmed->montant_base * $_acte_tarmed->quantite;
             $totaux["dh"] += $_acte_tarmed->montant_depassement;
         }
         $this->_tokens_tarmed = implode("|", $this->_codes_tarmed);
     }
     return $totaux;
 }