Example #1
0
 /**
  * Charge les séjours pour ce technicien en tant que référent à une date donnée
  *
  * @param date $date Date de reference
  *
  * @return CSejour[]
  */
 function loadRefsSejours($date)
 {
     $group = CGroups::loadCurrent();
     $leftjoin["bilan_ssr"] = "bilan_ssr.sejour_id = sejour.sejour_id";
     $where["type"] = "= 'ssr'";
     $where["group_id"] = "= '{$group->_id}'";
     $where["annule"] = "= '0'";
     $where["bilan_ssr.technicien_id"] = "= '{$this->_id}'";
     return $this->_ref_sejours_date = CSejour::loadListForDate($date, $where, null, null, null, $leftjoin);
 }
Example #2
0
 /**
  * Load Sejour for technicien at a date
  *
  * @param int  $technicien_id           Le technicien concerné
  * @param date $date                    La date de référence
  * @param bool $show_cancelled_services Afficher ou non les services inactifs
  *
  * @return CSejour[]
  */
 static function loadSejoursSSRfor($technicien_id, $date, $show_cancelled_services = true)
 {
     $group = CGroups::loadCurrent();
     // Masquer les services inactifs
     if (!$show_cancelled_services) {
         $service = new CService();
         $service->group_id = $group->_id;
         $service->cancelled = "1";
         $services = $service->loadMatchingList();
         $where[] = "sejour.service_id IS NULL OR sejour.service_id " . CSQLDataSource::prepareNotIn(array_keys($services));
     }
     $where["type"] = "= 'ssr'";
     $where["group_id"] = "= '{$group->_id}'";
     $where["annule"] = "= '0'";
     $where["bilan_ssr.technicien_id"] = $technicien_id ? "= '{$technicien_id}'" : "IS NULL";
     $leftjoin["bilan_ssr"] = "bilan_ssr.sejour_id = sejour.sejour_id";
     return CSejour::loadListForDate($date, $where, "entree_reelle", null, null, $leftjoin);
 }
foreach ($_days as $_number) {
    $days[] = CMbDT::date("+{$_number} DAYS", $monday);
}
if (!count($_days)) {
    $date = !count($_days) ? $date : reset($days);
}
$ljoin = array();
$ljoin["prescription"] = "sejour.sejour_id = prescription.object_id AND prescription.object_class = 'CSejour'";
$ljoin["prescription_line_element"] = "prescription_line_element.prescription_id = prescription.prescription_id";
$where = array();
$where["prescription.prescription_id"] = "IS NOT NULL";
$where["prescription_line_element.element_prescription_id"] = " = '{$element_id}'";
$where["sejour.type"] = "= 'ssr'";
$where["sejour.sejour_id"] = " <> '{$sejour_id}'";
$where["sejour.annule"] = " = '0'";
$sejours = CSejour::loadListForDate($date, $where, "entree", null, "sejour_id", $ljoin);
foreach ($sejours as $_sejour) {
    /* @var CSejour $_sejour*/
    $patient = $_sejour->loadRefPatient();
    $patient->loadIPP();
    $_sejour->loadRefPraticien();
    $bilan = $_sejour->loadRefBilanSSR();
    $bilan->loadRefPraticienDemandeur();
    $bilan->loadRefKineReferent();
    // Détail du séjour
    $_sejour->checkDaysRelative($date);
    $_sejour->loadNDA();
    $_sejour->loadRefsNotes();
    // Chargement du lit
    $_sejour->loadRefCurrAffectation()->loadRefLit();
}
}
if ($order_col == "libelle") {
    $order = "sejour.libelle {$order_way}, patients.nom, patients.prenom";
}
if ($order_col == "service_id") {
    $order = "sejour.service_id {$order_way}, patients.nom, patients.prenom";
}
// Masquer les services inactifs
if (!$show_cancelled_services) {
    $service = new CService();
    $service->group_id = $group->_id;
    $service->cancelled = "1";
    $services = $service->loadMatchingList();
    $where[] = " sejour.service_id IS NULL OR sejour.service_id " . CSQLDataSource::prepareNotIn(array_keys($services));
}
$sejours = CSejour::loadListForDate($date, $where, $order, null, null, $ljoin);
// Filtre sur les services
$services = array();
$praticiens = array();
$kines = array();
$sejours_by_kine = array("" => array());
CStoredObject::massLoadFwdRef($sejours, "praticien_id");
CStoredObject::massLoadBackRefs($sejours, "bilan_ssr");
// Filtres des séjours
foreach ($sejours as $_sejour) {
    // Filtre sur service
    $service = $_sejour->loadFwdRef("service_id", true);
    $services[$service->_id] = $service;
    if ($filter->service_id && $_sejour->service_id != $filter->service_id) {
        unset($sejours[$_sejour->_id]);
        continue;