/**
  * Generate content message
  *
  * @param CAffectation $affectation Movement
  * @param bool         $referent    Is referring ?
  *
  * @return void
  */
 function generateFromOperation(CAffectation $affectation, $referent)
 {
     $evenementsPatients = $this->documentElement;
     $evenementPatient = $this->addElement($evenementsPatients, "evenementPatient");
     $mouvementPatient = $this->addElement($evenementPatient, "mouvementPatient");
     $actionConversion = array("create" => "création", "store" => "modification", "delete" => "suppression");
     $affectation->loadLastLog();
     $action = $affectation->_ref_last_log->type ? $affectation->_ref_last_log->type : "create";
     $this->addAttribute($mouvementPatient, "action", $actionConversion[$action]);
     $affectation->loadRefSejour();
     $affectation->_ref_sejour->loadNDA();
     $affectation->_ref_sejour->loadRefPatient();
     $affectation->_ref_sejour->loadRefPraticien();
     $patient = $this->addElement($mouvementPatient, "patient");
     // Ajout du patient
     $this->addPatient($patient, $affectation->_ref_sejour->_ref_patient, $referent);
     $venue = $this->addElement($mouvementPatient, "venue");
     // Ajout de la venue
     $this->addVenue($venue, $affectation->_ref_sejour, $referent);
     // Ajout du mouvement (1 seul dans notre cas pas l'historique)
     $mouvements = $this->addElement($mouvementPatient, "mouvements");
     $this->addMouvement($mouvements, $affectation);
     // Traitement final
     $this->purgeEmptyElements();
 }
 /**
  * Loads siblings (prev, next)
  *
  * @param bool $use_sejour Try to use sejour bounds to guess prev et next (mostly no prev nor next)
  *
  * @return void
  */
 function loadRefsAffectations($use_sejour = false)
 {
     $sejour = $this->_ref_sejour;
     $this->_ref_prev = new CAffectation();
     $guess_no_prev = $use_sejour && $sejour && $this->entree == $sejour->entree;
     if (!$guess_no_prev) {
         $where = array("affectation_id" => "!= '{$this->_id}'", "sejour_id" => "= '{$this->sejour_id}'", "sortie" => "= '{$this->entree}'");
         $this->_ref_prev->loadObject($where);
     }
     $this->_ref_next = new CAffectation();
     $guess_no_next = $use_sejour && $sejour && $this->sortie == $sejour->sortie;
     if (!$guess_no_next) {
         $where = array("affectation_id" => "!= '{$this->_id}'", "sejour_id" => "= '{$this->sejour_id}'", "entree" => "= '{$this->sortie}'");
         $this->_ref_next->loadObject($where);
     }
 }
 /**
  * Check dispo
  *
  * @param string $date Date
  *
  * @return void
  */
 function checkDispo($date)
 {
     assert($this->_ref_affectations !== null);
     $index = "lit_id";
     // Last Dispo
     $where = array("lit_id" => "= '{$this->lit_id}'", "sortie" => "<= '{$date} 23:59:59'");
     $order = "sortie DESC";
     $this->_ref_last_dispo = new CAffectation();
     $this->_ref_last_dispo->loadObject($where, $order, null, null, $index);
     $this->_ref_last_dispo->checkDaysRelative($date);
     // Next Dispo
     $where = array("lit_id" => "= '{$this->lit_id}'", "entree" => ">= '{$date} 00:00:00'");
     $order = "entree ASC";
     $this->_ref_next_dispo = new CAffectation();
     $this->_ref_next_dispo->loadObject($where, $order, null, null, $index);
     $this->_ref_next_dispo->checkDaysRelative($date);
 }
Beispiel #4
0
 /**
  * Charge les affectations situées dans un couloir du service
  *
  * @param string $date               Date
  * @param bool   $with_effectue      Avec effectue
  * @param bool   $with_sortie_reelle Avec sortie reelle
  *
  * @return CAffectation[]
  */
 function loadRefsAffectationsCouloir($date, $with_effectue = true, $with_sortie_reelle = false)
 {
     $ljoin = array();
     $where = array("affectation.service_id" => "= '{$this->_id}'", "affectation.entree" => "<= '{$date} 23:59:59'", "affectation.sortie" => ">= '{$date} 00:00:00'");
     if (!$with_effectue) {
         if ($with_sortie_reelle) {
             $complement = "";
             if ($date == CMbDT::date()) {
                 $ljoin["sejour"] = "affectation.sejour_id = sejour.sejour_id";
                 $complement = "OR (sejour.sortie_reelle >= '" . CMbDT::dateTime() . "' AND affectation.sortie >= '" . CMbDT::dateTime() . "')";
             }
             $where[] = "affectation.effectue = '0' {$complement}";
         } else {
             $where["affectation.effectue"] = "= '0'";
         }
     }
     $where["affectation.lit_id"] = "IS NULL";
     $order = "affectation.sortie DESC";
     $affectation = new CAffectation();
     return $this->_ref_affectations_couloir = $affectation->loadList($where, $order, null, null, $ljoin);
 }
