function resetModifications()
 {
     $typeRepas = new CTypeRepas();
     $typeRepas->load($this->typerepas_id);
     $service = new CService();
     $service->load($this->service_id);
     $service->loadRefsBack();
     foreach ($service->_ref_chambres as $chambre_id => &$chambre) {
         $chambre->loadRefsBack();
         foreach ($chambre->_ref_lits as $lit_id => &$lit) {
             $lit->loadAffectations($this->date);
             foreach ($lit->_ref_affectations as $affectation_id => &$affectation) {
                 $affectation->loadRefSejour();
                 $affectation->loadMenu($this->date, array($this->typerepas_id => null));
                 $sejour =& $affectation->_ref_sejour;
                 $date_entree = substr($affectation->entree, 0, 10);
                 $date_sortie = substr($affectation->sortie, 0, 10);
                 $heure_entree = substr($affectation->entree, 11, 5);
                 $heure_sortie = substr($affectation->sortie, 11, 5);
                 if (!$sejour->sejour_id || $sejour->type == "ambu" || $this->date == $date_entree && $heure_entree > $typeRepas->fin || $this->date == $date_sortie && $heure_sortie < $typeRepas->debut) {
                 } else {
                     $repas =& $affectation->_list_repas[$this->date][$this->typerepas_id];
                     if ($repas->modif) {
                         $repas->modif = 0;
                         $repas->_no_synchro = true;
                         $repas->store();
                     }
                 }
             }
         }
     }
 }
 protected static function _getAllConfigs($class, $key, $value)
 {
     // Chargement des etablissements
     $group = new CGroups();
     /** @var CGroups[] $groups */
     $groups = $group->loadList();
     // Chargement des services
     $service = new CService();
     $services = $service->loadList();
     // Chargement de toutes les configs
     /** @var self $config */
     $config = new $class();
     /** @var self[] $all_configs */
     $all_configs = $config->loadList();
     if ($all_configs == null) {
         return null;
     }
     /** @var self[] $configs_default */
     // Creation du tableau de valeur par defaut (quelque soit l'etablissement)
     foreach ($all_configs as $_config) {
         if (!$_config->service_id && !$_config->group_id) {
             $configs_default[$_config->{$key}] = $_config;
         } else {
             if ($_config->service_id) {
                 $configs_service[$_config->service_id][$_config->{$key}] = $_config->{$value};
             } else {
                 $configs_group[$_config->group_id][$_config->{$key}] = $_config->{$value};
             }
         }
     }
     $configs = array();
     // Parcours des etablissements
     foreach ($groups as $group_id => $group) {
         $group->loadRefsServices();
         // Parcours des services
         foreach ($group->_ref_services as $service_id => $_service) {
             foreach ($configs_default as $_config_default) {
                 $configs[$group_id][$service_id][$_config_default->{$key}] = $_config_default->{$value};
                 if (isset($configs_group[$group_id][$_config_default->{$key}])) {
                     $configs[$group_id][$service_id][$_config_default->{$key}] = $configs_group[$group_id][$_config_default->{$key}];
                 }
                 if (isset($configs_service[$service_id][$_config_default->{$key}])) {
                     $configs[$group_id][$service_id][$_config_default->{$key}] = $configs_service[$service_id][$_config_default->{$key}];
                 }
             }
         }
         // Si aucun service
         foreach ($configs_default as $_config_default) {
             if (isset($configs_group[$group_id][$_config_default->{$key}])) {
                 $configs[$group_id]["none"][$_config_default->{$key}] = $configs_group[$group_id][$_config_default->{$key}];
             } else {
                 $configs[$group_id]["none"][$_config_default->{$key}] = $_config_default->{$value};
             }
         }
     }
     return $configs;
 }
 /**
  * @see parent::getPerm()
  */
 function getPerm($permType)
 {
     if (!$this->_ref_stock || !$this->_ref_service) {
         $this->loadRefsFwd();
     }
     if ($this->_ref_service) {
         return $this->_ref_stock->getPerm($permType) && $this->_ref_service->getPerm($permType);
     }
     return $this->_ref_stock->getPerm($permType);
 }
示例#4
0
/**
 * Charge complètement un service pour l'affichage des affectations
 *
 * @param CService $service       le service concerné
 * @param string   $date          le filtre de date sur les affectations
 * @param string   $mode          forcer le chargement des affectations effectuées
 * @param int      $praticien     charge les séjours pour un praticien en particulier
 * @param string   $type          charge les séjours pour un type d'hospitalisation
 * @param int      $prestation_id charge la prestation éventuellement associée à chaque séjour
 *
 *
 * @return void
 */
