<?php /** * $Id$ * * @package Mediboard * @subpackage dPcabinet * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ $consultation_id = CValue::post("consultation_id"); $plageconsult_id = CValue::post("plageconsult_id"); $heure = CValue::post("heure"); $consult = new CConsultation(); $consult->load($consultation_id); $new_consult = new CConsultation(); $new_consult->plageconsult_id = $plageconsult_id; $new_consult->heure = $heure; $new_consult->chrono = CConsultation::PLANIFIE; $new_consult->patient_id = $consult->patient_id; $new_consult->categorie_id = $consult->categorie_id; $msg = $new_consult->store(); if ($msg) { CAppUI::setMsg($msg, UI_MSG_ERROR); } else { CAppUI::setMsg(CAppUI::tr("CConsultation-msg-create"), UI_MSG_OK); } echo CAppUI::getMsg(); CApp::rip();
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}"); }
/** * @see parent::store() */ function store() { $this->completeField("pour_compte_id", "chir_id"); $change_pour_compte = $this->fieldModified("pour_compte_id"); if ($msg = parent::store()) { return $msg; } if ($change_pour_compte) { $consults = $this->loadRefsConsultations(); foreach ($consults as $_consult) { $facture = $_consult->loadRefFacture(); $facture->praticien_id = $this->pour_compte_id ? $this->pour_compte_id : $this->chir_id; $facture->store(); } } // pause if ($this->_update_pause && $this->_pause && $this->_pause_repeat_time) { $consult = new CConsultation(); $where = array(); $where["plageconsult_id"] = " = '{$this->_id}' "; $where["patient_id"] = " IS NULL"; $consult->loadObject($where); $consult->plageconsult_id = $this->_id; $consult->heure = $this->_pause; $consult->duree = $this->_pause_repeat_time; $consult->chrono = 16; $consult->_hour = null; $consult->_min = null; if ($msg = $consult->store()) { CAppUI::stepAjax($msg, UI_MSG_WARNING); } } return null; }
/** * @see parent::store() */ function store() { // Création du RPU en l'associant à un séjour existant if (!$this->_id && $this->sejour_id) { $sejour = $this->loadRefSejour(); // Si y'a un RPU déjà existant on alerte d'une erreur if ($sejour->countBackRefs("rpu")) { return CAppUI::tr("CRPU-already-exists"); } } // Création du RPU ET du séjour associé if (!$this->_id && !$this->sejour_id) { $sejour = new CSejour(); $sejour->patient_id = $this->_patient_id; $sejour->type = "urg"; $sejour->entree_reelle = $this->_entree; $sejour->group_id = CGroups::loadCurrent()->_id; $sortie_prevue = CAppUI::conf("dPurgences sortie_prevue") == "h24" ? CMbDT::dateTime("+1 DAY", $this->_entree) : CMbDT::date(null, $this->_entree) . " 23:59:59"; $sejour->sortie_prevue = $this->_sortie ? $this->_sortie : $sortie_prevue; // En cas de ressemblance à quelques heures près (cas des urgences), on a affaire au même séjour $siblings = $sejour->getSiblings(CAppUI::conf("dPurgences sibling_hours"), $sejour->type); if (count($siblings)) { $sibling = reset($siblings); $this->sejour_id = $sibling->_id; $sejour = $this->loadRefSejour(); // Si y'a un RPU déjà existant on alerte d'une erreur if ($sejour->countBackRefs("rpu")) { return CAppUI::tr("CRPU-already-exists"); } $sejour->service_id = $this->_service_id; $sejour->etablissement_entree_id = $this->_etablissement_entree_id; $sejour->service_entree_id = $this->_service_entree_id; $sejour->mode_entree = $this->_mode_entree; $sejour->mode_entree_id = $this->_mode_entree_id; $sejour->provenance = $this->_provenance; $sejour->destination = $this->_destination; $sejour->transport = $this->_transport; $sejour->UHCD = $this->_UHCD; $sejour->uf_soins_id = $this->_uf_soins_id; } } // Changement suivant le mode d'entrée switch ($this->_mode_entree) { case 6: $this->_etablissement_entree_id = ""; break; case 7: $this->_service_entree_id = ""; break; case 8: $this->_service_entree_id = ""; $this->_etablissement_entree_id = ""; break; default: } // Bind Sejour if ($msg = $this->bindSejour()) { return $msg; } // Synchronisation AT $this->loadRefConsult(); if ($this->_ref_consult->_id) { //Evite les check dans le cas des fusions lors du store de la consult $this->_ref_consult->_forwardRefMerging = $this->_forwardRefMerging; if ($this->_validation && CAppUI::conf("dPurgences valid_cotation_sortie_reelle")) { $this->_ref_consult->valide = "1"; } if ($this->fieldModified("date_at") && !$this->_date_at) { $this->_date_at = true; $this->_ref_consult->date_at = $this->date_at; } if ($msg = $this->_ref_consult->store()) { return $msg; } } if ($this->fieldModified("code_diag") && $this->code_diag) { $this->loadRefMotif(); $this->diag_infirmier = $this->_ref_motif->_ref_chapitre->nom; $this->diag_infirmier .= "\n" . $this->code_diag . ": " . $this->_ref_motif->nom; $this->diag_infirmier .= "\n Degrés d'urgence entre " . $this->_ref_motif->degre_min . " et " . $this->_ref_motif->degre_max; $this->ccmu = ""; } // Bind affectation if (CAppUI::conf("dPurgences create_affectation")) { if ($msg = $this->storeAffectation()) { return $msg; } } if ($this->fieldModified("code_diag") && $this->_old->code_diag != $this->code_diag) { foreach ($this->loadRefsReponses() as $_reponse) { if ($msg = $_reponse->delete()) { return $msg; } } if ($this->code_diag) { foreach ($this->loadRefMotif()->loadRefsQuestions() as $_question) { $reponse = new CMotifReponse(); $reponse->question_id = $_question->_id; $reponse->rpu_id = $this->_id; if ($msg = $reponse->store()) { return $msg; } } } } // Standard Store if ($msg = parent::store()) { return $msg; } // Déclenchement pour avoir les données RPU // Pas de sycnhro dans certains cas $this->_ref_sejour->_no_synchro = true; $this->_ref_sejour->notify("AfterStore"); return null; }
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; }