} else {
         // Chargement des lignes d'elements  avec pour chapitre $chapitre
         $prescription->loadRefsLinesElementByCat("1", "1", $chapitre, null, null, null, $hide_old_lines, null, null, $hide_line_inactive);
         foreach ($prescription->_ref_prescription_lines_element as $_line_elt) {
             $_line_elt->countPlanifications();
             $_line_elt->loadActiveDates();
         }
     }
     $with_calcul = $chapitre ? true : false;
     $prescription->calculPlanSoin($_dates, 0, null, null, null, $with_calcul, "");
     // Chargement des operations
     if ($prescription->_ref_object instanceof CSejour) {
         $operation = new COperation();
         $operation->sejour_id = $prescription->object_id;
         $operation->annulee = "0";
         $_operations = $operation->loadMatchingList();
         foreach ($_operations as $_operation) {
             if ($_operation->time_operation != "00:00:00") {
                 $_operation->loadRefPlageop();
                 $date_operation = CMbDT::date($_operation->_datetime_best);
                 $hour_op = CMbDT::time($_operation->_datetime_best);
                 $hour_operation = CMbDT::format($hour_op, '%H:00:00');
                 $operations["{$date_operation} {$hour_operation}"] = $hour_op;
                 $operations["{$date_operation} {$hour_operation} object"] = $_operation;
             }
         }
     }
 }
 // Calcul du nombre de produits (rowspan)
 $prescription->calculNbProduit();
 // Chargement des transmissions qui ciblent les lignes de la prescription
