/** * Get a unique order number * * @return string */ private function getUniqueNumber() { $format = CAppUI::conf('dPstock CProductOrder order_number_format'); if (strpos($format, '%id') === false) { $format .= '%id'; } $format = str_replace('%id', str_pad($this->_id ? $this->_id : 0, 4, '0', STR_PAD_LEFT), $format); return CMbDT::format(null, $format); }
/** * constructor * * @param string $date current date in the planning * @param null $date_min min date of the planning * @param null $date_max max * @param bool $selectable is the planning selectable * @param string $height [optional] height of the planning, default : auto * @param bool $large [optional] is the planning a large one * @param bool $adapt_range [optional] can the planning adapt the range */ function __construct($date, $date_min = null, $date_max = null, $selectable = false, $height = "auto", $large = false, $adapt_range = false) { parent::__construct($date); $this->today = CMbDT::date(); $this->type = "month"; $this->selectable = $selectable; $this->height = $height ? $height : "auto"; $this->large = $large; $this->adapt_range = $adapt_range; $this->no_dates = true; if (is_int($date) || is_int($date_min) || is_int($date_max)) { $this->no_dates = true; $this->date_min = $this->date_min_active = $this->_date_min_planning = $date_min; $this->date_max = $this->date_max_active = $this->_date_max_planning = $date_max; $this->nb_days = CMbDT::transform(null, $this->date_max, "%d") - CMbDT::transform(null, $this->date_min, "%d"); for ($i = 0; $i < $this->nb_days; $i++) { $this->days[$i] = array(); $this->load_data[$i] = array(); } } else { $this->date_min = $this->date_min_active = $this->_date_min_planning = CMbDT::date("first day of this month", $date); $this->date_max = $this->date_max_active = $this->_date_max_planning = CMbDT::date("last day of this month", $this->date_min); // add the last days of previous month $min_day_number = CMbDT::format($this->date_min, "%w"); $this->first_day_of_first_week = $first_day = CMbDT::date("this week", $min_day_number == 0 ? CMbDT::date("-1 DAY", $this->date_min) : $this->date_min); while ($first_day != $this->date_min) { $this->days[$first_day] = array(); $first_day = CMbDT::date("+1 DAY", $first_day); } $this->nb_days = CMbDT::transform(null, $this->date_max, "%d"); for ($i = 0; $i < $this->nb_days; $i++) { $_day = CMbDT::date("+{$i} day", $this->date_min); $this->days[$_day] = array(); $this->load_data[$_day] = array(); } //fill the rest of the last week $max_day_number = CMbDT::format($this->date_max, "%w"); if ($max_day_number != 0) { $last_day_of_week = CMbDT::date("this week +6 days", $this->date_max); $last_day_of_month = $this->date_max; while ($last_day_of_month <= $last_day_of_week) { $this->days[$last_day_of_month] = array(); $last_day_of_month = CMbDT::date("+1 DAY", $last_day_of_month); } } $this->classes_for_days = $this->days; } $this->previous_month = CMbDT::date("-1 DAY", $this->date_min); $this->next_month = CMbDT::date("+1 DAY", $this->date_max); $this->_date_min_planning = reset(array_keys($this->days)); $this->_date_max_planning = end(array_keys($this->days)); $this->_hours = array(); }
/** * constructor * * @param string $date date chosen */ public function __construct($date = null) { if (!$date) { $date = CMbDT::date(); } $this->date = $date; $this->number = (int) CMbDT::transform("", $date, "%j"); $dateTmp = explode("-", $date); $this->name = CMbDate::$days_name[(int) $dateTmp[1]][(int) ($dateTmp[2] - 1)]; $this->_nbDaysYear = CMbDT::format($date, "L") ? 366 : 365; $this->days_left = $this->_nbDaysYear - $this->number; //jour férie ? $holidays = CMbDate::getHolidays($this->date); if (array_key_exists($this->date, $holidays)) { $this->ferie = $holidays[$this->date]; } }
/** * Standard constructor * * @param date $date Reference ISO date * @param string $period One of day, week, month, year * @param string $date_column SELECT-like column, might be a expression such as DATE(when) * @param int $nb_periods Number of periods to display */ public function __construct($date, $period, $date_column, $nb_periods = 30) { // Prepare periods switch ($period) { case "day": $php_period = "days"; $sql_date = "{$date_column}"; break; case "week": $date = CMbDT::date("next monday", $date); $php_period = "weeks"; $sql_date = "DATE_ADD({$date_column}, INTERVAL (2 - DAYOFWEEK({$date_column})) DAY)"; break; case "month": $date = CMbDT::date("first day of +0 month", $date); $php_period = "months"; $sql_date = "DATE_ADD({$date_column}, INTERVAL (1 - DAYOFMONTH({$date_column})) DAY)"; break; case "year": $date = CMbDT::format($date, "%Y-01-01"); $php_period = "years"; $sql_date = "DATE_ADD({$date_column}, INTERVAL (1 - DAYOFYEAR({$date_column})) DAY)"; break; default: $php_period = null; $min_date = null; $sql_date = null; break; } // Prepare dates $dates = array(); foreach (range(0, $nb_periods - 1) as $n) { $dates[] = $min_date = CMbDT::date("- {$n} {$php_period}", $date); } $dates = array_reverse($dates); $min_date = reset($dates); $max_date = CMbDT::date("+1 {$this->period} -1 day", end($dates)); // Members $this->date = $date; $this->period = $period; $this->dates = $dates; $this->min_date = $min_date; $this->max_date = $max_date; $this->php_period = $php_period; $this->sql_date = $sql_date; }
/** * Génération d'un pdf à partir d'une source, avec stream au client si demandé * * @param string $content source html * @param boolean $stream envoi du pdf au navigateur * @param CCompteRendu $compte_rendu compte-rendu ciblé * @param CFile $file le CFile pour lequel générer le pdf * * @return string */ function generatePDF($content, $stream, $compte_rendu, $file) { $this->content = $this->fixBlockElements($content); // Remplacement des champs seulement à l'impression $this->content = str_replace("[Général - numéro de page]", "<span class='page'></span>", $this->content); $date_lock = ""; $locker = new CMediusers(); if ($compte_rendu->valide) { $locker = $compte_rendu->loadRefLocker(); $log_lock = $compte_rendu->loadLastLogForField("valide"); $date_lock = $log_lock->date; } $this->content = str_replace("[Meta Données - Date de verrouillage - Date]", $compte_rendu->valide ? CMbDT::format($date_lock, "%d/%m/%Y") : "", $this->content); $this->content = str_replace("[Meta Données - Date de verrouillage - Heure]", $compte_rendu->valide ? CMbDT::format($date_lock, "%Hh%M") : "", $this->content); $this->content = str_replace("[Meta Données - Verrouilleur - Nom]", $locker->_user_last_name, $this->content); $this->content = str_replace("[Meta Données - Verrouilleur - Prénom]", $locker->_user_first_name, $this->content); $this->content = str_replace("[Meta Données - Verrouilleur - Initiales]", $locker->_shortview, $this->content); CHtmlToPDFConverter::$_page_ordonnance = $compte_rendu->_page_ordonnance; $pdf_content = CHtmlToPDFConverter::convert($this->content, $compte_rendu->_page_format, $compte_rendu->_orientation); if ($file->_file_path) { file_put_contents($file->_file_path, $pdf_content); } $this->nbpages = preg_match_all("/\\/Page\\W/", $pdf_content, $matches); if ($stream) { header("Pragma: "); header("Cache-Control: "); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); //HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); // END extra headers to resolve IE caching bug header("MIME-Version: 1.0"); header("Content-length: " . strlen($pdf_content)); header('Content-type: application/pdf'); header("Content-disposition: inline; filename=\"" . $file->file_name . "\""); echo $pdf_content; } return $pdf_content; }
/** * Range constructor * * @param string $guid GUID * @param string $date Date * @param int $length Length * @param string $title Title * @param null $color Color * @param null $css_class CSS class */ function __construct($guid, $date, $length = 0, $title = "", $color = null, $css_class = null) { $this->guid = $guid; $this->internal_id = "CPlanningRange-" . uniqid(); $this->start = $date; $this->length = $length; $this->title = CMbString::htmlEntities($title); $this->color = $color; $this->css_class = is_array($css_class) ? implode(" ", $css_class) : $css_class; if (preg_match("/[0-9]+ /", $this->start)) { $parts = split(" ", $this->start); $this->end = "{$parts[0]} " . CMbDT::time("+{$this->length} MINUTES", $parts[1]); $this->day = $parts[0]; $this->hour = CMbDT::format($parts[1], "%H"); $this->minutes = CMbDT::format($parts[1], "%M"); } else { $this->day = CMbDT::date($date); $this->end = CMbDT::dateTime("+{$this->length} MINUTES", $date); $this->hour = CMbDT::format($date, "%H"); $this->minutes = CMbDT::format($date, "%M"); } }
/** * @see parent::updateFormFields() */ function updateFormFields() { $this->_view = "Séjour du " . CMbDT::format($this->date_mouvement, "%d/%m/%Y") . " [" . $this->external_id . "]"; }
/** * Ajoute un champ de type date et heure * * @param string $field Nom du champ * @param string $value Valeur du champ * * @return void */ function addDateTimeProperty($field, $value = null) { $value = $value ? CMbDT::format($value, CAppUI::conf("datetime")) : ""; $this->addProperty($field, $value); }
$targets = new CSearchTargetEntry(); $actes_ccam = array(); $diags_cim = array(); $results = array(); $tab_favoris = array(); $date = CMbDT::date("-1 month"); $types = array(); $group = CGroups::loadCurrent(); if (CAppUI::conf("search active_handler active_handler_search_types", $group)) { $types = explode("|", CAppUI::conf("search active_handler active_handler_search_types", $group)); } $test_search = new CSearch(); $test_search->testConnection($group); // On récupère les favoris if ($_ref_object instanceof CSejour) { $date = CMbDT::format($_ref_object->entree_reelle, "%Y-%m-%d"); /** @var $_ref_object CSejour */ // actes CCAM du séjour foreach ($_ref_object->loadRefsActesCCAM() as $_ccam) { $diags_actes[] = $_ccam->code_acte; } // actes CCAM du l'intervention foreach ($_ref_object->loadRefsOperations() as $_op) { foreach ($_op->loadRefsActesCCAM() as $_ccam) { $diags_actes[] = $_ccam->code_acte; } } if ($_ref_object->DP || $_ref_object->DR) { if ($_ref_object->DP) { $diags_actes[] = $_ref_object->DP; }
/** * Charge les codes CCAM en tant qu'objets externes * * @return void */ function loadExtCodesCCAM() { $this->_ext_codes_ccam = array(); $this->_ext_codes_ccam_princ = array(); $dateActe = CMbDT::format($this->_datetime, "%Y-%m-%d"); if ($this->_codes_ccam !== null) { foreach ($this->_codes_ccam as $code) { $code = CDatedCodeCCAM::get($code, $dateActe); /* On supprime l'activité 1 du code si celui fait partie de la liste */ if (in_array($code->code, self::$hidden_activity_1)) { unset($code->activites[1]); } $this->_ext_codes_ccam[] = $code; if ($code->type != 2) { $this->_ext_codes_ccam_princ[] = $code; } } CMbArray::ksortByProp($this->_ext_codes_ccam, "type", "_sorted_tarif"); } }
/** * @param CMbObject|CPatient|CSejour $object Object to build the vars array * * @return array */ static function getVars(CMbObject $object) { $vars = $object->getIncrementVars(); $default_vars = array("YYYY" => CMbDT::format(null, "%Y"), "YY" => CMbDT::format(null, "%y")); $vars = array_merge($vars, $default_vars); return $vars; }
function addDateTimeAttribute($elParent, $atName, $dateValue = null) { $this->addAttribute($elParent, $atName, CMbDT::format($dateValue, "%Y-%m-%dT%H:%M:%S")); }
function getDateTime() { static $datetime = null; if ($datetime === null) { $datetime = CMbDT::format(null, "%Y-%m-%d_%H-%M-%S"); } return $datetime; }
* @link http://www.mediboard.org */ global $date, $chir_id, $print; $print = 1; $function_id = CValue::get("function_id"); $date = CValue::get("date"); $start = CMbDT::date("this monday", $date); if ($start > $date) { $start = CMbDT::date("last monday", $date); } $end = CMbDT::date("next sunday", $start); $muser = new CMediusers(); $musers = $muser->loadProfessionnelDeSanteByPref(PERM_READ, $function_id); $function = new CFunctions(); $function->load($function_id); echo "<h1>" . $function->_view . " (" . CMbDT::format($start, CAppUI::conf('longdate')) . " - " . CMbDT::format($end, CAppUI::conf('longdate')) . ")</h1>"; $pconsult = new CPlageconsult(); $ds = $pconsult->getDS(); $where = array(); $where[] = "chir_id " . $ds->prepareIn(array_keys($musers)) . " OR remplacant_id " . $ds->prepareIn(array_keys($musers)); $where["date"] = " BETWEEN '{$start}' AND '{$end}' "; /** @var CPlageconsult[] $pconsults */ $pconsults = $pconsult->loadList($where, "date", null, "chir_id"); $pconsults_by_date_and_prat = array(); if (!count($pconsults)) { echo "<div class='small-info'>Les praticiens de ce cabinet n'ont pas de plages de consultations sur cette période</div>"; CApp::rip(); } foreach ($pconsults as $_pc) { $chir_id = CValue::get("chir_id", $_pc->chir_id); $_pc->loadRefChir();
* @package Mediboard * @subpackage PlanningOp * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision: 22873 $ */ CCanDo::checkRead(); $ds = CSQLDataSource::get("std"); $chir = CValue::get("chir", 0); $date = CValue::getOrSession("date_plagesel", CMbDT::date()); $group_id = CValue::get("group_id", CGroups::loadCurrent()->_id); $operation_id = CValue::get("operation_id", null); $curr_op_time = CValue::get("curr_op_time", "25:00"); $resp_bloc = CModule::getInstalled("dPbloc")->canEdit(); // Liste des mois selectionnables $date = CMbDT::format($date, "%Y-%m-01"); $listMonthes = array(); for ($i = -6; $i <= 12; $i++) { $curr_key = CMbDT::transform("{$i} month", $date, "%Y-%m-%d"); $curr_month = CMbDT::transform("{$i} month", $date, "%B %Y"); $listMonthes[$i]["date"] = $curr_key; $listMonthes[$i]["month"] = $curr_month; } // Chargement du chirurgien $mediChir = new CMediusers(); $mediChir->load($chir); $mediChir->loadBackRefs("secondary_functions"); $secondary_functions = array(); foreach ($mediChir->_back["secondary_functions"] as $curr_sec_func) { $secondary_functions[] = $curr_sec_func->function_id; }
/** * Add a load event * * @param CPlanningEvent|string $start an event * @param integer $length [optional] length of the load * * @return null */ function addLoad($start, $length = null) { $this->has_load = true; if ($start instanceof CPlanningEvent) { $event = $start; if ($this->no_dates) { $day = $event->day; } else { $day = CMbDT::date($event->day); } } else { if ($this->no_dates) { $day = $start; } else { $day = CMbDT::date($start); } $event = new CPlanningEvent(null, $start, $length); } $start = $event->start; $end = $event->end; $div_size = 60 / $this->hour_divider; $min = round(CMbDT::minutesRelative($day, $start) / $div_size) - 1; $max = round(CMbDT::minutesRelative($day, $end) / $div_size) + 1; for ($i = $min; $i <= $max; $i++) { $div_min = CMbDT::dateTime("+" . $i * $div_size . " MINUTES", $day); //$div_max = CMbDT::dateTime("+".(($i+1)*$div_size)." MINUTES", $day); // FIXME: ameliorer ce calcul if ($div_min >= $start && $div_min < $end) { $hour = CMbDT::format($div_min, "%H"); $min = CMbDT::format($div_min, "%M"); if (!isset($this->load_data[$day][$hour][$min])) { $this->load_data[$day][$hour][$min] = 0; } $this->load_data[$day][$hour][$min]++; } } }
} if ($_acte->montant_depassement) { $code .= " DH:" . $_acte->montant_depassement; } $actes_cotes .= "{$code}"; } $line[] = $actes_cotes; $csv->writeLine($line); } foreach ($consultations as $_consult) { $line = array(); if ($all_prats) { $line[] = $_consult->_ref_chir->_view; } $line[] = $_consult->_ref_patient->_view; $view = "Consultation le " . CMbDT::format($_consult->_datetime, "%d/%m/%Y"); if ($_consult->_ref_sejour && $_consult->_ref_sejour->libelle) { $view .= $_consult->_ref_sejour->libelle; } $line[] = $view; $line[] = !$_consult->_count_actes && !$_consult->_ext_codes_ccam ? "Aucun prévu" : $_consult->_actes_non_cotes . "acte(s)"; $actes = ""; foreach ($_consult->_ext_codes_ccam as $code) { $actes .= $actes == "" ? "" : "\n"; $actes .= "{$code->code}"; } $line[] = $actes; $actes_cotes = ""; foreach ($_consult->_ref_actes_ccam as $_acte) { $code .= $actes_cotes == "" ? "" : "\n"; $code .= $_acte->code_acte . "-" . $_acte->code_activite . "-" . $_acte->code_phase;
/** * Récupération des statistiques du nombre d'interventions par jour * selon plusieurs filtres * * @param string $date Date de début * @param int $prat_id Identifiant du praticien * @param int $salle_id Identifiant de la sall * @param int $bloc_id Identifiant du bloc * @param int $discipline_id Identifiant de la discipline * @param string $codes_ccam Code CCAM * @param string $type_hospi Type d'hospitalisation * @param bool $hors_plage Prise en compte des hors plage * * @return array */ function graphActiviteZoom($date, $prat_id = 0, $salle_id = 0, $bloc_id = 0, $func_id = 0, $discipline_id = 0, $codes_ccam = '', $type_hospi = "", $hors_plage = true) { if (!$date) { $date = CMbDT::transform("+0 DAY", CMbDT::date(), "%m/%Y"); } $prat = new CMediusers(); $prat->load($prat_id); $salle = new CSalle(); $salle->load($salle_id); $discipline = new CDiscipline(); $discipline->load($discipline_id); // Gestion de la date $debut = substr($date, 3, 7) . "-" . substr($date, 0, 2) . "-01"; $fin = CMbDT::date("+1 MONTH", $debut); $fin = CMbDT::date("-1 DAY", $fin); $step = "+1 DAY"; // Tableaux des jours $ticks = array(); $ticks2 = array(); $serie_total = array('label' => 'Total', 'data' => array(), 'markers' => array('show' => true), 'bars' => array('show' => false)); for ($i = $debut; $i <= $fin; $i = CMbDT::date($step, $i)) { $ticks[] = array(count($ticks), CMbDT::format($i, "%a %d")); $ticks2[] = array(count($ticks), CMbDT::format($i, "%d")); $serie_total['data'][] = array(count($serie_total['data']), 0); } $salles = CSalle::getSallesStats($salle_id, $bloc_id); $series = array(); $total = 0; foreach ($salles as $salle) { $serie = array('data' => array(), 'label' => utf8_encode($salle->nom)); $query = "SELECT COUNT(operations.operation_id) AS total,\r\n DATE_FORMAT(operations.date, '%d') AS jour,\r\n sallesbloc.nom AS nom\r\n FROM operations\r\n INNER JOIN sejour ON operations.sejour_id = sejour.sejour_id\r\n INNER JOIN sallesbloc ON operations.salle_id = sallesbloc.salle_id\r\n INNER JOIN plagesop ON operations.plageop_id = plagesop.plageop_id\r\n INNER JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\r\n WHERE operations.date BETWEEN '{$debut}' AND '{$fin}'\r\n AND operations.plageop_id IS NOT NULL\r\n AND operations.annulee = '0'\r\n AND sallesbloc.salle_id = '{$salle->_id}'"; if ($prat_id && !$prat->isFromType(array("Anesthésiste"))) { $query .= "\nAND operations.chir_id = '{$prat_id}'"; } if ($prat_id && $prat->isFromType(array("Anesthésiste"))) { $query .= "\nAND (operations.anesth_id = '{$prat_id}' OR \r\n (plagesop.anesth_id = '{$prat_id}' AND (operations.anesth_id = '0' OR operations.anesth_id IS NULL)))"; } if ($discipline_id) { $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codes_ccam) { $query .= "\nAND operations.codes_ccam LIKE '%{$codes_ccam}%'"; } if ($type_hospi) { $query .= "\nAND sejour.type = '{$type_hospi}'"; } $query .= "\nGROUP BY jour ORDER BY jour"; $result = $salle->_spec->ds->loadlist($query); $result_hors_plage = array(); if ($hors_plage) { $query_hors_plage = "SELECT COUNT(operations.operation_id) AS total,\r\n DATE_FORMAT(operations.date, '%d') AS jour,\r\n sallesbloc.nom AS nom\r\n FROM operations\r\n INNER JOIN sejour ON operations.sejour_id = sejour.sejour_id\r\n INNER JOIN sallesbloc ON operations.salle_id = sallesbloc.salle_id\r\n INNER JOIN users_mediboard ON operations.chir_id = users_mediboard.user_id\r\n WHERE operations.date BETWEEN '{$debut}' AND '{$fin}'\r\n AND operations.plageop_id IS NULL\r\n AND operations.annulee = '0'\r\n AND sallesbloc.salle_id = '{$salle->_id}'"; if ($prat_id && !$prat->isFromType(array("Anesthésiste"))) { $query_hors_plage .= "\nAND operations.chir_id = '{$prat_id}'"; } if ($prat_id && $prat->isFromType(array("Anesthésiste"))) { $query_hors_plage .= "\nAND operations.anesth_id = '{$prat_id}'"; } if ($discipline_id) { $query_hors_plage .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'"; } if ($codes_ccam) { $query_hors_plage .= "\nAND operations.codes_ccam LIKE '%{$codes_ccam}%'"; } if ($type_hospi) { $query_hors_plage .= "\nAND sejour.type = '{$type_hospi}'"; } $query_hors_plage .= "\nGROUP BY jour ORDER BY jour"; $result_hors_plage = $salle->_spec->ds->loadlist($query_hors_plage); } foreach ($ticks2 as $i => $tick) { $f = true; foreach ($result as $r) { if ($tick[1] == $r["jour"]) { if ($hors_plage) { foreach ($result_hors_plage as &$_r_h) { if ($tick[1] == $_r_h["jour"]) { $r["total"] += $_r_h["total"]; unset($_r_h); break; } } } $serie["data"][] = array($i, $r["total"]); $serie_total["data"][$i][1] += $r["total"]; $total += $r["total"]; $f = false; } } if ($f) { $serie["data"][] = array(count($serie["data"]), 0); } } $series[] = $serie; } $series[] = $serie_total; // Set up the title for the graph if ($prat_id && $prat->isFromType(array("Anesthésiste"))) { $title = "Nombre d'anesthésie par salle - " . CMbDT::format($debut, "%m/%Y"); $subtitle = "{$total} anesthésies"; } else { $title = "Nombre d'interventions par salle - " . CMbDT::format($debut, "%m/%Y"); $subtitle = "{$total} interventions"; } if ($prat_id) { $subtitle .= " - Dr {$prat->_view}"; } if ($discipline_id) { $subtitle .= " - {$discipline->_view}"; } if ($codes_ccam) { $subtitle .= " - CCAM : {$codes_ccam}"; } if ($type_hospi) { $subtitle .= " - " . CAppUI::tr("CSejour.type.{$type_hospi}"); } $options = CFlotrGraph::merge("bars", array('title' => utf8_encode($title), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('ticks' => $ticks), 'bars' => array('stacked' => true, 'barWidth' => 0.8))); return array('series' => $series, 'options' => $options); }
// 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 if ($context) { $constantes->patient_id = $patient_id; $constantes->context_class = $context->_class; $constantes->context_id = $context->_id; }
$_lastconsult_time = substr($lastconsult->heure, 0, 5); } $consults = $plageSel->_ref_consultations; CStoredObject::massLoadFwdRef($consults, "sejour_id"); $patients = CMbObject::massLoadFwdRef($consults, "patient_id"); CStoredObject::massCountBackRefs($patients, "notes"); CStoredObject::massLoadFwdRef($consults, "categorie_id"); // Détails sur les consultation affichées foreach ($plageSel->_ref_consultations as $keyConsult => &$consultation) { $consultation->_ref_plageconsult = $plageSel; $consultation->loadRefSejour(); $consultation->loadRefPatient()->loadRefsNotes(); $consultation->loadRefCategorie(); $consultation->countDocItems(); $consultation->_view = "Consult. de " . $consultation->_ref_patient->_view; $consultation->_view .= " (" . CMbDT::format($plageSel->date, "%d/%m/%Y") . ")"; //check 3333tel if (CModule::getActive("3333tel")) { C3333TelTools::checkConsults($consultation, $plageSel->_ref_chir->function_id); } } if ($plageSel->chir_id != $chirSel && $plageSel->remplacant_id != $chirSel && $plageSel->pour_compte_id != $chirSel) { $plageconsult_id = null; $plageSel = new CPlageconsult(); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("plageSel", $plageSel); $smarty->assign("chirSel", $chirSel); $smarty->assign("show_payees", $show_payees); $smarty->assign("show_annulees", $show_annulees);
// Filter on actions if ($phase && $entry["phase"] != $phase) { continue; } // Filter on duration if ($min_duration && $entry["duration"] < $min_duration) { continue; } $entries[] = $entry; } } $entries = array_reverse($entries); $table = array(); $rows_count = 0; foreach ($entries as $_entry) { if ($max_rows && $rows_count >= $max_rows) { break; } $rows_count++; $date = CMbDT::date($_entry["datetime"]); $hour = CMbDT::format($_entry["datetime"], "%Y-%m-%d %H:00:00"); $table[$date][$hour][] = $_entry; } // Création du template $smarty = new CSmartyDP(); $smarty->assign("params", CView::$params); $smarty->assign("entries_count", count($entries)); $smarty->assign("rows_count", $rows_count); $smarty->assign("lines_count", $lines_count); $smarty->assign("table", $table); $smarty->display("parse_log_as400.tpl");
public function updateFormFields() { $this->_date_inbox = CMbDT::date(null, $this->date_inbox); if ($this->_date_inbox == CMbDT::date()) { $this->_date_inbox = CMbDT::format($this->date_inbox, '%H:%M'); } else { if (CMbDT::format($this->date_inbox, '%Y') == CMbDT::format(CMbDT::date(), '%Y')) { $this->_date_inbox = CMbDT::format($this->date_inbox, '%d %B'); } } $this->_date_read = CMbDT::date(null, $this->date_read); if ($this->_date_read == CMbDT::date()) { $this->_date_read = CMbDT::format($this->date_read, '%H:%M'); } else { if (CMbDT::format($this->date_read, '%Y') == CMbDT::format(CMbDT::date(), '%Y')) { $this->_date_read = CMbDT::format($this->date_read, '%d %B'); } } }
/** * @see parent::updateFormFields() */ function loadView() { parent::loadView(); $this->_view = "Commande du " . CMbDT::format($this->date, CAppUI::conf("date")); $this->_view .= " pour " . $this->loadRefOperation()->loadRefPatient(); }
$smarty->assign("canceled", $canceled); $smarty->assign("sans_anesth", $sans_anesth); $smarty->assign("count_ops", $count_ops); $smarty->display("vw_idx_visite_anesth.tpl"); } else { // Selection des plages du praticien et de celles de sa spécialité $praticien_id = null; $function_ids = null; if ($selPraticien->isPraticien()) { $praticien_id = $selPraticien->user_id; $function_ids = CMbArray::pluck($selPraticien->loadBackRefs("secondary_functions"), "function_id"); $function_ids[] = $selPraticien->function_id; } // Planning du mois $month_min = CMbDT::format($date, "%Y-%m-01"); $month_max = CMbDT::format($date, "%Y-%m-31"); $sql = "SELECT plagesop.*, plagesop.date AS opdate,\r\n SEC_TO_TIME(SUM(TIME_TO_SEC(operations.temp_operation))) AS duree,\r\n COUNT(operations.operation_id) AS total,\r\n SUM(operations.rank_voulu > 0) AS planned_by_chir,\r\n COUNT(IF(operations.rank > 0, NULLIF(operations.rank, operations.rank_voulu), NULL)) AS order_validated,\r\n functions_mediboard.text AS nom_function, functions_mediboard.color as color_function\r\n FROM plagesop\r\n LEFT JOIN operations\r\n ON plagesop.plageop_id = operations.plageop_id\r\n AND operations.annulee = '0'\r\n AND operations.chir_id = '{$praticien_id}'\r\n LEFT JOIN functions_mediboard\r\n ON functions_mediboard.function_id = plagesop.spec_id\r\n WHERE (plagesop.chir_id = '{$praticien_id}' OR plagesop.spec_id " . CSQLDataSource::prepareIn($function_ids) . ")\r\n AND plagesop.date BETWEEN '{$month_min}' AND '{$month_max}'\r\n GROUP BY plagesop.plageop_id\r\n ORDER BY plagesop.date, plagesop.debut, plagesop.plageop_id"; $listPlages = array(); if ($praticien_id) { $listPlages = $ds->loadList($sql); } // Urgences du mois $sql = "SELECT operations.*, operations.date AS opdate,\r\n SEC_TO_TIME(SUM(TIME_TO_SEC(operations.temp_operation))) AS duree,\r\n COUNT(operations.operation_id) AS total\r\n FROM operations\r\n WHERE operations.annulee = '0'\r\n AND operations.chir_id = '{$praticien_id}'\r\n AND operations.plageop_id IS NULL\r\n AND operations.date BETWEEN '{$month_min}' AND '{$month_max}'\r\n GROUP BY operations.date\r\n ORDER BY operations.date"; $listUrgences = array(); if ($praticien_id) { $listUrgences = $ds->loadList($sql); } $listDays = array(); foreach ($listPlages as $curr_ops) { $listDays[$curr_ops["opdate"]][$curr_ops["plageop_id"]] = $curr_ops; }
$height = CValue::get('height', 100); $product = new CProduct(); $product->load($product_id); $product->loadRefStock(); $series = array(array("label" => utf8_encode("Entrées"), "color" => "#66CC00", "data" => array()), array("label" => utf8_encode("Sorties"), "color" => "#CB4B4B", "data" => array()), array("label" => utf8_encode("Périmés"), "color" => "#6600CC", "data" => array())); $ticks = array(); $max = 1; $now = CMbDT::date(); $date = CMbDT::date("-6 MONTHS"); $i = 0; while ($date < $now) { //$to = CMbDT::date("+1 MONTH", $date); //$ticks[] = "Du ".CMbDT::dateToLocale($date)." au ".CMbDT::dateToLocale($to); $date = CMbDT::format($date, "%Y-%m-01"); $to = CMbDT::date("+1 MONTH", $date); $ticks[] = array(count($ticks) * 2 - 0.4, utf8_encode(CMbDT::format($date, "%b"))); // Input ////////////////// $where = array("product.product_id" => "= '{$product->_id}'", "product_order_item_reception.date" => "BETWEEN '{$date}' AND '{$to}'"); $ljoin = array("product_order_item" => "product_order_item.order_item_id = product_order_item_reception.order_item_id", "product_reference" => "product_reference.reference_id = product_order_item.reference_id", "product" => "product.product_id = product_reference.product_id"); $lot = new CProductOrderItemReception(); /** @var CProductOrderItemReception[] $lots */ $lots = $lot->loadList($where, null, null, null, $ljoin); $total = 0; foreach ($lots as $_lot) { $total += $_lot->quantity; } $max = max($max, $total); $series[0]["data"][] = array(count($series[0]["data"]) * 2 - 0.6, $total); // Hack pour les etablissements qui ont un service "Périmés" $where_services = array("nom" => "= 'Périmés'"); $services_expired = new CService();
* @subpackage dPcabinet * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision: 24015 $ */ $prat_id = CValue::post("prat_id"); $consult = new CConsultation(); $consult->load(CValue::post("consultation_id")); $consult->loadRefPlageConsult(); $_datetime = $consult->_datetime; if (!isset($current_m)) { $current_m = CValue::post("current_m", "dPcabinet"); } $day_now = CMbDT::format($_datetime, "%Y-%m-%d"); $time_now = CMbDT::format($_datetime, "%H:%M:00"); $hour_now = CMbDT::format($_datetime, "%H:00:00"); $hour_next = CMbDT::time("+1 HOUR", $hour_now); $plage = new CPlageconsult(); $plageBefore = new CPlageconsult(); $plageAfter = new CPlageconsult(); // Cas ou une plage correspond $where = array(); $where["chir_id"] = "= '{$prat_id}'"; $where["date"] = "= '{$day_now}'"; $where["debut"] = "<= '{$time_now}'"; $where["fin"] = "> '{$time_now}'"; $plage->loadObject($where); if (!$plage->_id) { // Cas ou on a des plage en collision $where = array(); $where["chir_id"] = "= '{$prat_id}'";
/** * Génération des données des graphiques du palmarès ressources * * @param string $module Module concerné * @param string $date Date de référence * @param string $element Type de données à afficher * @param string $interval Interval de temps à analyser * @param int $numelem Nombre d'éléments maximum * * @return array Les données de palmarès */ function graphRessourceLog($module, $date, $element = 'duration', $interval = 'day', $numelem = 4) { if (!$date) { $date = CMbDT::date(); } switch ($interval) { default: case "day": $startx = "{$date} 00:00:00"; $endx = "{$date} 23:59:59"; break; case "month": $startx = CMbDT::dateTime("-1 MONTH", "{$date} 00:00:00"); $endx = "{$date} 23:59:59"; break; case "year": $startx = CMbDT::dateTime("-27 WEEKS", "{$date} 00:00:00"); $endx = "{$date} 23:59:59"; break; } if ($module == "total") { $groupmod = 0; $module_name = null; } elseif ($module == "modules") { $groupmod = 1; $module_name = null; } else { $groupmod = 0; $module_name = $module; } $logs = CAccessLog::loadAggregation($startx, $endx, $groupmod, $module_name); $series = array(); $i = 0; foreach ($logs as $data) { $series[$i]["data"] = array(array(0, $data->{$element})); $series[$i]["label"] = $module != 'modules' ? $data->_action : $data->_module; $i++; } if (!function_exists('compareDataPie')) { /** * Comparaison entre deux données du graphique en pie * * @param array $a Première donnée * @param array $b Deuxième donnée * * @return bool La première valeur est-elle inférieure à la deuxième */ function compareDataPie($a, $b) { return $a["data"][0][1] < $b["data"][0][1]; } } usort($series, "compareDataPie"); $seriesNew = array_slice($series, 0, $numelem); if (count($series) > $numelem) { $other = array_slice($series, $numelem); $seriesNew[$numelem]["data"] = array(array(0, 0)); $seriesNew[$numelem]["label"] = "Autres"; $n = 0; foreach ($other as $_other) { $seriesNew[$numelem]["data"][0][1] += $_other["data"][0][1]; $n++; } $seriesNew[$numelem]["label"] .= " ({$n})"; } $series = $seriesNew; // Set up the title for the graph $title = CMbDT::format($date, "%A %d %b %Y"); if ($module) { $title .= " : " . CAppUI::tr($module); } $options = array('title' => utf8_encode($title), 'HtmlText' => false, 'grid' => array('verticalLines' => false, 'horizontalLines' => false, 'outlineWidth' => 0), 'xaxis' => array('showLabels' => false), 'yaxis' => array('showLabels' => false), 'pie' => array('show' => true, 'sizeRatio' => 0.5), 'legend' => array('backgroundOpacity' => 0.3)); return array('series' => $series, 'options' => $options); }
* @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ $type = CValue::get("type"); $type_mouvement = CValue::get("type_mouvement"); $vue = CValue::getOrSession("vue", 0); $praticien_id = CValue::getOrSession("praticien_id", null); $services_ids = CValue::getOrSession("services_ids", null); $order_way = CValue::getOrSession("order_way", "ASC"); $order_col = CValue::getOrSession("order_col", "_patient"); $show_duree_preop = CAppUI::conf("dPplanningOp COperation show_duree_preop"); $show_hour_anesth = CAppUI::conf("dPhospi show_hour_anesth_mvt"); $mode = CValue::getOrSession("mode", 0); $prestation_id = CValue::getOrSession("prestation_id"); $hour_instantane = CValue::getOrSession("hour_instantane", CMbDT::format(CMbDT::time(), "%H")); if (is_array($services_ids)) { CMbArray::removeValue("", $services_ids); } $services = new CService(); $where = array(); $where["service_id"] = CSQLDataSource::prepareIn($services_ids); $services = $services->loadList($where); $update_count = ""; $praticien = new CMediusers(); $praticien->load($praticien_id); $dmi_active = CModule::getActive("dmi"); $group = CGroups::loadCurrent(); $types_hospi = array("comp", "ambu", "urg", "ssr", "psy"); $type_hospi = CValue::getOrSession("type_hospi", null); $entrees = array();
* @version $Revision$ */ $out = fopen('php://output', 'w'); header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename="ExportCompta.xls"'); $facture_class = CValue::get("facture_class", 'CFactureEtablissement'); $factures_id = CValue::get("factures", array()); $factures_id = explode("|", $factures_id); $where = array(); $where["facture_id"] = CSQLDataSource::prepareIn(array_values($factures_id)); $facture = new $facture_class(); $factures = $facture->loadList($where); // Ligne d'entête $fields = array(); $fields[] = "Date"; $fields[] = "Facture"; $fields[] = "Patient"; $fields[] = "Montant"; fputcsv($out, $fields, ';'); foreach ($factures as $_facture) { /* @var CFactureEtablissement $_facture*/ $_facture->loadRefPatient(); $_facture->loadRefsObjects(); $_facture->loadRefsReglements(); $fields = array(); $fields["Date"] = CMbDT::format($_facture->cloture, "%d/%m/%Y"); $fields["Facture"] = $_facture->_id; $fields["Patient"] = $_facture->_ref_patient; $fields["Montant"] = sprintf("%.2f", $_facture->_montant_avec_remise); fputcsv($out, $fields, ';'); }
/** * Get the latest constantes values * * @param int|CPatient $patient The patient to load the constantes for * @param string $datetime The reference datetime * @param array $selection A selection of constantes to load * @param CMbObject $context The context * @param boolean $use_cache Force the function to return the latest_values is already set * * @return array The constantes values and dates */ static function getLatestFor($patient, $datetime = null, $selection = array(), $context = null, $use_cache = true) { $patient_id = $patient instanceof CPatient ? $patient->_id : $patient; if (isset(self::$_latest_values[$patient_id][$datetime]) && $use_cache === true) { return self::$_latest_values[$patient_id][$datetime]; } if (empty($selection)) { $list_constantes = CConstantesMedicales::$list_constantes; } else { $list_constantes = array_intersect_key(CConstantesMedicales::$list_constantes, array_flip($selection)); } // Constante que l'on va construire $constante = new CConstantesMedicales(); if (!$patient_id) { return array($constante, array()); } $constante->patient_id = $patient_id; $constante->datetime = CMbDT::dateTime(); $constante->loadRefPatient(); $where = array("patient_id" => "= '{$patient_id}'"); if ($context) { $where["context_class"] = " = '{$context->_class}'"; $where["context_id"] = " = '{$context->_id}'"; } if ($datetime) { $where["datetime"] = "<= '{$datetime}'"; } if (count($selection)) { $ors = array(); foreach ($selection as $_item) { $ors[] = "{$_item} IS NOT NULL"; } $where[] = implode(" OR ", $ors); } $count = $constante->countList($where); // Load all constants instead of checking every type to reduce number of SQL queries /** @var self[] $all_list */ $all_list = array(); if ($count <= 30) { $all_list = $constante->loadList($where, "datetime DESC"); } $list_datetimes = array(); foreach ($list_constantes as $type => $params) { $list_datetimes[$type] = null; if ($type[0] == "_") { continue; } // Load them, if any ... if ($count > 0) { // Load them all and dispatch if ($count <= 30) { foreach ($all_list as $_const) { $_value = $_const->{$type}; if ($_value != null) { $constante->{$type} = $_value; $list_datetimes[$type] = $_const->datetime; break; } } } else { $_where = $where; $_where[$type] = "IS NOT NULL"; $_list = $constante->loadList($_where, "datetime DESC", 1); if (count($_list)) { $_const = reset($_list); $constante->{$type} = $_const->{$type}; $list_datetimes[$type] = $_const->datetime; } } } } // Cumul de la diurese if ($datetime) { foreach ($list_constantes as $_name => $_params) { if (isset($_params["cumul_reset_config"]) || isset($_params["formula"])) { $day_defore = CMbDT::dateTime("-24 hours", $datetime); if (isset($_params["cumul_reset_config"]) && !isset($_params['formula'])) { $cumul_field = '_' . $_name . '_cumul'; $reset_hour = str_pad(self::getHostConfig($_params["cumul_reset_config"], $context), 2, '0', STR_PAD_LEFT); $cumul_begin = ''; $cumul_end = ''; if ($datetime >= CMbDT::format($datetime, "%Y-%m-%d {$reset_hour}:00:00")) { $cumul_begin = CMbDT::format($datetime, "%Y-%m-%d {$reset_hour}:00:00"); $cumul_end = CMbDT::format(CMbDT::date('+1 DAY', $datetime), "%Y-%m-%d {$reset_hour}:00:00"); } else { $cumul_begin = CMbDT::format(CMbDT::date('-1 DAY', $datetime), "%Y-%m-%d {$reset_hour}:00:00"); $cumul_end = CMbDT::format($datetime, "%Y-%m-%d {$reset_hour}:00:00"); } $query = new CRequest(); $query->addSelect("SUM(`{$_name}`)"); $query->addTable('constantes_medicales'); $query->addWhere(array("`datetime` >= '{$cumul_begin}'", "`datetime` <= '{$cumul_end}'", "`{$_name}` IS NOT NULL", "`patient_id` = {$patient_id}")); $ds = CSQLDataSource::get('std'); $constante->{$cumul_field} = $ds->loadResult($query->makeSelect()); } else { // cumul de plusieurs champs (avec formule) $formula = $_params["formula"]; foreach ($formula as $_field => $_sign) { $_where = $where; $_where[$_field] = "IS NOT NULL"; $_where[] = "datetime >= '{$day_defore}'"; $_list = $constante->loadList($_where); foreach ($_list as $_const) { if ($_sign === "+") { $constante->{$_name} += $_const->{$_field}; } else { $constante->{$_name} -= $_const->{$_field}; } } } } } } } $constante->updateFormFields(); // Don't cache partial loadings if (empty($selection)) { self::$_latest_values[$patient_id][$datetime] = array($constante, $list_datetimes); } return array($constante, $list_datetimes); }