static function makeConsult($patient_id, $chir_id, $date, $store = true, $time = null) { $consult = new CConsultation(); $date = CMbDT::date($date); $plage = new CPlageconsult(); $where = array("plageconsult.chir_id" => "= '{$chir_id}'", "plageconsult.date" => "= '{$date}'"); $plage->loadObject($where); if (!$plage->_id) { $plage->date = $date; $plage->chir_id = $chir_id; $plage->debut = "09:00:00"; $plage->fin = "19:00:00"; $plage->freq = "00:30:00"; $plage->libelle = "Importation"; if ($msg = $plage->store()) { return $msg; } } $consult->patient_id = $patient_id; $consult->plageconsult_id = $plage->_id; $consult->heure = $time ? $time : "09:00:00"; $consult->chrono = $date < CMbDT::date() ? CConsultation::TERMINE : CConsultation::PLANIFIE; if ($store) { if ($msg = $consult->store()) { return $msg; } if (!$consult->_id) { CAppUI::setMsg("Consultation non trouvée et non importée : {$patient_id} / {$chir_id} / {$date}", UI_MSG_WARNING); return false; } } return $consult; }
if ($plageAfter->_id) { $plageBefore->fin = $plageAfter->debut; } else { $plageBefore->fin = max($plageBefore->fin, $hour_next); } $plage =& $plageBefore; } elseif ($plageAfter->_id) { $plageAfter->debut = min($plageAfter->debut, $hour_now); $plage =& $plageAfter; } else { $plage->chir_id = $prat_id; $plage->date = $day_now; $plage->freq = "00:" . CPlageconsult::$minutes_interval . ":00"; $plage->debut = $hour_now; $plage->fin = $hour_next; $plage->libelle = "automatique"; } $plage->updateFormFields(); if ($msg = $plage->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } } $consult->plageconsult_id = $plage->_id; if ($msg = $consult->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } if ($current_m == "dPurgences") { CAppUI::redirect("m=dPurgences&tab=edit_consultation&selConsult={$consult->_id}&ajax={$ajax}"); } else { CAppUI::redirect("m=dPcabinet&tab=edit_consultation&selConsult={$consult->_id}&ajax={$ajax}"); }
if ($msg = $obj->delete()) { CAppUI::setMsg("Plage non supprimée", UI_MSG_ERROR); CAppUI::setMsg("Plage du {$obj->date}: {$msg}", UI_MSG_ERROR); } else { CAppUI::setMsg("Plage supprimée", UI_MSG_OK); } } $repeat -= $obj->becomeNext(); } CValue::setSession("plageconsult_id"); } else { if ($obj->_id != 0) { // Modification des plages while ($repeat > 0) { if ($obj->_id) { if ($msg = $obj->store()) { CAppUI::setMsg("Plage non mise à jour", UI_MSG_ERROR); CAppUI::setMsg("Plage du {$obj->date}: {$msg}", UI_MSG_ERROR); } else { CAppUI::setMsg("Plage mise à jour", UI_MSG_OK); } } $repeat -= $obj->becomeNext(); } } else { // Creation des plages while ($repeat > 0) { if ($msg = $obj->store()) { CAppUI::setMsg("Plage non créée", UI_MSG_ERROR); CAppUI::setMsg("Plage du {$obj->date}: {$msg}", UI_MSG_ERROR); } else {