/**
  * @see parent::updateFormFields()
  */
 function updateFormFields()
 {
     static $unite_config = array();
     parent::updateFormFields();
     $this->loadRefPatient();
     $this->getIMC();
     // Calcul du poids en grammes
     if ($this->poids) {
         $this->_poids_g = $this->poids * 1000;
     }
     // Afficher le champ diurèse dans le formulaire si une des valeurs n'est pas vide
     // FIXME Utiliser "cumul_in"
     foreach (self::$list_constantes["_diurese"]["formula"] as $_field => $_sign) {
         if ($this->{$_field} && $this->_diurese == null) {
             $this->_diurese = " ";
             break;
         }
     }
     // Afficher le champ urine effective dans le formulaire si une des valeurs n'est pas vide
     foreach (self::$list_constantes["_urine_effective"]["formula"] as $_field => $_sign) {
         if ($this->{$_field} && $this->_urine_effective == null) {
             $this->_urine_effective = " ";
             break;
         }
     }
     // Détermination valeur IMC
     if ($this->poids && $this->taille) {
         $seuils = $this->_ref_patient->sexe != 'm' ? array(19, 24) : array(20, 25);
         if ($this->_imc < $seuils[0]) {
             $this->_imc_valeur = 'Maigreur';
         } elseif ($this->_imc > $seuils[1] && $this->_imc <= 30) {
             $this->_imc_valeur = 'Surpoids';
         } elseif ($this->_imc > 30 && $this->_imc <= 40) {
             $this->_imc_valeur = 'Obésité';
         } elseif ($this->_imc > 40) {
             $this->_imc_valeur = 'Obésité morbide';
         }
     }
     // Calcul du poids ideal
     if ($this->taille) {
         $factor = 4;
         if ($this->_ref_patient->sexe == 'f') {
             $factor = 2;
         }
         $this->_poids_ideal = $this->taille - 100 - ($this->taille - 150) / $factor;
     }
     // Calcul du Volume Sanguin Total
     if ($this->poids) {
         $this->_vst = ($this->_ref_patient->sexe != 'm' ? 65 : 70) * $this->poids;
     }
     // Calcul de la Tension Artérielle Moyenne
     if ($this->ta) {
         list($_ta_systole, $_ta_diastole) = explode('|', $this->ta);
         $this->_tam = round(($_ta_systole + 2 * $_ta_diastole) / 3, 2);
     }
     if (empty($unite_config)) {
         $group = CGroups::loadCurrent();
         $unite_config["unite_ta"] = CAppUI::conf('dPpatients CConstantesMedicales unite_ta', $group);
         $unite_config["unite_glycemie"] = CAppUI::conf('dPpatients CConstantesMedicales unite_glycemie', $group);
         $unite_config["unite_cetonemie"] = CAppUI::conf('dPpatients CConstantesMedicales unite_cetonemie', $group);
         $unite_config["unite_hemoglobine"] = CAppUI::conf('dPpatients CConstantesMedicales unite_hemoglobine', $group);
     }
     $this->_unite_ta = $unite_config["unite_ta"];
     $this->_unite_glycemie = $unite_config["unite_glycemie"];
     $this->_unite_cetonemie = $unite_config["unite_cetonemie"];
     $this->_unite_hemoglobine = $unite_config["unite_hemoglobine"];
     foreach (self::$list_constantes as $_constant => &$_params) {
         // Conversion des unités
         if (isset($_params["unit_config"]) && !self::$unit_conversion) {
             $_unit_config = '_' . $_params["unit_config"];
             $unit = $this->{$_unit_config};
             $_params_ref =& CConstantesMedicales::$list_constantes[$_constant];
             //$_params_ref["orig_unit"] = $_params_ref["unit"];
             if ($unit != $_params_ref["orig_unit"]) {
                 $conv = $_params["conversion"][$unit];
                 $_params_ref["unit"] = $unit;
                 $_params_ref["min"] *= $conv;
                 $_params_ref["max"] *= $conv;
                 if (isset($_params_ref["norm_min"])) {
                     $_params_ref["norm_min"] *= $conv;
                 }
                 if (isset($_params_ref["norm_max"])) {
                     $_params_ref["norm_max"] *= $conv;
                 }
             }
         }
         if ($this->{$_constant} === null || $this->{$_constant} === "") {
             continue;
         }
         if (isset($_params["formfields"])) {
             $conv = 1.0;
             if (isset($_params["unit_config"])) {
                 $form_field_unite = '_' . $_params["unit_config"];
                 $conv = self::getConv($_constant, $this->{$form_field_unite});
             }
             $_parts = explode("|", $this->{$_constant});
             foreach ($_params["formfields"] as $_i => $_formfield) {
                 $this->{$_formfield} = $_parts[$_i];
                 if ($conv != 1.0) {
                     $this->{$_formfield} = round($this->{$_formfield} * $conv, self::CONV_ROUND_DOWN);
                 }
             }
         }
     }
     /* Permet d'éviter que les conversions des min et max soit effectuée plusieurs fois */
     self::$unit_conversion = true;
     // Calcul de l'ECPA total
     $this->_ecpa_total = null;
     if ($this->ecpa_avant !== null) {
         $this->_ecpa_total += $this->ecpa_avant;
     }
     if ($this->ecpa_apres !== null) {
         $this->_ecpa_total += $this->ecpa_apres;
     }
 }