예제 #1
0
        if ($item_prestation->_id) {
            $_lit->_selected_item = $item_prestation;
        }
    }
}
array_multisort(CMbArray::pluck($services, "nom"), SORT_ASC, $services);
// Chargement des affectations
$where = array();
$where["lit_id"] = CSQLDataSource::prepareIn(array_keys($lits));
$where["affectation.entree"] = "< '{$date_max}'";
$where["affectation.sortie"] = "> '{$date_min}'";
$where[] = "sejour.annule = '0' OR sejour.annule IS NULL";
$ljoin = array();
$ljoin["sejour"] = "sejour.sejour_id = affectation.sejour_id";
$affectation = new CAffectation();
$nb_affectations = $affectation->countList($where, null, $ljoin);
if ($nb_affectations > CAppUI::conf("dPhospi max_affectations_view")) {
    $smarty = new CSmartyDP();
    $smarty->display("inc_vw_max_affectations.tpl");
    CApp::rip();
}
$affectations = $affectation->loadList($where, "parent_affectation_id ASC", null, null, $ljoin);
// Ajout des prolongations anormales
// (séjours avec entrée réelle et sortie non confirmée et sortie < maintenant
$nb_days_prolongation = CAppUI::conf("dPhospi nb_days_prolongation");
if ($nb_days_prolongation) {
    $sejour = new CSejour();
    $max = CMbDT::dateTime();
    $min = CMbDT::date("-{$nb_days_prolongation} days", $max) . " 00:00:00";
    $where = array("entree_reelle" => "IS NOT NULL", "sortie_reelle" => "IS NULL", "sortie_prevue" => "BETWEEN '{$min}' AND '{$max}'", "sejour.confirme" => "IS NULL", "group_id" => "= '{$group->_id}'", "annule" => "= '0'");
    /** @var CSejour[] $sejours_prolonges */
$sortie = CValue::post("sortie");
$function_id = CValue::post("function_id");
if ($_lock_all_lits || $_lock_all_lits_urgences) {
    /** @var C**t $lit */
    $lit = new C**t();
    $lit = $lit->load($lit_id);
    $lit->loadRefChambre()->loadRefService()->loadRefsChambres();
    foreach ($lit->_ref_chambre->_ref_service->_ref_chambres as $chambre) {
        $chambre->loadRefsLits();
        foreach ($chambre->_ref_lits as $lit) {
            // Recherche d'une ou plusieurs affectations existantes en collision avant de créer le blocage
            $aff_temp = new CAffectation();
            $where["lit_id"] = "= '{$lit->_id}'";
            $where[] = "entree < '{$sortie}' AND sortie > '{$entree}'";
            // Si collision, on passe au lit suivant
            if ($aff_temp->countList($where)) {
                continue;
            }
            $affectation = new CAffectation();
            $affectation->lit_id = $lit->_id;
            $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();
예제 #3
0
$whereNP["sejour.type"] = CSQLDataSource::prepareIn(array_keys($mouvements), $type_hospi);
if (count($services_ids)) {
    $whereNP[] = "((sejour.service_id " . CSQLDataSource::prepareIn($services_ids) . " OR sejour.service_id IS NULL) AND affectation.affectation_id IS NULL) OR " . "(affectation.lit_id IS NULL AND affectation.service_id " . CSQLDataSource::prepareIn($services_ids) . ")";
}
if ($praticien_id) {
    $whereNP["sejour.praticien_id"] = "= '{$praticien_id}'";
}
$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}'";