Esempio n. 1
0
 $kine = $_plage_conge->loadRefUser();
 $_sejours = array();
 $date_min = max($monday, $_plage_conge->date_debut);
 $date_max = CMbDT::date("+1 DAY", min($sunday, $_plage_conge->date_fin));
 // Cas des remplacements kinés
 if ($type == "kine" && !$_plage_conge->_activite) {
     $_sejours = CBilanSSR::loadSejoursSurConges($_plage_conge, $monday, $sunday);
 }
 // Cas des transferts de rééducateurs
 if ($type == "reeducateur") {
     $evenement = new CEvenementSSR();
     $where = array();
     $where["debut"] = " BETWEEN '{$date_min}' AND '{$date_max}'";
     $where["therapeute_id"] = " = '{$_plage_conge->user_id}'";
     /** @var CEvenementSSR[] $evenements */
     $evenements = $evenement->loadList($where);
     foreach ($evenements as $_evenement) {
         $sejour = $_evenement->loadRefSejour();
         $bilan = $sejour->loadRefBilanSSR();
         $bilan->loadRefTechnicien();
         $_sejours[$sejour->_id] = $sejour;
     }
 }
 foreach ($_sejours as $_sejour) {
     // On compte le nombre d'evenements SSR à transferer
     $evenement_ssr = new CEvenementSSR();
     $where = array();
     $where["sejour_id"] = " = '{$_sejour->_id}'";
     $where["therapeute_id"] = " = '{$_plage_conge->user_id}'";
     $where["debut"] = " BETWEEN '{$date_min}' AND '{$date_max}'";
     $count_evts["{$_plage_conge->_id}-{$_sejour->_id}"] = $evenement_ssr->countList($where);
$kine->load($kine_id);
$sejour = new CSejour();
$sejour->load($sejour_id);
$nb_days_planning = $sejour->_id ? $sejour->getNbJourPlanning($date) : CEvenementSSR::getNbJoursPlanning($kine_id, $date);
$planning = new CPlanningWeek($date, null, null, $nb_days_planning, $selectable, $height, $large, !$print);
$planning->title = $surveillance ? "Surveillance '{$kine->_view}'" : "Rééducateur '{$kine->_view}'";
$planning->guid = $kine->_guid;
$planning->guid .= $surveillance ? "-surv" : "-tech";
// Chargement des evenement SSR
$evenement = new CEvenementSSR();
$where = array();
$where["debut"] = "BETWEEN '{$planning->_date_min_planning} 00:00:00' AND '{$planning->_date_max_planning} 23:59:59'";
$where["therapeute_id"] = " = '{$kine->_id}'";
$where["type_seance"] = $surveillance ? " = 'non_dediee'" : " <> 'non_dediee'";
/** @var CEvenementSSR[] $evenements */
$evenements = $evenement->loadList($where);
// Chargement des evenements SSR de "charge"
$where["type_seance"] = $surveillance ? " <> 'non_dediee'" : " = 'non_dediee'";
/** @var CEvenementSSR[] $evenements_charge */
$evenements_charge = $evenement->loadList($where);
foreach ($evenements_charge as $_evenement) {
    $planning->addLoad($_evenement->debut, $_evenement->duree);
}
CMbObject::massLoadFwdRef($evenements, "prescription_line_element_id");
CMbObject::massLoadFwdRef($evenements, "equipement_id");
$therapeutes = CMbObject::massLoadFwdRef($evenements, "therapeute_id");
CMbObject::massLoadFwdRef($therapeutes, "function_id");
CMbObject::massCountBackRefs($evenements, "evenements_ssr");
CMbObject::massCountBackRefs($evenements, "actes_cdarr");
CMbObject::massCountBackRefs($evenements, "actes_csarr");
foreach ($evenements as $_evenement) {
CCanDo::checkRead();
$date = CValue::getOrSession("date", CMbDT::date());
$therapeute_id = CValue::get("therapeute_id");
$equipement_id = CValue::get("equipement_id");
$prescription_line_element_id = CValue::get("prescription_line_element_id");
$monday = CMbDT::date("last monday", CMbDT::date("+1 day", $date));
$sunday = CMbDT::date("next sunday", CMbDT::date("-1 DAY", $date));
// Chargement de la ligne
$line_element = new CPrescriptionLineElement();
$line_element->load($prescription_line_element_id);
$element_prescription_id = $line_element->element_prescription_id;
// Chargement des seances en fonction des parametres selectionnés
$seance = new CEvenementSSR();
$ljoin = array();
$ljoin[] = "evenement_ssr AS evt_seance ON (evt_seance.seance_collective_id = evenement_ssr.evenement_ssr_id)";
$ljoin["prescription_line_element"] = "evt_seance.prescription_line_element_id = prescription_line_element.prescription_line_element_id";
$where = array();
$where["evenement_ssr.sejour_id"] = " IS NULL";
$where["evenement_ssr.debut"] = "BETWEEN '{$monday} 00:00:00' AND '{$sunday} 23:59:59'";
$where["evenement_ssr.therapeute_id"] = " = '{$therapeute_id}'";
if ($equipement_id) {
    $where["evenement_ssr.equipement_id"] = " = '{$equipement_id}'";
} else {
    $where["evenement_ssr.equipement_id"] = " IS NULL";
}
$where["prescription_line_element.element_prescription_id"] = " = '{$element_prescription_id}'";
$seances = $seance->loadList($where, null, null, "evenement_ssr_id", $ljoin);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("seances", $seances);
$smarty->display("inc_vw_select_seance.tpl");
Esempio n. 4
0
$sejour = new CSejour();
$sejour->load($sejour_id);
$sejour->loadRefPatient();
$sejour->loadRefPraticien();
$bilan = $sejour->loadRefBilanSSR();
$technicien = $bilan->loadRefTechnicien();
$technicien->loadRefKine();
// Chargement des evenement SSR
$monday = CMbDT::date("last monday", CMbDT::date("+1 day", $date));
$sunday = CMbDT::date("next sunday", CMbDT::date("-1 DAY", $date));
$evenement_ssr = new CEvenementSSR();
$where = array();
$where["sejour_id"] = " = '{$sejour_id}'";
$where["debut"] = "BETWEEN '{$monday} 00:00:00' AND '{$sunday} 23:59:59'";
/** @var CEvenementSSR[] $evenements */
$evenements = $evenement_ssr->loadList($where);
$elements = array();
$intervenants = array();
foreach ($evenements as $_evenement) {
    $line = $_evenement->loadRefPrescriptionLineElement();
    $element = $line->_ref_element_prescription;
    $_evenement->loadRefTherapeute();
    $elements[$element->_id] = $element;
    $intervenants[$element->_id][$_evenement->therapeute_id] = $_evenement->_ref_therapeute;
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("date", $date);
$smarty->assign("elements", $elements);
$smarty->assign("intervenants", $intervenants);
$smarty->assign("sejour", $sejour);
Esempio n. 5
0
$large = CValue::get("large");
// Initialisation du planning
$date = CValue::getOrSession("date", CMbDT::date());
$nb_days_planning = $sejour->getNbJourPlanning($date);
$planning = new CPlanningWeek($date, $sejour->entree, $sejour->sortie, $nb_days_planning, $selectable, $height, $large, !$print);
$planning->title = "Patient '{$patient->_view}'";
$planning->guid = $sejour->_guid;
// Chargement des evenement SSR (ainsi que les seances collectives)
$evenement = new CEvenementSSR();
$ljoin = array();
$ljoin[] = "evenement_ssr AS evt_seance ON (evt_seance.seance_collective_id = evenement_ssr.evenement_ssr_id)";
$where = array();
$where[] = "(evenement_ssr.sejour_id = '{$sejour->_id}') OR (evenement_ssr.sejour_id IS NULL AND evt_seance.sejour_id = '{$sejour->_id}')";
$where["evenement_ssr.debut"] = "BETWEEN '{$planning->_date_min_planning} 00:00:00' AND '{$planning->_date_max_planning} 23:59:59'";
/** @var CEvenementSSR[] $evenements */
$evenements = $evenement->loadList($where, null, null, null, $ljoin);
foreach ($evenements as $_evenement) {
    if (!$_evenement->sejour_id) {
        // Chargement de l'evenement pour ce sejour
        $evt = new CEvenementSSR();
        $evt->sejour_id = $sejour->_id;
        $evt->seance_collective_id = $_evenement->_id;
        $evt->loadMatchingObject();
        // On reaffecte les valeurs indispensables a l'affichage
        $evt->debut = $_evenement->debut;
        $evt->duree = $_evenement->duree;
        $draggable_guid = $_evenement->_guid;
        // Remplacement de la seance collective par le bon evenement
        $_evenement = $evt;
    } else {
        $draggable_guid = $_evenement->_guid;
Esempio n. 6
0
foreach ($sejours as $_sejour) {
    $patient = $_sejour->loadRefPatient();
    foreach ($patient->loadRefsSejours() as $_other_sejour) {
        $_other_sejour->loadRefPatient();
        $all_sejours[$_other_sejour->_id] = $_other_sejour;
        $_other_sejour->loadRefBilanSSR()->loadRefTechnicien();
        $therapeutes += CEvenementSSR::getAllTherapeutes($_other_sejour->patient_id, $user->function_id);
    }
}
// Chargement des comptes d'événements
$evenements_counts = array();
$evenement = new CEvenementSSR();
$where["sejour_id"] = CSQLDataSource::prepareIn(array_keys($all_sejours));
$where["therapeute_id"] = CSQLDataSource::prepareIn(array_keys($therapeutes));
/** @var CEvenementSSR $_evenement */
foreach ($evenement->loadList($where) as $_evenement) {
    @$evenements_counts[$_evenement->sejour_id][$_evenement->therapeute_id]++;
}
if (!$replacement->_id) {
    $replacement->conge_id = $conge_id;
    $replacement->sejour_id = $sejour_id;
}
$transfer_count = 0;
$transfer_counts = array();
// Transfer event count
if ($type == 'kine') {
    $date_min = $conge->date_debut;
    $date_max = CMbDT::date("+1 DAY", $conge->date_fin);
    foreach ($sejours as $_sejour) {
        $bilan = $_sejour->loadRefBilanSSR();
        $tech = $bilan->loadRefTechnicien();
Esempio n. 7
0
 /**
  * @see parent::delete()
  */
 function delete()
 {
     // Lors de la suppression du remplacant, on reaffecte les evenements au kine principal
     $this->completeField("sejour_id", "conge_id", "replacer_id");
     $conge = $this->loadRefConge();
     $sejour = $this->loadRefSejour();
     $bilan = $sejour->loadRefBilanSSR();
     $bilan->loadRefTechnicien();
     $date_debut = $conge->date_debut;
     $date_fin = CMbDT::date("+1 DAY", $conge->date_fin);
     $evenement_ssr = new CEvenementSSR();
     $where = array();
     $where["therapeute_id"] = " = '{$this->replacer_id}'";
     $where["sejour_id"] = " = '{$this->sejour_id}'";
     $where["debut"] = "BETWEEN '{$date_debut}' AND '{$date_fin}'";
     /** @var CEvenementSSR[] $evenements */
     $evenements = $evenement_ssr->loadList($where);
     foreach ($evenements as $_evenement) {
         $_evenement->therapeute_id = $sejour->_ref_bilan_ssr->_ref_technicien->kine_id;
         if ($msg = $_evenement->store()) {
             CAppUI::setMsg($msg, UI_MSG_WARNING);
         }
     }
     return parent::delete();
 }