/** * Chargement des besoins * * @param string $from Date de début * @param string $to Date de fin * * @return CBesoinRessource[] */ function loadRefsBesoins($from, $to) { if (!$from && !$to) { return $this->_ref_besoins = array(); } $besoin = new CBesoinRessource(); $where = array(); $ljoin = array(); $from_date = CMbDT::date($from); $to_date = CMbDT::date($to); $ljoin["operations"] = "besoin_ressource.operation_id = operations.operation_id"; $ljoin["usage_ressource"] = "usage_ressource.besoin_ressource_id = besoin_ressource.besoin_ressource_id"; // On ne charge que les besoins qui n'ont pas d'usage $where[] = "usage_ressource.usage_ressource_id IS NULL"; $where["operations.date"] = "BETWEEN '{$from_date}' AND '{$to_date}'"; // Sur les interventions non annulées $where["operations.annulee"] = "= '0'"; if ($this->type_ressource_id) { $ljoin["ressource_materielle"] = "ressource_materielle.type_ressource_id = besoin_ressource.type_ressource_id"; $where["ressource_materielle.type_ressource_id"] = "= '{$this->type_ressource_id}'"; } /** @var CBesoinRessource[] $besoins */ $besoins = $besoin->loadList($where, null, null, "besoin_ressource_id", $ljoin); CMbObject::massLoadFwdRef($besoins, "operation_id"); foreach ($besoins as $_besoin) { $operation = $_besoin->loadRefOperation(); $operation->loadRefPlageOp(); $deb_op = $operation->_datetime; $fin_op = CMbDT::addDateTime($operation->temp_operation, $deb_op); if ($deb_op > $to || $fin_op < $from) { unset($besoins[$_besoin->_id]); } } return $this->_ref_besoins = $besoins; }
/** * @see parent::store() */ function store($reorder = true) { /** @var self $old */ $old = $this->loadOldObject(); $this->completeField("annulee", "rank", "codes_ccam", "plageop_id", "chir_id", "materiel", "commande_mat", "date"); // Si on a une plage, la date est celle de la plage if ($this->plageop_id) { $plage = $this->loadRefPlageOp(); $this->date = $plage->date; } // Si on choisit une plage, on copie la salle if ($this->fieldValued("plageop_id")) { $plage = $this->loadRefPlageOp(); $this->salle_id = $plage->salle_id; } // Cas d'une plage que l'on quitte /** @var CPlageOp $old_plage */ $old_plage = null; if ($this->fieldAltered("plageop_id") && $old->rank) { $old_plage = $old->loadRefPlageOp(); } $comments = $this->prepareAlert(); $place_after_interv_id = $this->_place_after_interv_id; $this->_place_after_interv_id = null; // Pré-remplissage de la durée préop si c'est une nouvelle intervention if (!$this->_id && !$this->duree_preop) { $patient = $this->loadRefSejour()->loadRefPatient(); if ($patient->_annees >= 18) { $this->duree_preop = "00:" . CAppUI::conf("dPplanningOp COperation duree_preop_adulte") . ":00"; } else { $this->duree_preop = "00:" . CAppUI::conf("dPplanningOp COperation duree_preop_enfant") . ":00"; } } // On recopie la sortie réveil possible sur le réel si pas utilisée en config if (!CAppUI::conf("dPsalleOp COperation use_sortie_reveil_reel", CGroups::loadCurrent()->_guid)) { $this->sortie_reveil_reel = $this->sortie_reveil_possible; } // Création d'une alerte si modification du libellé et/ou du côté if ($this->_id && ($this->fieldModified("libelle") || $this->fieldModified("cote"))) { $alerte = ""; $date = CMbDT::dateToLocale(CMbDT::date()); if ($this->fieldModified("libelle")) { $alerte = "Le libellé a été modifié le {$date}\n" . "Ancienne valeur : " . $old->getFormattedValue("libelle") . "\nNouvelle valeur : " . $this->getFormattedValue("libelle"); } $this->createAlert($alerte, true, "libelle"); $alerte = ""; if ($this->fieldModified("cote")) { $alerte = "Le côté a été modifié le {$date} : \n" . "Ancienne valeur : " . $old->getFormattedValue("cote") . "\nNouvelle valeur : " . $this->getFormattedValue("cote"); } $this->createAlert($alerte, true, "cote"); } $sejour = $this->loadRefSejour(); $do_store_sejour = false; // Flag pour storer le séjour une seule fois $do_update_time = false; // Synchronisation des heures d'admission if ($this->fieldModified('horaire_voulu') || $this->fieldModified('temp_operation') || $this->fieldModified('presence_preop') || $this->fieldModified('presence_postop') || $this->fieldModified('date') || $this->fieldModified('time_operation')) { $do_update_time = true; } if ($this->loadRefCommande()->_id && $this->_ref_commande_mat->etat != "annulee") { if ($this->fieldModified("annulee", "1")) { $this->_ref_commande_mat->cancelledOp(); } if ($this->fieldModified("materiel") || $this->fieldModified("date")) { $this->_ref_commande_mat->modifiedOp($this->materiel); } } // Standard storage if ($msg = parent::store()) { return $msg; } if ($do_update_time) { $do_store_sejour = $sejour->checkUpdateTimeAmbu(); } // Création des besoins d'après le protocole sélectionné // Ne le faire que pour une nouvelle intervention // Pour une intervention existante, l'application du protocole // store les protocoles if (CAppUI::conf("dPbloc CPlageOp systeme_materiel") == "expert" && $this->_types_ressources_ids && !$old->_id) { $types_ressources_ids = explode(",", $this->_types_ressources_ids); foreach ($types_ressources_ids as $_type_ressource_id) { $besoin = new CBesoinRessource(); $besoin->type_ressource_id = $_type_ressource_id; $besoin->operation_id = $this->_id; if ($msg = $besoin->store()) { return $msg; } } } $this->createAlert($comments); // Mise à jour du type de PeC du séjour en Chirurgical si pas déja obstétrique $sejour->completeField("type_pec"); if (!$this->_id && $sejour->type_pec != "O") { $sejour->type_pec = "C"; $do_store_sejour = true; } // Cas d'une annulation if (!$this->annulee) { // Si pas une annulation on recupére le sejour // et on regarde s'il n'est pas annulé if ($sejour->annule) { $sejour->annule = 0; $do_store_sejour = true; } // Application des protocoles de prescription en fonction de l'operation->_id if ($this->_protocole_prescription_chir_id || $this->_protocole_prescription_anesth_id) { $sejour->_protocole_prescription_chir_id = $this->_protocole_prescription_chir_id; $sejour->_protocole_prescription_anesth_id = $this->_protocole_prescription_anesth_id; $sejour->applyProtocolesPrescription($this->_id); // On les nullify pour eviter de les appliquer 2 fois $this->_protocole_prescription_anesth_id = null; $this->_protocole_prescription_chir_id = null; $sejour->_protocole_prescription_chir_id = null; $sejour->_protocole_prescription_anesth_id = null; } } elseif ($this->rank != 0 && !CAppUI::conf("dPplanningOp COperation save_rank_annulee_validee")) { $this->rank = 0; $this->time_operation = "00:00:00"; } // Store du séjour (une seule fois) if ($do_store_sejour) { $sejour->store(); } // Vérification qu'on a pas des actes CCAM codés obsolètes if ($this->codes_ccam) { $this->loadRefsActesCCAM(); foreach ($this->_ref_actes_ccam as $keyActe => $acte) { if (stripos($this->codes_ccam, $acte->code_acte) === false) { $this->_ref_actes_ccam[$keyActe]->delete(); } } } $reorder_rank_voulu = $this->_reorder_rank_voulu; $this->_reorder_rank_voulu = null; if ($this->plageop_id) { $plage = $this->loadRefPlageOp(); // Cas de la création dans une plage de spécialité if ($plage->spec_id && $plage->unique_chir) { $plage->chir_id = $this->chir_id; $plage->spec_id = ""; $plage->store(); } // Placement de l'interv selon la preference (placement souhaité) if ($place_after_interv_id) { $plage->loadRefsOperations(false, "rank, rank_voulu, horaire_voulu", true); unset($plage->_ref_operations[$this->_id]); if ($place_after_interv_id == -1) { $reorder = true; $reorder_rank_voulu = true; $plage->_ref_operations = CMbArray::mergeKeys(array($this->_id => $this), $plage->_ref_operations); // To preserve keys (array_unshift does not) } elseif (isset($plage->_ref_operations[$place_after_interv_id])) { $reorder = true; $reorder_rank_voulu = true; CMbArray::insertAfterKey($plage->_ref_operations, $place_after_interv_id, $this->_id, $this); } if ($reorder_rank_voulu) { $plage->_reorder_up_to_interv_id = $this->_id; } } } // Gestion du tarif et precodage des actes if ($this->_bind_tarif && $this->_id) { if ($msg = $this->bindTarif()) { return $msg; } } // Standard storage bis if ($msg = parent::store()) { return $msg; } // Réordonnancement post-store if ($reorder) { // Réordonner la plage que l'on quitte if ($old_plage) { $old_plage->reorderOp(); } $this->_ref_plageop->reorderOp($reorder_rank_voulu ? CPlageOp::RANK_REORDER : null); } return null; }
<?php /** * $Id$ * * @package Mediboard * @subpackage dPbloc * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ CCanDo::checkEdit(); $type = CValue::get("type"); $object_id = CValue::get("object_id"); $usage = CValue::get("usage", 0); $besoin = new CBesoinRessource(); $besoin->{$type} = $object_id; /** @var CBesoinRessource[] $besoins */ $besoins = $besoin->loadMatchingList(); CMbObject::massLoadFwdRef($besoins, "type_ressource_id"); $operation = new COperation(); $operation->load($object_id); $operation->loadRefPlageOp(); $deb_op = $operation->_datetime; $fin_op = CMbDT::addDateTime($operation->temp_operation, $deb_op); foreach ($besoins as $_besoin) { $_besoin->loadRefTypeRessource(); $_besoin->loadRefUsage(); // Côté protocole, rien à vérifier if ($type != "operation_id") { $_besoin->_color = "";
<?php /** * $Id$ * * @package Mediboard * @subpackage dPbloc * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ $types_ressources_ids = CValue::get("types_ressources_ids"); $type = CValue::get("type"); $types_ressources_ids = explode(",", $types_ressources_ids); $besoins = array(); CMbArray::removeValue("", $types_ressources_ids); foreach ($types_ressources_ids as $_type_ressource_id) { $besoin = new CBesoinRessource(); $besoin->type_ressource_id = $_type_ressource_id; $type_ressource = $besoin->loadRefTypeRessource(); $besoin->loadRefUsage(); $besoins[] = $besoin; } $smarty = new CSmartyDP(); $smarty->assign("besoins", $besoins); $smarty->assign("object_id", ""); $smarty->assign("type", $type); $smarty->display("inc_list_besoins.tpl");
/** * @see parent::store() */ function store() { if (!$this->_id && $this->_types_ressources_ids) { if ($msg = parent::store()) { return $msg; } $types_ressources_ids = explode(",", $this->_types_ressources_ids); foreach ($types_ressources_ids as $_type_ressource_id) { $besoin = new CBesoinRessource(); $besoin->type_ressource_id = $_type_ressource_id; $besoin->protocole_id = $this->_id; if ($msg = $besoin->store()) { return $msg; } } } return parent::store(); }