function loadServiceComplet(&$service, $date, $mode, $praticien_id = "", $type = "", $prestation_id = "", $with_dossier_medical = true)
{
    $service->_nb_lits_dispo = 0;
    $dossiers = array();
    $systeme_presta = CAppUI::conf("dPhospi prestations systeme_prestations", CGroups::loadCurrent());
    $lits = $service->loadRefsLits();
    foreach ($lits as $_lit) {
        $_lit->_ref_affectations = array();
        $_lit->checkDispo($date);
    }
    $affectations = $service->loadRefsAffectations($date, $mode, false, true);
    $sejours = CMbObject::massLoadFwdRef($affectations, "sejour_id");
    CMbObject::massLoadFwdRef($sejours, "patient_id");
    CMbObject::massLoadFwdRef($sejours, "prestation_id");
    CMbObject::massLoadFwdRef($sejours, "praticien_id");
    if (CModule::getActive("dPImeds")) {
        CSejour::massLoadNDA($sejours);
    }
    foreach ($affectations as $_affectation) {
        $sejour = $_affectation->loadRefSejour();
        if ($praticien_id) {
            if ($sejour->praticien_id != $praticien_id) {
                unset($affectations[$_affectation->_id]);
                continue;
            }
        }
        if ($type) {
            if ($sejour->type != $type) {
                unset($affectations[$_affectation->_id]);
                continue;
            }
        }
        $lits[$_affectation->lit_id]->_ref_affectations[$_affectation->_id] = $_affectation;
        $_affectation->loadRefsAffectations(true);
        $_affectation->checkDaysRelative($date);
        $aff_prev = $_affectation->_ref_prev;
        if ($aff_prev->_id) {
            if ($aff_prev->lit_id) {
                $aff_prev->loadRefLit();
            } else {
                $aff_prev->loadRefService();
            }
        }
        $aff_next = $_affectation->_ref_next;
        if ($aff_next->_id) {
            if ($aff_next->lit_id) {
                $aff_prev->loadRefLit();
            } else {
                $aff_prev->loadRefService();
            }
        }
        $sejour->loadRefPrestation();
        $sejour->loadRefsOperations();
        $sejour->loadNDA();
        $sejour->loadRefPraticien();
        $sejour->loadRefPatient();
        if ($with_dossier_medical) {
            $sejour->_ref_patient->loadRefDossierMedical(false);
            $dossiers[] = $sejour->_ref_patient->_ref_dossier_medical;
        }
        // Chargement des droits CMU
        $sejour->getDroitsCMU();
        foreach ($sejour->_ref_operations as $_operation) {
            $_operation->loadExtCodesCCAM();
        }
        $_affectation->_ref_lit = $lits[$_affectation->lit_id];
        $_affectation->loadRefLit();
        $_affectation->_ref_lit->_ref_chambre->_nb_affectations++;
        if ($systeme_presta == "expert" && $prestation_id) {
            $sejour->loadLiaisonsForDay($prestation_id, $date);
        }
    }
    foreach ($lits as $_lit) {
        array_multisort(CMbArray::pluck($_lit->_ref_affectations, "_ref_sejour", "entree"), SORT_ASC, $_lit->_ref_affectations);
    }
    if ($with_dossier_medical) {
        CDossierMedical::massCountAntecedentsByType($dossiers, "deficience");
    }
    if (!$service->externe) {
        foreach ($service->_ref_chambres as $_chambre) {
            $_chambre->checkChambre();
            $service->_nb_lits_dispo += $_chambre->_nb_lits_dispo;
        }
    }
}
 /**
  * Find the host from a context object
  *
  * @param CMbObject|string $context The context (séjour, rpu, service, etablissement)
  *
  * @return CGroups|CService|CFunctions|string
  */
 static function guessHost($context)
 {
     if ($context === "global") {
         return "global";
     }
     // Etablissement, service ou cabinet (deja un HOST)
     if ($context instanceof CGroups || $context instanceof CService || $context instanceof CFunctions || $context instanceof CBlocOperatoire) {
         return $context;
     }
     // Séjour d'urgence
     if ($context instanceof CSejour && $context->type == "urg") {
         $rpu = $context->loadRefRPU();
         if ($rpu && $rpu->_id) {
             $context = $rpu;
         }
     }
     // Sejour
     if ($context instanceof CSejour) {
         $affectation = $context->loadRefCurrAffectation();
         if (!$affectation->_id) {
             $affectation = $context->loadRefFirstAffectation();
         }
         return $affectation->loadRefService();
     }
     // Urgences
     if ($context instanceof CRPU) {
         /** @var CService $service */
         $service = null;
         if ($context->box_id) {
             return $context->loadRefBox()->loadRefService();
         }
         $sejour = $context->loadRefSejour();
         $affectation = $sejour->loadRefCurrAffectation();
         if (!$affectation->_id) {
             $affectation = $sejour->loadRefFirstAffectation();
         }
         $service = $affectation->loadRefService();
         if ($service && $service->_id) {
             return $service;
         }
         // Recherche du premier service d'urgences actif
         $group_id = CGroups::loadCurrent()->_id;
         $where = array("group_id" => "= '{$group_id}'", "urgence" => "= '1'", "cancelled" => "= '0'");
         $service = new CService();
         $service->loadObject($where, "nom");
         return $service;
     }
     // Utiliser le contexte de la consultation dans la cas des dossiers d'anesth
     if ($context instanceof CConsultAnesth) {
         $context = $context->loadRefConsultation();
     }
     // Utiliser le contexte du cabinet dans le cas des consultations
     if ($context instanceof CConsultation) {
         return $context->loadRefPlageConsult()->loadRefChir()->loadRefFunction();
     }
     return CGroups::loadCurrent();
 }
