/** * Check if the ressource is available or not, and set the color * * @return boolean */ function isAvailable() { $this->loadRefOperation(); $deb_op = $this->_ref_operation->_datetime_best; $fin_op = CMbDT::addDateTime($this->_ref_operation->temp_operation, $deb_op); $type_ressource = $this->loadRefTypeRessource(); $nb_ressources = $type_ressource->countBackRefs("ressources_materielles"); $_usage = $this->loadRefUsage(); $this->_color = '0a0'; // S'il y a un usage, alors on peut vérifier si conflit avec : // - un autre usage // - une indispo // - un besoin // Dans ce cas, on passe en rouge if ($_usage->_id) { $ressource = $_usage->loadRefRessource(); $_usages = $ressource->loadRefsUsages($deb_op, $fin_op); unset($_usages[$_usage->_id]); $_indispos = $ressource->loadRefsIndispos($deb_op, $fin_op); $_besoins = $ressource->loadRefsBesoins($deb_op, $fin_op); unset($_besoins[$this->_id]); if (count($_usages) + count($_indispos) + count($_besoins) >= $nb_ressources) { $this->_color = 'a00'; return 0; } return 1; } // Sinon, on parcourt les ressources associées au type de ressource du besoin. $ressources = $type_ressource->loadRefsRessources(); $_usages = 0; $_indispos = 0; $_besoins = 0; foreach ($ressources as $_ressource) { $_usages += count($_ressource->loadRefsUsages($deb_op, $fin_op)); $_indispos += count($_ressource->loadRefsIndispos($deb_op, $fin_op)); } // Pour compter les besoins, on ne le fait qu'une fois. // Car un besoin cible un type de ressource. // On décrémente d'une unité, car le besoin de la boucle est compté $_ressource = new CRessourceMaterielle(); $_ressource->type_ressource_id = $type_ressource->_id; $_besoins = count($_ressource->loadRefsBesoins($deb_op, $fin_op)) - 1; if ($_usages + $_indispos + $_besoins >= $nb_ressources) { $this->_color = 'a00'; return 0; } return 1; }
/** * @see parent::updatePlainFields() */ function updatePlainFields() { $this->loadRefPlageOp(); if ($this->_recuperation_start == "current") { $this->_recuperation_start = CMbDT::time(); } if ($this->_recuperation_end == "current") { $this->_recuperation_end = CMbDT::time(); } if ($this->_transfusion_start == "current") { $this->_transfusion_start = CMbDT::time(); } if ($this->_transfusion_end == "current") { $this->_transfusion_end = CMbDT::time(); } if ($this->_recuperation_start !== null && $this->_recuperation_start != "") { $this->_recuperation_start = CMbDT::time($this->_recuperation_start); $this->recuperation_start = CMbDT::addDateTime($this->_recuperation_start, CMbDT::date($this->_datetime)); } if ($this->_recuperation_start === "") { $this->recuperation_start = ""; } if ($this->_recuperation_end !== null && $this->_recuperation_end != "") { $this->_recuperation_end = CMbDT::time($this->_recuperation_end); $this->recuperation_end = CMbDT::addDateTime($this->_recuperation_end, CMbDT::date($this->_datetime)); } if ($this->_recuperation_end === "") { $this->recuperation_end = ""; } if ($this->_transfusion_start !== null && $this->_transfusion_start != "") { $this->_transfusion_start = CMbDT::time($this->_transfusion_start); $this->transfusion_start = CMbDT::addDateTime($this->_transfusion_start, CMbDT::date($this->_datetime)); } if ($this->_transfusion_start === "") { $this->transfusion_start = ""; } if ($this->_transfusion_end !== null && $this->_transfusion_end != "") { $this->_transfusion_end = CMbDT::time($this->_transfusion_end); $this->transfusion_end = CMbDT::addDateTime($this->_transfusion_end, CMbDT::date($this->_datetime)); } if ($this->_transfusion_end === "") { $this->transfusion_end = ""; } }
if ($where_service) { $where[] = $where_service; } $leftjoin["affectation"] = "sejour.sejour_id = affectation.sejour_id"; // Filtre sur les fonctions if ($filterFunction) { $leftjoin["users_mediboard"] = "sejour.praticien_id = users_mediboard.user_id"; $where["users_mediboard.function_id"] = " = '{$filterFunction}'"; } $sejour = new CSejour(); $alerte = $sejour->countList($where, null, $leftjoin); CApp::$chrono->stop("Patient à placer dans la semaine"); CApp::$chrono->start(); $affectation = new CAffectation(); $affectation->entree = CMbDT::addDateTime("08:00:00", $date); $affectation->sortie = CMbDT::addDateTime("23:00:00", $date); // Création du template $smarty = new CSmartyDP(); $smarty->assign("services_ids", $services_ids); $smarty->assign("affectation", $affectation); $smarty->assign("date", $date); $smarty->assign("demain", CMbDT::date("+ 1 day", $date)); $smarty->assign("heureLimit", $heureLimit); $smarty->assign("mode", $mode); $smarty->assign("emptySejour", $emptySejour); $smarty->assign("filterFunction", $filterFunction); $smarty->assign("totalLits", $totalLits); $smarty->assign("services", $services); $smarty->assign("alerte", $alerte); $smarty->assign("prestations", CPrestation::loadCurrentList()); $smarty->assign("prestation_id", $prestation_id);
/** * @see parent::updatePlainFields() */ function updatePlainFields() { if ($this->object_class == "COperation" || $this->object_class == "CBloodSalvage") { $this->loadRefObject(); $this->_ref_object->loadRefPlageOp(); if ($this->_debut == "current") { $this->_debut = CMbDT::time(); } if ($this->_fin == "current") { $this->_fin = CMbDT::time(); } if ($this->_debut !== null && $this->_debut != "") { $this->_debut = CMbDT::time($this->_debut); $this->debut = CMbDT::addDateTime($this->_debut, CMbDT::date($this->_ref_object->_datetime)); } if ($this->_fin !== null && $this->_fin != "") { $this->_fin = CMbDT::time($this->_fin); $this->fin = CMbDT::addDateTime($this->_fin, CMbDT::date($this->_ref_object->_datetime)); } if ($this->_debut_dt !== null && $this->_debut_dt != "") { $this->debut = $this->_debut_dt; } if ($this->_fin_dt !== null && $this->_fin_dt != "") { $this->fin = $this->_fin_dt; } // Suppression de la valeur if ($this->_debut === "") { $this->debut = ""; } if ($this->_fin === "") { $this->fin = ""; } // Mise a jour du champ realise if ($this->debut !== null && $this->fin !== null) { $this->realise = 1; } if ($this->debut === "" || $this->fin === "") { $this->realise = 0; } } }
$affectation->entree = $entree; $affectation->sortie = $sortie; if ($_lock_all_lits_urgences) { $affectation->function_id = $function_id; } if ($msg = $affectation->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } } } echo CAppUI::getMsg(); CApp::rip(); } else { $tolerance = CAppUI::conf("dPhospi CAffectation create_affectation_tolerance", CGroups::loadCurrent()); $sejour_id = CValue::post("sejour_id"); $affectation_id = CValue::post("affectation_id"); //Si on est en création d'afectation et qu'il y a un sejour_id if (!$affectation_id && $sejour_id) { $sejour = new CSejour(); $sejour->load($sejour_id); $curr_affectation = $sejour->loadRefCurrAffectation(); //On modifie au lieu de créer une affectation si l'afectation courante ne dépasse pas la tolérance if ($curr_affectation && $curr_affectation->_id) { if (CMbDT::addDateTime("00:{$tolerance}:00", $curr_affectation->entree) > $entree) { $_POST["affectation_id"] = $curr_affectation->_id; } } } $do = new CDoObjectAddEdit("CAffectation", "affectation_id"); $do->doIt(); }
/** * Charge la plage de consultation englobante * * @param boolean $cache [optional] Use cache * * @return CPlageconsult */ function loadRefPlageConsult($cache = true) { $this->completeField("plageconsult_id"); /** @var CPlageConsult $plage */ $plage = $this->loadFwdRef("plageconsult_id", $cache); $time = CMbDT::time("+" . CMbDT::minutesRelative("00:00:00", $plage->freq) * $this->duree . " MINUTES", $this->heure); $this->_date_fin = "{$plage->date} {$time}"; $this->_duree = CMbDT::minutesRelative("00:00:00", $plage->freq) * $this->duree; $plage->_ref_chir = $plage->loadFwdRef("chir_id", $cache); $plage->_ref_remplacant = $plage->loadFwdRef("remplacant_id", $cache); // Distant fields /** @var CMediusers $chir */ $chir = $plage->_ref_remplacant->_id ? $plage->_ref_remplacant : $plage->_ref_chir; $this->_date = $plage->date; $this->_datetime = CMbDT::addDateTime($this->heure, $this->_date); $this->_acte_execution = $this->_datetime; $this->_is_anesth = $chir->isAnesth(); $this->_is_dentiste = $chir->isDentiste(); $this->_praticien_id = $chir->_id; $this->_ref_chir = $chir; return $this->_ref_plageconsult = $plage; }
/** * 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; }
/** * Force la création d'une affectation en fonction de la tolérance(?) * * @param CAffectation $affectation Affectation concernée * @param bool $no_synchro No synchro * * @todo A détailler * @return CAffectation|null|string|void */ function forceAffectation(CAffectation $affectation, $no_synchro = false) { $datetime = $affectation->entree; $lit_id = $affectation->lit_id; $service_id = $affectation->service_id; $tolerance = CAppUI::conf("dPhospi CAffectation create_affectation_tolerance", CGroups::loadCurrent()); $splitting = new CAffectation(); $where["sejour_id"] = "= '{$this->_id}'"; $where["entree"] = "<= '{$datetime}'"; $where["sortie"] = ">= '{$datetime}'"; $splitting->loadObject($where); $create = new CAffectation(); // On retrouve une affectation a spliter if ($splitting->_id) { //on ne splite pas et on ne créé pas d'affectation si la tolérance n'est pas atteinte if (CMbDT::addDateTime("00:{$tolerance}:00", $splitting->entree) <= $affectation->entree || $affectation->_mutation_urg) { // Affecte la sortie de l'affectation a créer avec l'ancienne date de sortie $create->sortie = $splitting->sortie; $create->entree = $datetime; // On passe à effectuer la split $splitting->effectue = 1; $splitting->sortie = $datetime; $splitting->_no_synchro = $no_synchro; $splitting->_mutation_urg = $affectation->_mutation_urg; if ($msg = $splitting->store()) { return $msg; } } else { $create->affectation_id = $splitting->affectation_id; $create->sortie = $splitting->sortie; } } else { $create->entree = $datetime; $create->sortie = $this->sortie; } // Créé la nouvelle affectation $create->sejour_id = $this->_id; $create->lit_id = $lit_id; $create->service_id = $service_id; $create->_mutation_urg = $affectation->_mutation_urg; $create->_no_synchro = $no_synchro; if ($msg = $create->store()) { return $msg; } return $create; }
} $ljoin = array(); $ljoin['plagesop'] = "plagesop.plageop_id = operations.plageop_id"; $where = array(); $where[] = "(plagesop.date BETWEEN '{$debut}' AND '{$fin}') OR (operations.date BETWEEN '{$debut}' AND '{$fin}')"; $where["operations.sejour_id"] = " = '{$sejour_id}'"; $operation = new COperation(); $operations = $operation->loadList($where, null, null, "operation_id", $ljoin); foreach ($operations as $_operation) { /* @var COperation $_operation*/ $_operation->loadRefChir(); $_operation->loadRefPlageOp(); $color = "#fcc"; $class = null; if ($_operation->_acte_execution == $_operation->_datetime) { $_operation->_acte_execution = CMbDT::addDateTime($_operation->temp_operation, $_operation->_datetime); } $libelle = "Intervention par le Dr " . $_operation->_ref_chir->_view . " - {$_operation->libelle}"; $event = new CPlanningEvent($_operation->_guid, $_operation->_datetime, CMbDT::minutesRelative($_operation->_datetime, $_operation->_acte_execution), $libelle, $color, true); $event->onmousover = true; $planning->addEvent($event); } $dates = array($debut, $fin); $prescription = $sejour->loadRefPrescriptionSejour(); $lines["imagerie"] = $prescription->loadRefsLinesElement(null, "imagerie"); $lines["kine"] = $prescription->loadRefsLinesElement(null, "kine"); foreach ($lines as $category => $cat) { $color = $category == "kine" ? "#ccf" : "aaa"; foreach ($cat as $_line) { /* @var CPrescriptionLineElement $_line*/ // Chargement des planifications pour la date courante
// Les besoins sur cete même période $besoins = $ressource->loadRefsBesoins($date_min, $date_max); unset($besoins[$besoin_ressource_id]); foreach ($besoins as $key => $_besoin) { $_operation = $_besoin->loadRefOperation(); $_operation->loadRefPlageOp(); $_debut_op = $_operation->_datetime; $_fin_op = CMbDT::addDateTime($_operation->temp_operation, $_debut_op); $_besoin->_debut_offset = CMbDate::position($_debut_op, $date_min, "1hour"); $_besoin->_fin_offset = CMbDate::position(min($date_max, $_fin_op), $date_min, "1hour"); $_besoin->_width = $_besoin->_fin_offset - $_besoin->_debut_offset; if ($_besoin->_width <= 0) { unset($besoins[$key]); } foreach ($ressources as $_ressource) { if ($min_fin_op <= $_debut_op && CMbDT::addDateTime($_ressource->retablissement, $min_fin_op) > $_debut_op) { $display_alert[$_ressource->_id] = 1; } } } $smarty = new CSmartyDP(); $smarty->assign("ressources", $ressources); $smarty->assign("hours", $hours); $smarty->assign("operation", $operation); $smarty->assign("date", $date); $smarty->assign("date_before", $date_before); $smarty->assign("date_after", $date_after); $smarty->assign("besoins", $besoins); $smarty->assign("usage", $usage); $smarty->assign("display_alert", $display_alert); $smarty->assign("usages_by_ressource", $usages_by_ressource);
$hour_intervention = CValue::get("hour_intervention"); $duree = CValue::get("duree"); //days $duree_hours = $duree * 24; // hours if ($operation_id) { $operation = new COperation(); $operation->load($operation_id); $sejour = $operation->loadRefSejour(); } else { $sejour = new CSejour(); $sejour->load($sejour_id); if ($new_sejour) { $sejour->_id = null; $entree_prevue = CMbDT::date($date_move) . " " . $hour_intervention; $sortie_prevue = CMbDT::addDateTime($duree_hours, $entree_prevue); } } if (!$date_move) { $date_move = "{$operation->date} {$operation->time_operation}"; } if ($entree_prevue && $sortie_prevue) { $sejour->entree_prevue = $entree_prevue; $sejour->sortie_prevue = $sortie_prevue; } if (isset($operation)) { $nb_days = CMbDT::daysRelative("{$operation->date} {$operation->time_operation}", $date_move); } else { $nb_days = CMbDT::daysRelative($sejour->entree_prevue, $entree_prevue); } if ($nb_days > 0) {
if (!$modify_affectation) { $do = new CDoObjectAddEdit("CAffectation", "affectation_id"); $_POST["ajax"] = 1; $_POST["entree"] = $_POST["_date_split"]; $_POST["sortie"] = $sortie; $_POST["lit_id"] = $_POST["_new_lit_id"]; $_POST["affectation_id"] = null; $do->doSingle(false); } // Gérer le déplacement du ou des bébés si nécessaire if (CModule::getActive("maternite")) { /** @var CAffectation[] $affectations_enfant */ $affectations_enfant = $first_affectation->loadBackRefs("affectations_enfant"); foreach ($affectations_enfant as $_affectation) { $save_sortie = $_affectation->sortie; $modify_affectation_enfant = CMbDT::addDateTime("00:{$tolerance}:00", $_affectation->entree) > $_POST["_date_split"]; if ($modify_affectation_enfant) { $_affectation->lit_id = $_POST["_new_lit_id"]; } else { $_affectation->sortie = $_POST["_date_split"]; } if ($msg = $_affectation->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } if (!$modify_affectation_enfant) { $affectation = new CAffectation(); $affectation->lit_id = $_POST["_new_lit_id"]; $affectation->sejour_id = $_affectation->sejour_id; $affectation->parent_affectation_id = $do->_obj->_id; $affectation->entree = $_POST["_date_split"]; $affectation->sortie = $save_sortie;
$moments = array(); $dates_plan_soin = array(); $periods = ""; while ($date_temp <= $date_max) { $dates[$date_temp] = $date_temp; $date_temp = CMbDT::date("+1 day", $date_temp); } $colspan = 0; switch ($freq_poste) { case "1": case "2": case "4": $date_temp = CMbDT::transform(null, $datetime_min, "%Y-%m-%d %H:00:00"); while ($date_temp < CMbDT::transform(null, $datetime_max, "%Y-%m-%d %H:00:00")) { @($dates_plan_soin[CMbDT::date($date_temp)][CMbDT::time($date_temp)] = CMbDT::transform(null, $date_temp, "%H")); $date_temp = CMbDT::addDateTime("{$freq_poste}:00:00", $date_temp); $colspan++; } // Il faut tester la parité de l'heure de début. $count = 1; $first_key = reset($dates_plan_soin); $first_key = reset($first_key); for ($i = intval($first_key) % $freq_poste; $i < 24; $i += $freq_poste) { $postes["Poste {$count}"] = str_pad($i, 2, "0", STR_PAD_LEFT); $postes_to_hour[str_pad($i, 2, "0", STR_PAD_LEFT)] = str_pad($i, 2, "0", STR_PAD_LEFT); $moments["poste-{$count}"] = str_pad($i, 2, "0", STR_PAD_LEFT); $count++; $periods[] = $i; } break; case "poste":
* @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 = ""; continue; } $_besoin->isAvailable(); } $smarty = new CSmartyDP(); $smarty->assign("besoins", $besoins); $smarty->assign("object_id", $object_id); $smarty->assign("type", $type); $smarty->assign("usage", $usage);
/** * Récupération de la sortie * * @param DOMNode $node Node * @param CSejour $mbVenue Venue * * @return CSejour */ static function getSortie(DOMNode $node, CSejour $mbVenue) { $xpath = new CHPrimXPath($node->ownerDocument); $sortie = $xpath->queryUniqueNode("hprim:sortie", $node); $date = $xpath->queryTextNode("hprim:dateHeureOptionnelle/hprim:date", $sortie); $heure = CMbDT::transform($xpath->queryTextNode("hprim:dateHeureOptionnelle/hprim:heure", $sortie), null, "%H:%M:%S"); if ($date) { $dateHeure = "{$date} {$heure}"; } elseif (!$date && !$mbVenue->sortie_prevue) { $config = CAppUI::conf("dPplanningOp CSejour sortie_prevue " . $mbVenue->type); $dateHeure = CMbDT::addDateTime($config . ":00:00", $mbVenue->entree_reelle ? $mbVenue->entree_reelle : $mbVenue->entree_prevue); } else { $dateHeure = $mbVenue->sortie_reelle ? $mbVenue->sortie_reelle : $mbVenue->sortie_prevue; } // Cas dans lequel on ne récupère pas de sortie tant que l'on a pas la sortie réelle if (CAppUI::conf("hprimxml notifier_sortie_reelle") && self::getEtatVenue($node) == "clôturée") { $mbVenue->sortie_reelle = $dateHeure; } else { $mbVenue->sortie_prevue = $dateHeure; } $modeSortieHprim = $xpath->queryAttributNode("hprim:modeSortieHprim", $sortie, "valeur"); if (!$modeSortieHprim) { return $mbVenue; } // décès switch ($modeSortieHprim) { case "05": $mbVenue->mode_sortie = "deces"; break; case "02": // autre transfert dans un autre CH $mbVenue->mode_sortie = "transfert"; $destination = $xpath->queryUniqueNode("hprim:destination", $sortie); if ($destination) { $mbVenue = self::getEtablissementTransfert($mbVenue); } break; default: //retour au domicile $mbVenue->mode_sortie = "normal"; break; } return $mbVenue; }
/** * Calculs sur les champs d'horodatage dérivés, notamment en fonction de la plage * * @return void; */ function updateDatetimes() { $plage = $this->_ref_plageop; $date = $this->date; // Calcul du nombre de jour entre la date actuelle et le jour de l'operation $this->_compteur_jour = CMbDT::daysRelative($date, CMbDT::date()); // Horaire global if ($this->time_operation && $this->time_operation != "00:00:00") { $this->_datetime = "{$date} {$this->time_operation}"; } elseif ($this->horaire_voulu && $this->horaire_voulu != "00:00:00") { $this->_datetime = "{$date} {$this->horaire_voulu}"; } elseif ($plage && $plage->_id) { $this->_datetime = "{$date} " . $plage->debut; } else { $this->_datetime = "{$date} 00:00:00"; } $this->_datetime_best = $this->_datetime; $this->_datetime_reel = "{$date} {$this->debut_op}"; if ($this->debut_op) { $this->_datetime_best = $this->_datetime_reel; } $this->_datetime_reel_fin = "{$date} {$this->fin_op}"; // Heure standard d'exécution des actes if ($this->fin_op) { $this->_acte_execution = $this->_datetime_reel_fin; } elseif ($this->debut_op) { $this->_acte_execution = CMbDT::addDateTime($this->temp_operation, $this->_datetime_reel); } elseif ($this->time_operation != "00:00:00") { $this->_acte_execution = CMbDT::addDateTime($this->temp_operation, $this->_datetime); } else { $this->_acte_execution = $this->_datetime; } }
/** * Récupération de la d'entrée prévue * * @param DOMNode $node PV2 Node * @param CSejour $newVenue Admit * * @return void */ function getExpectedAdmitDischarge(DOMNode $node, CSejour $newVenue) { $entree_prevue = $this->queryTextNode("PV2.8", $node); $sortie_prevue = $this->queryTextNode("PV2.9", $node); if (!$entree_prevue) { $entree_prevue = $newVenue->entree_reelle ? $newVenue->entree_reelle : $newVenue->entree_prevue; } $newVenue->entree_prevue = $entree_prevue; if (!$sortie_prevue && !$newVenue->sortie_prevue) { $newVenue->sortie_prevue = CMbDT::addDateTime(CAppUI::conf("dPplanningOp CSejour sortie_prevue " . $newVenue->type) . ":00:00", $newVenue->entree_reelle ? $newVenue->entree_reelle : $newVenue->entree_prevue); } elseif (!$sortie_prevue && $newVenue->sortie_prevue) { // On ne modifie pas la sortie de Mediboard si on ne l'a pas dans le message } elseif ($sortie_prevue && preg_match("/^\\d{4}-\\d\\d-\\d\\d( 00:00:00)?\$/", $sortie_prevue)) { $newVenue->sortie_prevue = CMbDT::date($sortie_prevue) . " 00:00:00"; } elseif ($sortie_prevue && preg_match("/\\d{4}-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d/", $sortie_prevue)) { $newVenue->sortie_prevue = $sortie_prevue; } else { $newVenue->sortie_prevue = $newVenue->sortie_reelle ? $newVenue->sortie_reelle : $newVenue->sortie_prevue; } // On récupère l'entrée et sortie réelle ssi !entree_prevue && !sortie_prevue $parentNode = $node->parentNode; if (!$newVenue->entree_prevue) { $newVenue->entree_prevue = $this->queryTextNode("PV1.44", $this->queryNode("PV1", $parentNode)); } if (!$newVenue->sortie_prevue) { $newVenue->sortie_prevue = $this->queryTextNode("PV1.45", $this->queryNode("PV1", $parentNode)); } // Si les dates entrées/sorties sont incohérentes $sender = $this->_ref_sender; if ($sender->_configs["control_date"] == "permissif") { $newVenue->entree_prevue = min($newVenue->entree_prevue, $newVenue->sortie_prevue); $newVenue->sortie_prevue = max($newVenue->entree_prevue, $newVenue->sortie_prevue); } }
$affectation_cut->parent_affectation_id = $affectation_maman->_id; } } } if ($msg = $affectation->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } if ($msg = $affectation_cut->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); } // Scinder également les affectations des enfants if ($affectation->countBackRefs("affectations_enfant")) { $affectations_enfant = $affectation->loadBackRefs("affectations_enfant"); foreach ($affectations_enfant as $_affectation_enfant) { /** @var CAffectation $_affectation_enfant */ if (CMbDT::addDateTime("00:{$tolerance}:00", $_affectation_enfant->entree) > $_date_cut) { $_affectation = $_affectation_enfant; } else { $_affectation = new CAffectation(); $_affectation->entree = $_date_cut; $_affectation->sejour_id = $_affectation_enfant->sejour_id; $_affectation->sortie = $_affectation_enfant->sortie; $_affectation->uf_hebergement_id = $_affectation_enfant->uf_hebergement_id; $_affectation->uf_medicale_id = $_affectation_enfant->uf_medicale_id; $_affectation->uf_soins_id = $_affectation_enfant->uf_soins_id; $_affectation_enfant->sortie = $_date_cut; } $_affectation->lit_id = $lit_id ? $lit_id : $_affectation_enfant->lit_id; $_affectation->parent_affectation_id = $affectation_cut->_id; if ($msg = $_affectation_enfant->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR);