/** * Return the selected constants in an formatted array (see getConstantsByRank to see the format) * * @param array $selection The constant you want to select * @param string $type 'form' or 'graph' * @param CMbObject|string $host Host from which we'll get the configuration * * @return array */ static function selectConstants($selection, $type = 'form', $host = null) { if ($host) { $show_cat_tabs = CConstantesMedicales::getHostConfig("show_cat_tabs", $host); } else { $show_cat_tabs = CConstantesMedicales::getConfig("show_cat_tabs"); } $constants_by_rank = self::getRanksFor($type, $host); $list_constants = CConstantesMedicales::$list_constantes; // Keep only valid constant names $constants_by_rank = array_intersect_key($constants_by_rank, $list_constants); $constants_by_rank = CMbArray::flip($constants_by_rank); ksort($constants_by_rank); $result = array(); foreach ($constants_by_rank as $_rank => $_constants) { if ($_rank === -1) { continue; } foreach ($_constants as $_constant) { if (strpos($_constant, "_") === 0) { continue; } if ($show_cat_tabs) { $_type = $list_constants[$_constant]["type"]; if (!array_key_exists($_type, $result)) { $result[$_type] = array(); } if (!in_array($_constant, $selection)) { $rank = -1; } else { $rank = $_rank; } if (!array_key_exists($rank, $result[$_type])) { $result[$_type][$rank] = array(); } $result[$_type][$rank][] = $_constant; } else { if (!array_key_exists('all', $result)) { $result['all'] = array(); } if (!in_array($_constant, $selection)) { $rank = -1; } else { $rank = $_rank; } if (!array_key_exists($rank, $result['all'])) { $result['all'][$rank] = array(); } $result['all'][$rank][] = $_constant; } } } foreach ($result as $_type => $_ranks) { if (array_key_exists(-1, $result[$_type])) { $unselected_constants = $result[$_type][-1]; unset($result[$_type][-1]); $result[$_type]["hidden"] = $unselected_constants; } if (array_key_exists(-1, $result[$_type])) { unset($result[$_type][-1]); } } return $result; }
$host_guid = CValue::get('host_guid'); $display_graph = CValue::get('display_graph', 1); $unique_id = CValue::get('unique_id', ''); $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();
/** * Return the graphs display mode config * * @param CMbObject|string $host Host from which we'll get the configuration * * @return array */ static function getDisplayMode($host = null) { if ($host) { $config = CConstantesMedicales::getHostConfig('graphs_display_mode', $host); } else { $config = CConstantesMedicales::getConfig('graphs_display_mode'); } $config = explode('|', $config); return array('mode' => $config[0], 'time' => $config[1]); }