/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Hospi
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkEdit();
$affectation_id = CValue::get("affectation_id");
$lit_id = CValue::get("lit_id");
$urgence = CValue::get("urgence");
$from_tempo = CValue::get("from_tempo", 0);
$affectation = new CAffectation();
$affectation->load($affectation_id);
$lit = new C**t();
$lit->load($affectation->lit_id);
if ($urgence) {
    $service_urgence = CGroups::loadCurrent()->service_urgences_id;
    $affectation->function_id = $service_urgence;
}
$sejour_maman = null;
if (CModule::getActive("maternite") && $affectation->sejour_id) {
    $naissance = new CNaissance();
    $naissance->sejour_enfant_id = $affectation->sejour_id;
    $naissance->loadMatchingObject();
    if ($naissance->_id) {
        $sejour_maman = $naissance->loadRefSejourMaman();
        $sejour_maman->loadRefPatient();
Beispiel #6
0
    $sejour->sortie_reelle = CMbDT::dateTime();
}
$where = array();
$where["entree"] = "<= '{$sejour->sortie_reelle}'";
$where["sortie"] = ">= '{$sejour->sortie_reelle}'";
$where["function_id"] = "IS NOT NULL";
$leftjoin = array("affectation" => "affectation.lit_id = lit.lit_id");
$lit = new C**t();
//Lit réservé pour les urgences
$lits_urgence = $lit->loadList($where, null, null, null, $leftjoin);
$where["function_id"] = "IS NULL";
$where["sejour_id"] = "IS NULL";
$where["lit.lit_id"] = CSQLDataSource::prepareIn(array_keys($lits_urgence));
//lit qui sont bloqués
$lits_bloque = $lit->loadList($where, null, null, null, $leftjoin);
$affectation = new CAffectation();
unset($where["lit.lit_id"]);
unset($where["sejour_id"]);
/** @var C**t $_lit */
foreach ($lits_urgence as $_lit) {
    $sortie = CMbDT::transform($affectation->sortie, null, "%Hh%M %d-%m-%Y");
    $_lit->loadRefService()->loadRefsChambres();
    if (array_key_exists($_lit->_id, $lits_bloque)) {
        $_lit->_view .= " (bloqué jusqu'au {$sortie})";
        continue;
    }
    //On recherche une affectation d'un patient dans le lit d'urgence
    $where["lit_id"] = "= '{$_lit->_id}'";
    if (!$affectation->loadObject($where)) {
        continue;
    }
Beispiel #7
0
        $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";
foreach ($blocages_lit as $blocage) {
    $blocage->loadRefLit()->loadRefChambre()->loadRefService();
    $where["lit_id"] = "= '{$blocage->lit_id}'";
    if ($affectation->loadObject($where)) {
        $sejour = $affectation->loadRefSejour();
        $patient = $sejour->loadRefPatient();
        $blocage->_ref_lit->_view .= " indisponible jusqu'à " . CMbDT::transform($affectation->sortie, null, "%Hh%Mmin %d-%m-%Y");
        $blocage->_ref_lit->_view .= " (" . $patient->_view . " (" . strtoupper($patient->sexe) . ") ";
        $blocage->_ref_lit->_view .= CAppUI::conf("dPurgences age_patient_rpu_view") ? $patient->_age . ")" : ")";
    }
}
// Tableau de contraintes pour les champs du RPU
 /**
  * Get affectation HL7 event code
  *
  * @param CAffectation $affectation       Affectation
  * @param CAffectation $first_affectation First affectation
  *
  * @return null|string
  */
 function getCodeAffectation(CAffectation $affectation, CAffectation $first_affectation = null)
 {
     $current_log = $affectation->_ref_current_log;
     if (!in_array($current_log->type, array("create", "store"))) {
         return null;
     }
     $receiver = $affectation->_receiver;
     $configs = $receiver->_configs;
     $service = $affectation->loadRefService();
     $code = "A02";
     if ($service->uhcd || $service->radiologie || $service->urgence) {
         $code = $this->getModificationAdmitCode($receiver);
     }
     if ($current_log->type == "create") {
         /* Affectation dans un service externe */
         if ($service->externe) {
             return "A21";
         }
         // Dans le cas où il s'agit de la première affectation du séjour on ne fait pas une mutation mais une modification
         if ($first_affectation && $first_affectation->_id == $affectation->_id) {
             switch ($configs["send_first_affectation"]) {
                 case 'Z99':
                     return $this->getModificationAdmitCode($receiver);
                 default:
                     return $code;
             }
         }
         // Création d'une affectation
         switch ($configs["send_transfer_patient"]) {
             case 'Z99':
                 return $this->getModificationAdmitCode($receiver);
             default:
                 return $code;
         }
     }
     /* Affectation dans un service externe effectuée */
     if ($service->externe && !$affectation->_old->effectue && $affectation->effectue) {
         return "A22";
     }
     /* Affectation dans un service externe effectuée */
     if ($service->externe && $affectation->_old->effectue && !$affectation->effectue) {
         return "A53";
     }
     /* Changement d'UF Médicale */
     if ($affectation->_old->uf_medicale_id && $affectation->fieldModified("uf_medicale_id")) {
         /* @todo Gérer le cas où : création d'une nouvelle affectation && UM1 # UM2 */
         switch ($configs["send_change_medical_responsibility"]) {
             case 'Z80':
                 return "Z80";
             case 'A02':
                 return "A02";
             default:
                 return $this->getModificationAdmitCode($receiver);
         }
     }
     /* Changement d'UF de Soins */
     if ($affectation->_old->uf_soins_id && $affectation->fieldModified("uf_soins_id")) {
         /* @todo Gérer le cas où : création d'une nouvelle affectation && US1 # US2 */
         switch ($configs["send_change_nursing_ward"]) {
             case 'Z84':
                 return "Z84";
             case 'A02':
                 return "A02";
             default:
                 return $this->getModificationAdmitCode($receiver);
         }
     }
     // Modifcation d'une affectation
     return $this->getModificationAdmitCode($affectation->_receiver);
 }
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Hospi
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
global $can, $m, $g;
$affectation = new CAffectation();
$dateMin = CValue::get("dateMin", "YYYY-MM-JJ");
$where = array();
if ($dateMin != "YYYY-MM-JJ") {
    $where["sortie"] = ">= '{$dateMin} 00:00:00'";
}
$listAffectations = $affectation->loadList($where);
$entrees = 0;
$sorties = 0;
foreach ($listAffectations as &$curr_aff) {
    $curr_aff->loadRefsFwd();
    $changeSejour = 0;
    if (!$curr_aff->_ref_prev->affectation_id && $curr_aff->sejour_id) {
        if ($curr_aff->entree != $curr_aff->_ref_sejour->entree_prevue) {
            $curr_aff->_ref_sejour->entree_prevue = $curr_aff->entree;
            $changeSejour = 1;
            $entrees++;
        }
    }
 /**
  * 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;
 }
 function getAffectation()
 {
     $sejour = $this->_ref_sejour;
     if (!$this->_ref_sejour) {
         $sejour = $this->loadRefSejour();
     }
     if (!$this->_datetime_best) {
         $this->loadRefPlageOp();
     }
     $affectation = new CAffectation();
     $order = "entree";
     $where = array();
     $where["sejour_id"] = "= '{$this->sejour_id}'";
     $moment = $this->_datetime_best;
     // Si l'intervention est en dehors du séjour,
     // on recadre dans le bon intervalle
     if ($moment < $sejour->entree) {
         $moment = $sejour->entree;
     }
     if ($moment > $sejour->sortie) {
         $moment = $sejour->sortie;
     }
     if (CMbDT::time(null, $moment) == "00:00:00") {
         $where["entree"] = $this->_spec->ds->prepare("<= %", CMbDT::date(null, $moment) . " 23:59:59");
         $where["sortie"] = $this->_spec->ds->prepare(">= %", CMbDT::date(null, $moment) . " 00:00:01");
     } else {
         $where["entree"] = $this->_spec->ds->prepare("<= %", $moment);
         $where["sortie"] = $this->_spec->ds->prepare(">= %", $moment);
     }
     $affectation->loadObject($where, $order);
     return $affectation;
 }
/**
 * Chargement des affectations dans les couloirs
 */
function loadAffectationsCouloirs($where, $order = null, $praticien_id = null, $prestation_id = null)
{
    $group_id = CGroups::loadCurrent()->_id;
    $systeme_presta = CAppUI::conf("dPhospi prestations systeme_prestations", "CGroups-{$group_id}");
    $ljoin = array("sejour" => "affectation.sejour_id = sejour.sejour_id", "patients" => "sejour.patient_id = patients.patient_id", "users_mediboard" => "sejour.praticien_id = users_mediboard.user_id", "users" => "users.user_id = users_mediboard.user_id");
    if ($praticien_id) {
        $where["sejour.praticien_id"] = " = '{$praticien_id}'";
    }
    if ($order == null) {
        $order = "users_mediboard.function_id, sejour.entree_prevue, patients.nom, patients.prenom";
    }
    $where["affectation.lit_id"] = " IS NULL";
    $affectation = new CAffectation();
    /* @var CAffectation[] $affectations*/
    $affectations = $affectation->loadList($where, $order, null, null, $ljoin);
    $sejours = CMbObject::massLoadFwdRef($affectations, "sejour_id");
    CMbObject::massLoadFwdRef($sejours, "praticien_id");
    CMbObject::massLoadFwdRef($sejours, "patient_id");
    $tab_affectations = array();
    foreach ($affectations as $affectation) {
        $affectation->loadRefsAffectations();
        $affectation->loadRefSejour()->loadRefPatient();
        $affectation->_ref_prev->loadRefLit();
        $affectation->_ref_next->loadRefLit();
        $sejour =& $affectation->_ref_sejour;
        $sejour->loadRefPrestation();
        $sejour->loadRefsOperations();
        $sejour->loadNDA();
        $sejour->loadRefPraticien();
        $sejour->loadRefPatient();
        $sejour->_ref_patient->loadRefDossierMedical(false);
        if ($systeme_presta == "expert" && $prestation_id) {
            $sejour->loadLiaisonsForPrestation($prestation_id);
        }
        // Chargement des droits CMU
        $sejour->getDroitsCMU();
        foreach ($sejour->_ref_operations as $operation_id => $curr_operation) {
            $sejour->_ref_operations[$operation_id]->loadExtCodesCCAM();
        }
        $tab_affectations[$affectation->service_id][] = $affectation;
    }
    $dossiers = CMbArray::pluck($affectations, "_ref_sejour", "_ref_patient", "_ref_dossier_medical");
    CDossierMedical::massCountAntecedentsByType($dossiers, "deficience");
    return $tab_affectations;
}
    $inverse = array_flip($prestations_ids);
    $item_prestation = $items_prestations[$inverse[$prestation_id]];
    if ($item_prestation->_id) {
        $lit->_selected_item = $item_prestation;
    } else {
        $lit->_selected_item = new CItemPrestation();
    }
} else {
    $lit->_selected_item = new CItemPrestation();
}
// Chargement des affectations
$where = array();
$where["lit_id"] = "= '{$lit_id}'";
$where["entree"] = "<= '{$date_max}'";
$where["sortie"] = ">= '{$date_min}'";
$affectation = new CAffectation();
$affectations = $affectation->loadList($where, "parent_affectation_id ASC");
// 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}'");
    /** @var CSejour[] $sejours_prolonges */
    $sejours_prolonges = $sejour->loadList($where);
    $affectations_prolong = array();
    foreach ($sejours_prolonges as $_sejour) {
        $aff = $_sejour->getCurrAffectation($_sejour->sortie);
        if (!$aff->_id || $aff->lit_id != $lit_id) {
Beispiel #14
0
$max_entree = 0;
$max_sortie = 0;
$ds = $lit->getDS();
foreach ($lits as $key => $_lit) {
    $_lit->_ref_affectations = array();
    $_lit->loadCompleteView();
    if ($_lit->_id == $affectation->lit_id) {
        $_lit->_ref_last_dispo = new CAffectation();
        $_lit->_ref_last_dispo->sortie = $entree;
        $_lit->_dispo_depuis = 0;
    } else {
        $where = array();
        $where["lit_id"] = "= '{$_lit->_id}'";
        $where["entree"] = "<= '{$sortie}'";
        $where["sortie"] = ">= '{$entree}'";
        $affectation_collide = new CAffectation();
        $affectation_collide->loadObject($where);
        if ($affectation_collide->_id) {
            unset($lits[$key]);
            continue;
        }
        $where = array("lit_id" => "= '{$_lit->_id}'", "sortie" => "<= '{$entree}'");
        $index = "lit_id";
        $_lit->_ref_last_dispo = new CAffectation();
        $_lit->_ref_last_dispo->loadObject($where, "sortie DESC", null, null, $index);
        $_lit->_dispo_depuis = strtotime($entree) - strtotime($_lit->_ref_last_dispo->sortie);
        if ($_lit->_dispo_depuis < 0) {
            unset($lits[$key]);
            continue;
        }
        if ($_lit->_ref_last_dispo->_id && $_lit->_dispo_depuis > $max_entree) {
Beispiel #15
0
            $where["prescription_line_mix.praticien_id"] = " = '{$user_id}'";
            unset($where_line["signee"]);
            $ljoin_line["prescription"] = "prescription.prescription_id = prescription_line_mix.prescription_id";
            $ljoin_line["sejour"] = "prescription.object_id = sejour.sejour_id";
            $lines = $line_mix->loadList($where_line, null, null, null, $ljoin_line);
            foreach ($lines as $_line) {
                $_line->loadRefPrescription();
                $_sejour = $_line->_ref_prescription->_ref_object;
                if (!isset($sejours[$_sejour->_id])) {
                    $sejours[$_sejour->_id] = $_sejour;
                }
            }
        } else {
            $sejours = array();
            if ($service_id || $praticien_id || $function_id) {
                $affectation = new CAffectation();
                $affectations = $affectation->loadList($where, $order, null, "affectation.sejour_id", $ljoin);
                /** @var CSejour[] $sejours */
                $sejours = CStoredObject::massLoadFwdRef($affectations, "sejour_id", null, true);
                /* @var CAffectation[] $affectations*/
                foreach ($affectations as $_affectation) {
                    $_affectation->loadRefLit()->loadCompleteView();
                    $_affectation->_view = $_affectation->_ref_lit->_view;
                    $sejour = $_affectation->loadRefSejour(1);
                    $sejour->_ref_curr_affectation = $_affectation;
                }
            }
        }
    }
}
/* @var CPatient[] $patients */
Beispiel #16
0
        $item_prestation = $items_prestations[$inverse[$prestation_id]];
        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'");
Beispiel #17
0
CValue::setSession("prestation_id", $prestation_id);
$mouvements = array("comp" => array("entrees" => array("place" => 0, "non_place" => 0), "sorties" => array("place" => 0, "non_place" => 0)), "ambu" => array("entrees" => array("place" => 0, "non_place" => 0), "sorties" => array("place" => 0, "non_place" => 0)), "urg" => array("entrees" => array("place" => 0, "non_place" => 0), "sorties" => array("place" => 0, "non_place" => 0)), "ssr" => array("entrees" => array("place" => 0, "non_place" => 0), "sorties" => array("place" => 0, "non_place" => 0)), "psy" => array("entrees" => array("place" => 0, "non_place" => 0), "sorties" => array("place" => 0, "non_place" => 0)));
$group = CGroups::loadCurrent();
// Récupération de la liste des services et du service selectionné
$where = array("externe" => "= '0'", "group_id" => "= '{$group->_id}'");
$order = "nom";
$services_ids = CService::getServicesIdsPref($services_ids);
// Récupération de la liste des praticiens et du praticien selectionné
$praticien = new CMediusers();
$praticiens = $praticien->loadPraticiens(PERM_READ);
$praticien_id = CValue::getOrSession("praticien_id", null);
$date = CValue::getOrSession("date", CMbDT::date());
$limit1 = $date . " 00:00:00";
$limit2 = $date . " 23:59:59";
// Patients placés
$affectation = new CAffectation();
$ljoin = array();
$ljoin["sejour"] = "sejour.sejour_id = affectation.sejour_id";
$ljoin["patients"] = "sejour.patient_id = patients.patient_id";
$ljoin["users"] = "sejour.praticien_id = users.user_id";
$ljoin["service"] = "service.service_id = affectation.service_id";
$where = array();
$where["service.group_id"] = "= '{$group->_id}'";
$where["service.service_id"] = CSQLDataSource::prepareIn($services_ids);
$where["sejour.type"] = CSQLDataSource::prepareIn(array_keys($mouvements), $type_hospi);
$where["sejour.annule"] = "= '0'";
if ($vue) {
    $where["sejour.confirme"] = " IS NULL";
}
if ($praticien_id) {
    $where["sejour.praticien_id"] = "= '{$praticien_id}'";
$dmi_active = CModule::getActive("dmi");
$group = CGroups::loadCurrent();
$types_hospi = array("comp", "ambu", "urg", "ssr", "psy");
$type_hospi = CValue::getOrSession("type_hospi", null);
$entrees = array();
$sorties = array();
// Récupération de la liste des services
$where = array();
$where["externe"] = "= '0'";
$where["group_id"] = "= '{$group->_id}'";
// Récupération de la journée à afficher
$date = CValue::getOrSession("date", CMbDT::date());
$limit1 = $date . " 00:00:00";
$limit2 = $date . " 23:59:59";
// Patients placés
$affectation = new CAffectation();
$ljoin = array();
$ljoin["sejour"] = "sejour.sejour_id = affectation.sejour_id";
$ljoin["patients"] = "sejour.patient_id = patients.patient_id";
$ljoin["users"] = "sejour.praticien_id = users.user_id";
$ljoin["service"] = "service.service_id = affectation.service_id";
$where = array();
$where["service.group_id"] = "= '{$group->_id}'";
$where["affectation.service_id"] = CSQLDataSource::prepareIn($services_ids);
$where["affectation.lit_id"] = "IS NOT NULL";
$where["sejour.type"] = CSQLDataSource::prepareIn($types_hospi, $type_hospi);
if ($praticien_id) {
    $where["sejour.praticien_id"] = "= '{$praticien->_id}'";
}
// Patients non placés
$sejour = new CSejour();
 /**
  * Mapping mouvements
  *
  * @param DOMNode      $node        Node
  * @param CSejour      $newVenue    Venue
  * @param CAffectation $affectation Affectation
  *
  * @return string
  */
 function mappingMovement(DOMNode $node, CSejour $newVenue, CAffectation $affectation)
 {
     $xpath = new CHPrimXPath($node->ownerDocument);
     $sender = $this->_ref_echange_hprim->_ref_sender;
     // Recherche d'une affectation existante
     $id = $newVenue->_guid . "-" . $xpath->queryTextNode("hprim:identifiant/hprim:emetteur", $node);
     $tag = $sender->_tag_hprimxml;
     $idex = CIdSante400::getMatch("CAffectation", $tag, $id);
     if ($idex->_id) {
         $affectation->load($idex->object_id);
         if ($affectation->sejour_id != $newVenue->_id) {
             return CAppUI::tr("hprimxml-error-E301");
         }
     }
     $affectation->sejour_id = $newVenue->_id;
     // Praticien responsable
     $medecinResponsable = $xpath->queryUniqueNode("hprim:medecinResponsable", $node);
     $affectation->praticien_id = $this->getMedecin($medecinResponsable);
     // Emplacement
     $this->getEmplacement($node, $newVenue, $affectation);
     // Début de l'affectation
     $debut = $xpath->queryUniqueNode("hprim:debut", $node);
     $date = $xpath->queryTextNode("hprim:date", $debut);
     $heure = CMbDT::transform($xpath->queryTextNode("hprim:heure", $debut), null, "%H:%M:%S");
     $affectation->entree = "{$date} {$heure}";
     // Fin de l'affectation
     $fin = $xpath->queryUniqueNode("hprim:fin", $node);
     if ($fin) {
         $date = $xpath->queryTextNode("hprim:date", $fin);
         $heure = CMbDT::transform($xpath->queryTextNode("hprim:heure", $fin), null, "%H:%M:%S");
         $affectation->sortie = "{$date} {$heure}";
     }
     if (!$affectation->_id) {
         $affectation = $newVenue->forceAffectation($affectation, true);
         if (is_string($affectation)) {
             return $affectation;
         }
     } else {
         if ($msg = $affectation->store()) {
             return $msg;
         }
     }
     if (!$idex->_id) {
         $idex->object_id = $affectation->_id;
         if ($msg = $idex->store()) {
             return $msg;
         }
     }
     return null;
 }
    } else {
        $_sejour->loadRefPatient()->loadRefDossierMedical(false);
        $_sejour->checkDaysRelative($date);
    }
    $_sejour->loadRefPrestation();
}
$dossiers = CMbArray::pluck($listNotAff["Non placés"], "_ref_patient", "_ref_dossier_medical");
CDossierMedical::massCountAntecedentsByType($dossiers, "deficience");
// Chargement des affectations dans les couloirs (sans lit_id)
$where = array();
$ljoin = array();
$where["lit_id"] = "IS NULL";
$where["service_id"] = CSQLDataSource::prepareIn($services_ids);
$where["entree"] = "<= '{$date_max}'";
$where["sortie"] = ">= '{$date_min}'";
$affectation = new CAffectation();
$listNotAff["Couloir"] = $affectation->loadList($where, "entree ASC", null, null, $ljoin);
foreach ($listNotAff["Couloir"] as $_aff) {
    $_aff->loadView();
    $sejour = $_aff->loadRefSejour();
    $sejour->loadRefPatient()->loadRefDossierMedical(false);
    $sejour->checkDaysRelative($date);
    $sejour->loadRefPrestation();
}
$dossiers = CMbArray::pluck($listNotAff["Couloir"], "_ref_sejour", "_ref_patient", "_ref_dossier_medical");
CDossierMedical::massCountAntecedentsByType($dossiers, "deficience");
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("chambres", $chambres);
$smarty->assign("date", $date);
$smarty->assign("chambres_affectees", $listAff);
Beispiel #21
0
$where["sejour.annule"] = "= '0'";
if ($duree_uscpo) {
    $ljoin["operations"] = "operations.sejour_id = affectation.sejour_id";
    $where["duree_uscpo"] = "> 0";
}
if ($isolement) {
    $ljoin["sejour"] = "sejour.sejour_id = affectation.sejour_id";
    $where["isolement"] = "= '1'";
}
if ($item_prestation_id && $prestation_id) {
    if (isset($items_prestation[$item_prestation_id])) {
        $ljoin["item_liaison"] = "affectation.sejour_id = item_liaison.sejour_id";
        $where["item_liaison.item_souhait_id"] = " = '{$item_prestation_id}'";
    }
}
$affectation = new CAffectation();
$affectations = $affectation->loadList($where, $order, null, null, $ljoin);
$_sejours = CStoredObject::massLoadFwdRef($affectations, "sejour_id");
$services = $services + CStoredObject::massLoadFwdRef($affectations, "service_id");
$patients = CStoredObject::massLoadFwdRef($_sejours, "patient_id");
CPatient::massCountPhotoIdentite($patients);
foreach ($affectations as $_affectation_imc) {
    /* @var CAffectation $_affectation_imc*/
    if (CAppUI::conf("dPhospi vue_temporelle show_imc_patient", "CService-" . $_affectation_imc->service_id)) {
        $_affectation_imc->loadRefSejour()->loadRefPatient()->loadRefLatestConstantes(null, array("poids", "taille"));
    }
}
// Préchargement des users
$user = new CUser();
$where = array("user_id" => CSQLDataSource::prepareIn(CMbArray::pluck($_sejours, "praticien_id")));
$users = $user->loadList($where);
<?php

/* $Id$ */
/**
* @package Mediboard
* @subpackage dPrepas
* @version $Revision$
* @author Sébastien Fillonneau
*/
CCanDo::checkEdit();
$date = CValue::getOrSession("date", CMbDT::date());
$typerepas_id = CValue::getOrSession("typerepas_id", null);
$affectation_id = CValue::getOrSession("affectation_id", null);
$affectation = new CAffectation();
$listRepas = new CMenu();
$typeRepas = new CTypeRepas();
$repas = new CRepas();
if (!$affectation->load($affectation_id) || !$typeRepas->load($typerepas_id)) {
    // Pas d'affectation
    CValue::setSession("affectation_id", null);
    CAppUI::setMsg("Veuillez sélectionner une affectation", UI_MSG_ALERT);
    CAppUI::redirect("m=dPrepas&tab=vw_planning_repas");
} else {
    $affectation->loadRefSejour();
    $affectation->loadRefLit();
    $affectation->_ref_lit->loadCompleteView();
    $canAffectation = $affectation->canDo();
    if (!$canAffectation->read || !$affectation->_ref_sejour->sejour_id || $affectation->_ref_sejour->type == "ambu") {
        // Droit Interdit ou Ambulatoire
        CValue::setSession("affectation_id", null);
        $affectation_id = null;
 /**
  * Represents an HL7 ZBE message segment (Movement)
  *
  * @param CSejour $sejour Admit
  *
  * @return void
  */
 function addZBE(CSejour $sejour = null)
 {
     $segment_name = $this->_is_i18n ? "ZBE_FR" : "ZBE";
     /** @var CHL7v2SegmentZBE $ZBE */
     $ZBE = CHL7v2Segment::create($segment_name, $this->message);
     $ZBE->sejour = $sejour;
     $movement = $sejour->_ref_hl7_movement;
     $affectation = new CAffectation();
     if ($movement && $movement->affectation_id) {
         $affectation->load($movement->affectation_id);
     }
     $ZBE->curr_affectation = $affectation;
     $ZBE->movement = $movement;
     $ZBE->other_affectation = $sejour->_ref_hl7_affectation;
     $ZBE->build($this);
 }
Beispiel #24
0
            }
        }
    } else {
        if ($typeVue == 2) {
            // Recherche de tous les lits bloques pour urgences
            $ljoin = array();
            $ljoin["lit"] = "lit.lit_id = affectation.lit_id";
            $ljoin["chambre"] = "lit.chambre_id = chambre.chambre_id";
            $where = array();
            $where["chambre.annule"] = " = '0'";
            $where["lit.annule"] = " = '0'";
            $where["affectation.effectue"] = " = '0'";
            $where["affectation.sejour_id"] = " IS NULL";
            $where["affectation.function_id"] = " IS NOT NULL";
            $where[] = " '{$date_recherche}' BETWEEN affectation.entree AND affectation.sortie";
            $affectation = new CAffectation();
            $occupes = $affectation->loadList($where, null, null, null, $ljoin);
            foreach ($occupes as $_affectation) {
                /* @var CAffectation $_affectation*/
                $_affectation->loadRefLit()->loadRefChambre()->loadRefService();
            }
        }
    }
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("date_recherche", $date_recherche);
$smarty->assign("occupes", $occupes);
$smarty->assign("libre", $libre);
$smarty->assign("typeVue", $typeVue);
$smarty->assign("selPrat", $selPrat);
Beispiel #25
0
 /**
  * Chargement des affectations courantes et à venir du patient
  *
  * @param date $date Date de référence
  *
  * @return void
  */
 function loadRefsAffectations($date = null)
 {
     $affectation = new CAffectation();
     // Affectations inactives
     if (!$affectation->_ref_module) {
         $this->_ref_curr_affectation = null;
         $this->_ref_next_affectation = null;
     }
     if (!$date) {
         $date = CMbDT::dateTime();
     }
     $sejours = $this->loadRefsSejours();
     $group = CGroups::loadCurrent();
     // Affectation actuelle et prochaine affectation
     $where["affectation.sejour_id"] = CSQLDataSource::prepareIn(array_keys($sejours));
     $where["sejour.group_id"] = "= '{$group->_id}'";
     $order = "affectation.entree";
     // @FIXME A quoi sert cette jointure ?
     $ljoin["sejour"] = "sejour.sejour_id = affectation.sejour_id";
     // Affection courante
     $this->_ref_curr_affectation = new CAffectation();
     $where["affectation.entree"] = "<  '{$date}'";
     $where["affectation.sortie"] = ">= '{$date}'";
     $this->_ref_curr_affectation->loadObject($where, $order, null, $ljoin);
     // Prochaine affectations
     $this->_ref_next_affectation = new CAffectation();
     $where["affectation.entree"] = "> '{$date}'";
     $this->_ref_next_affectation->loadObject($where, $order, null, $ljoin);
 }
Beispiel #26
0
     if ($msg = $sejour->store()) {
         CAppUI::stepAjax($msg, UI_MSG_ERROR);
     }
     break;
 case "A11":
     $sejour_id = CValue::post("sejour_id");
     $sejour = new CSejour();
     $sejour->load($sejour_id);
     $sejour->annule = "1";
     if ($msg = $sejour->store()) {
         CAppUI::stepAjax($msg, UI_MSG_ERROR);
     }
     break;
 case "A12":
     $affectation_id = CValue::post("affectation_id");
     $affectation = new CAffectation();
     $affectation->load($affectation_id);
     if ($msg = $affectation->delete()) {
         CAppUI::stepAjax($msg, UI_MSG_ERROR);
     }
     break;
 case "A13":
     $sejour_id = CValue::post("sejour_id");
     $sejour = new CSejour();
     $sejour->load($sejour_id);
     $sejour->sortie_reelle = "";
     if ($msg = $sejour->store()) {
         CAppUI::stepAjax($msg, UI_MSG_ERROR);
     }
     break;
 case "INSERT":
$where["externe"] = "= '0'";
$where["cancelled"] = "= '0'";
$service = new CService();
$services = $service->loadGroupList($where);
foreach ($services as $_service) {
    $_service->loadRefUFSoins();
}
$sortie_sejour = CMbDT::dateTime();
if ($sejour->sortie_reelle) {
    $sortie_sejour = $sejour->sortie_reelle;
}
$where = array();
$where["entree"] = "<= '" . $sortie_sejour . "'";
$where["sortie"] = ">= '" . $sortie_sejour . "'";
$where["function_id"] = "IS NOT NULL";
$affectatione = new CAffectation();
/** @var CAffectation[] $blocages_lit */
$blocages_lit = $affectatione->loadList($where);
$where["function_id"] = "IS NULL";
foreach ($blocages_lit as $key => $blocage) {
    $blocage->loadRefLit()->loadRefChambre()->loadRefService();
    $where["lit_id"] = "= '{$blocage->lit_id}'";
    if (!$sejour->_id && $affectatione->loadObject($where)) {
        $affectatione->loadRefSejour();
        $affectatione->_ref_sejour->loadRefPatient();
        $jusqua = CMbDT::transform($affectatione->sortie, null, "%Hh%Mmin %d-%m-%Y") . " (" . $affectatione->_ref_sejour->_ref_patient->_view;
        $blocage->_ref_lit->_view .= " indisponible jusqu'à " . $jusqua . ")";
    }
}
$exchange_source = CExchangeSource::get("mediuser-" . CAppUI::$user->_id, "smtp");
$_functions = array();
 /**
  * Ajout de l'UF responsable
  *
  * @param DOMNode      $elParent    Node
  * @param CAffectation $affectation Affectation
  *
  * @return void
  */
 function addUFResponsable(DOMNode $elParent, CAffectation $affectation)
 {
     $ufs = $affectation->getUFs();
     $uf_hebergement = CMbArray::get($ufs, "hebergement");
     if (isset($uf_hebergement->_id)) {
         $uniteFonctionnelleResponsable = $this->addElement($elParent, "uniteFonctionnelleResponsable");
         $this->addCodeLibelleAttribute($uniteFonctionnelleResponsable, $uf_hebergement->code, $uf_hebergement->libelle, "responsabilite", "h");
     }
     $uf_medicale = CMbArray::get($ufs, "medicale");
     if (isset($uf_medicale->_id)) {
         $uniteFonctionnelleResponsable = $this->addElement($elParent, "uniteFonctionnelleResponsable");
         $this->addCodeLibelleAttribute($uniteFonctionnelleResponsable, $uf_medicale->code, $uf_medicale->libelle, "responsabilite", "m");
     }
     $uf_soins = CMbArray::get($ufs, "soins");
     if (isset($uf_soins->_id)) {
         $uniteFonctionnelleResponsable = $this->addElement($elParent, "uniteFonctionnelleResponsable");
         $this->addCodeLibelleAttribute($uniteFonctionnelleResponsable, $uf_soins->code, $uf_soins->libelle, "responsabilite", "s");
     }
 }
Beispiel #29
0
        }
        // Autres cas
        if ($_prat->_id == $_sejour->_ref_praticien->_id && $_sejour->type == "comp") {
            $totalPrat[$_prat->_id]["hospi"]++;
            $totalHospi++;
        }
        // Total des hospitalisations (Ambu + autres)
        if ($_prat->_id == $_sejour->_ref_praticien->_id) {
            $totalPrat[$_prat->_id]["total"] = $totalPrat[$_prat->_id]["ambu"] + $totalPrat[$_prat->_id]["hospi"];
            $totalMedecin++;
        }
    }
}
// Calcul des patients par service
// Calcul du nombre d'affectations a la date $date
$affectation = new CAffectation();
$whereAffect = array();
$ljoin = array();
$whereAffect["affectation.entree"] = "<= '{$dateEntree}'";
$whereAffect["affectation.sortie"] = ">= '{$dateSortie}'";
$whereAffect["affectation.sejour_id"] = "!= '0'";
$whereAffect["sejour.group_id"] = "= '" . CGroups::loadCurrent()->_id . "'";
$ljoin["sejour"] = "sejour.sejour_id = affectation.sejour_id";
$groupAffect = "affectation.sejour_id";
$list_affectations = $affectation->loadList($whereAffect, null, null, $groupAffect, $ljoin);
$total_service = array();
foreach ($services as $_service) {
    $total_service[$_service->_id]["service"] = $_service;
    $total_service[$_service->_id]["total"] = 0;
}
foreach ($list_affectations as $key => $_affectation) {
    /** @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();
    CApp::rip();
} else {
    $tolerance = CAppUI::conf("dPhospi CAffectation create_affectation_tolerance", CGroups::loadCurrent());