示例#6
0
$filter->convalescence = CValue::getOrSession("convalescence");
$filter->_specialite = CValue::getOrSession("_specialite");
$filter->_filter_type = CValue::getOrSession("_filter_type");
$filter->_ccam_libelle = CValue::getOrSession("_ccam_libelle", "1");
$filter->_coordonnees = CValue::getOrSession("_coordonnees");
$filter->_notes = CValue::getOrSession("_notes");
$filter->_by_date = CValue::getOrSession("_by_date");
$listPrat = new CMediusers();
$listPrat = $listPrat->loadPraticiens(PERM_READ);
$listSpec = new CFunctions();
$listSpec = $listSpec->loadSpecialites(PERM_READ);
// Récupération de la liste des services
$where = array();
$where["externe"] = "= '0'";
$where["cancelled"] = "= '0'";
$service = new CService();
$services = $service->loadGroupList($where);
$yesterday = CMbDT::date("-1 day", $today);
$tomorrow = CMbDT::date("+1 day", $today);
$j2 = CMbDT::date("+2 day", $today);
$j3 = CMbDT::date("+3 day", $today);
$week_deb = CMbDT::date("last sunday", $today);
$week_fin = CMbDT::date("next sunday", $week_deb);
$week_deb = CMbDT::date("+1 day", $week_deb);
$next_week_deb = CMbDT::date("+1 day", $week_fin);
$next_week_fin = CMbDT::date("next sunday", $next_week_deb);
$yesterday_deb = "{$yesterday} 06:00:00";
$yesterday_fin = "{$yesterday} 21:00:00";
$today_deb = "{$today} 06:00:00";
$today_fin = "{$today} 21:00:00";
$tomorrow_deb = "{$tomorrow} 06:00:00";
 /**
  * Get others PV1 QPD element
  *
  * @param DOMNode $node QPD element
  *
  * @return array
  */
 function getOtherRequestSejour(DOMNode $node)
 {
     // Recherche du service
     $service = new CService();
     $ds = $service->getDS();
     $where_returns = array();
     if ($service_name = $this->getDemographicsFields($node, "CSejour", "3.1")) {
         $service_name = preg_replace("/\\*+/", "%", $service_name);
         $where["code"] = $ds->prepare("LIKE %", $service_name);
         $ids = array_unique($service->loadIds($where, null, 100));
         // FIXME prendre les affectations en compte
         $where_returns["sejour.service_id"] = $ds->prepareIn($ids);
     }
     // Praticien
     if (($attending_doctor_name = $this->getDemographicsFields($node, "CSejour", "7.2.1")) || ($attending_doctor_name = $this->getDemographicsFields($node, "CSejour", "17.2.1"))) {
         $user = new CUser();
         $attending_doctor_name = preg_replace("/\\*+/", "%", $attending_doctor_name);
         $where["user_last_name"] = $ds->prepare("LIKE %", $attending_doctor_name);
         $ids = array_unique($user->loadIds($where, null, 100));
         $where_returns["sejour.praticien_id"] = $ds->prepareIn($ids);
     }
     // Médecin adressant
     if ($referring_doctor_name = $this->getDemographicsFields($node, "CSejour", "8.2.1")) {
         $medecin = new CMedecin();
         $referring_doctor_name = preg_replace("/\\*+/", "%", $referring_doctor_name);
         $where["nom"] = $ds->prepare("LIKE %", $referring_doctor_name);
         $ids = array_unique($medecin->loadIds($where, null, 100));
         $where_returns["sejour.adresse_par_prat_id"] = $ds->prepareIn($ids);
     }
     return $where_returns;
 }
}
$categories = CPrescription::getCategoriesForPeriod($service_id, $date, $real_time);
if (!count($categories_id_pancarte)) {
    $categories_id_pancarte = array("med");
    foreach ($categories as $_categorie) {
        foreach ($_categorie as $_elts) {
            $categories_id_pancarte = array_merge($categories_id_pancarte, array_keys($_elts));
        }
    }
}
$filter_line = new CPrescriptionLineMedicament();
$filter_line->debut = $date;
// Récupération de la liste des services
$where = array();
$where["externe"] = "= '0'";
$where["cancelled"] = "= '0'";
$service = new CService();
$services = $service->loadGroupList($where);
// Smarty template
$smarty = new CSmartyDP();
$smarty->assign("service", $service);
$smarty->assign("filter_line", $filter_line);
$smarty->assign("services", $services);
$smarty->assign("service_id", $service_id);
$smarty->assign("date", $date);
$smarty->assign('day', CMbDT::date());
$smarty->assign('real_time', $real_time);
$smarty->assign("categories", $categories);
$smarty->assign("date_min", "");
$smarty->assign("categories_id_pancarte", $categories_id_pancarte);
$smarty->display('vw_pancarte_service.tpl');
 $ticks[] = array(count($ticks) * 2 - 0.4, utf8_encode(CMbDT::format($date, "%b")));
 // Input //////////////////
 $where = array("product.product_id" => "= '{$product->_id}'", "product_order_item_reception.date" => "BETWEEN '{$date}' AND '{$to}'");
 $ljoin = array("product_order_item" => "product_order_item.order_item_id = product_order_item_reception.order_item_id", "product_reference" => "product_reference.reference_id = product_order_item.reference_id", "product" => "product.product_id = product_reference.product_id");
 $lot = new CProductOrderItemReception();
 /** @var CProductOrderItemReception[] $lots */
 $lots = $lot->loadList($where, null, null, null, $ljoin);
 $total = 0;
 foreach ($lots as $_lot) {
     $total += $_lot->quantity;
 }
 $max = max($max, $total);
 $series[0]["data"][] = array(count($series[0]["data"]) * 2 - 0.6, $total);
 // Hack pour les etablissements qui ont un service "Périmés"
 $where_services = array("nom" => "= 'Périmés'");
 $services_expired = new CService();
 $services_expired_ids = $services_expired->loadIds($where_services);
 // Output //////////////////
 $where = array("product_delivery.stock_class" => "= 'CProductStockGroup'", "product_delivery.stock_id" => "= '{$product->_ref_stock_group->_id}'", "product_delivery_trace.date_delivery" => "BETWEEN '{$date}' AND '{$to}'");
 if (count($services_expired_ids)) {
     $where[100] = "(product_delivery.type != 'expired' OR product_delivery.type IS NULL)\r\n                   AND product_delivery.service_id NOT IN (" . implode(',', $services_expired_ids) . ")";
 } else {
     $where[100] = "product_delivery.type != 'expired' OR product_delivery.type IS NULL";
 }
 $ljoin = array("product_delivery" => "product_delivery.delivery_id = product_delivery_trace.delivery_id");
 $trace = new CProductDeliveryTrace();
 /** @var CProductDeliveryTrace $traces */
 $traces = $trace->loadList($where, null, null, null, $ljoin);
 $total = 0;
 foreach ($traces as $_trace) {
     $total += $_trace->quantity;
示例#10
0
/**
 * $Id$
 *
 * @category Soins
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$service_id = CValue::get("service_id");
// Le service_id en get lors du fetch pour le plan de soins pose problème
unset($_GET["service_id"]);
$date = CValue::get("date", CMbDT::date());
$service = new CService();
$service->load($service_id);
$datetime_min = "{$date} 00:00:00";
$datetime_max = "{$date} 23:59:59";
$datetime_avg = "{$date} " . CMbDT::time();
$date_tolerance = CAppUI::conf("dPurgences date_tolerance");
$date_before = CMbDT::date("-{$date_tolerance} DAY", $date);
$date_after = CMbDT::date("+1 DAY", $date);
$group = CGroups::loadCurrent();
$sejour = new CSejour();
$where = array();
$ljoin = array();
$ljoin["affectation"] = "sejour.sejour_id = affectation.sejour_id";
$where["sejour.entree"] = "<= '{$datetime_max}'";
$where["sejour.sortie"] = " >= '{$datetime_min}'";
$where["sejour.group_id"] = "= '{$group->_id}'";
示例#11
0
CCanDo::checkRead();
// Filtres d'affichage
$selSortis = CValue::getOrSession("selSortis", "0");
$order_col = CValue::getOrSession("order_col", "patient_id");
$order_way = CValue::getOrSession("order_way", "ASC");
$date = CValue::getOrSession("date", CMbDT::date());
$type = CValue::getOrSession("type");
$service_id = CValue::getOrSession("service_id");
$prat_id = CValue::getOrSession("prat_id");
$period = CValue::getOrSession("period");
$filterFunction = CValue::getOrSession("filterFunction");
$date_actuelle = CMbDT::dateTime("00:00:00");
$date_demain = CMbDT::dateTime("00:00:00", "+ 1 day");
$hier = CMbDT::date("- 1 day", $date);
$demain = CMbDT::date("+ 1 day", $date);
$service_id = CService::getServicesIdsPref($service_id);
// Récupération de la liste des praticiens
$prat = CMediusers::get();
$prats = $prat->loadPraticiens();
$sejour = new CSejour();
$sejour->_type_admission = $type;
$sejour->praticien_id = $prat_id;
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("sejour", $sejour);
$smarty->assign("date_demain", $date_demain);
$smarty->assign("date_actuelle", $date_actuelle);
$smarty->assign("date", $date);
$smarty->assign("selSortis", $selSortis);
$smarty->assign("order_way", $order_way);
$smarty->assign("order_col", $order_col);
示例#12
0
 public function bind($mobile, $no, $name)
 {
     $members = CService::factory("Member")->queryMemberAnd($mobile, $no, $name);
     if (empty($members)) {
         $this->setError("can not find this member!");
         return array(-1, null);
     }
     $arr = array();
     foreach ($members as $key => $value) {
         $cards = D("Card")->getAllCards($value['id']);
         foreach ($cards as $card) {
             $info = array("card_id" => $card['card_number']);
             $club_id = "";
             $clubs = array();
             $contracts = D("Contract")->getAllContract($card['id']);
             foreach ($contracts as $contract) {
                 $clbs = D("CardUseclub")->getAllUseClub($contract['card_type_id']);
                 foreach ($clbs as $clb) {
                     $clubs[] = $clb['id'];
                 }
             }
             $clubs = array_unique($clubs);
             $club_id = implode(',', $clubs);
             $info['club_id'] = $club_id;
             $arr[] = $info;
         }
     }
     return array(0, $arr);
 }
示例#13
0
         $key++;
     }
     // suppression des series vides
     foreach ($series as $_key => $_serie) {
         if ($_serie['subtotal'] == 0) {
             unset($series[$_key]);
         }
     }
     $series = array_values($series);
     break;
     // Nombre de mutations
 // Nombre de mutations
 case "mutations_count":
     $data[$axe] = array("options" => array("title" => utf8_encode("Nombre de mutations")), "series" => array());
     $series =& $data[$axe]['series'];
     $service = new CService();
     $service->group_id = CGroups::loadCurrent()->_id;
     $service->cancelled = 0;
     $services = $service->loadMatchingList("nom");
     $services["none"] = new CService();
     $services["none"]->_view = "Non renseigné";
     $where["sejour.mode_sortie"] = "= 'mutation'";
     $key = 0;
     foreach ($services as $_id => $_service) {
         $series[$key] = array('data' => array(), 'label' => utf8_encode($_service->_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.service_sortie_id'] = $_id === "none" ? "IS NULL" : "= '{$_id}'";
             $count = $sejour->countList($where, null, $ljoin);
示例#14
0
<?php

/**
 * $Id$
 *
 * @category Admissions
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
CCanDo::checkRead();
// Chargement du séjour s'il y en a un
$sejour = new CSejour();
$sejour->load(CValue::get("sejour_id"));
$service_id = $sejour->service_sortie_id;
$service = new CService();
$service->load($service_id);
// Chargement des services
$order = "nom";
$services = $service->loadList(null, $order);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("service", $service);
$smarty->assign("services", $services);
$smarty->display("inc_vw_services.tpl");
示例#15
0
<?php

/* $Id: do_delivery_aed.php 6067 2009-04-14 08:04:15Z phenxdesign $ */
/**
 * @package Mediboard
 * @subpackage soins
 * @version $Revision: 6067 $
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 */
$service_id = CValue::get('service_id');
$date_min = CValue::get('date_min');
$date_max = CValue::get('date_max');
$service = new CService();
$orders = array();
if ($service->load($service_id) && $date_min && $date_max) {
    $stocks = $service->loadBackRefs('product_stock_services');
    if ($stocks) {
        foreach ($stocks as $stock) {
            $stock->loadRefsFwd();
            $stock_group = CProductStockGroup::getFromCode($stock->_ref_product->code);
            $target_quantity = $stock->order_threshold_optimum ? $stock->order_threshold_optimum : $stock->order_threshold_max;
            if (CAppUI::conf('dPstock CProductStockService infinite_quantity') != 1) {
                $effective_quantity = $stock->quantity;
                $where = array('product_delivery.date_dispensation' => "BETWEEN '{$date_min} 00:00:00' AND '{$date_max} 23:59:59'", 'product_delivery.stock_id' => " = '{$stock_group->_id}'", 'product_delivery.stock_class' => " = '{$stock_group->_class}'", 'product.category_id' => " = '" . CAppUI::conf('dPmedicament CBcbProduitLivretTherapeutique product_category_id') . "'");
                $ljoin = array('product_stock_group' => 'product_delivery.stock_id = product_stock_group.stock_id', 'product' => 'product.product_id = product_stock_group.product_id');
                $delivery = new CProductDelivery();
                $deliveries = $delivery->loadList($where, null, null, null, $ljoin);
                foreach ($deliveries as $delivery) {
                    if ($delivery->order == 1 && $delivery->quantity > 0) {
                        $effective_quantity += $delivery->quantity;
示例#16
0
$services = array();
$services_type = array("Urgences" => CService::loadServicesUrgence(), "UHCD" => CService::loadServicesUHCD());
if (CAppUI::conf("dPurgences view_rpu_uhcd")) {
    // Affichage des services UHCD et d'urgence
    $services = CService::loadServicesUHCDRPU();
} elseif ($sejour->type == "comp" && $sejour->UHCD) {
    // UHCD pour un séjour "comp" et en UHCD
    $services = $services_type["UHCD"];
    unset($services_type["Urgences"]);
} else {
    // Urgences pour un séjour "urg"
    $services = $services_type["Urgences"];
    unset($services_type["UHCD"]);
}
if ($imagerie_etendue) {
    $service_imagerie = CService::loadServicesImagerie();
    $services_type["Imagerie"] = $service_imagerie;
    $services = array_merge($services, $services_type["Imagerie"]);
}
$module_orumip = CModule::getActive("orumip");
$orumip_active = $module_orumip && $module_orumip->mod_active;
$nb_printers = 0;
if (CModule::getActive("printing")) {
    // Chargement des imprimantes pour l'impression d'étiquettes
    $user_printers = CMediusers::get();
    $function = $user_printers->loadRefFunction();
    $nb_printers = $function->countBackRefs("printers");
}
$list_mode_entree = array();
if (CAppUI::conf("dPplanningOp CSejour use_custom_mode_entree")) {
    $mode_entree = new CModeEntreeSejour();
 /**
  * Mapping et enregistrement de l'affectation
  *
  * @param CSejour   $newVenue Admit
  * @param array     $data     Datas
  * @param CMovement $movement Movement
  *
  * @return CAffectation|string|null
  */
 function mapAndStoreAffectation(CSejour $newVenue, $data, CMovement $movement = null)
 {
     $sender = $this->_ref_sender;
     if ($newVenue->annule) {
         return null;
     }
     $PV1_3 = $this->queryNode("PV1.3", $data["PV1"]);
     $affectation = new CAffectation();
     $affectation->sejour_id = $newVenue->_id;
     $event_code = $this->_ref_exchange_hl7v2->code;
     // Récupération de la date de réalisation de l'évènement
     // Dans le cas spécifique de quelques évènements, on récupère le code sur le ZBE
     $datetime = $this->queryTextNode("EVN.6/TS.1", $data["EVN"]);
     if (array_key_exists("ZBE", $data) && $data["ZBE"] && CMbArray::in($event_code, array("A01", "A02", "A04", "A15", "Z80", "Z84"))) {
         $datetime = $this->queryTextNode("ZBE.2/TS.1", $data["ZBE"]);
     }
     switch ($event_code) {
         // Cas d'une suppression de mutation ou d'une permission d'absence
         case "A12":
         case "A52":
             // Quand on a un mouvement (provenant d'un ZBE)
             if (array_key_exists("ZBE", $data) && $data["ZBE"]) {
                 if (!$movement) {
                     return null;
                 }
                 $affectation->load($movement->affectation_id);
                 if (!$affectation->_id) {
                     return "Le mouvement '{$movement->_id}' n'est pas lié à une affectation dans Mediboard";
                 }
             } else {
                 $affectation->entree = $datetime;
                 $affectation->loadMatchingObject();
                 if (!$affectation->_id) {
                     return null;
                 }
             }
             // Pas de synchronisation
             $affectation->_no_synchro = true;
             if ($msgAffectation = $affectation->delete()) {
                 return $msgAffectation;
             }
             return null;
             // Annulation admission
         // Annulation admission
         case "A11":
             if (!$movement) {
                 return null;
             }
             $affectation = $newVenue->getCurrAffectation($datetime);
             // Si le mouvement n'a pas d'affectation associée, et que l'on a déjà une affectation dans MB
             if (!$movement->affectation_id && $affectation->_id) {
                 return "Le mouvement '{$movement->_id}' n'est pas lié à une affectation dans Mediboard";
             }
             // Si on a une affectation associée, alors on charge celle-ci
             if ($movement->affectation_id) {
                 $affectation = $movement->loadRefAffectation();
             }
             // Pas de synchronisation
             $affectation->_no_synchro = true;
             if ($msg = $affectation->delete()) {
                 return $msg;
             }
             return null;
             // Annuler le retour du patient
         // Annuler le retour du patient
         case "A53":
             if (!$movement) {
                 return null;
             }
             $affectation->load($movement->affectation_id);
             if (!$affectation->_id) {
                 return "Le mouvement '{$movement->_id}' n'est pas lié à une affectation dans Mediboard";
             }
             $affectation->effectue = 0;
             // Pas de synchronisation
             $affectation->_no_synchro = true;
             $affectation->_eai_sender_guid = $sender->_guid;
             if ($msg = $affectation->store()) {
                 return $msg;
             }
             return $affectation;
             // Cas d'un départ pour une permission d'absence
         // Cas d'un départ pour une permission d'absence
         case "A21":
             $affectation->entree = $datetime;
             $affectation->loadMatchingObject();
             // Si on ne retrouve pas une affectation
             // Création de l'affectation
             // et mettre à 'effectuee' la précédente si elle existe sinon création de celle-ci
             if (!$affectation->_id) {
                 $service_externe = CService::loadServiceExterne($sender->group_id);
                 if (!$service_externe->_id) {
                     return "CService-externe-none";
                 }
                 $affectation->service_id = $service_externe->_id;
                 $return_affectation = $newVenue->forceAffectation($affectation, true);
                 //$datetime, $affectation->lit_id, $affectation->service_id);
                 if (is_string($return_affectation)) {
                     return $return_affectation;
                 }
                 $affectation = $return_affectation;
             }
             return $affectation;
             // Cas d'un retour pour une permission d'absence
         // Cas d'un retour pour une permission d'absence
         case "A22":
             $service_externe = CService::loadServiceExterne($sender->group_id);
             if (!$service_externe->_id) {
                 return "CService-externe-none";
             }
             // Recherche de l'affectation correspondant à une permission d'absence
             $search = new CAffectation();
             $where = array();
             $where["sejour_id"] = "=  '{$newVenue->_id}'";
             $where["service_id"] = "=  '{$service_externe->_id}'";
             $where["effectue"] = "=  '0'";
             $where["entree"] = "<= '{$datetime}'";
             $where["sortie"] = ">= '{$datetime}'";
             $search->loadObject($where);
             // Si on ne la retrouve pas on prend la plus proche
             if (!$search->_id) {
                 $where = array();
                 $where["sejour_id"] = "=  '{$newVenue->_id}'";
                 $where["service_id"] = "=  '{$service_externe->_id}'";
                 $where["effectue"] = "=  '0'";
                 $search->loadObject($where);
             }
             $search->effectue = 1;
             $search->sortie = $datetime;
             $search->_eai_sender_guid = $sender->_guid;
             if ($msg = $search->store()) {
                 return $msg;
             }
             return $search;
             // Cas mutation
         // Cas mutation
         case "A02":
             $affectation->entree = $datetime;
             $affectation->loadMatchingObject();
             // Si on ne retrouve pas une affectation
             // Création de l'affectation
             // et mettre à 'effectuee' la précédente si elle existe sinon création de celle-ci
             if (!$affectation->_id) {
                 // Récupération du Lit et UFs
                 $this->getPL($PV1_3, $affectation, $newVenue);
                 $return_affectation = $newVenue->forceAffectation($affectation, true);
                 //$datetime, $affectation->lit_id, $affectation->service_id);
                 if (is_string($return_affectation)) {
                     return $return_affectation;
                 }
                 $affectation = $return_affectation;
             }
             break;
             // Cas modification
         // Cas modification
         case "Z99":
             if (!$movement) {
                 return null;
             }
             // Si on a une affectation associée, alors on charge celle-ci
             if ($movement->affectation_id) {
                 $affectation = $movement->loadRefAffectation();
             } else {
                 // On recherche l'affectation "courante"
                 // Si qu'une affectation sur le séjour
                 $newVenue->loadRefsAffectations();
                 if (count($newVenue->_ref_affectations) == 1) {
                     $affectation = reset($newVenue->_ref_affectations);
                 } else {
                     // On recherche l'affectation "courante"
                     $affectation = $newVenue->getCurrAffectation($datetime);
                 }
                 // Sinon on récupère et on met à jour la première affectation
                 if (!$affectation->_id) {
                     $affectation->sejour_id = $newVenue->_id;
                     $affectation->entree = $newVenue->entree;
                     $affectation->sortie = $newVenue->sortie;
                 }
             }
             break;
             // Tous les autres cas on récupère et on met à jour la première affectation
         // Tous les autres cas on récupère et on met à jour la première affectation
         default:
             $newVenue->loadRefsAffectations();
             $affectation = $newVenue->_ref_first_affectation;
             if (!$affectation->_id) {
                 $affectation->sejour_id = $newVenue->_id;
                 $affectation->entree = $newVenue->entree;
                 $affectation->sortie = $newVenue->sortie;
             }
     }
     // Si pas d'UF/service/chambre/lit on retourne une affectation vide
     if (!$PV1_3) {
         if ($msgVenue = self::storeUFMedicaleSoinsSejour($data, $newVenue)) {
             return $msgVenue;
         }
         return $affectation;
     }
     if ($this->queryTextNode("PL.1", $PV1_3) == $sender->_configs["handle_PV1_3_null"]) {
         if ($msgVenue = self::storeUFMedicaleSoinsSejour($data, $newVenue)) {
             return $msgVenue;
         }
         return $affectation;
     }
     // Si pas de lit on affecte le service sur le séjour
     if (!$this->queryTextNode("PL.3", $PV1_3)) {
         $affectation_uf = new CAffectationUniteFonctionnelle();
         // On essaye de récupérer le service dans ce cas depuis l'UF d'hébergement
         $date_deb = $affectation->_id ? CMbDT::date($affectation->sortie) : CMbDT::date($newVenue->sortie);
         $date_fin = $affectation->_id ? CMbDT::date($affectation->entree) : CMbDT::date($newVenue->entree);
         $uf = CUniteFonctionnelle::getUF($this->queryTextNode("PL.1", $PV1_3), "hebergement", $newVenue->group_id, $date_deb, $date_fin);
         if ($uf->code && $uf->_id) {
             $affectation_uf->uf_id = $uf->_id;
             $affectation_uf->object_class = "CService";
             $affectation_uf->loadMatchingObject();
         }
         // Dans le cas où l'on retrouve un service associé à l'UF d'hébergement
         if ($affectation_uf->_id) {
             $newVenue->service_id = $affectation_uf->object_id;
             $newVenue->uf_hebergement_id = $affectation_uf->uf_id;
         }
         $uf_med = $this->mappingUFMedicale($data, $newVenue, $affectation);
         $newVenue->uf_medicale_id = $uf_med ? $uf_med->_id : null;
         $uf_soins = $this->mappingUFSoins($data, $newVenue, $affectation);
         $newVenue->uf_soins_id = $uf_soins ? $uf_soins->_id : null;
         // On ne check pas la cohérence des dates des consults/intervs
         $newVenue->_skip_date_consistencies = true;
         $newVenue->_eai_sender_guid = $sender->_guid;
         if ($msgVenue = self::storeUFMedicaleSoinsSejour($data, $newVenue)) {
             return $msgVenue;
         }
         // Si on a pas d'UF on retourne une affectation vide
         if (!$uf->_id || !$affectation_uf->_id) {
             return $affectation;
         }
     }
     // Récupération du Lit et UFs
     $this->getPL($PV1_3, $affectation, $newVenue);
     $uf_med = $this->mappingUFMedicale($data, $newVenue, $affectation);
     $affectation->uf_medicale_id = $uf_med ? $uf_med->_id : null;
     $uf_soins = $this->mappingUFSoins($data, $newVenue, $affectation);
     $affectation->uf_soins_id = $uf_soins ? $uf_soins->_id : null;
     $affectation->_eai_sender_guid = $sender->_guid;
     if ($msg = $affectation->store()) {
         return $msg;
     }
     return $affectation;
 }
示例#18
0
    {
        $ccmu1 = CValue::first($sejour1->_ref_rpu->ccmu, "9");
        $ccmu2 = CValue::first($sejour2->_ref_rpu->ccmu, "9");
        if ($ccmu1 == "P") {
            $ccmu1 = "1";
        }
        if ($ccmu2 == "P") {
            $ccmu2 = "1";
        }
        return $ccmu2 - $ccmu1;
    }
    uasort($listSejours, "ccmu_cmp");
}
// Chargement des boxes d'urgences
$boxes = array();
foreach (CService::loadServicesUHCD() as $service) {
    foreach ($service->_ref_chambres as $chambre) {
        foreach ($chambre->_ref_lits as $lit) {
            $boxes[$lit->_id] = $lit;
        }
    }
}
// Si admin sur le module urgences, alors modification autorisée du diagnostic
// infirmier depuis la main courante.
$module = new CModule();
$module->mod_name = "dPurgences";
$module->loadMatchingObject();
$admin_urgences = $module->canAdmin();
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("boxes", $boxes);
示例#19
0
 *
 * @package    Mediboard
 * @subpackage Hospi
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$group = CGroups::loadCurrent();
$ds = CSQLDataSource::get("std");
$service_id = CValue::getOrSession("service_id", 0);
$bloc_id = CValue::getOrSession("bloc_id", 0);
$date_suivi = CValue::getOrSession("date_suivi", CMbDT::date());
$listOps = array();
// Liste des services
$service = new CService();
$where = array();
$where["group_id"] = "= '{$group->_id}'";
$where["cancelled"] = "= '0'";
$order = "nom";
$services = $service->loadListWithPerms(PERM_READ, $where, $order);
// Liste des blocs
$bloc = new CBlocOperatoire();
$where = array();
$where["group_id"] = "= '{$group->_id}'";
$order = "nom";
$blocs = $bloc->loadListWithPerms(PERM_READ, $where, $order);
// Listes des interventions
$operation = new COperation();
$ljoin = array("plagesop" => "`operations`.`plageop_id` = `plagesop`.`plageop_id`", "sallesbloc" => "`operations`.`salle_id` = `sallesbloc`.`salle_id`", "sejour" => "`operations`.`sejour_id` = `sejour`.`sejour_id`");
$where = array();
/**
 * $Id: offline_prescriptions_multipart.php 27852 2015-04-03 09:55:15Z alexis_granger $
 *
 * @package    Mediboard
 * @subpackage Soins
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 27852 $
 */
ob_clean();
CApp::setMemoryLimit("1024M");
CApp::setTimeLimit(240);
$service_id = CValue::get("service_id");
$date = CValue::get("date", CMbDT::date());
$service = new CService();
$service->load($service_id);
$datetime_min = "{$date} 00:00:00";
$datetime_max = "{$date} 23:59:59";
$datetime_avg = "{$date} " . CMbDT::time();
$sejour = new CSejour();
$where = array();
$ljoin = array();
$ljoin["affectation"] = "sejour.sejour_id = affectation.sejour_id";
$where["sejour.entree"] = "<= '{$datetime_max}'";
$where["sejour.sortie"] = " >= '{$datetime_min}'";
$where["affectation.entree"] = "<= '{$datetime_max}'";
$where["affectation.sortie"] = ">= '{$datetime_min}'";
$where["affectation.service_id"] = " = '{$service_id}'";
/** @var CSejour[] $sejours */
$sejours = $sejour->loadList($where, null, null, "sejour.sejour_id", $ljoin);
示例#21
0
/**
 * Affichage du graphique de la réparition des patients par service
 *
 * @param date   $debut         Début de la période
 * @param date   $fin           Fin de la période
 * @param int    $prat_id       Filtre sur un praticien
 * @param int    $service_id    Filtre sur un service
 * @param string $type_adm      Filtre sur le type d'admission
 * @param int    $func_id       Filtre sur un cabinet
 * @param int    $discipline_id Filtre sur une discipline
 * @param int    $septique      Filtre sur les patients septiques
 * @param string $type_data     Choix du type de données
 *
 * @return array
 */
function graphPatParService($debut = null, $fin = null, $prat_id = 0, $service_id = 0, $type_adm = "", $func_id = 0, $discipline_id = 0, $septique = 0, $type_data = "prevue")
{
    if (!$debut) {
        $debut = CMbDT::date("-1 YEAR");
    }
    if (!$fin) {
        $fin = CMbDT::date();
    }
    $group_id = CGroups::loadCurrent()->_id;
    $prat = new CMediusers();
    $prat->load($prat_id);
    $discipline = new CDiscipline();
    $discipline->load($discipline_id);
    $ticks = array();
    $serie_total = array('label' => 'Total', 'data' => array(), 'markers' => array('show' => true), 'bars' => array('show' => false));
    for ($i = $debut; $i <= $fin; $i = CMbDT::date("+1 MONTH", $i)) {
        $ticks[] = array(count($ticks), CMbDT::transform("+0 DAY", $i, "%m/%Y"));
        $serie_total['data'][] = array(count($serie_total['data']), 0);
    }
    $where = array();
    if ($service_id) {
        $where["service_id"] = "= '{$service_id}'";
    }
    $service = new CService();
    $services = $service->loadGroupList($where);
    $sejour = new CSejour();
    $listHospis = array(1 => "Hospi complètes + ambu") + $sejour->_specs["type"]->_locales;
    $total = 0;
    $series = array();
    // Patients placés
    foreach ($services as $service) {
        $serie = array('data' => array(), 'label' => utf8_encode($service->nom));
        $query = "SELECT COUNT(DISTINCT sejour.sejour_id) AS total, service.nom AS nom,\r\n      DATE_FORMAT(affectation.entree, '%m/%Y') AS mois,\r\n      DATE_FORMAT(affectation.entree, '%Y%m') AS orderitem\r\n      FROM sejour\r\n      LEFT JOIN users_mediboard ON sejour.praticien_id = users_mediboard.user_id\r\n      LEFT JOIN affectation ON sejour.sejour_id = affectation.sejour_id\r\n      LEFT JOIN service ON affectation.service_id = service.service_id\r\n      WHERE\r\n        sejour.annule = '0' AND\r\n        sejour.group_id = '{$group_id}' AND\r\n        affectation.entree < '{$fin} 23:59:59' AND\r\n        affectation.sortie > '{$debut} 00:00:00' AND\r\n        service.service_id = '{$service->_id}'";
        if ($type_data == "reelle") {
            $query .= "\nAND sejour.entree_reelle BETWEEN  '{$debut} 00:00:00' AND '{$fin} 23:59:59'";
        }
        if ($prat_id) {
            $query .= "\nAND sejour.praticien_id = '{$prat_id}'";
        }
        if ($discipline_id) {
            $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'";
        }
        if ($septique) {
            $query .= "\nAND sejour.septique = '{$septique}'";
        }
        if ($type_adm) {
            if ($type_adm == 1) {
                $query .= "\nAND (sejour.type = 'comp' OR sejour.type = 'ambu')";
            } else {
                $query .= "\nAND sejour.type = '{$type_adm}'";
            }
        }
        $query .= "\nGROUP BY mois ORDER BY orderitem";
        $result = $sejour->_spec->ds->loadlist($query);
        foreach ($ticks as $i => $tick) {
            $f = true;
            foreach ($result as $r) {
                if ($tick[1] == $r["mois"]) {
                    $serie["data"][] = array($i, $r["total"]);
                    $serie_total["data"][$i][1] += $r["total"];
                    $total += $r["total"];
                    $f = false;
                    break;
                }
            }
            if ($f) {
                $serie["data"][] = array(count($serie["data"]), 0);
            }
        }
        $series[] = $serie;
    }
    // Patients non placés
    if (!$service_id) {
        $serie = array('data' => array(), 'label' => utf8_encode("Non placés"));
        $query = "SELECT COUNT(DISTINCT sejour.sejour_id) AS total, 'Non placés' AS nom,\r\n      DATE_FORMAT(sejour.entree_{$type_data}, '%m/%Y') AS mois,\r\n      DATE_FORMAT(sejour.entree_{$type_data}, '%Y%m') AS orderitem\r\n      FROM sejour\r\n      LEFT JOIN users_mediboard ON sejour.praticien_id = users_mediboard.user_id\r\n      LEFT JOIN  affectation ON sejour.sejour_id = affectation.sejour_id\r\n      WHERE \r\n        sejour.annule = '0' AND\r\n        sejour.group_id = '{$group_id}' AND\r\n        sejour.entree_{$type_data} < '{$fin} 23:59:59' AND\r\n        sejour.sortie_{$type_data} > '{$debut} 00:00:00' AND\r\n\r\n        affectation.affectation_id IS NULL";
        if ($prat_id) {
            $query .= "\nAND sejour.praticien_id = '{$prat_id}'";
        }
        if ($discipline_id) {
            $query .= "\nAND users_mediboard.discipline_id = '{$discipline_id}'";
        }
        if ($septique) {
            $query .= "\nAND sejour.septique = '{$septique}'";
        }
        if ($type_adm) {
            if ($type_adm == 1) {
                $query .= "\nAND (sejour.type = 'comp' OR sejour.type = 'ambu')";
            } else {
                $query .= "\nAND sejour.type = '{$type_adm}'";
            }
        }
        $query .= "\nGROUP BY mois ORDER BY orderitem";
        $resultNP = $sejour->_spec->ds->loadlist($query);
        foreach ($ticks as $i => $tick) {
            $f = true;
            foreach ($resultNP as $r) {
                if ($tick[1] == $r["mois"]) {
                    $serie["data"][] = array($i, $r["total"]);
                    $serie_total["data"][$i][1] += $r["total"];
                    $total += $r["total"];
                    $f = false;
                    break;
                }
            }
            if ($f) {
                $serie["data"][] = array(count($serie["data"]), 0);
            }
        }
        $series[] = $serie;
    }
    $series[] = $serie_total;
    $subtitle = "{$total} passages";
    if ($prat_id) {
        $subtitle .= " - Dr {$prat->_view}";
    }
    if ($discipline_id) {
        $subtitle .= " - {$discipline->_view}";
    }
    if ($type_adm) {
        $subtitle .= " - " . $listHospis[$type_adm];
    }
    if ($septique) {
        $subtitle .= " - Septiques";
    }
    $options = array('title' => utf8_encode("Nombre de patients par service - {$type_data}"), 'subtitle' => utf8_encode($subtitle), 'xaxis' => array('labelsAngle' => 45, 'ticks' => $ticks), 'yaxis' => array('min' => 0, 'autoscaleMargin' => 1), 'bars' => array('show' => true, 'stacked' => true, 'barWidth' => 0.8), 'HtmlText' => false, 'legend' => array('show' => true, 'position' => 'nw'), 'grid' => array('verticalLines' => false), 'spreadsheet' => array('show' => true, 'csvFileSeparator' => ';', 'decimalSeparator' => ',', 'tabGraphLabel' => utf8_encode('Graphique'), 'tabDataLabel' => utf8_encode('Données'), 'toolbarDownload' => utf8_encode('Fichier CSV'), 'toolbarSelectAll' => utf8_encode('Sélectionner tout le tableau')));
    return array('series' => $series, 'options' => $options);
}
 * @subpackage Hospi
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
// Récupération des paramètres
$date = CValue::getOrSession("date", CMbDT::dateTime());
$services_ids = CValue::getOrSession("services_ids");
$services_ids = CService::getServicesIdsPref($services_ids);
if (!$services_ids) {
    $smarty = new CSmartyDP();
    $smarty->display("inc_no_services.tpl");
    CApp::rip();
}
$service = new CService();
$services = $service->loadAll($services_ids, "nom");
$services_noms = array();
foreach ($services as $serv) {
    /* @var CService $serv*/
    $services_noms[$serv->_id] = $serv->nom;
}
$chambres = array();
$grilles = array();
$ensemble_lits_charges = array();
$conf_nb_colonnes = CAppUI::conf("dPhospi nb_colonnes_vue_topologique");
foreach ($services as $serv) {
    $grille = null;
    $grille = array_fill(0, $conf_nb_colonnes, array_fill(0, $conf_nb_colonnes, 0));
    $chambres = $serv->loadRefsChambres(false);
    foreach ($chambres as $ch) {
示例#23
0
if ($rpu && $rpu->_id) {
    // Mise en session du rpu_id
    $_SESSION["dPurgences"]["rpu_id"] = $rpu->_id;
    $rpu->loadRefSejourMutation();
    $affectation = $sejour->loadRefCurrAffectation();
    $affectation->loadRefService();
    // Urgences pour un séjour "urg"
    if ($sejour->type == "urg") {
        $services = CService::loadServicesUrgence();
    }
    // UHCD pour un séjour "comp" et en UHCD
    if ($sejour->type == "comp" && $sejour->UHCD) {
        $services = CService::loadServicesUHCD();
    }
    if ($affectation->_ref_service && $affectation->_ref_service->radiologie == "1") {
        $services = CService::loadServicesImagerie();
    }
    if (CAppUI::conf("dPplanningOp CSejour use_custom_mode_sortie")) {
        $mode_sortie = new CModeSortieSejour();
        $where = array("actif" => "= '1'");
        $list_mode_sortie = $mode_sortie->loadGroupList($where);
    }
}
$where = array();
$where["entree"] = "<= '" . CMbDT::dateTime() . "'";
$where["sortie"] = ">= '" . CMbDT::dateTime() . "'";
$where["function_id"] = "IS NOT NULL";
$affectation = new CAffectation();
/** @var CAffectation[] $blocages_lit */
$blocages_lit = $affectation->loadList($where);
$where["function_id"] = "IS NULL";
示例#24
0
$lastmonth = CMbDT::date("first day of previous month", $date);
$sans_anesth = CValue::getOrSession("sans_anesth", 0);
// Sélection du praticien
$mediuser = CMediusers::get();
$listPrat = $mediuser->loadPraticiens(PERM_EDIT);
foreach ($listPrat as $_prat) {
    $_prat->loadRefFunction();
}
$selPrat = CValue::getOrSession("selPrat", $mediuser->isPraticien() ? $mediuser->user_id : null);
$selPraticien = new CMediusers();
$selPraticien->load($selPrat);
$group = CGroups::loadCurrent();
if ($selPraticien->isAnesth()) {
    // Selection des différentes interventions de la journée par service
    $count_ops = array("ambu" => 0, "comp" => 0, "hors_plage" => 0);
    $service = new CService();
    $services = $service->loadGroupList();
    $interv = new COperation();
    $order = "operations.chir_id, operations.time_operation";
    $ljoin = array("plagesop" => "plagesop.plageop_id = operations.plageop_id", "sejour" => "sejour.sejour_id = operations.sejour_id", "affectation" => "affectation.sejour_id = sejour.sejour_id\r\n      AND '{$date}' BETWEEN DATE(affectation.entree)\r\n      AND DATE(affectation.sortie)", "lit" => "lit.lit_id = affectation.lit_id", "chambre" => "chambre.chambre_id = lit.chambre_id", "service" => "service.service_id = chambre.service_id");
    $where_anesth = "operations.anesth_id = '{$selPraticien->_id}' OR plagesop.anesth_id = '{$selPraticien->_id}'";
    if ($sans_anesth) {
        $where_anesth .= " OR operations.anesth_id IS NULL OR plagesop.anesth_id IS NULL";
    }
    $whereAmbu = array("operations.date" => "= '{$date}'", "sejour.type" => "= 'ambu'", "sejour.group_id" => "= '{$group->_id}'");
    $whereAmbu[] = $where_anesth;
    if (!$canceled) {
        $whereAmbu["operations.annulee"] = " = '0'";
    }
    $whereHospi = array("operations.date" => "= '{$date}'", "sejour.type" => "= 'comp'", "sejour.group_id" => "= '{$group->_id}'");
    $whereHospi[] = $where_anesth;
 /**
  * Get servoces list
  *
  * @return CService[]
  */
 static function getServicesList()
 {
     $service = new CService();
     $where = array();
     if (CAppUI::conf("dPstock host_group_id")) {
         $where["group_id"] = "IS NOT NULL";
     }
     return $service->loadListWithPerms(PERM_READ, $where, "nom");
 }
示例#26
0
 static function getServicesIdsPref($services_ids = array())
 {
     // Détection du changement d'établissement
     $group_id = CValue::get("g");
     if (!$services_ids || $group_id) {
         $group_id = $group_id ? $group_id : CGroups::loadCurrent()->_id;
         $pref_services_ids = json_decode(CAppUI::pref("services_ids_hospi"));
         // Si la préférence existe, alors on la charge
         if (isset($pref_services_ids->{"g{$group_id}"})) {
             $services_ids = $pref_services_ids->{"g{$group_id}"};
             $services_ids = explode("|", $services_ids);
             CMbArray::removeValue("", $services_ids);
         } else {
             $service = new CService();
             $where = array();
             $where["group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
             $where["cancelled"] = "= '0'";
             $services_ids = array_keys($service->loadListWithPerms(PERM_READ, $where, "externe, nom"));
         }
     }
     if (is_array($services_ids)) {
         CMbArray::removeValue("", $services_ids);
     }
     global $m;
     $save_m = $m;
     foreach (array("dPhospi", "dPadmissions") as $_module) {
         $m = $_module;
         CValue::setSession("services_ids", $services_ids);
     }
     $m = $save_m;
     return $services_ids;
 }
示例#27
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Hospi
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$services_ids = CValue::getOrSession("services_ids");
$readonly = CValue::getOrSession("readonly");
$services_ids = CService::getServicesIdsPref($services_ids);
$smarty = new CSmartyDP();
$smarty->assign("readonly", $readonly);
$smarty->display("vw_placements.tpl");
示例#28
0
 * @version    $Revision$
 */
$services_ids = CValue::getOrSession("services_ids", array());
$services_ids_suggest = CValue::get("services_ids_suggest", null);
$view = CValue::get("view");
$ajax_request = CValue::get("ajax_request", 1);
if (!is_array($services_ids_suggest) && !is_null($services_ids_suggest)) {
    $services_ids = explode(",", $services_ids_suggest);
}
$group_id = CGroups::loadCurrent()->_id;
$where = array();
$where["group_id"] = "= '{$group_id}'";
$where["cancelled"] = "= '0'";
$where["secteur_id"] = "IS NULL";
$order = "externe, nom";
$service = new CService();
$all_services = $service->loadList($where, $order);
unset($where["secteur_id"]);
$services_allowed = $service->loadListWithPerms(PERM_READ, $where, $order);
$where = array();
$where["group_id"] = "= '{$group_id}'";
$secteur = new CSecteur();
$secteurs = $secteur->loadList($where, "nom");
foreach ($secteurs as $_secteur) {
    $_secteur->loadRefsServices();
    $keys2 = array_keys($_secteur->_ref_services);
    $_secteur->_all_checked = count($_secteur->_ref_services) > 0 ? array_values(array_intersect($services_ids, $keys2)) == $keys2 : false;
}
$services_ids_hospi = CAppUI::pref("services_ids_hospi");
if (!$services_ids_hospi) {
    $services_ids_hospi = "{}";
示例#29
0
 * @package    Mediboard
 * @subpackage Hospi
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 20186 $
 */
$date = CValue::getOrSession("date");
// Chargement des praticiens
$med = new CMediusers();
$listPrat = $med->loadPraticiens(PERM_READ);
$dateEntree = CMbDT::dateTime("23:59:00", $date);
$dateSortie = CMbDT::dateTime("00:01:00", $date);
$hierEntree = CMbDT::date("- 1 day", $dateEntree);
$hierEntree = CMbDT::dateTime("23:59:00", $hierEntree);
// Chargement des services
$service = new CService();
$whereServices = array();
$whereServices["group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
$whereServices["cancelled"] = "= '0'";
$services = $service->loadListWithPerms(PERM_READ, $whereServices, "nom");
// Initialisations
$totalHospi = 0;
$totalAmbulatoire = 0;
$totalMedecin = 0;
$total_prat = array();
foreach ($listPrat as $key => $prat) {
    $totalPrat[$prat->_id]["prat"] = $prat;
    $totalPrat[$prat->_id]["hospi"] = 0;
    $totalPrat[$prat->_id]["ambu"] = 0;
    $totalPrat[$prat->_id]["total"] = 0;
}
    $sejour->loadNDA();
    // Cas des urgences
    $rpu = $sejour->loadRefRPU();
    if ($rpu && $rpu->_id) {
        $rpu->loadRefSejourMutation();
        $sejour->loadRefCurrAffectation()->loadRefService();
        // Urgences pour un séjour "urg"
        if ($sejour->type == "urg") {
            $services = CService::loadServicesUrgence();
        }
        if ($sejour->_ref_curr_affectation->_ref_service->radiologie == "1") {
            $services = array_merge($services, CService::loadServicesImagerie());
        }
        // UHCD pour un séjour "comp" et en UHCD
        if ($sejour->type == "comp" && $sejour->UHCD) {
            $services = CService::loadServicesUHCD();
        }
        if (CAppUI::conf("dPplanningOp CSejour use_custom_mode_sortie")) {
            $mode_sortie = new CModeSortieSejour();
            $where = array("actif" => "= '1'");
            $list_mode_sortie = $mode_sortie->loadGroupList($where);
        }
    }
}
$smarty = new CSmartyDP();
$smarty->assign("listAnesths", $listAnesths);
$smarty->assign("listChirs", $listChirs);
$smarty->assign("services", $services);
$smarty->assign("list_mode_sortie", $list_mode_sortie);
$smarty->assign("consult", $consult);
$smarty->assign("consult_anesth", $consult_anesth);