/** * logSejourAccess * * @param CSejour $sejour * * @return bool has the access been logged */ static function logForSejour($sejour) { $group = $sejour->loadRefEtablissement(); if (!CAppUI::conf("admin CLogAccessMedicalData enable_log_access", $group) || !$sejour->_id) { return false; } $user = CMediusers::get(); $conf = CAppUI::conf("admin CLogAccessMedicalData round_datetime", $group); $datetime = CMbDT::dateTime(); switch ($conf) { case '1m': // minute $datetime = CMbDT::format($datetime, "%y-%m-%d %H:%M:00"); break; case '10m': // 10 minutes $minute = CMbDT::format($datetime, "%M"); $minute = str_pad(floor($minute / 10) * 10, 2, 0, STR_PAD_RIGHT); $datetime = CMbDT::format($datetime, "%y-%m-%d %H:{$minute}:00"); break; case '1d': // 1 day $datetime = CMbDT::format($datetime, "%y-%m-%d 00:00:00"); break; default: // 1 hour $datetime = CMbDT::format($datetime, "%y-%m-%d %H:00:00"); break; } return self::logintoDb($user->_id, $sejour->_class, $sejour->_id, $datetime, $group->_id); }
/** * check if we can access to the view following the configuration and already granted. * * @param CSejour $sejour sejour object * * @return bool */ static function canAccess($sejour) { $group = $sejour->loadRefEtablissement(); $user = CMediusers::get(); //check for config and elements if (!$sejour->_id || !CAppUI::conf("admin CBrisDeGlace enable_bris_de_glace", $group) || $sejour->praticien_id == $user->_id || !$user->use_bris_de_glace) { return true; } $today = CMbDT::date(); $bris = new self(); $where = array(); $where["date"] = " BETWEEN '{$today} 00:00:00' AND '{$today} 23:59:59'"; $where["object_class"] = " = 'CSejour'"; $where["object_id"] = " = '{$sejour->_id}'"; $where["user_id"] = " = '{$user->_id}'"; // no need of bris de glace if ($bris->countList($where)) { return true; } return false; }
/** * Get PL : person location * * @param CInteropReceiver $receiver Receiver * @param CSejour $sejour Admit * @param CAffectation $affectation Affectation * * @return array */ function getPL(CInteropReceiver $receiver, CSejour $sejour, CAffectation $affectation = null) { $group = $sejour->loadRefEtablissement(); $default_name = null; if ($receiver && $receiver->_id && isset($receiver->_configs)) { $default_name = $receiver->_configs["build_PV1_3_1_default"]; } if (!$affectation) { // Chargement de l'affectation courante $affectation = $sejour->getCurrAffectation(); // Si on n'a pas d'affectation on va essayer de chercher la première if (!$affectation->_id) { $affectation = $sejour->loadRefFirstAffectation(); } } $affectation->loadRefLit()->loadRefChambre(); $current_uf = $sejour->getUFs(null, $affectation->_id); $name = null; if ($receiver && $receiver->_id && isset($receiver->_configs)) { switch ($receiver->_configs["build_PV1_3_1"]) { case "UF": $name = $current_uf["hebergement"]->code; break; case "service": if ($affectation->_id) { $name = $affectation->loadRefService()->nom; } if (!$name) { $name = $sejour->loadRefService()->nom; } break; default: } } $pl1 = $name ? $name : $default_name; return array(array($pl1, $this->getPL2($receiver, $affectation), $this->getPL3($receiver, $affectation), $this->getGroupAssigningAuthority($sejour->loadRefEtablissement()), $this->getPL5($receiver), null, CHL7v2TableEntry::mapTo("307", $group->_id))); }