$where[] = CAppUI::pref("showMissingRPU") ? "sejour.type = 'urg' OR rpu.rpu_id IS NOT NULL" : "rpu.rpu_id IS NOT NULL"; $where["sejour.sortie_reelle"] = "IS NULL"; $where["sejour.annule"] = " = '0'"; if (CAppUI::conf("dPurgences create_sejour_hospit")) { $where["rpu.mutation_sejour_id"] = "IS NULL"; } break; default: $where["affectation.entree"] = "<= '{$datetime_max}'"; $where["affectation.sortie"] = ">= '{$datetime_min}'"; $where["affectation.service_id"] = " = '{$service_id}'"; } $patients_offline = array(); /** @var CSejour[] $sejours */ $sejours = $sejour->loadList($where, null, null, "sejour.sejour_id", $ljoin); CSejour::massLoadSurrAffectation($sejours, $datetime_avg); CSejour::massLoadCurrAffectation($sejours, $datetime_avg, $service_id); CSejour::massLoadNDA($sejours); /** @var CPatient[] $patients */ $patients = CStoredObject::massLoadFwdRef($sejours, "patient_id"); CPatient::massLoadIPP($patients); CStoredObject::massCountBackRefs($sejours, "operations"); // Recherche de transmissions // observations // consultations $datetime_delta = CMbDT::date("-3 days", $datetime_avg); $sejours_ids = CMbArray::pluck($sejours, "_id"); $where = array("sejour_id" => CSQLDataSource::prepareIn($sejours_ids)); // Transmissions $whereTrans = $where; $whereTrans["libelle_atc"] = "IS NOT NULL"; $whereTrans["date"] = "BETWEEN '{$datetime_delta}' AND '{$datetime_avg}'"; $transmission = new CTransmissionMedicale();
$_affectation->_view = $_affectation->_ref_lit->_view; $sejour = $_affectation->loadRefSejour(1); $sejour->_ref_curr_affectation = $_affectation; } } } } } /* @var CPatient[] $patients */ $patients = CStoredObject::massLoadFwdRef($sejours, "patient_id"); CPatient::massLoadIPP($patients); CStoredObject::massLoadBackRefs($patients, "dossier_medical"); CStoredObject::massLoadFwdRef($sejours, "praticien_id"); CStoredObject::massCountBackRefs($sejours, "tasks", array("realise" => "= '0'"), array(), "taches_non_realisees"); CStoredObject::massLoadBackRefs($sejours, "dossier_medical"); CSejour::massLoadSurrAffectation($sejours); CSejour::massLoadBackRefs($sejours, "user_sejour"); CSejour::massLoadNDA($sejours); $count_my_patient = 0; foreach ($sejours as $sejour) { $count_my_patient += count($sejour->loadRefsUserSejour($userCourant)); $sejour->loadRefPatient(); $sejour->loadRefPraticien(); $sejour->checkDaysRelative($date); $sejour->loadRefPrescriptionSejour(); $prescription = $sejour->_ref_prescription_sejour; if ($prescription->_id) { $prescription->loadJourOp(CMbDT::date()); } // Chargement des taches non effectuées $sejour->_count_tasks = $sejour->_count["taches_non_realisees"];