// Chargement de l'utilisateur courant
$user = CMediusers::get();
if (!$praticien_id && $user->isPraticien() && !$user->isAnesth()) {
    $praticien_id = $user->user_id;
}
// Selection des salles
$listBlocs = CGroups::loadCurrent()->loadBlocs(PERM_READ);
// Chargement des chirurgiens ayant une intervention ce jour
$listPermPrats = $user->loadPraticiens(PERM_READ);
$listPrats = array();
$operation = new COperation();
$operation->date = $date;
$operation->annulee = '0';
$groupby = "operations.chir_id";
/** @var COperation[] $operations */
$operations = $operation->loadMatchingList(null, null, $groupby);
foreach ($operations as $_operation) {
    if (array_key_exists($_operation->chir_id, $listPermPrats)) {
        $listPrats[$_operation->chir_id] = $listPermPrats[$_operation->chir_id];
    }
}
$listPrats = CMbArray::pluck($listPrats, "_view");
asort($listPrats);
// Selection des plages opératoires de la journée
$praticien = new CMediusers();
if ($praticien->load($praticien_id)) {
    $praticien->loadRefsForDay($date, true);
    foreach ($praticien->_ref_plages as $plage) {
        $plage->loadRefsNotes();
    }
}
$callback = CValue::get("callback");
//same salle
if ($salle_2 == $salle_1) {
    return;
}
//gathering
$operation_1 = new COperation();
$operation_1->salle_id = $salle_1;
$operation_1->date = $date;
/** @var COperation[] $operations_1 */
$operations_1 = $operation_1->loadMatchingList();
$operation_2 = new COperation();
$operation_2->salle_id = $salle_2;
$operation_2->date = $date;
/** @var COperation[] $operations_2 */
$operations_2 = $operation_2->loadMatchingList();
// switching
foreach ($operations_1 as $_op_1) {
    $_op_1->salle_id = $salle_2;
    if ($msg = $_op_1->store()) {
        CAppUI::stepAjax($msg, UI_MSG_ERROR);
    }
}
foreach ($operations_2 as $_op_2) {
    $_op_2->salle_id = $salle_1;
    if ($msg = $_op_2->store()) {
        CAppUI::stepAjax($msg, UI_MSG_ERROR);
    }
}
//succeed
$salle_n1 = new CSalle();
 /**
  * @see parent::mine
  */
 function mine($salle_id, $date)
 {
     parent::mine($salle_id, $date);
     // plages
     $plage_op = new CPlageOp();
     $plage_op->date = $date;
     $plage_op->salle_id = $salle_id;
     /** @var CPlageOp[] $plages */
     $plages = $plage_op->loadMatchingList();
     $plages_to_use = array();
     $range_plage = array();
     foreach ($plages as $kp => $_plage) {
         if ($_plage->debut >= $_plage->fin) {
             continue;
         }
         $plages_to_use[$kp] = $_plage;
         CMbRange::union($range_plage, array("lower" => $_plage->debut, "upper" => $_plage->fin));
     }
     $this->nb_plages_planned = count($plages);
     $this->nb_plages_planned_valid = count($plages_to_use);
     $this->cumulative_plages_planned = 0;
     foreach ($range_plage as $_range) {
         $this->cumulative_plages_planned += CMbDT::minutesRelative($_range["lower"], $_range["upper"]);
     }
     // interventions
     $interv = new COperation();
     $interv->salle_id = $salle_id;
     $interv->date = $date;
     /** @var COperation[] $intervs */
     $intervs = $interv->loadMatchingList();
     $interv_to_use = array();
     $range_inter = array();
     foreach ($intervs as $ki => $_interv) {
         // cleanup invalid
         if (!$_interv->entree_salle || !$_interv->sortie_salle || $_interv->entree_salle >= $_interv->sortie_salle) {
             continue;
         }
         $interv_to_use[$ki] = $_interv;
         CMbRange::union($range_inter, array("lower" => $_interv->entree_salle, "upper" => $_interv->sortie_salle));
     }
     $this->nb_real_interventions = count($intervs);
     $this->nb_real_intervention_valid = count($interv_to_use);
     $this->cumulative_real_interventions = 0;
     foreach ($range_inter as $_range) {
         $this->cumulative_real_interventions += CMbDT::minutesRelative($_range["lower"], $_range["upper"]);
     }
     // opening patient
     $interv_to_use = array();
     $range_inter_opened = array();
     foreach ($intervs as $ki => $_interv) {
         // cleanup invalid
         if (!$_interv->debut_op || !$_interv->fin_op || $_interv->debut_op >= $_interv->fin_op) {
             continue;
         }
         $interv_to_use[$ki] = $_interv;
         CMbRange::union($range_inter_opened, array("lower" => $_interv->debut_op, "upper" => $_interv->fin_op));
     }
     $this->nb_interventions_opened_patient = count($intervs);
     $this->nb_intervention_opened_patient_valid = count($interv_to_use);
     $this->cumulative_opened_patient = 0;
     foreach ($range_inter_opened as $_range) {
         $this->cumulative_opened_patient += CMbDT::minutesRelative($_range["lower"], $_range["upper"]);
     }
     // range operation
     $this->cumulative_plages_minus_interventions = 0;
     $plages_minus_interv = CMbRange::multiCrop($range_plage, $range_inter);
     foreach ($plages_minus_interv as $_plage) {
         $this->cumulative_plages_minus_interventions = CMbDT::minutesRelative($_plage["lower"], $_plage["upper"]);
     }
     $this->cumulative_interventions_minus_plages = 0;
     $interv_minus_plage = CMbRange::multiCrop($range_inter, $range_plage);
     foreach ($interv_minus_plage as $_plage) {
         $this->cumulative_interventions_minus_plages = CMbDT::minutesRelative($_plage["lower"], $_plage["upper"]);
     }
     return $this;
 }
Example #5
0
 /**
  * Charge toutes les interventions du jour
  *
  * @param datetime $date Datetime de référence
  *
  * @return COperation[]
  */
 function loadRefCurrOperations($date)
 {
     if (!$this->_id) {
         return $this->_ref_curr_operations = array();
     }
     $operation = new COperation();
     $operation->sejour_id = $this->_id;
     $operation->date = CMbDT::date($date);
     return $this->_ref_curr_operations = $operation->loadMatchingList();
 }
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage PMSI
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkAdmin();
CAppUI::stepAjax("Fonctionnalité désactivée pour le moment", UI_MSG_ERROR);
return;
$operation = new COperation();
$operation->facture = "1";
$count = $operation->countMatchingList();
CAppUI::stepAjax("'%s' opérations facturées trouvées", UI_MSG_OK, $count);
$operation->facture = "0";
$count = $operation->countMatchingList();
CAppUI::stepAjax("'%s' opérations non facturées trouvées", UI_MSG_OK, $count);
$start = 30000;
$max = 100;
$limit = "{$start}, {$max}";
/** @var COperation $_operation */
foreach ($operation->loadMatchingList(null, $limit) as $_operation) {
    $_operation->loadHprimFiles();
    if ($count = count($_operation->_ref_hprim_files)) {
        CAppUI::stepAjax("'%s' HPRIM files for operation '%s'", UI_MSG_OK, $count, $_operation->_view);
    }
}