$context = null;
if ($context_guid) {
    $context = CMbObject::loadFromGuid($context_guid);
}
/** @var CGroups|CService|CRPU $host */
// On cherche le meilleur "herbegement" des constantes, pour charger les configuration adequat
if ($host_guid) {
    $host = CMbObject::loadFromGuid($host_guid);
} else {
    $host = CConstantesMedicales::guessHost($context);
}
$show_cat_tabs = CConstantesMedicales::getHostConfig("show_cat_tabs", $host);
$show_enable_all_button = CConstantesMedicales::getHostConfig("show_enable_all_button", $host);
$dates = array();
if (!$selection) {
    $selection = CConstantesMedicales::getConstantsByRank('form', true, $host);
} else {
    $selection = CConstantesMedicales::selectConstants($selection, 'form');
}
foreach (CConstantesMedicales::$list_constantes as $key => $cst) {
    $dates["{$key}"] = CMbDT::format(null, '%d/%m/%y');
}
$patient_id = $constantes->patient_id ? $constantes->patient_id : $patient_id;
$patient = CPatient::loadFromGuid("CPatient-{$patient_id}");
$patient->loadRefLatestConstantes(null, array("poids", "taille"), null, false);
$constantes = new CConstantesMedicales();
$constantes->load($const_id);
$constantes->loadRefContext();
$constantes->loadRefPatient();
$constantes->updateFormFields();
// Pour forcer le chargement des unités lors de la saisie d'une nouvelle constante
 *
 * @package    Mediboard
 * @subpackage dPpatients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CSessionHandler::writeClose();
