/** * Create movement * * @param string $code HL7 event code * @param CSejour $sejour Admit * @param CAffectation $affectation Affectation * * @return CMovement|mixed */ function createMovement($code, CSejour $sejour, CAffectation $affectation = null) { $insert = in_array($code, CHL7v2SegmentZBE::$actions["INSERT"]); $update = in_array($code, CHL7v2SegmentZBE::$actions["UPDATE"]); $cancel = in_array($code, CHL7v2SegmentZBE::$actions["CANCEL"]); $movement = new CMovement(); // Initialise le mouvement $movement->sejour_id = $sejour->_id; $receiver = $sejour->_receiver; $configs = $receiver->_configs; $affectation_id = null; if ($affectation) { $current_log = $affectation->_ref_current_log; $first_affectation = $sejour->loadRefFirstAffectation(); /** @var CService $service */ $service = $affectation->loadRefService(); // Si le service est d'UHCD, de radiologie, d'urgence ou // Dans le cas où il s'agit de la première affectation du séjour et qu'on est en type "création" on ne recherche pas // un mouvement avec l'affectation, mais on va prendre le mouvement d'admission if ($service->uhcd || $service->radiologie || $service->urgence || $current_log && $current_log->type == "create" && $first_affectation && $first_affectation->_id == $affectation->_id) { switch ($configs["send_first_affectation"]) { case 'Z99': $affectation_id = $affectation->_id; $affectation = null; break; default: $movement->affectation_id = $affectation->_id; } } else { $movement->affectation_id = $affectation->_id; } } if ($insert) { // Dans le cas d'un insert le type correspond nécessairement au type actuel du séjour $movement->movement_type = $sejour->getMovementType($code); $movement->original_trigger_code = $code; $movement->start_of_movement = $this->getStartOfMovement($code, $sejour, $affectation); $movement->loadMatchingObject(); $movement->store(); return $sejour->_ref_hl7_movement = $movement; } elseif ($update) { // Dans le cas d'un update le type correspond à celui du trigger $movement_type = null; // Mise à jour entrée réelle if ($sejour->fieldModified("entree_reelle")) { $movement_type = "ADMI"; } // Mise à jour sortie réelle if ($sejour->fieldModified("sortie_reelle")) { $movement_type = "SORT"; } $movement->movement_type = $movement_type; // On ne recherche pas parmi les mouvements annulés $movement->cancel = 0; } $order = "affectation_id DESC"; $movements = $movement->loadMatchingList($order); if (!empty($movements)) { $movement = reset($movements); } if ($update) { if ($movement->original_trigger_code == "A02") { if (!$affectation) { $affectation = new CAffectation(); } $affectation->load($movement->affectation_id); } $movement->start_of_movement = $this->getStartOfMovement($movement->original_trigger_code, $sejour, $affectation, $movement); } // on annule un mouvement sauf dans le cas d'une annulation de mutation et que if ($cancel && !($code == "A12" && $movement->original_trigger_code != "A02")) { $movement->cancel = 1; } if ($affectation_id) { $movement->affectation_id = $affectation_id; } $movement->store(); return $sejour->_ref_hl7_movement = $movement; }
CAppUI::stepAjax($msg, UI_MSG_ERROR); } break; case "A11": $sejour_id = CValue::post("sejour_id"); $sejour = new CSejour(); $sejour->load($sejour_id); $sejour->annule = "1"; if ($msg = $sejour->store()) { CAppUI::stepAjax($msg, UI_MSG_ERROR); } break; case "A12": $affectation_id = CValue::post("affectation_id"); $affectation = new CAffectation(); $affectation->load($affectation_id); if ($msg = $affectation->delete()) { CAppUI::stepAjax($msg, UI_MSG_ERROR); } break; case "A13": $sejour_id = CValue::post("sejour_id"); $sejour = new CSejour(); $sejour->load($sejour_id); $sejour->sortie_reelle = ""; if ($msg = $sejour->store()) { CAppUI::stepAjax($msg, UI_MSG_ERROR); } break; case "INSERT": $sejour_id = CValue::post("sejour_id");
/** * Mapping et enregistrement de l'affectation * * @param CSejour $newVenue Admit * @param array $data Datas * @param CMovement $movement Movement * * @return CAffectation|string|null */ function mapAndStoreAffectation(CSejour $newVenue, $data, CMovement $movement = null) { $sender = $this->_ref_sender; if ($newVenue->annule) { return null; } $PV1_3 = $this->queryNode("PV1.3", $data["PV1"]); $affectation = new CAffectation(); $affectation->sejour_id = $newVenue->_id; $event_code = $this->_ref_exchange_hl7v2->code; // Récupération de la date de réalisation de l'évènement // Dans le cas spécifique de quelques évènements, on récupère le code sur le ZBE $datetime = $this->queryTextNode("EVN.6/TS.1", $data["EVN"]); if (array_key_exists("ZBE", $data) && $data["ZBE"] && CMbArray::in($event_code, array("A01", "A02", "A04", "A15", "Z80", "Z84"))) { $datetime = $this->queryTextNode("ZBE.2/TS.1", $data["ZBE"]); } switch ($event_code) { // Cas d'une suppression de mutation ou d'une permission d'absence case "A12": case "A52": // Quand on a un mouvement (provenant d'un ZBE) if (array_key_exists("ZBE", $data) && $data["ZBE"]) { if (!$movement) { return null; } $affectation->load($movement->affectation_id); if (!$affectation->_id) { return "Le mouvement '{$movement->_id}' n'est pas lié à une affectation dans Mediboard"; } } else { $affectation->entree = $datetime; $affectation->loadMatchingObject(); if (!$affectation->_id) { return null; } } // Pas de synchronisation $affectation->_no_synchro = true; if ($msgAffectation = $affectation->delete()) { return $msgAffectation; } return null; // Annulation admission // Annulation admission case "A11": if (!$movement) { return null; } $affectation = $newVenue->getCurrAffectation($datetime); // Si le mouvement n'a pas d'affectation associée, et que l'on a déjà une affectation dans MB if (!$movement->affectation_id && $affectation->_id) { return "Le mouvement '{$movement->_id}' n'est pas lié à une affectation dans Mediboard"; } // Si on a une affectation associée, alors on charge celle-ci if ($movement->affectation_id) { $affectation = $movement->loadRefAffectation(); } // Pas de synchronisation $affectation->_no_synchro = true; if ($msg = $affectation->delete()) { return $msg; } return null; // Annuler le retour du patient // Annuler le retour du patient case "A53": if (!$movement) { return null; } $affectation->load($movement->affectation_id); if (!$affectation->_id) { return "Le mouvement '{$movement->_id}' n'est pas lié à une affectation dans Mediboard"; } $affectation->effectue = 0; // Pas de synchronisation $affectation->_no_synchro = true; $affectation->_eai_sender_guid = $sender->_guid; if ($msg = $affectation->store()) { return $msg; } return $affectation; // Cas d'un départ pour une permission d'absence // Cas d'un départ pour une permission d'absence case "A21": $affectation->entree = $datetime; $affectation->loadMatchingObject(); // Si on ne retrouve pas une affectation // Création de l'affectation // et mettre à 'effectuee' la précédente si elle existe sinon création de celle-ci if (!$affectation->_id) { $service_externe = CService::loadServiceExterne($sender->group_id); if (!$service_externe->_id) { return "CService-externe-none"; } $affectation->service_id = $service_externe->_id; $return_affectation = $newVenue->forceAffectation($affectation, true); //$datetime, $affectation->lit_id, $affectation->service_id); if (is_string($return_affectation)) { return $return_affectation; } $affectation = $return_affectation; } return $affectation; // Cas d'un retour pour une permission d'absence // Cas d'un retour pour une permission d'absence case "A22": $service_externe = CService::loadServiceExterne($sender->group_id); if (!$service_externe->_id) { return "CService-externe-none"; } // Recherche de l'affectation correspondant à une permission d'absence $search = new CAffectation(); $where = array(); $where["sejour_id"] = "= '{$newVenue->_id}'"; $where["service_id"] = "= '{$service_externe->_id}'"; $where["effectue"] = "= '0'"; $where["entree"] = "<= '{$datetime}'"; $where["sortie"] = ">= '{$datetime}'"; $search->loadObject($where); // Si on ne la retrouve pas on prend la plus proche if (!$search->_id) { $where = array(); $where["sejour_id"] = "= '{$newVenue->_id}'"; $where["service_id"] = "= '{$service_externe->_id}'"; $where["effectue"] = "= '0'"; $search->loadObject($where); } $search->effectue = 1; $search->sortie = $datetime; $search->_eai_sender_guid = $sender->_guid; if ($msg = $search->store()) { return $msg; } return $search; // Cas mutation // Cas mutation case "A02": $affectation->entree = $datetime; $affectation->loadMatchingObject(); // Si on ne retrouve pas une affectation // Création de l'affectation // et mettre à 'effectuee' la précédente si elle existe sinon création de celle-ci if (!$affectation->_id) { // Récupération du Lit et UFs $this->getPL($PV1_3, $affectation, $newVenue); $return_affectation = $newVenue->forceAffectation($affectation, true); //$datetime, $affectation->lit_id, $affectation->service_id); if (is_string($return_affectation)) { return $return_affectation; } $affectation = $return_affectation; } break; // Cas modification // Cas modification case "Z99": if (!$movement) { return null; } // Si on a une affectation associée, alors on charge celle-ci if ($movement->affectation_id) { $affectation = $movement->loadRefAffectation(); } else { // On recherche l'affectation "courante" // Si qu'une affectation sur le séjour $newVenue->loadRefsAffectations(); if (count($newVenue->_ref_affectations) == 1) { $affectation = reset($newVenue->_ref_affectations); } else { // On recherche l'affectation "courante" $affectation = $newVenue->getCurrAffectation($datetime); } // Sinon on récupère et on met à jour la première affectation if (!$affectation->_id) { $affectation->sejour_id = $newVenue->_id; $affectation->entree = $newVenue->entree; $affectation->sortie = $newVenue->sortie; } } break; // Tous les autres cas on récupère et on met à jour la première affectation // Tous les autres cas on récupère et on met à jour la première affectation default: $newVenue->loadRefsAffectations(); $affectation = $newVenue->_ref_first_affectation; if (!$affectation->_id) { $affectation->sejour_id = $newVenue->_id; $affectation->entree = $newVenue->entree; $affectation->sortie = $newVenue->sortie; } } // Si pas d'UF/service/chambre/lit on retourne une affectation vide if (!$PV1_3) { if ($msgVenue = self::storeUFMedicaleSoinsSejour($data, $newVenue)) { return $msgVenue; } return $affectation; } if ($this->queryTextNode("PL.1", $PV1_3) == $sender->_configs["handle_PV1_3_null"]) { if ($msgVenue = self::storeUFMedicaleSoinsSejour($data, $newVenue)) { return $msgVenue; } return $affectation; } // Si pas de lit on affecte le service sur le séjour if (!$this->queryTextNode("PL.3", $PV1_3)) { $affectation_uf = new CAffectationUniteFonctionnelle(); // On essaye de récupérer le service dans ce cas depuis l'UF d'hébergement $date_deb = $affectation->_id ? CMbDT::date($affectation->sortie) : CMbDT::date($newVenue->sortie); $date_fin = $affectation->_id ? CMbDT::date($affectation->entree) : CMbDT::date($newVenue->entree); $uf = CUniteFonctionnelle::getUF($this->queryTextNode("PL.1", $PV1_3), "hebergement", $newVenue->group_id, $date_deb, $date_fin); if ($uf->code && $uf->_id) { $affectation_uf->uf_id = $uf->_id; $affectation_uf->object_class = "CService"; $affectation_uf->loadMatchingObject(); } // Dans le cas où l'on retrouve un service associé à l'UF d'hébergement if ($affectation_uf->_id) { $newVenue->service_id = $affectation_uf->object_id; $newVenue->uf_hebergement_id = $affectation_uf->uf_id; } $uf_med = $this->mappingUFMedicale($data, $newVenue, $affectation); $newVenue->uf_medicale_id = $uf_med ? $uf_med->_id : null; $uf_soins = $this->mappingUFSoins($data, $newVenue, $affectation); $newVenue->uf_soins_id = $uf_soins ? $uf_soins->_id : null; // On ne check pas la cohérence des dates des consults/intervs $newVenue->_skip_date_consistencies = true; $newVenue->_eai_sender_guid = $sender->_guid; if ($msgVenue = self::storeUFMedicaleSoinsSejour($data, $newVenue)) { return $msgVenue; } // Si on a pas d'UF on retourne une affectation vide if (!$uf->_id || !$affectation_uf->_id) { return $affectation; } } // Récupération du Lit et UFs $this->getPL($PV1_3, $affectation, $newVenue); $uf_med = $this->mappingUFMedicale($data, $newVenue, $affectation); $affectation->uf_medicale_id = $uf_med ? $uf_med->_id : null; $uf_soins = $this->mappingUFSoins($data, $newVenue, $affectation); $affectation->uf_soins_id = $uf_soins ? $uf_soins->_id : null; $affectation->_eai_sender_guid = $sender->_guid; if ($msg = $affectation->store()) { return $msg; } return $affectation; }
/** * Represents an HL7 ZBE message segment (Movement) * * @param CSejour $sejour Admit * * @return void */ function addZBE(CSejour $sejour = null) { $segment_name = $this->_is_i18n ? "ZBE_FR" : "ZBE"; /** @var CHL7v2SegmentZBE $ZBE */ $ZBE = CHL7v2Segment::create($segment_name, $this->message); $ZBE->sejour = $sejour; $movement = $sejour->_ref_hl7_movement; $affectation = new CAffectation(); if ($movement && $movement->affectation_id) { $affectation->load($movement->affectation_id); } $ZBE->curr_affectation = $affectation; $ZBE->movement = $movement; $ZBE->other_affectation = $sejour->_ref_hl7_affectation; $ZBE->build($this); }
/** * Mapping mouvements * * @param DOMNode $node Node * @param CSejour $newVenue Venue * @param CAffectation $affectation Affectation * * @return string */ function mappingMovement(DOMNode $node, CSejour $newVenue, CAffectation $affectation) { $xpath = new CHPrimXPath($node->ownerDocument); $sender = $this->_ref_echange_hprim->_ref_sender; // Recherche d'une affectation existante $id = $newVenue->_guid . "-" . $xpath->queryTextNode("hprim:identifiant/hprim:emetteur", $node); $tag = $sender->_tag_hprimxml; $idex = CIdSante400::getMatch("CAffectation", $tag, $id); if ($idex->_id) { $affectation->load($idex->object_id); if ($affectation->sejour_id != $newVenue->_id) { return CAppUI::tr("hprimxml-error-E301"); } } $affectation->sejour_id = $newVenue->_id; // Praticien responsable $medecinResponsable = $xpath->queryUniqueNode("hprim:medecinResponsable", $node); $affectation->praticien_id = $this->getMedecin($medecinResponsable); // Emplacement $this->getEmplacement($node, $newVenue, $affectation); // Début de l'affectation $debut = $xpath->queryUniqueNode("hprim:debut", $node); $date = $xpath->queryTextNode("hprim:date", $debut); $heure = CMbDT::transform($xpath->queryTextNode("hprim:heure", $debut), null, "%H:%M:%S"); $affectation->entree = "{$date} {$heure}"; // Fin de l'affectation $fin = $xpath->queryUniqueNode("hprim:fin", $node); if ($fin) { $date = $xpath->queryTextNode("hprim:date", $fin); $heure = CMbDT::transform($xpath->queryTextNode("hprim:heure", $fin), null, "%H:%M:%S"); $affectation->sortie = "{$date} {$heure}"; } if (!$affectation->_id) { $affectation = $newVenue->forceAffectation($affectation, true); if (is_string($affectation)) { return $affectation; } } else { if ($msg = $affectation->store()) { return $msg; } } if (!$idex->_id) { $idex->object_id = $affectation->_id; if ($msg = $idex->store()) { return $msg; } } return null; }
/* $Id$ */ /** * @package Mediboard * @subpackage dPrepas * @version $Revision$ * @author Sébastien Fillonneau */ CCanDo::checkEdit(); $date = CValue::getOrSession("date", CMbDT::date()); $typerepas_id = CValue::getOrSession("typerepas_id", null); $affectation_id = CValue::getOrSession("affectation_id", null); $affectation = new CAffectation(); $listRepas = new CMenu(); $typeRepas = new CTypeRepas(); $repas = new CRepas(); if (!$affectation->load($affectation_id) || !$typeRepas->load($typerepas_id)) { // Pas d'affectation CValue::setSession("affectation_id", null); CAppUI::setMsg("Veuillez sélectionner une affectation", UI_MSG_ALERT); CAppUI::redirect("m=dPrepas&tab=vw_planning_repas"); } else { $affectation->loadRefSejour(); $affectation->loadRefLit(); $affectation->_ref_lit->loadCompleteView(); $canAffectation = $affectation->canDo(); if (!$canAffectation->read || !$affectation->_ref_sejour->sejour_id || $affectation->_ref_sejour->type == "ambu") { // Droit Interdit ou Ambulatoire CValue::setSession("affectation_id", null); $affectation_id = null; if (!$affectation->_canRead) { $msg = "Vous n'avez pas les droit suffisant pour cette affectation";
* @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ */ $affectation_id = CValue::get("affectation_id"); $_link_affectation = CValue::get("_link_affectation", 0); $services_ids_suggest = CValue::get("services_ids_suggest"); $datetime = CValue::get("datetime"); if (!$datetime) { $datetime = CMbDT::dateTime(); } $entree = $datetime; $sortie = null; $lit_id = null; $affectation = new CAffectation(); $affectation->load($affectation_id)->loadRefLit()->loadRefChambre(); if (!$services_ids_suggest) { $group_id = CGroups::loadCurrent()->_id; $pref_services_ids = json_decode(CAppUI::pref("services_ids_hospi")); if (isset($pref_services_ids->{"g{$group_id}"})) { $services_ids = $pref_services_ids->{"g{$group_id}"}; if ($services_ids) { $services_ids_suggest = explode("|", $services_ids); } } if (!count($services_ids_suggest)) { $services_ids_suggest = array($affectation->_ref_lit->_ref_chambre->service_id); } } else { $services_ids_suggest = explode(",", $services_ids_suggest); }
/** * @see parent::store() */ function store() { $this->completeField("sejour_id", "lit_id", "entree", "sortie"); $create_affectations = false; $sejour = $this->loadRefSejour(); $sejour->loadRefPatient(); // Conserver l'ancien objet avant d'enregistrer $old = new CAffectation(); if ($this->_id) { $old->load($this->_id); // Si ce n'est pas la première affectation de la série, alors la ref_prev et la ref_next sont erronées // si prises depuis l'affectation old if (isset($this->_is_prev) || isset($this->_is_next)) { $this->loadRefsAffectations(); $old->_ref_prev = $this->_ref_prev; $old->_ref_next = $this->_ref_next; } else { $old->loadRefsAffectations(); } } // Gestion du service_id if ($this->lit_id) { $this->service_id = $this->loadRefLit(false)->loadRefChambre(false)->service_id; } // Gestion des UFs $this->makeUF(); // Si c'est une création d'affectation, avec ni une précédente ni une suivante, // que le séjour est relié à une grossesse, et que le module maternité est actif, // alors il faut créer les affectations des bébés. if (CModule::getActive("maternite") && !is_numeric($sejour->_ref_patient->nom) && $sejour->grossesse_id && !$this->_id) { $this->loadRefsAffectations(); if (!$this->_ref_prev->_id && !$this->_ref_next->_id) { $create_affectations = true; } } $store_prestations = false; if ($this->lit_id && $this->sejour_id && (!$this->_id || $this->fieldModified("lit_id"))) { $store_prestations = true; } // Si on place le patient alors que le séjour a déjà une sortie réelle // alors on passe le flag effectue à 1 sur l'affectation if (!$this->_id && $sejour->sortie_reelle) { $this->effectue = 1; } // Enregistrement standard if ($msg = parent::store()) { return $msg; } // Niveaux de prestations réalisées à créer // pour une nouvelle affectation (par rapport aux niveaux de prestations du lit) if ($store_prestations) { $this->loadRefsAffectations(); $lit = $this->_ref_lit; $liaisons_lit = $lit->loadRefsLiaisonsItems(); CMbObject::massLoadFwdRef($liaisons_lit, "item_prestation_id"); $where = array(); $ljoin = array(); $where["sejour_id"] = "= '{$sejour->_id}'"; $where["item_prestation.object_class"] = "= 'CPrestationJournaliere'"; // On teste également le réalisé, si une affectation avait déjà été faite puis supprimée. $ljoin["item_prestation"] = "item_prestation.item_prestation_id = item_liaison.item_souhait_id\r\n OR item_prestation.item_prestation_id = item_liaison.item_realise_id"; $filter_entree = CMbDT::date($this->entree); foreach ($liaisons_lit as $_liaison) { $item_liaison = new CItemLiaison(); $_item = $_liaison->loadRefItemPrestation(); // Recherche d'une liaison : // - date de début si première affectation ou dans la même journée // - le jour suivant sinon, car il doit y avoir un passage d'une case pour le calcul des prestations $where["item_prestation.object_id"] = "= '{$_item->object_id}'"; $where["date"] = "= '" . $filter_entree . "'"; $item_liaison->loadObject($where, null, null, $ljoin); // Si existante, alors on affecte le réalisé au niveau de prestation du lit if ($item_liaison->_id) { $item_liaison->item_realise_id = $_liaison->item_prestation_id; if ($msg = $item_liaison->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } } else { $item_liaison->sejour_id = $sejour->_id; $item_liaison->date = $filter_entree; $item_liaison->quantite = 0; $item_liaison->item_realise_id = $_liaison->item_prestation_id; // Recherche d'une précédente liaison pour appliquer l'item souhaité s'il existe $where["date"] = "<= '" . CMbDT::date($this->entree) . "'"; $ljoin["item_prestation"] = "item_prestation.item_prestation_id = item_liaison.item_souhait_id"; $_item_liaison_souhait = new CItemLiaison(); $_item_liaison_souhait->loadObject($where, "date DESC", null, $ljoin); if ($_item_liaison_souhait->_id) { $item_liaison->item_souhait_id = $_item_liaison_souhait->item_souhait_id; $item_liaison->sous_item_id = $_item_liaison_souhait->sous_item_id; } if ($msg = $item_liaison->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } } // Dans tous les cas, il faut parcourir les liaisons existantes entre les dates de début et fin de l'affectation $where["date"] = "BETWEEN '" . $filter_entree . "' AND '" . CMbDT::date($this->sortie) . "'"; $ljoin["item_prestation"] = "item_prestation.item_prestation_id = item_liaison.item_souhait_id\r\n OR item_prestation.item_prestation_id = item_liaison.item_realise_id"; $liaisons_existantes = $item_liaison->loadList($where, null, null, null, $ljoin); foreach ($liaisons_existantes as $_liaison_existante) { $_liaison_existante->item_realise_id = $_liaison->item_prestation_id; if ($msg = $_liaison_existante->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } } } } if ($create_affectations) { $grossesse = $this->_ref_sejour->loadRefGrossesse(); $naissances = $grossesse->loadRefsNaissances(); $sejours = CMbObject::massLoadFwdRef($naissances, "sejour_enfant_id"); foreach ($sejours as $_sejour) { $_affectation = new CAffectation(); $_affectation->lit_id = $this->lit_id; $_affectation->sejour_id = $_sejour->_id; $_affectation->parent_affectation_id = $this->_id; $_affectation->entree = CMbDT::dateTime(); $_affectation->sortie = $this->sortie; if ($msg = $_affectation->store()) { return $msg; } } } // Pas de problème de synchro pour les blocages de lits if (!$this->sejour_id || $this->_no_synchro) { return $msg; } // Modification de la date d'admission et de la durée de l'hospi $this->load($this->_id); if ($old->_id) { $this->_ref_prev = $old->_ref_prev; $this->_ref_next = $old->_ref_next; } else { $this->loadRefsAffectations(); } $changeSejour = 0; $changePrev = 0; $changeNext = 0; $prev = $this->_ref_prev; $next = $this->_ref_next; // Mise à jour vs l'entrée if (!$prev->_id) { if ($this->entree != $sejour->entree) { $field = $sejour->entree_reelle ? "entree_reelle" : "entree_prevue"; $sejour->{$field} = $this->entree; $changeSejour = 1; } } elseif ($this->entree != $prev->sortie) { $prev->sortie = $this->entree; $changePrev = 1; } // Mise à jour vs la sortie if (!$next->_id) { if ($this->sortie != $sejour->sortie) { $field = $sejour->sortie_reelle ? "sortie_reelle" : "sortie_prevue"; $sejour->{$field} = $this->sortie; $changeSejour = 1; } } elseif ($this->sortie != $next->entree) { $next->entree = $this->sortie; $changeNext = 1; } if ($changePrev) { $prev->_is_prev = 1; $prev->store(); } if ($changeNext) { $next->_is_next = 1; $next->store(); } if ($changeSejour) { $sejour->_no_synchro = 1; $sejour->updateFormFields(); if ($msg = $sejour->store()) { return $msg; } } return $msg; }
/** * Détermine les UFs d'hébergement, de soins et médicaux pour une date donnée * et éventuellement une affectation donnée * * @param null $date Date de référence * @param null $affectation_id Affectation spécifique * * @return array|CUniteFonctionnelle[] */ function getUFs($date = null, $affectation_id = null) { if (!$date) { $date = CMbDT::dateTime(); } if ($affectation_id) { $affectation = new CAffectation(); $affectation->load($affectation_id); } else { // Chargement de l'affectation courante $affectation = $this->getCurrAffectation($date); // Si on n'a pas d'affectation on va essayer de chercher la première if (!$affectation->_id) { $this->loadSurrAffectations(); $affectation = $this->_ref_next_affectation; } } if ($affectation->_id) { $ufs = $affectation->getUFs(); $this->uf_hebergement_id = $affectation->uf_hebergement_id; $this->uf_soins_id = $affectation->uf_soins_id; $this->uf_medicale_id = $affectation->uf_medicale_id; return $ufs; } else { $this->makeUF(); } return array("hebergement" => $this->loadRefUFHebergement(), "medicale" => $this->loadRefUFMedicale(), "soins" => $this->loadRefUFSoins()); }