public function testPluck() { $this->assertNull($this->stub->pluck(null, "")); $array = array("key" => array("key2" => "val", "key3" => array("key4" => "val"))); $this->assertEquals(array("key" => "val"), $this->stub->pluck($array, "key2")); $array = array('key' => (object) array("property" => 1), 'key2' => (object) array("property" => 2)); $this->assertEquals(array("key" => 1, "key2" => 2), $this->stub->pluck($array, "property")); }
/** * Delete content and update exchange * * @param CContentTabular $content_tabular Content tabular * @param int $type_content_id Content ID * @param date $date_max Date max * @param int $max Max exchange * * @return int */ function deleteContentAndUpdateExchange(CContentTabular $content_tabular, $type_content_id, $date_max, $max) { $ds = $content_tabular->_spec->ds; // Récupère les content Tabulé $query = "SELECT cx.content_id\r\n FROM content_tabular AS cx, exchange_hl7v2 AS ec\r\n WHERE ec.`date_production` < '{$date_max}'\r\n AND ec.{$type_content_id} = cx.content_id\r\n LIMIT {$max};"; $ids = CMbArray::pluck($ds->loadList($query), "content_id"); // Suppression du contenu Tabulé $query = "DELETE FROM content_tabular\r\n WHERE content_id " . CSQLDataSource::prepareIn($ids); $ds->exec($query); // Mise à jour des échanges $query = "UPDATE exchange_hl7v2\r\n SET `{$type_content_id}` = NULL \r\n WHERE `{$type_content_id}` " . CSQLDataSource::prepareIn($ids); $ds->exec($query); $count = $ds->affectedRows(); return $count; }
/** * Load all salutation from a given class * * @param string $object_class Target object class * @param integer|null $object_id Target object ID * @param int $perm Permission needed on owners * @param integer|null $owner_id Specific owner ID * * @return CSalutation[] */ static function loadAllSalutations($object_class, $object_id = null, $perm = PERM_EDIT, $owner_id = null) { if (!$owner_id) { $users = new CMediusers(); $users = $users->loadListWithPerms($perm, array('actif' => "= '1'")); $user_ids = $users ? CMbArray::pluck($users, '_id') : array(CMediusers::get()->_id); unset($users); } else { $user_ids = array($owner_id); } /** @var CSalutation $salutation */ $salutation = new self(); $ds = $salutation->_spec->ds; $where = array('owner_id' => $ds->prepareIn($user_ids), 'object_class' => $ds->prepare('= ?', $object_class)); if ($object_id) { $where['object_id'] = $ds->prepare('= ?', $object_id); } return $salutation->loadList($where); }
function doStore() { parent::doStore(); if (CModule::getActive("dPprescription") && !$this->_old->_id) { $p_to_c = new CPrescriptionProtocoleToConcept(); $count_p_to_c = $p_to_c->countList(); if ($count_p_to_c > 0) { /** @var CExObject $ex_object */ $ex_object = $this->_obj; $all_fields = $ex_object->loadRefExClass()->loadRefsAllFields(); $bool_concept_ids = array(); foreach ($all_fields as $_field) { if (strpos($_field->prop, "bool") === 0 && $_field->concept_id && $ex_object->{$_field->name} == "1") { $bool_concept_ids[] = $_field->concept_id; } } $bool_concept_ids = array_unique($bool_concept_ids); $where = array("concept_id" => $p_to_c->getDS()->prepareIn($bool_concept_ids)); $protocole_ids = array_values(CMbArray::pluck($p_to_c->loadList($where), "protocole_id")); if (count($protocole_ids)) { /** @var CSejour $sejour */ $sejour = $ex_object->getReferenceObject("CSejour"); if ($sejour && $sejour->_id) { $prescription = $sejour->loadRefPrescriptionSejour(); if (!$prescription->_id) { $prescription = new CPrescription(); $prescription->object_id = $sejour->_id; $prescription->object_class = $sejour->_class; $prescription->type = "sejour"; if ($msg = $prescription->store()) { CAppUI::setMsg($msg, UI_MSG_WARNING); } } $ops_ids = implode("-", CMbArray::pluck($sejour->loadRefsOperations(array("annulee" => "= '0'")), "operation_id")); CAppUI::callbackAjax("window.opener.ExObject.checkOpsBeforeProtocole", $protocole_ids, $prescription->_id, $sejour->_id, $ops_ids); } } } } }
CMbObject::massCountBackRefs($_plage->_ref_operations, 'actes_ccam'); $sejours = CMbObject::massLoadFwdRef($_plage->_ref_operations, "sejour_id"); CMbObject::massLoadFwdRef($sejours, "patient_id"); foreach ($_plage->_ref_operations as $_op) { $_op->loadRefsFwd(); $_sejour = $_op->_ref_sejour; $_op->countDocItems(); $_op->canDo(); $_op->loadRefCommande(); $_sejour->canDo(); $_sejour->loadRefsFwd(); $_sejour->_ref_patient->loadRefDossierMedical()->countAllergies(); $_sejour->countDocItems(); /* Comptage du nombre d'activités CCAM */ $_op->_count['codes_ccam'] = 0; foreach (CMbArray::pluck($_op->_ext_codes_ccam, "activites") as $_code) { $_op->_count['codes_ccam'] += count($_code); } $presc = $_sejour->loadRefPrescriptionSejour(); if ($presc && $presc->_id) { $presc->countLinesMedsElements($userSel->_id); } foreach ($_sejour->_ref_documents as $_doc) { $_doc->canDo(); } } } } // Praticien concerné $user = CMediusers::get(); if ($user->isPraticien()) {
foreach ($no_extid as $_object) { $_object->_disabled = true; } $_selected = reset($extid); } } } // Selected object IS selected (!) $_selected->_selected = true; // Check merge /** @var CMbObject $result */ $result = new $objects_class(); $checkMerge = $result->checkMerge($objects); // Merge trivial fields foreach (array_keys($result->getPlainFields()) as $field) { $values = CMbArray::pluck($objects, $field); CMbArray::removeValue("", $values); // No values if (!count($values)) { $statuses[$field] = "none"; continue; } $result->{$field} = reset($values); // One unique value if (count($values) == 1) { $statuses[$field] = "unique"; continue; } // Multiple values $statuses[$field] = count(array_unique($values)) == 1 ? "duplicate" : "multiple"; }
/** * Load trigger data * * @return void */ function loadTriggeredData() { $triggers = $this->loadBackRefs("ex_triggers"); $this->_triggered_data = array(); if (!count($triggers)) { return; } $keys = CMbArray::pluck($triggers, "trigger_value"); $values = CMbArray::pluck($triggers, "ex_class_triggered_id"); $this->_triggered_data = array_combine($keys, $values); }
/** * Get categories tree * * @param bool $operation see operations * * @return array */ static function getCategoriesTree($operation = false) { $object = new self(); $target_classes = CDailyCheckList::getNonHASClasses($operation); $targets = array(); $by_class = array(); foreach ($target_classes as $_class) { if ($_class != "COperation") { /** @var CSalle|CBlocOperatoire $_object */ $_object = new $_class(); //$_targets = $_object->loadGroupList(); $_targets = $_object->loadList(); array_unshift($_targets, $_object); $targets[$_class] = array_combine(CMbArray::pluck($_targets, "_id"), $_targets); } $where = array("target_class" => "= '{$_class}'"); if ($_class == "COperation") { $where["list_type_id"] = ' IS NOT NULL'; } /** @var CDailyCheckItemCategory[] $_list */ $_list = $object->loadList($where, "target_id+0, title"); // target_id+0 to have NULL at the beginning $by_object = array(); foreach ($_list as $_category) { $_key = $_category->target_id ? $_category->target_id : "all"; $by_object[$_key][$_category->_id] = $_category; } $by_class[$_class] = $by_object; } return array($targets, $by_class); }
if (null == ($object_class = CValue::get("object_class"))) { CAppUI::stepMessage(UI_MSG_WARNING, "{$tab}-msg-mode-missing"); return; } $unlock_dossier = CValue::get("unlock_dossier", 0); $NDA = ""; $IPP = ""; switch ($object_class) { case "COperation": $object = new COperation(); // Chargement de l'opération et génération du document $operation_id = CValue::post("mb_operation_id", CValue::getOrSession("object_id")); if ($object->load($operation_id)) { $object->loadRefs(); $codes = explode("|", $object->codes_ccam); $actes = CMbArray::pluck($object->_ref_actes_ccam, "code_acte"); foreach ($object->_ref_actes_ccam as $acte_ccam) { $acte_ccam->loadRefsFwd(); } // Suppression des actes non codés if (CAppUI::conf("dPsalleOp CActeCCAM del_actes_non_cotes")) { foreach ($codes as $_key => $_code) { $key = array_search($_code, $actes); if ($key === false) { unset($codes[$_key]); } } } $object->_codes_ccam = $codes; $mbSejour =& $object->_ref_sejour; $mbSejour->loadRefsFwd();
$where["sejour.praticien_id"] = "= '{$chirSel}'"; } $where["sejour.entree"] = "<= '{$date} 23:59:59'"; $where["sejour.sortie"] = ">= '{$date} 00:00:00'"; $where["sejour.annule"] = "= '0'"; $where["sejour.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'"; $sejour = new CSejour(); /** @var CSejour[] $listSejours */ $listSejours = $sejour->loadList($where, null, null, null, $ljoin); CStoredObject::massLoadFwdRef($listSejours, "patient_id"); foreach ($listSejours as $_sejour) { $_sejour->loadRefPraticien(); $_sejour->loadRefPatient(); $_sejour->loadRefsOperations(); $_sejour->loadRefCurrAffectation("{$date} " . CMbDT::time()); $_sejour->_ref_curr_affectation->loadRefLit(); $_sejour->_ref_curr_affectation->_ref_lit->loadCompleteView(); } $lits = CMbArray::pluck($listSejours, "_ref_curr_affectation", "_ref_lit"); $sorter_chambre = CMbArray::pluck($lits, "_ref_chambre", "_view"); $sorter_service = CMbArray::pluck($lits, "_ref_chambre", "_ref_service", "_view"); $sorter_lit = CMbArray::pluck($lits, "_view"); $sorter_sejour_sortie = CMbArray::pluck($listSejours, "sortie"); $sorter_sejour_entree = CMbArray::pluck($listSejours, "entree"); array_multisort($sorter_service, SORT_ASC, $sorter_chambre, SORT_ASC, $sorter_lit, SORT_ASC, $sorter_sejour_sortie, SORT_ASC, $sorter_sejour_entree, SORT_DESC, $listSejours); // Création du template $smarty = new CSmartyDP(); $smarty->assign("date", $date); $smarty->assign("praticien", $praticien); $smarty->assign("listSejours", $listSejours); $smarty->display("inc_vw_hospi.tpl");
$smarty->assign("date", $date); $smarty->assign("listPrat", $listPrat); $smarty->assign("listInterv", $listInterv); $smarty->assign("services", $services); $smarty->assign("selPrat", $selPrat); $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);
public function lists($column, $key = null) { $columns = is_null($key) ? array($column) : array($column, $key); // First we will just get all of the column values for the record result set // then we can associate those values with the column if it was specified // otherwise we can just give these values back without a specific key. $results = $this->get($columns); $values = CMbArray::pluck($results, $column); // If a key was specified and we have results, we will go ahead and combine // the values with the keys of all of the records so that the values can // be accessed by the key of the rows instead of simply being numeric. if (!is_null($key) and count($results) > 0) { return array_combine(CMbArray::pluck($results, $key), $values); } return $values; }
/** * used for decoding a multi mime string into one line * * @param string $string decode mime string * * @return string */ private function flatMimeDecode($string) { $parts = imap_mime_header_decode($string); $str = implode("", CMbArray::pluck($parts, "text")); if (strpos($string, 'UTF-8') !== false) { $str = utf8_decode($str); } return addslashes($str); }
if ($mode == "count" || $mode == "plannable") { if (!CModule::getActive("dPprescription")) { $counts["plannable"] = null; $sejours = array(); } else { // Séjours élligibles $where = array(); $where["sejour.type"] = "= 'ssr'"; $where["sejour.entree"] = "<= '{$planning->date_max}'"; $where["sejour.sortie"] = ">= '{$planning->date_min}'"; $where["sejour.annule"] = "= '0'"; $sejour_ids = $sejour->loadIds($where); // Identifiants de catégorie de prescriptions disponibles $function = $mediuser->loadRefFunction(); $executants = $function->loadBackRefs("executants_prescription"); $category_ids = CMbArray::pluck($executants, "category_prescription_id"); // Recherche des lignes de prescriptions executables $line = new CPrescriptionLineElement(); $join = array(); $where = array(); $join["element_prescription"] = "element_prescription.element_prescription_id = prescription_line_element.element_prescription_id"; $where["element_prescription.category_prescription_id"] = $ds->prepareIn($category_ids); $join["prescription"] = "prescription.prescription_id = prescription_line_element.prescription_id"; $where["prescription.type"] = "= 'sejour'"; $where["prescription.object_class"] = "= 'CSejour'"; $where["prescription.object_id"] = $ds->prepareIn($sejour_ids); $line_ids = $line->loadIds($where, null, null, null, $join); // Prescriptions exécutables $query = new CRequest(); $query->addSelect("DISTINCT prescription_id"); $query->addTable("prescription_line_element");
/** * Get a marked where clause * * @return string SQL where clause */ function getNewMarkedClause($marked, $max = 100) { $mark = new CTriggerMark(); $mark->trigger_class = get_class($this); if ($marked) { $where["trigger_class"] = "= '{$mark->trigger_class}'"; $where["done"] = "= '0'"; $where["mark"] = "!= '========'"; $marks = $mark->loadList($where, null, $max); $clause = "\n WHERE {$this->trigger_key_field} " . CSQLDataSource::prepareIn(CMbArray::pluck($marks, "trigger_number")); } else { $mark->loadMatchingObject("trigger_number DESC"); $last_number = $mark->trigger_number ? $mark->trigger_number : 0; $clause = "\n WHERE {$this->trigger_key_field} > '{$last_number}'"; } return $clause; }
$where = array("user_id" => CSQLDataSource::prepareIn(CMbArray::pluck($_sejours, "praticien_id"))); $users = $user->loadList($where); $praticiens = CStoredObject::massLoadFwdRef($_sejours, "praticien_id"); CStoredObject::massLoadFwdRef($praticiens, "function_id"); CStoredObject::massCountBackRefs($affectations, "affectations_enfant"); $_operations = CStoredObject::massLoadBackRefs($sejours, "operations", "date ASC"); CStoredObject::massLoadFwdRef($_operations, "plageop_id"); loadVueTempo($sejours, $suivi_affectation, null, $operations, $date_min, $date_max, $period, $prestation_id, $functions_filter, $filter_function, $sejours_non_affectes); if (CAppUI::conf("dPadmissions show_deficience")) { CStoredObject::massLoadBackRefs($patients, "dossier_medical"); $dossiers = CMbArray::pluck($sejours, "_ref_patient", "_ref_dossier_medical"); CDossierMedical::massCountAntecedentsByType($dossiers, "deficience"); } loadVueTempo($affectations, $suivi_affectation, null, $operations, $date_min, $date_max, $period, $prestation_id, $functions_filter, $filter_function, $sejours_non_affectes); if (count($affectations) && CAppUI::conf("dPadmissions show_deficience")) { $dossiers = CMbArray::pluck($affectations, "_ref_sejour", "_ref_patient", "_ref_dossier_medical"); CDossierMedical::massCountAntecedentsByType($dossiers, "deficience"); } ksort($sejours_non_affectes, SORT_STRING); $_sejour = new CSejour(); $_sejour->_type_admission = $_type_admission; $smarty = new CSmartyDP(); $smarty->assign("sejours_non_affectes", $sejours_non_affectes); $smarty->assign("_sejour", $_sejour); $smarty->assign("triAdm", $triAdm); $smarty->assign("functions_filter", $functions_filter); $smarty->assign("filter_function", $filter_function); $smarty->assign("granularite", $granularite); $smarty->assign("date", $date); $smarty->assign("date_min", $date_min); $smarty->assign("date_max", $date_max);
$patients_count = CPatientState::getAllNumberPatient($date_min, $date_max); if ($patients_count[$state] > 0) { /** @var CPatient[] $patients */ $where["status"] = " = '{$state}'"; if ($state != "vali") { $where["vip"] = "= '0'"; } if ($state == "cach") { $where["vip"] = "= '1'"; $where["status"] = "!= 'VALI'"; } if ($state == "dpot") { $patient_link = new CPatientLink(); $patient_links = $patient_link->loadList(null, null, "{$page}, 30"); $patient_ids1 = CMbArray::pluck($patient_links, "patient_id1"); $patient_ids2 = CMbArray::pluck($patient_links, "patient_id2"); $where = array("patient_id" => CSQLDataSource::prepareIn(array_merge($patient_ids1, $patient_ids2))); $patients = $patient->loadList($where); } else { $patients = $patient->loadList($where, "nom, prenom", "{$page}, 30", null, $leftjoin); } CPatient::massLoadIPP($patients); /** @var CPatientState $patients_state */ $patients_state = CPatient::massLoadBackRefs($patients, "patient_state", "datetime DESC"); $mediusers = CPatientState::massLoadFwdRef($patients_state, "mediuser_id"); /** @var CPatientLink[] $link1 */ $link1 = CPatient::massLoadBackRefs($patients, "patient_link1"); /** @var CPatientLink[] $link2 */ $link2 = CPatient::massLoadBackRefs($patients, "patient_link2"); $patient_link1 = CPatientLink::massLoadFwdRef($link1, "patient_id2"); $patient_link2 = CPatientLink::massLoadFwdRef($link2, "patient_id1");
$listAnesths = new CMediusers(); $listAnesths = $listAnesths->loadAnesthesistes(PERM_DENY); $listChirs = new CMediusers(); $listChirs = $listChirs->loadPraticiens(PERM_DENY); $type_personnel = array("op", "op_panseuse", "iade", "sagefemme", "manipulateur"); if (count($daily_check_list_types) && $require_check_list) { $type_personnel = array(); foreach ($daily_check_list_types as $check_list_type) { $validateurs = explode("|", $check_list_type->type_validateur); foreach ($validateurs as $validateur) { $type_personnel[] = $validateur; } } } $listValidateurs = CPersonnel::loadListPers(array_unique(array_values($type_personnel)), true, true); $operateurs_disp_vasc = implode("-", array_merge(CMbArray::pluck($listChirs, "_id"), CMbArray::pluck($listValidateurs, "user_id"))); $nb_op_no_close = 0; if ($type == "fermeture_salle") { $salle->loadRefsForDay($date); // Calcul du nombre d'actes codé dans les interventions if ($salle->_ref_plages) { foreach ($salle->_ref_plages as $_plage) { foreach ($_plage->_ref_operations as $_operation) { if (!$_operation->sortie_salle && !$_operation->annulee) { $nb_op_no_close++; } } foreach ($_plage->_unordered_operations as $_operation) { if (!$_operation->sortie_salle && !$_operation->annulee) { $nb_op_no_close++; }
CStoredObject::massLoadBackRefs($consultations, "actes_ccam"); foreach ($consultations as $key => $_consult) { // Chargemement des codes CCAM $_consult->loadExtCodesCCAM(); $codes_ccam = $_consult->_ext_codes_ccam; // Nombre d'acte cotés par le praticien et réinitialisation du count pour le cache $nb_actes_ccam = count($_consult->loadRefsActesCCAM()); // Aucun acte prévu ou coté if (!count($codes_ccam) && !$_consult->_count_actes) { $_consult->loadRefSejour(); $_consult->loadRefPraticien()->loadRefFunction(); $_consult->loadRefPatient(); continue; } // Actes prévus restant en suspend $activites = CMbArray::pluck($codes_ccam, "activites"); $nbCodes = 0; foreach ($activites as $_activite) { if ($all_prats) { $nbCodes += count($_activite); continue; } foreach ($_activite as $_key_activite => $_type_activite) { if ($user->_is_anesth && $_key_activite == 4) { $nbCodes++; } if (!$user->_is_anesth && $_key_activite != 4) { $nbCodes++; } } }
/** * Mass load mechanism for forward references of an object collection * * @param self[] $objects Array of objects * @param string $field Field to load * @param string $object_class Restrict to explicit object class in case of meta reference * @param bool $keep_sorted Keep the same order as the one in $objects * * @return self[] Loaded collection, null if unavailable, with ids as keys of guids for meta references */ static function massLoadFwdRef($objects, $field, $object_class = null, $keep_sorted = false) { if (!count($objects)) { return array(); } $object = reset($objects); $spec = $object->_specs[$field]; if (!$spec instanceof CRefSpec) { trigger_error("Can't mass load not ref '{$field}' for class '{$object->_class}'", E_USER_WARNING); return null; } $meta = $spec->meta; if ($object_class && !$spec->meta) { trigger_error("Mass load with object class is unavailable for non meta ref '{$field}' in class '{$object->_class}'", E_USER_WARNING); return null; } // Delegated mass load forward references by meta class then append in global array with guid as keys if ($meta && !$object_class) { $object_classes = array(); foreach ($objects as $_object) { $object_classes[$_object->{$meta}] = true; } $fwd_objects = array(); foreach (array_keys($object_classes) as $_object_class) { // Merge array_values to get rid of non integer keys $fwd_objects = array_merge($fwd_objects, array_values(self::massLoadFwdRef($objects, $field, $_object_class))); } // Final array has guids for keys; return array_combine(CMbArray::pluck($fwd_objects, "_guid"), $fwd_objects); } // No existing class if (!self::classExists($spec->class)) { return null; } /** @var self $fwd */ $class = CValue::first($object_class, $spec->class); $fwd = self::getInstance($class); // Inactive module if (!$fwd->_ref_module) { return null; } // Get the ids $fwd_ids = array(); if ($object_class) { foreach ($objects as $_object) { if ($_object->{$meta} == $object_class) { $fwd_ids[] = $_object->{$field}; } } } else { $fwd_ids = CMbArray::pluck($objects, $field); } // Trim real ids $fwd_ids = array_unique($fwd_ids); CMbArray::removeValue("", $fwd_ids); // Only run when there's something to look for if (!count($fwd_ids)) { return array(); } $where[$fwd->_spec->key] = CSQLDataSource::prepareIn($fwd_ids); $list = $fwd->loadList($where); if (!$keep_sorted) { return $list; } $list_sorted = array(); foreach ($fwd_ids as $_fwd_id) { $list_sorted[$_fwd_id] = $list[$_fwd_id]; } return $list_sorted; }
/** * Get the object's tags * * @param bool $cache Use cache * * @return array */ function getTags($cache = true) { $tag_items = $this->loadRefsTagItems($cache); return CMbArray::pluck($tag_items, "_ref_tag"); }
foreach ($wheres as $_i => $_where) { $where[0] = $_where; // Pour ne pas afficher les prescriptions en double (== group by prescription_id) if (count($keys)) { $where["prescription.prescription_id"] = $prescription->_spec->ds->prepareNotIn($keys); } $ljoin[$leftjoins[$_i][0]] = $leftjoins[$_i][1]; $_prescriptions = $prescription->loadList($where, null, null, "prescription_id", $ljoin); $keys = array_merge($keys, array_keys($_prescriptions)); $prescriptions = array_merge($prescriptions, $_prescriptions); $ljoin = $ljoin_save; } foreach ($prescriptions as $_presc) { $_presc->_ref_object->loadRefPatient(); } array_multisort(CMbArray::pluck($prescriptions, "_ref_object", "_ref_patient", "nom"), SORT_ASC, $prescriptions); } else { $prescriptions = $prescription->loadList($where, "patients.nom", null, "prescription_id", $ljoin); } if ($type_prescription == "sortie_manquante") { foreach ($prescriptions as $_prescription) { // Recherche d'une prescription de sortie correspondant à la prescription de sejour $_prescription_sortie = new CPrescription(); $_prescription_sortie->type = "sortie"; $_prescription_sortie->object_id = $_prescription->object_id; $_prescription_sortie->object_class = $_prescription->object_class; $_prescription_sortie->loadMatchingObject(); if ($_prescription_sortie->_id) { unset($prescriptions[$_prescription->_id]); } }
function fillLimitedTemplate(&$template) { CDestinataire::makeAllFor($this); $destinataires = CDestinataire::$destByClass; foreach ($destinataires as $_destinataires_by_class) { foreach ($_destinataires_by_class as $_destinataire) { if (!isset($_destinataire->nom) || strlen($_destinataire->nom) == 0 || $_destinataire->nom === " ") { continue; } $template->destinataires[] = array("nom" => $_destinataire->nom, "email" => $_destinataire->email, "tag" => $_destinataire->tag); } } $this->loadRefsFwd(); $this->loadRefLatestConstantes(null, array(), null, false); $this->loadIPP(); $this->loadLastINS(); $this->notify("BeforeFillLimitedTemplate", $template); $template->addProperty("Patient - article", $this->_civilite); $template->addProperty("Patient - article long", ucfirst($this->_civilite_long)); $template->addProperty("Patient - article long (minuscule)", strtolower($this->_civilite_long)); $template->addProperty("Patient - nom", $this->nom); $template->addProperty("Patient - nom jeune fille", $this->nom_jeune_fille); $template->addProperty("Patient - prénom", $this->prenom); $template->addProperty("Patient - adresse", $this->adresse); $template->addProperty("Patient - ville", $this->ville); $template->addProperty("Patient - cp", $this->cp); $template->addProperty("Patient - années", $this->_annees); $template->addProperty("Patient - âge", $this->_age); $template->addProperty("Patient - date de naissance", $this->getFormattedValue("naissance")); $template->addProperty("Patient - lieu de naissance", $this->lieu_naissance); $template->addProperty("Patient - sexe", strtolower($this->getFormattedValue("sexe"))); $template->addProperty("Patient - sexe court", substr(strtolower($this->getFormattedValue("sexe")), 0, 1)); $template->addProperty("Patient - numéro d'assuré", $this->getFormattedValue("matricule")); $template->addProperty("Patient - téléphone", $this->getFormattedValue("tel")); $template->addProperty("Patient - mobile", $this->getFormattedValue("tel2")); $template->addProperty("Patient - téléphone autre", $this->tel_autre); $template->addProperty("Patient - profession", $this->profession); $template->addProperty("Patient - IPP", $this->_IPP); $template->addProperty("Patient - Qualité bénéficiaire", $this->qual_beneficiaire); $this->guessExoneration(); $template->addProperty("Patient - Qualité bénéficiaire - Libellé", $this->libelle_exo); $template->addProperty("Patient - Numéro de sécurité sociale", $this->getFormattedValue("matricule")); $template->addBarcode("Patient - Code barre ID", $this->_id); $template->addBarcode("Patient - Code barre IPP", $this->_IPP); $template->addBarcode("Patient - Code barre INS", $this->_ref_last_ins ? $this->_ref_last_ins->ins : ""); if ($this->sexe === "m") { $template->addProperty("Patient - il/elle", "il"); $template->addProperty("Patient - Il/Elle (majuscule)", "Il"); $template->addProperty("Patient - le/la", "le"); $template->addProperty("Patient - Le/La (majuscule)", "Le"); $template->addProperty("Patient - du/de la", "du"); $template->addProperty("Patient - au/à la", "au"); $template->addProperty("Patient - accord genre", ""); } else { $template->addProperty("Patient - il/elle", "elle"); $template->addProperty("Patient - Il/Elle (majuscule)", "Elle"); $template->addProperty("Patient - le/la", "la"); $template->addProperty("Patient - Le/La (majuscule)", "La"); $template->addProperty("Patient - du/de la", "de la"); $template->addProperty("Patient - au/à la", "à la"); $template->addProperty("Patient - accord genre", "e"); } $medecin = $this->_ref_medecin_traitant->_id ? $this->_ref_medecin_traitant : new CMedecin(); $template->addProperty("Patient - médecin traitant", "{$medecin->nom} {$medecin->prenom}"); $template->addProperty("Patient - médecin traitant - Nom Prénom", "{$medecin->nom} {$medecin->prenom}"); $template->addProperty("Patient - médecin traitant - nom", $medecin->nom); $template->addProperty("Patient - médecin traitant - prenom", $medecin->prenom); $template->addProperty("Patient - médecin traitant - adresse", "{$medecin->adresse} \n {$medecin->cp} {$medecin->ville}"); $template->addProperty("Patient - médecin traitant - voie", $medecin->adresse); $template->addProperty("Patient - médecin traitant - cp", $medecin->cp); $template->addProperty("Patient - médecin traitant - ville", $medecin->ville); $template->addProperty("Patient - médecin traitant - confraternité", $medecin->_confraternite); $template->addProperty("Patient - médecin traitant - tel", $medecin->getFormattedValue("tel")); $template->addProperty("Patient - médecin traitant - fax", $medecin->getFormattedValue("fax")); if ($medecin->sexe == "f") { $template->addProperty("Patient - médecin traitant - accord genre", "e"); $template->addProperty("Patient - médecin traitant - article long", "Mme le docteur"); } elseif ($medecin->sexe == "m") { $template->addProperty("Patient - médecin traitant - accord genre", ""); $template->addProperty("Patient - médecin traitant - article long", "Mr le docteur"); } else { $template->addProperty("Patient - médecin traitant - accord genre", ""); $template->addProperty("Patient - médecin traitant - article long", "le docteur"); } // Employeur $this->loadRefsCorrespondantsPatient(); $correspondants = $this->_ref_cp_by_relation; foreach ($correspondants as $relation => $_correspondants) { $_correspondant = @reset($_correspondants); // Dans le cas d'un modèle, création d'un correspondant pour chaque type de relation if (!count($_correspondants)) { $_correspondant = new CCorrespondantPatient(); $_correspondant->relation = $relation; } switch ($_correspondant->relation) { case "employeur": $template->addProperty("Patient - employeur - nom", $_correspondant->nom); $template->addProperty("Patient - employeur - adresse", $_correspondant->adresse); $template->addProperty("Patient - employeur - cp", $_correspondant->cp); $template->addProperty("Patient - employeur - ville", $_correspondant->ville); $template->addProperty("Patient - employeur - tel", $_correspondant->getFormattedValue("tel")); $template->addProperty("Patient - employeur - mobile", $_correspondant->getFormattedValue("mob")); $template->addProperty("Patient - employeur - urssaf", $_correspondant->urssaf); break; case "prevenir": $template->addProperty("Patient - prévenir - nom", $_correspondant->nom); $template->addProperty("Patient - prévenir - prénom", $_correspondant->prenom); $template->addProperty("Patient - prévenir - adresse", $_correspondant->adresse); $template->addProperty("Patient - prévenir - cp", $_correspondant->cp); $template->addProperty("Patient - prévenir - ville", $_correspondant->ville); $template->addProperty("Patient - prévenir - tel", $_correspondant->getFormattedValue("tel")); $template->addProperty("Patient - prévenir - mobile", $_correspondant->getFormattedValue("mob")); $template->addProperty("Patient - prévenir - parente", $_correspondant->parente); break; case "confiance": $template->addProperty("Patient - confiance - nom", $_correspondant->nom); $template->addProperty("Patient - confiance - nom de jeune fille", $_correspondant->nom_jeune_fille); $template->addProperty("Patient - confiance - prénom", $_correspondant->prenom); $template->addProperty("Patient - confiance - date de naissance", $_correspondant->getFormattedValue("naissance")); $template->addProperty("Patient - confiance - adresse", $_correspondant->adresse); $template->addProperty("Patient - confiance - cp", $_correspondant->cp); $template->addProperty("Patient - confiance - ville", $_correspondant->ville); $template->addProperty("Patient - confiance - tel", $_correspondant->getFormattedValue("tel")); $template->addProperty("Patient - confiance - mobile", $_correspondant->getFormattedValue("mob")); $template->addProperty("Patient - confiance - parente", $_correspondant->parente); } } // Vider les anciens holders for ($i = 1; $i < 4; $i++) { $template->addProperty("Patient - médecin correspondant {$i}"); $template->addProperty("Patient - médecin correspondant {$i} - adresse"); $template->addProperty("Patient - médecin correspondant {$i} - spécialité"); } $this->loadRefsCorrespondants(); $i = 0; $noms = array(); foreach ($this->_ref_medecins_correspondants as $corresp) { $i++; $corresp->loadRefsFwd(); $medecin = $corresp->_ref_medecin; $nom = "{$medecin->nom} {$medecin->prenom}"; $noms[] = $nom; $template->addProperty("Patient - médecin correspondant {$i}", $nom); $template->addProperty("Patient - médecin correspondant {$i} - adresse", "{$medecin->adresse}\n{$medecin->cp} {$medecin->ville}"); $template->addProperty("Patient - médecin correspondant {$i} - spécialité", CMbString::htmlEntities($medecin->disciplines)); } $template->addProperty("Patient - médecins correspondants", implode(" - ", $noms)); //Liste des séjours du patient $this->loadRefsSejours(); if (is_array($this->_ref_sejours)) { foreach ($this->_ref_sejours as $_sejour) { $_sejour->loadRefPraticien(); } $smarty = new CSmartyDP("modules/dPpatients"); $smarty->assign("sejours", $this->_ref_sejours); $sejours = $smarty->fetch("print_closed_sejours.tpl", '', '', 0); $sejours = preg_replace('`([\\n\\r])`', '', $sejours); } else { $sejours = CAppUI::tr("CSejour.none"); } $template->addProperty("Patient - liste des séjours", $sejours, '', false); $const_med = $this->_ref_constantes_medicales; $const_dates = $this->_latest_constantes_dates; $grid_complet = CConstantesMedicales::buildGridLatest($const_med, $const_dates, true); $grid_minimal = CConstantesMedicales::buildGridLatest($const_med, $const_dates, false); $grid_valued = CConstantesMedicales::buildGridLatest($const_med, $const_dates, false, true); $smarty = new CSmartyDP("modules/dPpatients"); // Horizontal $smarty->assign("constantes_medicales_grid", $grid_complet); $constantes_complet_horiz = $smarty->fetch("print_constantes.tpl", '', '', 0); $constantes_complet_horiz = preg_replace('`([\\n\\r])`', '', $constantes_complet_horiz); $smarty->assign("constantes_medicales_grid", $grid_minimal); $constantes_minimal_horiz = $smarty->fetch("print_constantes.tpl", '', '', 0); $constantes_minimal_horiz = preg_replace('`([\\n\\r])`', '', $constantes_minimal_horiz); $smarty->assign("constantes_medicales_grid", $grid_valued); $constantes_valued_horiz = $smarty->fetch("print_constantes.tpl", '', '', 0); $constantes_valued_horiz = preg_replace('`([\\n\\r])`', '', $constantes_valued_horiz); // Vertical $smarty->assign("constantes_medicales_grid", $grid_complet); $constantes_complet_vert = $smarty->fetch("print_constantes_vert.tpl", '', '', 0); $constantes_complet_vert = preg_replace('`([\\n\\r])`', '', $constantes_complet_vert); $smarty->assign("constantes_medicales_grid", $grid_minimal); $constantes_minimal_vert = $smarty->fetch("print_constantes_vert.tpl", '', '', 0); $constantes_minimal_vert = preg_replace('`([\\n\\r])`', '', $constantes_minimal_vert); $smarty->assign("constantes_medicales_grid", $grid_valued); $constantes_valued_vert = $smarty->fetch("print_constantes_vert.tpl", '', '', 0); $constantes_valued_vert = preg_replace('`([\\n\\r])`', '', $constantes_valued_vert); // Liste des fichiers $this->loadRefsFiles(); $list = CMbArray::pluck($this->_ref_files, "file_name"); $template->addListProperty("Patient - Liste des fichiers", $list); // Identité $identite = $this->loadNamedFile("identite.jpg"); $template->addImageProperty("Patient - Photo d'identite", $identite->_id); $template->addProperty("Patient - Constantes - mode complet horizontal", $constantes_complet_horiz, '', false); $template->addProperty("Patient - Constantes - mode minimal horizontal", $constantes_minimal_horiz, '', false); $template->addProperty("Patient - Constantes - mode avec valeurs horizontal", $constantes_valued_horiz, '', false); $template->addProperty("Patient - Constantes - mode complet vertical", $constantes_complet_vert, '', false); $template->addProperty("Patient - Constantes - mode minimal vertical", $constantes_minimal_vert, '', false); $template->addProperty("Patient - Constantes - mode avec valeurs vertical", $constantes_valued_vert, '', false); $template->addProperty("Patient - poids", "{$const_med->poids} kg"); $template->addProperty("Patient - taille", "{$const_med->taille} cm"); $template->addProperty("Patient - Pouls", $const_med->pouls); $template->addProperty("Patient - IMC", $const_med->_imc); $template->addProperty("Patient - VST", $const_med->_vst); $template->addProperty("Patient - température", $const_med->temperature . "°"); $template->addProperty("Patient - TA", $const_med->ta ? "{$const_med->_ta_systole} / {$const_med->_ta_diastole}" : ""); $template->addProperty("Patient - Saturation (spo2)", $const_med->spo2); // Assuré social $template->addProperty("Patient - Assuré social - nom", $this->assure_nom); $template->addProperty("Patient - Assuré social - nom jeune fille", $this->assure_nom_jeune_fille); $template->addProperty("Patient - Assuré social - prénom", $this->assure_prenom); $template->addProperty("Patient - Assuré social - date de naissance", $this->getFormattedValue("assure_naissance")); $template->addProperty("Patient - Assuré social - article", $this->_assure_civilite); $template->addProperty("Patient - Assuré social - article long", $this->_assure_civilite_long); $template->addProperty("Patient - Assuré social - adresse", $this->assure_adresse); $template->addProperty("Patient - Assuré social - ville", $this->assure_ville); $template->addProperty("Patient - Assuré social - cp", $this->assure_cp); $template->addProperty("Patient - Assuré social - pays", $this->assure_pays); $template->addProperty("Patient - Assuré social - téléphone", $this->assure_tel); $template->addProperty("Patient - Assuré social - mobile", $this->assure_tel2); $template->addProperty("Patient - Assuré social - cp naissance", $this->assure_cp_naissance); $template->addProperty("Patient - Assuré social - lieu de naissance", $this->assure_lieu_naissance); $template->addProperty("Patient - Assuré social - profession", $this->assure_profession); // Bénéficiaire de soins $template->addProperty("Patient - Bénéficiaire de soin - code régime", $this->code_regime); $template->addProperty("Patient - Bénéficiaire de soin - caisse gest", $this->caisse_gest); $template->addProperty("Patient - Bénéficiaire de soin - centre gest", $this->centre_gest); $template->addProperty("Patient - Bénéficiaire de soin - code gest", $this->code_gestion); $template->addProperty("Patient - Bénéficiaire de soin - régime santé", $this->regime_sante); $template->addDateProperty("Patient - Bénéficiaire de soin - début période", $this->deb_amo); $template->addDateProperty("Patient - Bénéficiaire de soin - fin période", $this->fin_amo); $template->addProperty("Patient - Bénéficiaire de soin - régime am", $this->getFormattedValue("regime_am")); $template->addProperty("Patient - Bénéficiaire de soin - ald", $this->getFormattedValue("ald")); $template->addProperty("Patient - Bénéficiaire de soin - incapable majeur", $this->getFormattedValue("incapable_majeur")); $template->addProperty("Patient - Bénéficiaire de soin - cmu", $this->getFormattedValue("cmu")); $template->addProperty("Patient - Bénéficiaire de soin - ATNC", $this->getFormattedValue("ATNC")); $template->addDateProperty("Patient - Bénéficiaire de soin - validité vitale", $this->fin_validite_vitale); $template->addProperty("Patient - Bénéficiaire de soin - médecin traitant déclaré", $this->getFormattedValue("medecin_traitant_declare")); $template->addProperty("Patient - Bénéficiaire de soin - types contrat mutuelle", addslashes($this->mutuelle_types_contrat)); $template->addProperty("Patient - Bénéficiaire de soin - notes amo", addslashes($this->notes_amo)); $template->addProperty("Patient - Bénéficiaire de soin - libellé exo", addslashes($this->libelle_exo)); $template->addProperty("Patient - Bénéficiaire de soin - notes amc", addslashes($this->notes_amc)); if (CModule::getActive("maternite")) { $allaitement = $this->loadLastAllaitement(); $template->addDateProperty("Patient - Allaitement - Début", $allaitement->date_debut); $template->addDateProperty("Patient - Allaitement - Fin", $allaitement->date_fin); $grossesse = $this->loadLastGrossesse(); $template->addDateProperty("Patient - Grossesse - Terme prévu", $grossesse->terme_prevu); $template->addDateProperty("Patient - Grossesse - Date des dernières règles", $grossesse->date_dernieres_regles); $template->addProperty("Patient - Grossesse - En cours", $grossesse->getFormattedValue("active")); $template->addProperty("Patient - Grossesse - Multiple", $grossesse->getFormattedValue("multiple")); $template->addProperty("Patient - Grossesse - Allaitement maternel", $grossesse->getFormattedValue("allaitement_maternel")); $template->addProperty("Patient - Grossesse - Fausse couche", $grossesse->getFormattedValue('fausse_couche'), null, false); $template->addProperty("Patient - Grossesse - Lieu d'accouchement", $grossesse->getFormattedValue("lieu_accouchement")); $template->addProperty("Patient - Grossesse - Remarques", $grossesse->rques); } if (CModule::getActive("forms")) { CExObject::addFormsToTemplate($template, $this, "Patient"); } $this->notify("AfterFillLimitedTemplate", $template); }
function otherOrder(&$mouvements = array(), $type, $order_col, $order_way) { if (!in_array($order_col, array("_anesth", "_hour"))) { return; } $sorter_patient = $type == "np" ? @CMbArray::pluck($mouvements, "_ref_patient", "_view") : @CMbArray::pluck($mouvements, "_ref_sejour", "_ref_patient", "_view"); switch ($order_col) { default: case "_hour": $sorter_other = $type == "np" ? @CMbArray::pluck($mouvements, "_ref_curr_operation", "_datetime_best") : @CMbArray::pluck($mouvements, "_ref_sejour", "_ref_curr_operation", "_datetime_best"); break; case "_anesth": $sorter_other = $type == "np" ? @CMbArray::pluck($mouvements, "_ref_curr_operation", "_ref_anesth", "_view") : @CMbArray::pluck($mouvements, "_ref_sejour", "_ref_curr_operation", "_ref_anesth", "_view"); } @array_multisort($sorter_other, constant("SORT_{$order_way}"), $sorter_patient, SORT_ASC, $mouvements); }
/** * Handle event * * @param CHL7Acknowledgment $ack Acknowledgement * @param CPatient $newPatient Person * @param array $data Nodes data * * @return null|string */ function handle(CHL7Acknowledgment $ack, CPatient $newPatient, $data) { // Traitement du message des erreurs $comment = $warning = ""; $exchange_hl7v2 = $this->_ref_exchange_hl7v2; $exchange_hl7v2->_ref_sender->loadConfigValues(); $sender = $exchange_hl7v2->_ref_sender; foreach ($data["merge"] as $_data_merge) { $data = $_data_merge; $mbPatient = new CPatient(); $mbPatientElimine = new CPatient(); $patientPI = CValue::read($data['personIdentifiers'], "PI"); $patientRI = CValue::read($data['personIdentifiers'], "RI"); $patientEliminePI = CValue::read($data['personElimineIdentifiers'], "PI"); $patientElimineRI = CValue::read($data['personElimineIdentifiers'], "RI"); // Acquittement d'erreur : identifiants RI et PI non fournis if (!$patientRI && !$patientPI || !$patientElimineRI && !$patientEliminePI) { return $exchange_hl7v2->setAckAR($ack, "E100", null, $newPatient); } $idexPatient = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $patientPI); if ($mbPatient->load($patientRI)) { if ($idexPatient->object_id && $mbPatient->_id != $idexPatient->object_id) { $comment = "L'identifiant source fait référence au patient : {$idexPatient->object_id}"; $comment .= " et l'identifiant cible au patient : {$mbPatient->_id}."; return $exchange_hl7v2->setAckAR($ack, "E130", $comment, $newPatient); } } if (!$mbPatient->_id) { $mbPatient->load($idexPatient->object_id); } $idexPatientElimine = CIdSante400::getMatch("CPatient", $sender->_tag_patient, $patientEliminePI); if ($mbPatientElimine->load($patientElimineRI)) { if ($idexPatientElimine->object_id && $mbPatientElimine->_id != $idexPatientElimine->object_id) { $comment = "L'identifiant source fait référence au patient : {$idexPatientElimine->object_id}"; $comment .= "et l'identifiant cible au patient : {$mbPatientElimine->_id}."; return $exchange_hl7v2->setAckAR($ack, "E131", $comment, $newPatient); } } if (!$mbPatientElimine->_id) { $mbPatientElimine->load($idexPatientElimine->object_id); } if (!$mbPatient->_id || !$mbPatientElimine->_id) { $comment = !$mbPatient->_id ? "Le patient {$mbPatient->_id} est inconnu dans Mediboard." : "Le patient {$mbPatientElimine->_id} est inconnu dans Mediboard."; return $exchange_hl7v2->setAckAR($ack, "E120", $comment, $newPatient); } // Passage en trash de l'IPP du patient a éliminer $newPatient->trashIPP($idexPatientElimine); if ($mbPatient->_id == $mbPatientElimine->_id) { return $exchange_hl7v2->setAckAA($ack, "I104", null, $newPatient); } $patientsElimine_array = array($mbPatientElimine); $first_patient_id = $mbPatient->_id; $checkMerge = $mbPatient->checkMerge($patientsElimine_array); // Erreur sur le check du merge if ($checkMerge) { $comment = "La fusion de ces deux patients n'est pas possible à cause des problèmes suivants : {$checkMerge}"; return $exchange_hl7v2->setAckAR($ack, "E121", $comment, $newPatient); } $mbPatientElimine_id = $mbPatientElimine->_id; /** @todo mergePlainFields resets the _id */ $mbPatient->_id = $first_patient_id; // Notifier les autres destinataires $mbPatient->_eai_sender_guid = $sender->_guid; $mbPatient->_merging = CMbArray::pluck($patientsElimine_array, "_id"); if ($msg = $mbPatient->merge($patientsElimine_array)) { return $exchange_hl7v2->setAckAR($ack, "E103", $msg, $mbPatient); } $mbPatient->_mbPatientElimine_id = $mbPatientElimine_id; $comment = CEAIPatient::getComment($mbPatient, $mbPatientElimine); } return $exchange_hl7v2->setAckAA($ack, "I103", $comment, $mbPatient); }
/** * Get maximal value from a results set * * @param array $results The results as array of two values * * @return float */ protected static function _getMax($results) { return max(CMbArray::pluck($results, 1)); }
$chir->loadBackRefs("secondary_functions"); foreach ($chir->_back["secondary_functions"] as $curr_sec_func) { $functions[] = $curr_sec_func->function_id; } $list_functions = implode(",", $functions); $where[] = "protocole.chir_id = '{$chir->_id}' OR protocole.function_id IN ({$list_functions})"; } else { $where["function_id"] = " = '{$function_id}'"; } $where["for_sejour"] = $type == 'interv' ? "= '0'" : "= '1'"; if ($sejour_type) { $where["type"] = "= '{$sejour_type}'"; } $order = "libelle_sejour, libelle, codes_ccam"; $list_protocoles = $protocole->loadListWithPerms(PERM_READ, $where, $order, "{$page[$type]},{$step}"); $systeme_materiel_expert = CAppUI::conf("dPbloc CPlageOp systeme_materiel") == "expert"; foreach ($list_protocoles as $_prot) { $_prot->loadRefsFwd(); if ($systeme_materiel_expert == "expert") { $_prot->_types_ressources_ids = implode(",", CMbArray::pluck($_prot->loadRefsBesoins(), "type_ressource_id")); } } // Création du template $smarty = new CSmartyDP(); $smarty->assign("list_protocoles", $list_protocoles); $smarty->assign("total_protocoles", $protocole->_totalWithPerms); $smarty->assign("page", $page); $smarty->assign("step", $step); $smarty->assign("chir", $mediuser); $smarty->assign("type", $type); $smarty->display("inc_list_protocoles.tpl");
foreach ($plagesJour as $curr_plage) { if (array_key_exists($curr_plage->chir_id, $listPermPrats)) { $listPrats[$curr_plage->chir_id] = $listPermPrats[$curr_plage->chir_id]; } } $opsJour = new COperation(); $where = array(); $where["date"] = "= '{$date}'"; $groupby = "chir_id"; $opsJour = $opsJour->loadList($where, null, null, $groupby); foreach ($opsJour as $curr_op) { if (array_key_exists($curr_op->chir_id, $listPermPrats)) { $listPrats[$curr_op->chir_id] = $listPermPrats[$curr_op->chir_id]; } } $listPrats = CMbArray::pluck($listPrats, "_view"); asort($listPrats); // Selection des plages opératoires de la journée $praticien = new CMediusers(); if ($praticien->load(CValue::getOrSession("praticien_id"))) { $praticien->loadRefsForDay($date); } // Création du template $smarty = new CSmartyDP(); $smarty->assign("vueReduite", false); $smarty->assign("praticien", $praticien); $smarty->assign("salle", new CSalle()); $smarty->assign("listBlocs", $listBlocs); $smarty->assign("listPrats", $listPrats); $smarty->assign("date", $date); $smarty->assign("operation_id", $operation_id);
/** * Calcul le taux d'utilisation de prise de rendez-vous par créneaux de 5 minutes * * @param CPlageconsult[] $plages Plages * @param array $list Liste * @param CPlageconsult $plage Plage * * @return array */ function utilisation_rdv($plages, $list, $plage) { $utilisation = array(); // Granularité de 5 minutes. // 288 créneaux de 5 minutes dans 24 heures for ($i = 0; $i < 288; $i++) { $time = CMbDT::time($i * 5 . " minutes", $plage->debut); $utilisation[$time] = 0; if ($time == $plage->fin) { break; } } foreach ($plages as $_plage) { $rdvs = $_plage->loadRefsConsultations(false); $freq = CMbDT::transform($_plage->freq, null, "%M"); foreach ($rdvs as $_rdv) { $nb_cases = $_rdv->duree * $freq / 5; for ($i = 0; $i < $nb_cases; $i++) { $time = CMbDT::time($i * 5 . " minutes", $_rdv->heure); if (!isset($utilisation[$time])) { continue; } $utilisation[$time]++; } } } ksort($utilisation); // Granularité à la fréquence des consultations de la plage $creneaux = array_flip(CMbArray::pluck($list, "time")); $save_key = 0; foreach ($utilisation as $key => $_util) { if (!isset($creneaux[$key]) && isset($utilisation[$save_key])) { $utilisation[$save_key] = max($_util, $utilisation[$save_key]); unset($utilisation[$key]); } else { $utilisation[$key] = $_util; $save_key = $key; } } return $utilisation; }
function getAutocompleteList($keywords, $where = null, $limit = null, $ljoin = null, $order = null) { $list = $this->loadList($where, null, null, null, $ljoin); /** @var self[] $real_list */ $real_list = array(); $re = preg_quote($keywords); $re = CMbString::allowDiacriticsInRegexp($re); $re = str_replace("/", "\\/", $re); $re = "/({$re})/i"; foreach ($list as $_match) { if ($keywords == "%" || $keywords == "" || preg_match($re, $_match->_view)) { $_match->loadView(); $real_list[$_match->_id] = $_match; } } $views = CMbArray::pluck($real_list, "_view"); array_multisort($views, $real_list); $empty = new self(); $empty->_id = null; $empty->_guid = "{$this->_class}-{$this->_id}"; // FIXME $empty->_view = " -- "; array_unshift($real_list, $empty); return $real_list; }