function makeUF()
 {
     $this->completeField("lit_id", "uf_hebergement_id", "uf_soins_id", "uf_medicale_id", "sortie", "entree");
     $this->loadRefsAffectations();
     $this->loadRefLit()->loadRefChambre()->loadRefService();
     $lit = $this->_ref_lit;
     $chambre = $lit->_ref_chambre;
     $service = $this->loadRefService();
     $sejour = $this->loadRefSejour();
     $prev_aff = $this->_ref_prev;
     $ljoin = array("uf" => "uf.uf_id = affectation_uf.uf_id");
     $where = array();
     $where[] = "uf.date_debut IS NULL OR uf.date_debut < '" . CMbDT::date($this->sortie) . "'";
     $where[] = "uf.date_fin IS NULL OR uf.date_fin > '" . CMbDT::date($this->entree) . "'";
     if (!$this->uf_hebergement_id || $this->fieldModified("service_id") || $this->fieldModified("lit_id")) {
         $affectation_uf = new CAffectationUniteFonctionnelle();
         $where["uf.type"] = "= 'hebergement'";
         if (!$affectation_uf->uf_id) {
             $where["object_id"] = "= '{$lit->_id}'";
             $where["object_class"] = "= 'C**t'";
             $affectation_uf->loadObject($where, null, null, $ljoin);
             if (!$affectation_uf->_id) {
                 $where["object_id"] = "= '{$chambre->_id}'";
                 $where["object_class"] = "= 'CChambre'";
                 $affectation_uf->loadObject($where, null, null, $ljoin);
                 if (!$affectation_uf->_id) {
                     $where["object_id"] = "= '{$service->_id}'";
                     $where["object_class"] = "= 'CService'";
                     $affectation_uf->loadObject($where, null, null, $ljoin);
                 }
             }
         }
         $this->uf_hebergement_id = $affectation_uf->uf_id;
     }
     if (!$this->uf_soins_id || $this->fieldModified("service_id")) {
         $affectation_uf = new CAffectationUniteFonctionnelle();
         $where["uf.type"] = "= 'soins'";
         if (!$prev_aff->_id) {
             $affectation_uf->uf_id = $sejour->uf_soins_id;
         }
         if (!$affectation_uf->uf_id) {
             $where["object_id"] = "= '{$service->_id}'";
             $where["object_class"] = "= 'CService'";
             $affectation_uf->loadObject($where, null, null, $ljoin);
         }
         $this->uf_soins_id = $affectation_uf->uf_id;
     }
     if (!$this->uf_medicale_id) {
         $affectation_uf = new CAffectationUniteFonctionnelle();
         $where["uf.type"] = "= 'medicale'";
         if (!$prev_aff->_id) {
             $affectation_uf->uf_id = $sejour->uf_medicale_id;
         }
         if (!$affectation_uf->uf_id) {
             if (!$this->praticien_id) {
                 $praticien = $this->loadRefSejour()->loadRefPraticien();
             } else {
                 $praticien = $this->loadRefPraticien();
                 $praticien->loadRefFunction();
             }
             $where["object_id"] = "= '{$praticien->_id}'";
             $where["object_class"] = "= 'CMediusers'";
             $affectation_uf->loadObject($where, null, null, $ljoin);
             if (!$affectation_uf->_id) {
                 $function = $praticien->_ref_function;
                 $where["object_id"] = "= '{$function->_id}'";
                 $where["object_class"] = "= 'CFunctions'";
                 $affectation_uf->loadObject($where, null, null, $ljoin);
             }
         }
         $this->uf_medicale_id = $affectation_uf->uf_id;
     }
 }
示例#2
0
 function makeUF()
 {
     $this->completeField("uf_hebergement_id", "uf_soins_id", "uf_medicale_id", "entree_prevue", "sortie_prevue");
     $ljoin = array("uf" => "uf.uf_id = affectation_uf.uf_id");
     $where = array();
     $where[] = "uf.date_debut IS NULL OR uf.date_debut < '" . CMbDT::date($this->sortie) . "'";
     $where[] = "uf.date_fin IS NULL OR uf.date_fin > '" . CMbDT::date($this->entree) . "'";
     if (!$this->uf_hebergement_id && !$this->fieldModified("uf_hebergement_id") || $this->fieldModified("service_id")) {
         $affectation_uf = new CAffectationUniteFonctionnelle();
         $where["uf.type"] = "= 'hebergement'";
         if (!$affectation_uf->uf_id) {
             $where["object_id"] = "= '{$this->service_id}'";
             $where["object_class"] = "= 'CService'";
             $affectation_uf->loadObject($where, null, null, $ljoin);
         }
         $this->uf_hebergement_id = $affectation_uf->uf_id;
     }
     if (!$this->uf_soins_id && !$this->fieldModified("uf_soins_id") || $this->fieldModified("service_id")) {
         $affectation_uf = new CAffectationUniteFonctionnelle();
         $where["uf.type"] = "= 'soins'";
         if (!$affectation_uf->uf_id) {
             $where["object_id"] = "= '{$this->service_id}'";
             $where["object_class"] = "= 'CService'";
             $affectation_uf->loadObject($where, null, null, $ljoin);
         }
         $this->uf_soins_id = $affectation_uf->uf_id;
     }
     if (!$this->uf_medicale_id && !$this->fieldModified("uf_medicale_id")) {
         $affectation_uf = new CAffectationUniteFonctionnelle();
         $where["uf.type"] = "= 'medicale'";
         if (!$affectation_uf->uf_id) {
             $praticien = $this->loadRefPraticien();
             $praticien->loadRefFunction();
             $where["object_id"] = "= '{$praticien->_id}'";
             $where["object_class"] = "= 'CMediusers'";
             $affectation_uf->loadObject($where, null, null, $ljoin);
             if (!$affectation_uf->_id) {
                 $function = $praticien->_ref_function;
                 $where["object_id"] = "= '{$function->_id}'";
                 $where["object_class"] = "= 'CFunctions'";
                 $affectation_uf->loadObject($where, null, null, $ljoin);
             }
         }
         $this->uf_medicale_id = $affectation_uf->uf_id;
     }
 }