*
 * @package    Mediboard
 * @subpackage soins
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 * @link       http://www.mediboard.org
 */
$patient_id = CValue::get('patient_id', 0);
$sejour_id = CValue::get('sejour_id');
$patient = new CPatient();
$patient->load($patient_id);
$sejour = new CSejour();
$sejour->load($sejour_id);
if ($patient->_id) {
    $constantes = $patient->loadRefLatestConstantes(null, array('poids', 'taille'));
    $poids = '&mdash;';
    $taille = '&mdash;';
    $imc = '&mdash;';
    $unit_poids = CConstantesMedicales::$list_constantes['poids']['unit'];
    $unit_taille = CConstantesMedicales::$list_constantes['taille']['unit'];
    if ($constantes[0]->poids) {
        $date = CMbDT::format($constantes[1]['poids'], CAppUI::conf('datetime'));
        $poids = "<span title='{$date}'>{$constantes[0]->poids} {$unit_poids}</span>";
        if ($sejour && $sejour->_id) {
            if ($constantes[1]['poids'] < $sejour->entree || $constantes[1]['poids'] > $sejour->sortie) {
                // Weight outdated
                $msg = utf8_encode(CAppUI::tr('CPatient-msg-Entry is outdated'));
                $date = CMbDT::format($constantes[1]['poids'], CAppUI::conf('datetime'));
                $poids = "<span title='{$msg} : {$date}' style='color: firebrick;'><strong>{$constantes[0]->poids} {$unit_poids}</strong></span>";
            }
 * $Id$
 *  
 * @category Cabinet
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$consult_id = CValue::get("consult_id");
$patient_id = CValue::get("patient_id");
$consult_anesth = new CConsultAnesth();
$consult_anesth->load($consult_id);
$patient = new CPatient();
$patient->load($patient_id);
$constantes = reset($patient->loadRefLatestConstantes(null, array("poids", "taille")));
$auto_55 = false;
$auto_imc26 = false;
if ($patient->_annees) {
    $consult_anesth->plus_de_55_ans = $patient->_annees > 55 ? 1 : 0;
    $auto_55 = 1;
}
if ($constantes->_imc) {
    $consult_anesth->imc_sup_26 = $constantes->_imc > 26 ? 1 : 0;
    $auto_imc26 = 1;
}
$smarty = new CSmartyDP();
$smarty->assign("consult_anesth", $consult_anesth);
$smarty->assign("plus_de_55_ans", $auto_55);
$smarty->assign("imc_sup_26", $auto_imc26);
$smarty->display("inc_guess_ventilation.tpl");
            $where[] = implode(" OR ", $whereOr);
        } else {
            $where["context_class"] = " = '{$context->_class}'";
            $where["context_id"] = " = '{$context->_id}'";
        }
    } else {
        $where["context_class"] = " = '{$context->_class}'";
        $where["context_id"] = " = '{$context->_id}'";
    }
    // Needed to know if we are in the right context
    $constantes->context_class = $context->_class;
    $constantes->context_id = $context->_id;
    $constantes->loadRefContext();
}
//CConstantesMedicales::$_latest_values = array();
$latest_constantes = $patient->loadRefLatestConstantes(CMbDT::dateTime(), array(), $context, false);
// On récupère dans tous les cas le poids et la taille du patient
$patient->loadRefLatestConstantes(null, array("poids", "taille"), null, false);
$constantes->updateFormFields();
// Pour forcer le chargement des unités lors de la saisie d'une nouvelle constante
$whereOr = array();
foreach ($constants_to_draw as $_cat => $_ranks) {
    foreach ($_ranks as $rank => $_constants) {
        foreach ($_constants as $name) {
            if ($name[0] === "_") {
                continue;
            }
            $whereOr[] = "{$name} IS NOT NULL ";
        }
    }
}