/** * @see parent::updateFormFields() */ function updateFormFields() { parent::updateFormFields(); if ($this->end_datetime && $this->start_datetime) { $this->_duration = CMbDT::timeRelative($this->start_datetime, $this->end_datetime); } }
/** * $Id: inc_personnel.php 20938 2013-11-13 11:02:47Z aurelie17 $ * * @package Mediboard * @subpackage bloodSalvage * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision: 20938 $ */ function loadAffected(&$blood_salvage_id, &$list_nurse_sspi, &$tabAffected, &$timingAffect) { $affectation = new CAffectationPersonnel(); $affectation->object_class = "CBloodSalvage"; $affectation->object_id = $blood_salvage_id; $tabAffected = $affectation->loadMatchingList(); foreach ($tabAffected as $key => $affect) { if (array_key_exists($affect->personnel_id, $list_nurse_sspi)) { unset($list_nurse_sspi[$affect->personnel_id]); } $affect->_ref_personnel->loadRefUser(); } // Initialisations des tableaux des timings foreach ($tabAffected as $key => $affectation) { $timingAffect[$affectation->_id]["_debut"] = array(); $timingAffect[$affectation->_id]["_fin"] = array(); } // Remplissage des tableaux des timings foreach ($tabAffected as $id => $affectation) { foreach ($timingAffect[$affectation->_id] as $key => $value) { for ($i = -10; $i < 10 && $affectation->{$key} !== null; $i++) { $timingAffect[$affectation->_id][$key][] = CMbDT::time("{$i} minutes", $affectation->{$key}); } } } }
/** * @see parent::build */ function build(CHPREvent $event) { parent::build($event); $message = $event->message; $data = array(); // H-1 : Field Separator $data[] = $message->fieldSeparator; // H-2: Encoding Characters (ST) $data[] = substr($message->getEncodingCharacters(), 1); // H-3 : Message ID $data[] = $event->_exchange_hpr->_id; // H-4 : Password $data[] = null; // H-5 : Sender ID $data[] = $event->_sender->nom; // H-6 : Sender address $data[] = null; // H-7 : Context $data[] = $event->event_type; // H-8 : Sender phone $data[] = null; // H-9 : Transmission characteristics $data[] = null; // H-10 : Receiver ID $data[] = array($event->_receiver->_id, $event->_receiver->nom); // H-11 : Comment $data[] = null; // H-12 : Processing ID $data[] = null; // H-13 : Version and Type $data[] = array(array($event->version, $event->_exchange_hpr->type)); // H-14 : Date/Time of Message $data[] = CMbDT::dateTime(); $this->fill($data); }
protected function updateDateCodage() { $ds = $this->ds; $query = "SELECT * FROM `codage_ccam`;"; $rows = $ds->exec($query); while ($_codage = $ds->fetchObject($rows, 'CCodageCCAM')) { $_codage->loadCodable(); $date = null; switch ($_codage->codable_class) { case 'CConsultation': $_codage->_ref_codable->loadRefPlageConsult(); $date = $_codage->_ref_codable->_date; break; case 'COperation': $date = $_codage->_ref_codable->date; break; case 'CSejour': $date = CMbDT::date('', $_codage->_ref_codable->entree); break; } $query = "UPDATE `codage_ccam`\r\n SET `date` = '{$date}' WHERE `codage_ccam_id` = {$_codage->_id};"; $ds->exec($query); } return true; }
/** * @see parent::checkProperty() */ function checkProperty($object) { $propValue =& $object->{$this->fieldName}; $time_format = "/^\\d{1,2}:\\d{1,2}(:\\d{1,2})?\$/"; // Format if (!preg_match($time_format, $propValue)) { if ($propValue === 'current' || $propValue === 'now') { $propValue = CMbDT::time(); return null; } return "Format d'heure invalide"; } // min if ($this->min) { if (!preg_match($time_format, $this->min)) { trigger_error("Spécification de minimum time invalide (min = {$this->min})", E_USER_WARNING); return "Erreur système"; } if ($propValue < $this->min) { return "Doit avoir une valeur minimale de {$this->min}"; } } // max if ($this->max) { if (!preg_match($time_format, $this->max)) { trigger_error("Spécification de maximum time invalide (max = {$this->max})", E_USER_WARNING); return "Erreur système"; } if ($propValue > $this->max) { return "Doit avoir une valeur maximale de {$this->max}"; } } return null; }
/** * @see parent::store() */ function store() { if ($this->fieldModified("content") || !$this->last_modified) { $this->last_modified = CMbDT::dateTime(); } return parent::store(); }
/** * @see parent::store() */ function store() { $this->completeField("handled"); if (!$this->creation_date) { $this->creation_date = CMbDT::dateTime(); if ($this->_id) { $this->creation_date = $this->loadFirstLog()->date; } } if ($this->fieldModified("handled", "1") || $this->handled && !$this->handled_date && !$this->handled_user_id) { $this->handled_date = CMbDT::dateTime(); $this->handled_user_id = CMediusers::get()->_id; if ($this->handled) { $last_log = $this->loadLastLog(); $this->handled_date = $last_log->date; $this->handled_user_id = $last_log->user_id; } } if ($this->fieldModified("handled", "0")) { $this->handled_date = $this->handled_user_id = ""; } if ($msg = parent::store()) { return $msg; } }
/** * Build EVN segement * * @param CHL7v2Event $event Event * * @return null */ function build(CHL7v2Event $event) { parent::build($event); $version = $event->message->version; $data = array(); // EVN-1: Event Type Code (ID) (optional) // This field has been retained for backward compatibility only $data[] = $version < "2.5" ? $event->code : null; // EVN-2: Recorded Date/Time (TS) $data[] = CMbDT::dateTime(); // EVN-3: Date/Time Planned Event (TS)(optional) $data[] = $this->planned_datetime; // EVN-4: Event Reason Code (IS) (optional) // Table 062 // 01 - Patient request // 02 - Physician/health practitioner order // 03 - Census management // O - Other // U - Unknown $data[] = null; // EVN-5: Operator ID (XCN) (optional repeating) //$data[] = $this->getXCN($event->last_log->loadRefUser()); $data[] = null; // EVN-6: Event Occurred (TS) (optional) $data[] = $this->occured_datetime; // EVN-7: Event Facility (HD) (optional) $data[] = null; $this->fill($data); }
/** * Menu upgrade * * @return bool */ protected function fixRepet() { $ds = $this->ds; $query = "SELECT * FROM menu"; $menus = $ds->loadList($query); foreach ($menus as $menu) { $nbDays = CMbDT::daysRelative($menu["debut"], $menu["fin"]); $nbWeeks = floor($nbDays / 7); if (!$nbWeeks) { $menu["nb_repet"] = 1; } else { $menu["nb_repet"] = ceil($nbWeeks / $menu["repetition"]); } $query = "UPDATE `menu` SET `nb_repet` = '" . $menu["nb_repet"] . "' WHERE(`menu_id`='" . $menu["menu_id"] . "');"; $ds->exec($query); $ds->error(); $query = "UPDATE `repas` SET `typerepas_id`='" . $menu["typerepas"] . "' WHERE(`menu_id`='" . $menu["menu_id"] . "');"; $ds->exec($query); $ds->error(); } $query = "ALTER TABLE `menu` DROP `fin`;"; $ds->exec($query); $ds->error(); return true; }
/** * Loads messages from a publication date perspective * * @param string $status Wanted status, null for all * @param string $mod_name Module name restriction, null for all * @param int $group_id Group ID * * @return self[] Published messages */ function loadPublications($status = null, $mod_name = null, $group_id = null) { $now = CMbDT::dateTime(); $where = array(); switch ($status) { case "past": $where["fin"] = "< '{$now}'"; break; case "present": $where["deb"] = "< '{$now}'"; $where["fin"] = "> '{$now}'"; break; case "future": $where["deb"] = "> '{$now}'"; break; } if ($group_id) { $where[] = "group_id = '{$group_id}' OR group_id IS NULL"; } /** @var self[] $messages */ $messages = $this->loadList($where, "deb DESC"); // Module name restriction if ($mod_name) { foreach ($messages as $message_id => $_message) { if ($_message->module_id) { if ($_message->loadRefModuleObject()->mod_name != $mod_name) { unset($messages[$message_id]); } } } } return $messages; }
static function mine($parent_class) { $classes = CApp::getChildClasses($parent_class); $limit = CAppUI::conf("dataminer_limit"); foreach ($classes as $_class) { $miner = new $_class(); $report = $miner->mineSome($limit, "mine"); $dt = CMbDT::dateTime(); echo "<{$dt}> Miner: {$_class}. Success mining count is '" . $report["success"] . "'\n"; if (!$report["failure"]) { echo "<{$dt}> Miner: {$_class}. Failure mining counts is '" . $report["failure"] . "'\n"; } $miner = new $_class(); $report = $miner->mineSome($limit, "remine"); $dt = CMbDT::dateTime(); echo "<{$dt}> Reminer: {$_class}. Success remining count is '" . $report["success"] . "'\n"; if (!$report["failure"]) { echo "<{$dt}> Reminer: {$_class}. Failure remining counts is '" . $report["failure"] . "'\n"; } $miner = new $_class(); $report = $miner->mineSome($limit, "postmine"); $dt = CMbDT::dateTime(); echo "<{$dt}> Postminer: {$_class}. Success postmining count is '" . $report["success"] . "'\n"; if (!$report["failure"]) { echo "<{$dt}> Postminer: {$_class}. Failure postmining counts is '" . $report["failure"] . "'\n"; } } }
/** * Magic method (do not call directly) * * @param string $name method name * @param array $args arguments * * @return mixed * * @throws Exception * @throws CMbException */ function __call($name, $args) { $name = strtolower($name); $silent = strncmp($name, 'try', 3) === 0; $function_name = $silent ? substr($name, 3) : $name; $function_name = '_' . (isset(self::$aliases[$function_name]) ? self::$aliases[$function_name] : $function_name); if (!method_exists($this, $function_name)) { throw new CMbException("CSourceSFTP-call-undefined-method", $name); } if ($function_name == "_init") { return call_user_func_array(array($this, $function_name), $args); } if (!$this->loggable) { try { return call_user_func_array(array($this, $function_name), $args); } catch (CMbException $fault) { throw $fault; } } $echange_ftp = new CExchangeFTP(); $echange_ftp->date_echange = CMbDT::dateTime(); $echange_ftp->emetteur = CAppUI::conf("mb_id"); $echange_ftp->destinataire = $this->hostname; $echange_ftp->function_name = $name; CApp::$chrono->stop(); $chrono = new Chronometer(); $chrono->start(); $output = null; try { $output = call_user_func_array(array($this, $function_name), $args); } catch (CMbException $fault) { $echange_ftp->date_echange = CMbDT::dateTime(); $echange_ftp->output = $fault->getMessage(); $echange_ftp->ftp_fault = 1; $echange_ftp->store(); CApp::$chrono->start(); throw $fault; } $chrono->stop(); CApp::$chrono->start(); // response time $echange_ftp->response_time = $chrono->total; // Truncate input and output before storing $args = array_map_recursive(array("CFTP", "truncate"), $args); $echange_ftp->input = serialize($args); if ($echange_ftp->ftp_fault != 1) { if ($function_name == "_getlistfiles") { // Truncate le tableau des fichiers reçus dans le cas où c'est > 100 $array_count = count($output); if ($array_count > 100) { $output = array_slice($output, 0, 100); $output["count"] = "{$array_count} files"; } } $echange_ftp->output = serialize(array_map_recursive(array("CSFTP", "truncate"), $output)); } $echange_ftp->store(); return $output; }
/** * @see parent::updateFormFields() */ function updateFormFields() { parent::updateFormFields(); $this->_view = "Allaitement du " . CMbDT::transform($this->date_debut, null, CAppUI::conf("date")) . " à " . CMbDT::transform($this->date_debut, null, CAppUI::conf("time")); if ($this->date_fin) { $this->_view .= " au " . CMbDT::transform($this->date_fin, null, CAppUI::conf("date")) . " à " . CMbDT::transform($this->date_fin, null, CAppUI::conf("time")); } }
/** * @see parent::updateFormFields() */ function updateFormFields() { parent::updateFormFields(); $this->_view = "Indisponibilité du " . CMbDT::dateToLocale($this->deb); if ($this->deb != $this->fin) { $this->_view .= " au " . CMbDT::dateToLocale($this->fin); } }
/** * Récupération des statistiques du nombre de consultations par mois * selon plusieurs filtres * * @param string $debut Date de début * @param string $fin Date de fin * @param int $prat_id Identifiant du praticien * * @return array */ function graphConsultations($debut = null, $fin = null, $prat_id = 0) { if (!$debut) { $debut = CMbDT::date("-1 YEAR"); } if (!$fin) { $fin = CMbDT::date(); } $rectif = CMbDT::transform("+0 DAY", $debut, "%d") - 1; $debutact = CMbDT::date("-{$rectif} DAYS", $debut); $rectif = CMbDT::transform("+0 DAY", $fin, "%d") - 1; $finact = CMbDT::date("-{$rectif} DAYS", $fin); $finact = CMbDT::date("+ 1 MONTH", $finact); $finact = CMbDT::date("-1 DAY", $finact); $pratSel = new CMediusers(); $pratSel->load($prat_id); $ticks = array(); $serie_total = array('label' => 'Total', 'data' => array(), 'markers' => array('show' => true), 'bars' => array('show' => false)); for ($i = $debut; $i <= $fin; $i = CMbDT::date("+1 MONTH", $i)) { $ticks[] = array(count($ticks), CMbDT::transform("+0 DAY", $i, "%m/%Y")); $serie_total['data'][] = array(count($serie_total['data']), 0); } $ds = CSQLDataSource::get("std"); $total = 0; $series = array(); $query = "SELECT COUNT(consultation.consultation_id) AS total,\r\n DATE_FORMAT(plageconsult.date, '%m/%Y') AS mois,\r\n DATE_FORMAT(plageconsult.date, '%Y%m') AS orderitem\r\n FROM consultation\r\n INNER JOIN plageconsult\r\n ON consultation.plageconsult_id = plageconsult.plageconsult_id\r\n INNER JOIN users_mediboard\r\n ON plageconsult.chir_id = users_mediboard.user_id\r\n WHERE plageconsult.date BETWEEN '{$debutact}' AND '{$finact}'\r\n AND consultation.annule = '0'"; if ($prat_id) { $query .= "\nAND plageconsult.chir_id = '{$prat_id}'"; } $query .= "\nGROUP BY mois ORDER BY orderitem"; $serie = array('data' => array()); $result = $ds->loadlist($query); foreach ($ticks as $i => $tick) { $f = true; foreach ($result as $r) { if ($tick[1] == $r["mois"]) { $serie["data"][] = array($i, $r["total"]); $serie_total["data"][$i][1] += $r["total"]; $total += $r["total"]; $f = false; break; } } if ($f) { $serie["data"][] = array(count($serie["data"]), 0); } } $series[] = $serie; // Set up the title for the graph $title = "Nombre de consultations"; $subtitle = "- {$total} consultations -"; if ($prat_id) { $subtitle .= " Dr {$pratSel->_view} -"; } $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); }
/** * 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); }
/** * @see parent::store() */ function store() { if (!$this->creation_datetime) { $this->creation_datetime = CMbDT::dateTime(); } if ($msg = parent::store()) { return $msg; } }
/** * @see parent::doStore() */ function doStore() { if (isset($_FILES['attachment'])) { $mail_id = CValue::post('mail_id'); $mail = new CUserMail(); $mail->load($mail_id); $files = array(); foreach ($_FILES['attachment']['error'] as $key => $file_error) { if (isset($_FILES['attachment']['name'][$key])) { $files[] = array('name' => $_FILES['attachment']['name'][$key], 'tmp_name' => $_FILES['attachment']['tmp_name'][$key], 'error' => $_FILES['attachment']['error'][$key], 'size' => $_FILES['attachment']['size'][$key]); } } foreach ($files as $_key => $_file) { if ($_file['error'] == UPLOAD_ERR_NO_FILE) { continue; } if ($_file['error'] != 0) { CAppUI::setMsg(CAppUI::tr("CFile-msg-upload-error-" . $_file["error"]), UI_MSG_ERROR); continue; } $attachment = new CMailAttachments(); $attachment->name = $_file['name']; $content_type = mime_content_type($_file['tmp_name']); $attachment->type = $attachment->getTypeInt($content_type); $attachment->bytes = $_file['size']; $attachment->mail_id = $mail_id; $content_type = explode('/', $content_type); $attachment->subtype = strtoupper($content_type[1]); $attachment->disposition = 'ATTACHMENT'; $attachment->extension = substr(strrchr($attachment->name, '.'), 1); $attachment->part = $mail->countBackRefs('mail_attachments') + 1; $attachment->store(); $file = new CFile(); $file->setObject($attachment); $file->author_id = CAppUI::$user->_id; $file->file_name = $attachment->name; $file->file_date = CMbDT::dateTime(); $file->fillFields(); $file->updateFormFields(); $file->doc_size = $attachment->bytes; $file->file_type = mime_content_type($_file['tmp_name']); $file->moveFile($_file, true); if ($msg = $file->store()) { CAppUI::setMsg(CAppUI::tr('CMailAttachments-error-upload-file') . ':' . CAppUI::tr($msg), UI_MSG_ERROR); CApp::rip(); } $attachment->file_id = $file->_id; if ($msg = $attachment->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); CApp::rip(); } } CAppUI::setMsg('CMailAttachments-msg-added', UI_MSG_OK); } else { parent::doStore(); } }
/** * History constructor * * @param string $m Module * @param string $action Action * @param string $actionType Action type * @param CMbObject $object Object * @param array $params Parameters * @param string $type Type of view */ protected function __construct($m, $action, $actionType, CMbObject $object, $params, $type) { $this->datetime = CMbDT::dateTime(); $this->m = $m; $this->action = $action; $this->actionType = $actionType; $this->params = $params; $this->type = $type; $this->object_guid = $object->_guid; $this->object = $object; }
/** * check if $this is an older rule * * @return bool */ function checkOlder() { $now = CMbDT::dateTime(); if ($this->date_min && $now < $this->date_min) { return $this->_inactive = true; } if ($this->date_max && $now > $this->date_max) { return $this->_inactive = true; } return $this->_inactive = false; }
/** * @see parent::checkProperty() */ function checkProperty($object) { $propValue =& $object->{$this->fieldName}; if (!preg_match("/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}[ \\+][0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2})?\$/", $propValue)) { if ($propValue === 'current' || $propValue === 'now') { $propValue = CMbDT::dateTime(); return null; } return "format de dateTime invalide : '{$propValue}'"; } $propValue = strtr($propValue, "+", " "); return null; }
/** * @see parent::store() */ function store() { // Save owner and creation date if (!$this->_id) { if (!$this->creation_date) { $this->creation_date = CMbDT::dateTime(); } if (!$this->owner_id) { $this->owner_id = CMediusers::get()->_id; } } return parent::store(); }
/** * Fill other identifiers * * @param array &$identifiers Identifiers * @param CPatient $patient Person * @param CInteropActor $actor Interop actor * * @return null */ function fillOtherIdentifiers(&$identifiers, CPatient $patient, CInteropActor $actor = null) { $ins = $patient->loadLastINS(); if ($ins) { $identifiers[] = array($ins->ins, null, null, $this->getAssigningAuthority("INS-{$ins->type}"), "INS-{$ins->type}", null, CMbDT::date($ins->date)); } if ($patient->matricule) { $identifiers[] = array($patient->matricule, null, null, $this->getAssigningAuthority("INSEE"), "SS"); } if ($actor->_configs["send_own_identifier"]) { $identifiers[] = array($patient->_id, null, null, $this->getAssigningAuthority("mediboard"), $actor->_configs["build_identifier_authority"] == "PI_AN" ? "PI" : "RI"); } }
/** * @see parent::store() */ function store() { // Transfert de séjours vers un autre technicien if ($this->_transfer_id) { foreach ($this->loadRefsSejours(CMbDT::date()) as $_sejour) { $bilan = $_sejour->loadRefBilanSSR(); $bilan->technicien_id = $this->_transfer_id; if ($msg = $bilan->store()) { return $msg; } } } return parent::store(); }
/** * Build ZFD segement * * @param CHL7v2Event $event Event * * @return null */ function build(CHL7v2Event $event) { parent::build($event); $patient = $this->patient; // ZFD-1: Date lunaire if (CMbDT::isLunarDate($patient->naissance)) { $date = explode("-", $patient->naissance); $data[] = array($date[2], $date[1], $date[0]); } else { $data[] = null; } // ZFD-2: Nombre de semaines de gestation $data[] = null; $this->fill($data); }
function bindEchange($fileName = null) { $this->_echange_hprim21->date_production = CMbDT::dateTime($this->date); $this->_echange_hprim21->version = $this->version; $this->_echange_hprim21->nom_fichier = $this->nom_fichier; // Read => Mediboard $this->_echange_hprim21->receiver_id = null; $this->_echange_hprim21->sous_type = $this->sous_type; $this->_echange_hprim21->type = $this->type; $this->_echange_hprim21->date_echange = CMbDT::dateTime(); if ($fileName) { $this->_echange_hprim21->_message = file_get_contents($fileName); } return $this->_echange_hprim21; }
/** * Generate exchange HL7v3 * * @return CExchangeHL7v3 */ function generateExchange() { $exchange_hl7v3 = new CExchangeHL7v3(); $exchange_hl7v3->date_production = CMbDT::dateTime(); $exchange_hl7v3->receiver_id = $this->_receiver->_id; $exchange_hl7v3->group_id = $this->_receiver->group_id; $exchange_hl7v3->sender_id = $this->_sender ? $this->_sender->_id : null; $exchange_hl7v3->sender_class = $this->_sender ? $this->_sender->_id : null; $exchange_hl7v3->type = $this->event_type; $exchange_hl7v3->sous_type = $this->interaction_id; $exchange_hl7v3->object_id = $this->object->_id; $exchange_hl7v3->object_class = $this->object->_class; $exchange_hl7v3->store(); return $this->_exchange_hl7v3 = $exchange_hl7v3; }
/** * Check if the ressource is available or not, and set the color * * @return boolean */ function isAvailable() { $this->loadRefOperation(); $deb_op = $this->_ref_operation->_datetime_best; $fin_op = CMbDT::addDateTime($this->_ref_operation->temp_operation, $deb_op); $type_ressource = $this->loadRefTypeRessource(); $nb_ressources = $type_ressource->countBackRefs("ressources_materielles"); $_usage = $this->loadRefUsage(); $this->_color = '0a0'; // S'il y a un usage, alors on peut vérifier si conflit avec : // - un autre usage // - une indispo // - un besoin // Dans ce cas, on passe en rouge if ($_usage->_id) { $ressource = $_usage->loadRefRessource(); $_usages = $ressource->loadRefsUsages($deb_op, $fin_op); unset($_usages[$_usage->_id]); $_indispos = $ressource->loadRefsIndispos($deb_op, $fin_op); $_besoins = $ressource->loadRefsBesoins($deb_op, $fin_op); unset($_besoins[$this->_id]); if (count($_usages) + count($_indispos) + count($_besoins) >= $nb_ressources) { $this->_color = 'a00'; return 0; } return 1; } // Sinon, on parcourt les ressources associées au type de ressource du besoin. $ressources = $type_ressource->loadRefsRessources(); $_usages = 0; $_indispos = 0; $_besoins = 0; foreach ($ressources as $_ressource) { $_usages += count($_ressource->loadRefsUsages($deb_op, $fin_op)); $_indispos += count($_ressource->loadRefsIndispos($deb_op, $fin_op)); } // Pour compter les besoins, on ne le fait qu'une fois. // Car un besoin cible un type de ressource. // On décrémente d'une unité, car le besoin de la boucle est compté $_ressource = new CRessourceMaterielle(); $_ressource->type_ressource_id = $type_ressource->_id; $_besoins = count($_ressource->loadRefsBesoins($deb_op, $fin_op)) - 1; if ($_usages + $_indispos + $_besoins >= $nb_ressources) { $this->_color = 'a00'; return 0; } return 1; }
/** * store into temporary table all the data from CMbObject * Méthode effectuant tous les remplissages de la table buffer selon les CMbObject * * @param string $name_type the name of the CMbObject required * * @return string[] */ function firstIndexingStore($name_type) { $date = CMbDT::dateTime(); switch ($name_type) { case 'CCompteRendu': $queries = array("INSERT INTO `search_indexing` (`object_class`, `object_id`, `type`, `date`)\n SELECT 'CCompteRendu', `compte_rendu`.`compte_rendu_id`, 'create', '{$date}'\n FROM `compte_rendu`, `users_mediboard`, `functions_mediboard`\n WHERE `compte_rendu`.`object_id` IS NOT NULL\n AND `compte_rendu`.`object_class` != 'CPatient'\n AND `users_mediboard`.`user_id` = `compte_rendu`.`author_id`\n AND `functions_mediboard`.`function_id` = `users_mediboard`.`function_id`"); break; case 'CTransmissionMedicale': $queries = array("INSERT INTO `search_indexing` (`object_class`, `object_id`, `type`, `date`)\n SELECT 'CTransmissionMedicale', `transmission_medicale`.`transmission_medicale_id`, 'create', '{$date}'\n FROM `transmission_medicale`, `users_mediboard`, `functions_mediboard`\n WHERE `users_mediboard`.`user_id` = `transmission_medicale`.`user_id`\n AND `functions_mediboard`.`function_id` = `users_mediboard`.`function_id`"); break; case 'CObservationMedicale': $queries = array("INSERT INTO `search_indexing` (`object_class`, `object_id`, `type`, `date`)\n SELECT 'CObservationMedicale', `observation_medicale`.`observation_medicale_id`, 'create', '{$date}'\n FROM `observation_medicale`, `users_mediboard`, `functions_mediboard`\n WHERE `users_mediboard`.`user_id` = `observation_medicale`.`user_id`\n AND `functions_mediboard`.`function_id` = `users_mediboard`.`function_id`"); break; case 'CConsultation': $queries = array("INSERT INTO `search_indexing` (`object_class`, `object_id`, `type`, `date`)\n SELECT 'CConsultation', `consultation`.`consultation_id`, 'create', '{$date}'\n FROM `consultation`, `users_mediboard`, `functions_mediboard`, `plageconsult`\n WHERE `plageconsult`.`plageconsult_id` = `consultation`.`plageconsult_id`\n AND `users_mediboard`.`user_id` = `plageconsult`.`chir_id`\n AND `functions_mediboard`.`function_id` = `users_mediboard`.`function_id`"); break; case 'CConsultAnesth': $queries = array("INSERT INTO `search_indexing` (`object_class`, `object_id`, `type`, `date`)\n SELECT 'CConsultAnesth', `consultation_anesth`.`consultation_anesth_id`, 'create', '{$date}'\n FROM `consultation_anesth`, `users_mediboard`, `functions_mediboard`, `plageconsult`, `consultation`\n WHERE `consultation_anesth`.`consultation_id` = `consultation`.`consultation_id`\n AND `plageconsult`.`plageconsult_id` = `consultation`.`plageconsult_id`\n AND `users_mediboard`.`user_id` = `plageconsult`.`chir_id`\n AND `functions_mediboard`.`function_id` = `users_mediboard`.`function_id`"); break; case 'CFile': $queries = array("INSERT INTO `search_indexing` (`object_class`, `object_id`, `type`, `date`)\n SELECT 'CFile', `files_mediboard`.`file_id`, 'create', '{$date}'\n FROM `files_mediboard`\n WHERE `files_mediboard`.`object_class` IN ('CSejour', 'CConsultation', 'CConsultAnesth', 'COperation')\n AND `files_mediboard`.`file_type` NOT LIKE 'video/%'\n AND `files_mediboard`.`file_type` NOT LIKE 'audio/%'"); break; case 'CPrescriptionLineMedicament': $queries = array("INSERT INTO `search_indexing` (`object_class`, `object_id`, `type`, `date`)\n SELECT 'CPrescriptionLineMedicament', `prescription_line_medicament`.`prescription_line_medicament_id`, 'create', '{$date}'\n FROM `prescription_line_medicament`, `prescription`\n WHERE `prescription_line_medicament`.`prescription_id` = `prescription`.`prescription_id`\n AND `prescription`.`object_class` != 'CDossierMedical'\n AND `prescription`.`object_id` IS NOT NULL"); break; case 'CPrescriptionLineMix': $queries = array("INSERT INTO `search_indexing` (`object_class`, `object_id`, `type`, `date`)\n SELECT 'CPrescriptionLineMix', `prescription_line_mix`.`prescription_line_mix_id`, 'create', '{$date}'\n FROM `prescription_line_mix`, `prescription`\n WHERE `prescription_line_mix`.`prescription_id` = `prescription`.`prescription_id`\n AND `prescription`.`object_class` != 'CDossierMedical'\n AND `prescription`.`object_id` IS NOT NULL"); break; case 'CPrescriptionLineElement': $queries = array("INSERT INTO `search_indexing` (`object_class`, `object_id`, `type`, `date`)\n SELECT 'CPrescriptionLineElement', `prescription_line_element`.`prescription_line_element_id`, 'create', '{$date}'\n FROM `prescription_line_element`, `prescription`\n WHERE `prescription_line_element`.`prescription_id` = `prescription`.`prescription_id`\n AND `prescription`.`object_class` != 'CDossierMedical'\n AND `prescription`.`object_id` IS NOT NULL"); break; case 'CExObject': $ds = $this->getDS(); $ex_classes_ids = $ds->loadColumn("SELECT ex_class_id FROM ex_class"); $queries = array(); foreach ($ex_classes_ids as $_ex_class_id) { $queries[] = "INSERT INTO `search_indexing` (`object_class`, `object_id`, `type`, `date`)\n SELECT 'CExObject_{$_ex_class_id}', `ex_object_id`, 'create', '{$date}'\n FROM `ex_object_{$_ex_class_id}`"; } break; case 'COperation': $queries = array("INSERT INTO `search_indexing` (`object_class`, `object_id`, `type`, `date`)\n SELECT 'COperation', `operations`.`operation_id`, 'create', '{$date}'\n FROM `operations`, `users_mediboard`, `functions_mediboard`\n WHERE `users_mediboard`.`user_id` = `operations`.`chir_id`\n AND `functions_mediboard`.`function_id` = `users_mediboard`.`function_id`"); break; default: $queries = array(); } // on retourne un tableau à cause des formulaires. return $queries; }
/** * 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; }