<?php

/**
 * $Id: httpreq_get_hospi_time.php 19840 2013-07-09 19:36:14Z phenxdesign $
 *
 * @package    Mediboard
 * @subpackage PlanningOp
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 19840 $
 */
CCanDo::checkRead();
$chir_id = CValue::get("chir_id", 0);
$codes = CValue::get("codes", "");
$javascript = CValue::get("javascript", true);
$codes = explode("|", $codes);
$result = CTempsHospi::getTime($chir_id, $codes);
$temps = $result ? sprintf("%.2f", $result) . "j" : "-";
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("temps", $temps);
$smarty->assign("javascript", $javascript);
$smarty->display("inc_get_time.tpl");
Example #2
0
 /**
  * Durée moyenne d'hospitlisation en jours
  *
  * @param int          $praticien_id Praticien concerné
  * @param array|string $ccam         Code CCAM concerné
  * @param string       $type         Type de séjour concerné
  *
  * @return int|bool Durée en jours, 0 si aucun séjour, false si temps non calculé
  */
 static function getTime($praticien_id = 0, $ccam = null, $type = null)
 {
     $where = array();
     $total = array();
     $total["duree_somme"] = 0;
     $total["nbSejours"] = 0;
     $where["praticien_id"] = "= '{$praticien_id}'";
     if ($type) {
         $where["type"] = "= '{$type}'";
     }
     if (is_array($ccam)) {
         foreach ($ccam as $code) {
             $where[] = "ccam LIKE '%" . strtoupper($code) . "%'";
         }
     } elseif ($ccam) {
         $where["ccam"] = "LIKE '%" . strtoupper($ccam) . "%'";
     }
     $temp = new CTempsHospi();
     if (null == ($liste = $temp->loadList($where))) {
         return false;
     }
     foreach ($liste as $temps) {
         $total["nbSejours"] += $temps->nb_sejour;
         $total["duree_somme"] += $temps->nb_sejour * $temps->duree_moy;
     }
     if ($total["nbSejours"]) {
         $time = $total["duree_somme"] / $total["nbSejours"];
     } else {
         $time = 0;
     }
     return $time;
 }