* @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 24144 $
 */
global $g;
CCanDo::checkRead();
// Récupération des paramètres
$date = CValue::getOrSession("date", CMbDT::dateTime());
$service_id = CValue::get("service_id");
$chambre_id = CValue::get("chambre_id");
$service = new CService();
if ($service_id) {
    $service->load($service_id);
} elseif ($chambre_id) {
    $chambre = new CChambre();
    $chambre->load($chambre_id);
    $service = $chambre->loadRefService();
}
$ensemble_lits_charges = array();
$grille = array_fill(0, 10, array_fill(0, 10, 0));
$chambres = $service->loadRefsChambres();
foreach ($chambres as $ch) {
    /* @var CChambre $ch*/
    $ch->loadRefEmplacement();
    if ($ch->_ref_emplacement->_id) {
        $ch->loadRefsLits();
        if (!count($ch->_ref_lits)) {
            unset($chambres[$ch->_id]);
            continue;
        }
        foreach ($ch->_ref_lits as $lit) {
 /**
  * Récupération de la location du patient
  *
  * @param DOMNode      $node        PV1 Node
  * @param CAffectation $affectation Affectation
  * @param CSejour      $newVenue    Séjour
  *
  * @return void
  */
 function getPL(DOMNode $node, CAffectation $affectation, CSejour $newVenue = null)
 {
     $sender = $this->_ref_sender;
     // Récupération de la chambre
     $nom_chambre = $this->queryTextNode("PL.2", $node);
     $chambre = new CChambre();
     // Récupération du lit
     $nom_lit = $this->queryTextNode("PL.3", $node);
     $lit = new C**t();
     switch ($sender->_configs["handle_PV1_3"]) {
         // idex du service
         case 'idex':
             $chambre_id = CIdSante400::getMatch("CChambre", $sender->_tag_chambre, $nom_chambre)->object_id;
             $chambre->load($chambre_id);
             $lit_id = CIdSante400::getMatch("C**t", $sender->_tag_lit, $nom_lit)->object_id;
             $lit->load($lit_id);
             break;
             // Dans tous les cas le nom du lit est celui que l'on reçoit du flux
         // Dans tous les cas le nom du lit est celui que l'on reçoit du flux
         default:
             $where = $ljoin = array();
             $ljoin["service"] = "service.service_id = chambre.service_id";
             $where["chambre.nom"] = " = '{$nom_chambre}'";
             $where["chambre.annule"] = " = '0'";
             $where["group_id"] = " = '{$sender->group_id}'";
             $chambre->escapeValues();
             $chambre->loadObject($where, null, null, $ljoin);
             $chambre->unescapeValues();
             $where = $ljoin = array();
             $ljoin["chambre"] = "chambre.chambre_id = lit.chambre_id";
             $ljoin["service"] = "service.service_id = chambre.service_id";
             $where["lit.nom"] = " = '{$nom_lit}'";
             $where["lit.annule"] = " = '0'";
             $where["service.cancelled"] = " = '0'";
             $where["group_id"] = " = '{$sender->group_id}'";
             if ($chambre->_id) {
                 $where["chambre.chambre_id"] = " = '{$chambre->_id}'";
             }
             $lit->escapeValues();
             $lit->loadObject($where, null, null, $ljoin);
             $lit->unescapeValues();
             break;
     }
     // Affectation du lit
     $affectation->lit_id = $lit->_id;
     // Affectation de l'UF 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", $node), "hebergement", $newVenue->group_id, $date_deb, $date_fin);
     if (!$uf->_id) {
         return;
     }
     $affectation->uf_hebergement_id = $uf->_id;
     // Affectation du service (couloir)
     if (!$affectation->lit_id) {
         $affectation_uf = new CAffectationUniteFonctionnelle();
         $affectation_uf->uf_id = $uf->_id;
         $affectation_uf->object_class = "CService";
         $affectation_uf->loadMatchingObject();
         $affectation->service_id = $affectation_uf->object_id;
     }
 }
Example #3
0
/**
 * Mettre en cache les lits
 *
 * @param CAffectation $affectation Affectation
 *
 * @return void
 */
function cacheLit(CAffectation $affectation)
{
    // Cache des lits
    $lit_id = $affectation->lit_id;
    static $lits = array();
    if (!array_key_exists($lit_id, $lits)) {
        $lit = new C**t();
        $lit->load($lit_id);
        $lits[$lit_id] = $lit;
    }
    $lit = $lits[$lit_id];
    $lit->_ref_affectations[$affectation->_id] = $affectation;
    // Cache des chambres
    $chambre_id = $lit->chambre_id;
    static $chambres = array();
    if (!array_key_exists($chambre_id, $chambres)) {
        $chambre = new CChambre();
        $chambre->load($chambre_id);
        $chambres[$chambre_id] = $chambre;
    }
    $chambre = $chambres[$chambre_id];
    $chambre->_ref_lits[$lit_id] = $lit;
    // Cache de services
    global $sejoursParService;
    $service_id = $chambre->service_id;
    if (!array_key_exists($service_id, $sejoursParService)) {
        $service = new CService();
        $service->load($service_id);
        $sejoursParService[$service_id] = $service;
    }
    $service = $sejoursParService[$service_id];
    $service->_ref_chambres[$chambre_id] = $chambre;
}