$const = new CConstantesMedicales();
$perms = $const->canDo();
if (!$perms->read) {
    $perms->redirect();
}
$context_guid = CValue::get('context_guid');
$context = CStoredObject::loadFromGuid($context_guid);
$ranks = CConstantesMedicales::getConstantsByRank('graph', false, CConstantesMedicales::guessHost($context));
$list_cste = array();
$list_cumul = array();
$cste_nb = 0;
$cumul_nb = 0;
if (array_key_exists(1, $ranks['all'])) {
    /* We only display constants with rank 1 */
    foreach ($ranks['all'][1] as $_cste) {
        if (substr($_cste, 0, 1) === "_") {
            continue;
        }
        /* We display at most 4 graph with cumuled constants */
        if (isset(CConstantesMedicales::$list_constantes[$_cste]['cumul_reset_config'])) {
            if ($cumul_nb < 4) {
                $list_cumul[] = $_cste;
                $cumul_nb++;
示例#3
0
 /**
  * Sort the constants by rank, and create a structure for dividing the constants in graphs
  *
  * @param CConstantesMedicales[] $constants The CConstantesMedicales objects who contain the values for the constants
  *
  * @return array
  */
 function sortConstantsbyGraph($constants)
 {
     $constants_list = array();
     $constants_by_graph = array();
     $constants_by_rank = CConstantesMedicales::getConstantsByRank('graph', false, $this->host);
     /* The valued constants are sorted by rank */
     foreach (CConstantesMedicales::$list_constantes as $cst_name => $cst_attr) {
         if (substr($cst_name, 0, 1) == '_' && !isset($cst_attr['plot'])) {
             continue;
         }
         foreach ($constants as $cst) {
             if (!is_null($cst->{$cst_name}) && array_search($cst_name, $constants_list) === false) {
                 $rank = CMbArray::searchRecursive($cst_name, $constants_by_rank);
                 if (empty($rank)) {
                     continue;
                 }
                 $rank = array_keys($rank['all']);
                 $rank = $rank[0];
                 if (!array_key_exists($rank, $constants_by_graph)) {
                     $constants_by_graph[$rank] = array();
                 }
                 $constants_by_graph[$rank][] = $cst_name;
                 $constants_list[] = $cst_name;
             }
         }
     }
     /* We remove the constant with the rank 0, sort the array and add the rank 0 at the end of the array */
     $hidden_cst = null;
     if (array_key_exists('hidden', $constants_by_graph)) {
         $hidden_cst = $constants_by_graph['hidden'];
         unset($constants_by_graph['hidden']);
     }
     ksort($constants_by_graph);
     if (!is_null($hidden_cst)) {
         $constants_by_graph['hidden'] = $hidden_cst;
     }
     $stacked_graphs = CConstantesMedicales::getHostConfig('stacked_graphs', $this->host);
     foreach ($constants_by_graph as $_rank => $_constants) {
         $constants_by_graph[$_rank] = array();
         if ($_rank != 'hidden' && $stacked_graphs) {
             $cumuls_constants = array();
             foreach ($_constants as $_key => $_constant) {
                 /* The constants with a cumul can't be stacked with other constants */
                 if (isset(CConstantesMedicales::$list_constantes[$_constant]['cumul_reset_config'])) {
                     unset($_constants[$_key]);
                     $cumuls_constants[] = $_constant;
                 }
             }
             /* The number of constants by graph is limited to 5 */
             if (count($_constants) > 5) {
                 $constants = array();
                 for ($i = 0; $i < count($_constants); $i = $i + 5) {
                     $constants[] = array_slice($_constants, $i, 5);
                 }
                 foreach ($cumuls_constants as $_key => $_cumul) {
                     $cumuls_constants[$_key] = array($_cumul);
                 }
                 $constants_by_graph[$_rank] = array_merge($constants, $cumuls_constants);
             } else {
                 if (!empty($_constants)) {
                     $constants_by_graph[$_rank][] = $_constants;
                 }
                 foreach ($cumuls_constants as $_cumul) {
                     $constants_by_graph[$_rank][] = array($_cumul);
                 }
             }
         } else {
             /* The constants with a rank of 0 can't be stacked */
             foreach ($_constants as $_constant) {
                 $constants_by_graph[$_rank][] = array($_constant);
             }
         }
     }
     $this->structure = $constants_by_graph;
 }
}
$current_context = null;
if ($context_guid) {
    $current_context = CMbObject::loadFromGuid($context_guid);
}
$custom_selection = $selection ? $selection : array();
/** @var CGroups|CService|CRPU $host */
// On cherche le meilleur "hebergement" des constantes, pour charger les configurations adequat
if ($host_guid) {
    $host = CMbObject::loadFromGuid($host_guid);
} else {
    $host = CConstantesMedicales::guessHost($current_context);
}
$show_cat_tabs = CConstantesMedicales::getHostConfig("show_cat_tabs", $host);
if (!$selection || $selected_context_guid === 'all') {
    $selection = CConstantesMedicales::getConstantsByRank('form', $show_cat_tabs, $host);
} else {
    $selection = CConstantesMedicales::selectConstants($selection, 'form', $host);
}
// If print mode, no need to include hidden graphs
if ($print) {
    $selection["all"]["hidden"] = array();
}
$old_constants_to_draw = $print == 1 ? $selection : CConstantesMedicales::$list_constantes;
$show_enable_all_button = CConstantesMedicales::getHostConfig("show_enable_all_button", $host);
$constants_to_draw = $selection;
/** @var CMbObject|CPatient|CSejour $context */
if ($selected_context_guid !== 'all') {
    $context = CMbObject::loadFromGuid($selected_context_guid);
} else {
    $context = CMbObject::loadFromGuid($context_guid);
        $where['context_id'] = " = {$context->_id}";
    }
}
$where['patient_id'] = " = {$patient->_id}";
$limit = "0, {$nb_input_display}";
$constantes = new CConstantesMedicales();
$constantes->patient_id = $patient->_id;
$constantes->loadRefPatient();
$constantes->updateFormFields();
if ($context) {
    $constantes->context_id = $context->_id;
    $constantes->context_class = $context->_class;
    $constantes->loadRefContext();
}
if (empty($selection) || is_null($host)) {
    $constants_ranks = CConstantesMedicales::getConstantsByRank('form', false, $host);
} else {
    $constants_ranks = CConstantesMedicales::selectConstants($selection, 'form', $host);
}
$list_constantes = $constantes->loadList($where, 'datetime DESC', $limit);
$smarty = new CSmartyDP();
$smarty->assign('patient_id', $patient_id);
$smarty->assign('constantes', $constantes);
$smarty->assign('latest_constantes', $latest_constantes);
$smarty->assign('list_constantes', $list_constantes);
$smarty->assign('context', $context);
$smarty->assign('context_guid', $context_guid);
$smarty->assign('constants_ranks', $constants_ranks);
$smarty->assign('selection', $selection);
$smarty->assign('display_search_field', $display_search_field);
$smarty->display('inc_constantes_table_mode.tpl');