$date = CValue::getOrSession("date", CMbDT::date());
$page = CValue::get("page", 0);
$next = CMbDT::date("+1 day", $date);
$sejour = new CSejour();
$where = array();
$where["entree"] = "< '{$next}'";
$where["sortie"] = "> '{$date}'";
$where["group_id"] = "= '{$group->_id}'";
$where["annule"] = "= '0'";
$order = array();
$order[] = "sortie";
$order[] = "entree";
$step = 30;
$limit = "{$page},{$step}";
/** @var CSejour[] $listSejours */
$count = $sejour->countList($where);
$listSejours = $sejour->loadList($where, $order, $limit);
$patients = CSejour::massLoadFwdRef($listSejours, "patient_id");
$ipps = CPatient::massLoadIPP($patients);
$ndas = CSejour::massLoadNDA($listSejours);
$praticiens = CSejour::massLoadFwdRef($listSejours, "praticien_id");
CMediusers::massLoadFwdRef($praticiens, "function_id");
CSejour::massLoadFwdRef($listSejours, "group_id");
CSejour::massLoadFwdRef($listSejours, "etablissement_sortie_id");
CSejour::massLoadFwdRef($listSejours, "service_sortie_id");
CSejour::massLoadFwdRef($listSejours, "service_sortie_id");
foreach ($listSejours as $_sejour) {
    $_sejour->_ref_patient = $patients[$_sejour->patient_id];
    $_sejour->loadRefPraticien();
    $_sejour->loadExtCodesCCAM();
    $_sejour->loadRefsFactureEtablissement();
Example #2
0
$whereVeille["type"] = "= 'comp'";
$countPresentVeille = $sejourVeille->countList($whereVeille);
// entree du jour
$sejourEntreeJour = new CSejour();
$whereEntree = array();
$whereEntree["sejour.entree"] = "BETWEEN '{$date_debut}' AND '{$date_fin}'";
$whereEntree["annule"] = "= '0'";
$whereEntree["type"] = "= 'comp'";
$countEntreeJour = $sejourEntreeJour->countList($whereEntree);
// sorties du jour
$sejourSortieJour = new CSejour();
$whereSortie = array();
$whereSortie["sejour.sortie"] = "BETWEEN '{$date_debut}' AND '{$date_fin}'";
$whereSortie["annule"] = "= '0'";
$whereSortie["type"] = "= 'comp'";
$countSortieJour = $sejourSortieJour->countList($whereSortie);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("date", $date);
$smarty->assign("totalHospi", $totalHospi);
$smarty->assign("totalMedecin", $totalMedecin);
$smarty->assign("totalAmbulatoire", $totalAmbulatoire);
$smarty->assign("services", $services);
$smarty->assign("list_affectations", $list_affectations);
$smarty->assign("total_service", $total_service);
$smarty->assign("countPresentVeille", $countPresentVeille);
$smarty->assign("countSortieJour", $countSortieJour);
$smarty->assign("countEntreeJour", $countEntreeJour);
$smarty->assign("countPresentJour", $countPresentJour);
$smarty->assign("listPrat", $listPrat);
$smarty->assign("totalPrat", $totalPrat);
Example #3
0
$ds = CSQLDataSource::get("std");
// Sejours pour lesquels le kine est référent
if ($mode == "count" || $mode == "referenced") {
    $join = array();
    $join["patients"] = "patients.patient_id = sejour.patient_id";
    $order = "nom, prenom";
    $join["bilan_ssr"] = "bilan_ssr.sejour_id = sejour.sejour_id";
    $join["technicien"] = "technicien.technicien_id = bilan_ssr.technicien_id";
    $where = array();
    $where["sejour.type"] = "= 'ssr'";
    $where["sejour.entree"] = "<= '{$planning->date_max}'";
    $where["sejour.sortie"] = ">= '{$planning->date_min}'";
    $where["sejour.annule"] = "= '0'";
    $where["technicien.kine_id"] = "= '{$kine_id}'";
    if ($mode == "count") {
        $counts["referenced"] = $sejour->countList($where, null, $join);
    } else {
        $sejours = $sejour->loadList($where, $order, null, null, $join);
    }
}
// Sejours pour lesquels le kine est remplaçant
if ($mode == "count" || $mode == "replaced") {
    $order = "nom, prenom";
    $join = array();
    $join["patients"] = "patients.patient_id = sejour.patient_id";
    $join["replacement"] = "replacement.sejour_id = sejour.sejour_id";
    $join["plageconge"] = "plageconge.plage_id = replacement.conge_id";
    $where = array();
    $where["sejour.type"] = "= 'ssr'";
    $where["sejour.entree"] = "<= '{$planning->date_max}'";
    $where["sejour.sortie"] = ">= '{$planning->date_min}'";
Example #4
0
    }
    if ($consult->adresse_par_prat_id && $consult->adresse_par_prat_id != $pat->_ref_medecin_traitant->_id) {
        $consult->loadRefAdresseParPraticien();
    }
    // grossesse
    if (CModule::getActive("maternite")) {
        $consult->loadRefGrossesse();
    }
    $sejour = new CSejour();
    $whereSejour = array();
    $group = CGroups::loadCurrent();
    $whereSejour["type"] = "!= 'consult'";
    $whereSejour[] = "'{$consult->_date}' BETWEEN DATE(entree) AND DATE(sortie)";
    $whereSejour["patient_id"] = "= '{$consult->patient_id}'";
    $whereSejour["group_id"] = "= '{$group->_id}'";
    $consult->_count_matching_sejours = $sejour->countList($whereSejour);
    //next consultation ?
    $dateW = $consult->_ref_plageconsult->date;
    $where = array();
    $whereN["patient_id"] = " = '{$consult->patient_id}'";
    $whereN["date"] = " >= '{$dateW}'";
    $ljoin["plageconsult"] = "plageconsult.plageconsult_id = consultation.plageconsult_id";
    $count_next_plage = $consult->countList($whereN, null, $ljoin);
}
if (!$modal) {
    // Save history
    $params = array("consult_urgence_id" => $consult_urgence_id, "consultation_id" => $consultation_id, "plageconsult_id" => $plageconsult_id, "sejour_id" => $sejour_id, "date_planning" => $date_planning, "grossesse_id" => $grossesse_id);
    $object = null;
    $type = CViewHistory::TYPE_VIEW;
    if ($consultation_id) {
        $object = $consult;
    $where["sejour.type"] = "!= 'urg'";
}
if ($_type_admission != "seances") {
    $where[] = "affectation.affectation_id IS NULL";
}
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);
    if ($convalescence_sejour) {
        $where_convalescence = "`convalescence` LIKE '%{$convalescence_sejour}%'";
        $where_sejour[] = $where_convalescence;
    }
    if ($remarque_sejour) {
        $where_remarque = "`rques` LIKE '%{$remarque_sejour}%'";
        $where_sejour[] = $where_remarque;
    }
    if ($where_sejour) {
        $where_sejour = implode(" OR ", $where_sejour);
    }
}
$order_sejour = "patient_id";
$total_sejours = null;
if ($where_sejour) {
    $total_sejours = $sejour->countList($where_sejour);
    $sejours = $sejour->loadList($where_sejour, $order_sejour, "{$page_sejour}, 30");
}
foreach ($sejours as $value) {
    $value->loadRefPatient();
}
// Recherches sur les Interventions
/** @var COperation[] $interventions */
$interventions = array();
$intervention = new COperation();
$patients_intervention = array();
$where_intervention = null;
if ($recherche_intervention == "and") {
    if ($materiel_intervention) {
        $where_intervention["materiel"] = "LIKE '%{$materiel_intervention}%'";
    }
    $sejour = new CSejour();
    $action = CValue::get("action", "start");
    // Tous les départs possibles
    $idMins = array("start" => CValue::get("id_start", "000000"), "continue" => CValue::getOrSession("idContinue"), "retry" => CValue::getOrSession("idRetry"));
    $idMin = CValue::first(@$idMins[$action], "000000");
    CValue::setSession("idRetry", $idMin);
    // Requêtes
    $where = array();
    $where[$sejour->_spec->key] = "> '{$idMin}'";
    $where['annule'] = " = '0'";
    $date_min = CValue::getOrSession('date_min', CMbDT::dateTime("-7 day"));
    $date_max = CValue::getOrSession('date_max', CMbDT::dateTime("+1 day"));
    // Bornes
    $where['entree'] = " BETWEEN '{$date_min}' AND '{$date_max}'";
    // Comptage
    $count_sejours = $sejour->countList($where);
    $max = min(CValue::get("count", 30), $count_sejours);
    CAppUI::stepAjax("Export de {$max} sur {$count_sejours} objets de type 'CSejour' à partir de l'ID '{$idMin}'", UI_MSG_OK);
    // Time limit
    $seconds = max($max / 20, 120);
    CAppUI::stepAjax("Limite de temps du script positionné à '{$seconds}' secondes", UI_MSG_OK);
    CApp::setTimeLimit($seconds);
    // Export réel
    $sejours = $sejour->loadList($where, $sejour->_spec->key, "0, {$max}");
}
$errors = 0;
$exchange = 0;
foreach ($sejours as $_sejour) {
    $_sejour->loadRefPraticien();
    $_sejour->loadRefPatient();
    $_sejour->loadNDA($receiver->group_id);
Example #8
0
 $query->addWhere(array("sejour.entree" => "BETWEEN '{$start}' AND '{$end}'", "sejour.etablissement_sortie_id" => "IS NOT NULL"));
 $etab_externe_ids = $sejour->_spec->ds->loadColumn($query->makeSelect());
 $etab_externe = new CEtabExterne();
 $etabs = $etab_externe->loadList(array($etab_externe->_spec->key => $etab_externe->_spec->ds->prepareIn($etab_externe_ids)));
 $etabs["none"] = $etab_externe;
 $etabs["none"]->_view = "Non renseigné";
 $where["sejour.mode_sortie"] = "= 'transfert'";
 $key = 0;
 foreach ($etabs as $_id => $_etab) {
     $series[$key] = array('data' => array(), 'label' => utf8_encode($_etab->_view));
     $sub_total = 0;
     foreach ($dates as $i => $_date) {
         $_date_next = CMbDT::date("+1 {$period}", $_date);
         $where['sejour.entree'] = "BETWEEN '{$_date}' AND '{$_date_next}'";
         $where['sejour.etablissement_sortie_id'] = $_id === "none" ? "IS NULL" : "= '{$_id}'";
         $count = $sejour->countList($where, null, $ljoin);
         $total += $count;
         $sub_total += $count;
         $series[$key]['data'][$i] = array($i, intval($count));
     }
     $series[$key]['subtotal'] = $sub_total;
     $key++;
 }
 // suppression des series vides
 foreach ($series as $_key => $_serie) {
     if ($_serie['subtotal'] == 0) {
         unset($series[$_key]);
     }
 }
 $series = array_values($series);
 break;
if ($current_m == "ssr") {
    $sejour->_type_admission = "ssr";
}
$sejour->service_id = $service_id;
$sejour->praticien_id = $prat_id;
// Liste des séjours en attente de validation
$g = CGroups::loadCurrent()->_id;
$where = array();
$where["group_id"] = "= '{$g}'";
$where["recuse"] = "= '-1'";
$where["annule"] = "= '0'";
if ($current_m == "ssr") {
    $where["type"] = "= 'ssr'";
}
$where["entree"] = ">= '" . CMbDT::date() . "'";
$nb_sejours_attente = $sejour->countList($where);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("current_m", $current_m);
$smarty->assign("sejour", $sejour);
$smarty->assign("date_demain", $date_demain);
$smarty->assign("date_actuelle", $date_actuelle);
$smarty->assign("date", $date);
$smarty->assign("recuse", $recuse);
$smarty->assign("envoi_mail", $envoi_mail);
$smarty->assign("order_way", $order_way);
$smarty->assign("order_col", $order_col);
$smarty->assign("services", $services);
$smarty->assign("prats", $prats);
$smarty->assign("hier", $hier);
$smarty->assign("demain", $demain);
Example #10
0
$datetime_check = "{$date} {$hour_instantane}:00:00";
// Comptage des patients présents
$wherePresents = $where;
if ($mode) {
    $wherePresents[] = "'{$date}' BETWEEN DATE(affectation.entree) AND DATE(affectation.sortie)";
} else {
    $wherePresents[] = "('{$datetime_check}' BETWEEN affectation.entree AND affectation.sortie) AND affectation.effectue = '0'";
}
$presents = $affectation->countList($wherePresents, null, $ljoin);
$wherePresentsNP = $whereNP;
if ($mode) {
    $wherePresentsNP[] = "'{$date}' BETWEEN DATE(sejour.entree) AND DATE(sejour.sortie)";
} else {
    $wherePresentsNP[] = "'{$datetime_check}' BETWEEN sejour.entree AND sejour.sortie";
}
$presentsNP = $sejour->countList($wherePresentsNP, null, $ljoinNP);
// Comptage des déplacements
if ($vue) {
    unset($where["sejour.confirme"]);
    $where["effectue"] = "= '0'";
}
$whereEntrants = $whereSortants = $where;
$whereSortants["affectation.sortie"] = "BETWEEN '{$limit1}' AND '{$limit2}'";
$whereEntrants["affectation.entree"] = "BETWEEN '{$limit1}' AND '{$limit2}'";
$whereEntrants["sejour.entree"] = "!= affectation.entree";
$whereSortants["sejour.sortie"] = "!= affectation.sortie";
$dep_entrants = $affectation->countList($whereEntrants, null, $ljoin);
$dep_sortants = $affectation->countList($whereSortants, null, $ljoin);
// Comptage des entrées/sorties
foreach ($mouvements as $type => &$_mouvement) {
    if ($type_hospi && $type_hospi != $type || $type_hospi == "ambu") {
Example #11
0
 /**
  * Count sejours including a specific date
  *
  * @param string $datetime Date to check for inclusion
  * @param array  $where    Array of additional where clauses
  * @param array  $leftjoin Array of left join clauses
  *
  * @return int Count null if module is not installed
  */
 static function countForDateTime($datetime, $where = null, $leftjoin = null)
 {
     $where[] = "sejour.entree <= '{$datetime}'";
     $where[] = "sejour.sortie >= '{$datetime}'";
     $sejour = new CSejour();
     return $sejour->countList($where, null, $leftjoin);
 }
if (count($services_ids) && $enabled_service) {
    $ljoin["affectation"] = "affectation.sejour_id = sejour.sejour_id AND affectation.sortie = sejour.sortie";
    $where["affectation.service_id"] = CSQLDataSource::prepareIn($services_ids);
}
// filtre sur le praticien
if ($prat_id) {
    $where["sejour.praticien_id"] = "= '{$prat_id}'";
}
$group = CGroups::loadCurrent();
$sejour = new CSejour();
$where["sejour.annule"] = "= '0'";
$where["sejour.group_id"] = "= '{$group->_id}'";
// Liste des admissions par jour
foreach ($days as $_date => $num) {
    $date_min = CMbDT::dateTime("00:00:00", $_date);
    $date_max = CMbDT::dateTime("23:59:00", $_date);
    $where["sejour.entree"] = "<= '{$date_max}'";
    $where["sejour.sortie"] = ">= '{$date_min}'";
    $days[$_date] = $sejour->countList($where, null, $ljoin);
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("hier", $hier);
$smarty->assign("demain", $demain);
$smarty->assign("bank_holidays", $bank_holidays);
$smarty->assign('date', $date);
$smarty->assign('lastmonth', $lastmonth);
$smarty->assign('nextmonth', $nextmonth);
$smarty->assign('days', $days);
$smarty->assign('enabled_service', $enabled_service);
$smarty->display('inc_vw_all_presents.tpl');
$type = CValue::get("type");
$entree = CValue::get("entree");
$group = CGroups::loadCurrent();
$group->loadConfigValues();
$sejour = new CSejour();
$nb_sejour = 0;
if ($type && $entree) {
    $where = array("type" => "= '{$type}'", "annule" => "= '0'", "group_id" => "= '{$group->_id}'");
    $min = $entree;
    $max = CMbDT::date("+1 DAY", $min);
    if ($type == "ambu") {
        $where[] = "entree BETWEEN '{$min}' AND '{$max}'";
    } elseif ($type == "comp") {
        $where[] = "'{$max}' BETWEEN entree AND sortie";
    }
    $nb_sejour = $sejour->countList($where);
}
$occupation = -1;
if ($type == "ambu" && $group->_configs["max_ambu"]) {
    $occupation = $nb_sejour / $group->_configs["max_ambu"] * 100;
} else {
    if ($type == "comp" && $group->_configs["max_comp"]) {
        $occupation = $nb_sejour / $group->_configs["max_comp"] * 100;
    }
}
$pct = min($occupation, 100);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("occupation", $occupation);
$smarty->assign("pct", $pct);
$smarty->display("inc_show_occupation_lits.tpl");