//best time (horaire voulu / time_operation)
 $horaire = CMbDT::time($_operation->_datetime_best);
 $debut = "{$i} {$horaire}";
 $debut_op = $horaire;
 $fin_op = $_operation->sortie_salle ? $_operation->sortie_salle : CMbDT::addTime($_operation->temp_operation, $horaire);
 $duree = CMbDT::minutesRelative($horaire, $fin_op);
 // pré op
 if ($_operation->presence_preop) {
     $hour_debut_preop = CMbDT::subTime($_operation->presence_preop, $_operation->time_operation);
     $offset_top = CMbDT::minutesRelative($hour_debut_preop, $_operation->time_operation);
     $duree = $duree + $offset_top;
     $debut = "{$i} {$hour_debut_preop}";
 }
 //post op
 if ($_operation->presence_postop) {
     $hour_fin_postop = CMbDT::addTime($_operation->presence_postop, $fin_op);
     // Si l'heure de fin postop est inférieure à la fin de l'intervention, alors on est à la journée suivante
     // On simule une fin à 23h59 afin de rester dans la même journée
     $save_hour_fin_postop = "";
     if ($hour_fin_postop < $fin_op) {
         $save_hour_fin_postop = $hour_fin_postop;
         $hour_fin_postop = "23:59:59";
     }
     $offset_bottom = CMbDT::minutesRelative($fin_op, $hour_fin_postop);
     if ($save_hour_fin_postop) {
         $offset_bottom += CMbDT::minutesRelative("00:00:00", $save_hour_fin_postop);
         // On simule une fin à 23h59, alors il faut encore une minute pour aller jusqu'à 00h00
         $offset_bottom += 1;
     }
     $duree = $duree + $offset_bottom;
 }
 /**
  * Calcul du tableau d'occupation de la plage de consultation
  *
  * @return array
  */
 function getUtilisation()
 {
     $utilisation = array();
     $old = $this->debut;
     for ($i = $this->debut; $i < $this->fin; $i = CMbDT::addTime("+" . $this->freq, $i)) {
         if ($old > $i) {
             break;
         }
         $utilisation[$i] = 0;
         $old = $i;
     }
     foreach ($this->_ref_consultations as $_consult) {
         if (!isset($utilisation[$_consult->heure])) {
             continue;
         }
         $emplacement = $_consult->heure;
         for ($i = 0; $i < $_consult->duree; $i++) {
             if (isset($utilisation[$emplacement])) {
                 $utilisation[$emplacement]++;
             }
             $emplacement = CMbDT::addTime("+" . $this->freq, $emplacement);
         }
     }
     return $utilisation;
 }
            }
            $total["duree_first_to_last"] = $newTotalFirstToLast;
        }
        // Durée réèlle
        $newTotalReel = CMbDT::addTime($curr_plage->_duree_total_op, $total["duree_reelle"]);
        if ($newTotalReel < $total["duree_reelle"]) {
            $total["days_duree_reelle"]++;
        }
        $total["duree_reelle"] = $newTotalReel;
        // Durée du personnel
        foreach ($curr_plage->_duree_total_personnel as $_key_cat => $_curr_cat) {
            if (!isset($total["personnel"][$_key_cat])) {
                $total["personnel"][$_key_cat]["duree"] = "00:00:00";
                $total["personnel"][$_key_cat]["days_duree"] = 0;
            }
            $newTotalPersonnel = CMbDT::addTime($curr_plage->_duree_total_personnel[$_key_cat]["duree"], $total["personnel"][$_key_cat]["duree"]);
            $total["personnel"][$_key_cat]["days_duree"] += $curr_plage->_duree_total_personnel[$_key_cat]["days_duree"];
            if ($newTotalPersonnel < $total["personnel"][$_key_cat]["duree"]) {
                $total["personnel"][$_key_cat]["days_duree"]++;
            }
            $total["personnel"][$_key_cat]["duree"] = $newTotalPersonnel;
        }
    }
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("listPrats", $listPrats);
$smarty->assign("deb_personnel", $deb_personnel);
$smarty->assign("fin_personnel", $fin_personnel);
$smarty->assign("prat_personnel", $prat_personnel);
$smarty->assign("listPlages", $listPlages);
 /**
  * @see parent::updateFormFields()
  */
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_time_op = $this->temp_operation;
     $this->_time_urgence = $this->time_operation;
     /** @var CTypeAnesth $type_anesth */
     $this->_ref_type_anesth = $type_anesth = $this->loadFwdRef("type_anesth", true);
     $this->_lu_type_anesth = $type_anesth->name;
     $this->_fin_prevue = CMbDT::addTime($this->time_operation, $this->temp_operation);
     if ($this->debut_op && $this->fin_op && $this->fin_op > $this->debut_op) {
         $this->_duree_interv = CMbDT::subTime($this->debut_op, $this->fin_op);
     }
     if ($this->pose_garrot && $this->retrait_garrot && $this->retrait_garrot > $this->pose_garrot) {
         $this->_duree_garrot = CMbDT::subTime($this->pose_garrot, $this->retrait_garrot);
     }
     if ($this->induction_debut && $this->induction_fin && $this->induction_fin > $this->induction_debut) {
         $this->_duree_induction = CMbDT::subTime($this->induction_debut, $this->induction_fin);
     }
     if ($this->entree_salle && $this->sortie_salle && $this->sortie_salle > $this->entree_salle) {
         $this->_presence_salle = CMbDT::subTime($this->entree_salle, $this->sortie_salle);
     }
     if ($this->entree_reveil && $this->sortie_reveil_possible && $this->sortie_reveil_possible > $this->entree_reveil) {
         $this->_duree_sspi = CMbDT::subTime($this->entree_reveil, $this->sortie_reveil_possible);
     }
     $this->_acte_depassement = $this->depassement;
     $this->_acte_depassement_anesth = $this->depassement_anesth;
     $this->updateView();
     $this->updateDatetimes();
 }
Beispiel #5
0
 /**
  * Calcul de l'horaire souhaité de l'intervention
  *
  * @return bool
  */
 function guessHoraireVoulu()
 {
     if ($this->spec_id && !$this->unique_chir) {
         return false;
     }
     $this->completeField("debut", "temps_inter_op");
     $new_time = $this->debut;
     foreach ($this->_ref_operations as $op) {
         $op->_horaire_voulu = $new_time;
         // Durée de l'operation
         // + durée entre les operations
         // + durée de pause
         $new_time = CMbDT::addTime($op->temp_operation, $new_time);
         $new_time = CMbDT::addTime($this->temps_inter_op, $new_time);
         $new_time = CMbDT::addTime($op->pause, $new_time);
     }
     return true;
 }
Beispiel #6
0
$plageop->load(CValue::get("plageop_id"));
$plageop->loadRefSalle();
$where = array("chir_id" => "= '{$chir_id}'");
$plageop->loadRefsOperations(false, null, true, null, $where);
$plageop->guessHoraireVoulu();
$rank_validated = array();
$rank_not_validated = array();
$_op = new COperation();
$_last_op = null;
foreach ($plageop->_ref_operations as $_op) {
    $_op->loadRefChir()->loadRefFunction();
    $_op->loadRefSejour()->loadRefPatient()->loadRefDossierMedical()->countAllergies();
    $_op->loadExtCodesCCAM();
    if ($_op->_horaire_voulu) {
        $_last_op = $_op;
    }
}
$horaire_voulu = $plageop->debut;
if ($_last_op) {
    $horaire_voulu = $_last_op->_horaire_voulu;
    $horaire_voulu = CMbDT::addTime($_last_op->temp_operation, $horaire_voulu);
    $horaire_voulu = CMbDT::addTime($plageop->temps_inter_op, $horaire_voulu);
    $horaire_voulu = CMbDT::addTime($_last_op->pause, $horaire_voulu);
}
$new_op = new COperation();
$new_op->_horaire_voulu = $horaire_voulu;
$plageop->_ref_operations[] = $new_op;
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("plageop", $plageop);
$smarty->display("inc_prog_plageop.tpl");
 function addIntervention($elParent, COperation $operation, $referent = null, $light = false)
 {
     $identifiant = $this->addElement($elParent, "identifiant");
     $this->addElement($identifiant, "emetteur", $operation->_id);
     $last_idex = $operation->_ref_last_id400;
     if (isset($last_idex->_id)) {
         $this->addElement($identifiant, "recepteur", $last_idex->id400);
     }
     $sejour = $operation->loadRefSejour();
     if (!$operation->plageop_id) {
         $operation->completeField("date");
     }
     // Calcul du début de l'intervention
     $mbOpDate = CValue::first($operation->_ref_plageop->date, $operation->date);
     $time_operation = $operation->time_operation == "00:00:00" ? null : $operation->time_operation;
     $mbOpHeureDebut = CValue::first($operation->debut_op, $operation->entree_salle, $time_operation, $operation->horaire_voulu, $operation->_ref_plageop->debut);
     $mbOpDebut = CMbRange::forceInside($sejour->entree, $sejour->sortie, "{$mbOpDate} {$mbOpHeureDebut}");
     // Calcul de la fin de l'intervention
     $mbOpHeureFin = CValue::first($operation->fin_op, $operation->sortie_salle, CMbDT::addTime($operation->temp_operation, CMbDT::time($mbOpDebut)));
     $mbOpFin = CMbRange::forceInside($sejour->entree, $sejour->sortie, "{$mbOpDate} {$mbOpHeureFin}");
     $debut = $this->addElement($elParent, "debut");
     $this->addElement($debut, "date", CMbDT::date($mbOpDebut));
     $this->addElement($debut, "heure", CMbDT::time($mbOpDebut));
     $fin = $this->addElement($elParent, "fin");
     $this->addElement($fin, "date", CMbDT::date($mbOpFin));
     $this->addElement($fin, "heure", CMbDT::time($mbOpFin));
     if ($light) {
         // Ajout des participants
         $mbParticipants = array();
         foreach ($operation->_ref_actes_ccam as $acte_ccam) {
             $acte_ccam->loadRefExecutant();
             $mbParticipant = $acte_ccam->_ref_executant;
             $mbParticipants[$mbParticipant->user_id] = $mbParticipant;
         }
         $participants = $this->addElement($elParent, "participants");
         foreach ($mbParticipants as $mbParticipant) {
             $participant = $this->addElement($participants, "participant");
             $medecin = $this->addElement($participant, "medecin");
             $this->addProfessionnelSante($medecin, $mbParticipant);
         }
         // Libellé de l'opération
         $this->addTexte($elParent, "libelle", $operation->libelle, 80);
     } else {
         $this->addUniteFonctionnelle($elParent, $operation);
         // Uniquement le responsable de l’'intervention
         $participants = $this->addElement($elParent, "participants");
         $participant = $this->addElement($participants, "participant");
         $medecin = $this->addElement($participant, "medecin");
         $this->addProfessionnelSante($medecin, $operation->loadRefChir());
         // Libellé de l'opération
         $this->addTexte($elParent, "libelle", $operation->libelle, 4000);
         // Remarques sur l'opération
         $this->addTexte($elParent, "commentaire", CMbString::convertHTMLToXMLEntities("{$operation->materiel} - {$operation->rques}"), 4000);
         // Conventionnée ?
         $this->addElement($elParent, "convention", $operation->conventionne ? 1 : 0);
         // TypeAnesthésie : nomemclature externe (idex)
         if ($operation->type_anesth) {
             $tag_hprimxml = $this->_ref_receiver->_tag_hprimxml;
             $idexTypeAnesth = CIdSante400::getMatch("CTypeAnesth", $tag_hprimxml, null, $operation->type_anesth);
             $this->addElement($elParent, "typeAnesthesie", $idexTypeAnesth->id400);
         }
         // Indicateurs
         $indicateurs = $this->addElement($elParent, "indicateurs");
         $dossier_medical = new CDossierMedical();
         $dossier_medical->object_class = "CPatient";
         $dossier_medical->object_id = $operation->loadRefPatient()->_id;
         $dossier_medical->loadMatchingObject();
         $antecedents = $dossier_medical->loadRefsAntecedents();
         foreach ($antecedents as $_antecedent) {
             $rques = CMbString::htmlspecialchars($_antecedent->rques);
             $rques = CMbString::convertHTMLToXMLEntities($rques);
             $this->addCodeLibelle($indicateurs, "indicateur", $_antecedent->_id, $rques);
         }
         // Extemporané
         if ($operation->exam_extempo) {
             $this->addCodeLibelle($indicateurs, "indicateur", "EXT", "Extemporané");
         }
         // Recours / Durée USCPO
         $this->addElement($elParent, "recoursUscpo", $operation->duree_uscpo ? 1 : 0);
         $this->addElement($elParent, "dureeUscpo", $operation->duree_uscpo ? $operation->duree_uscpo : null);
         // Côté (droit|gauche|bilatéral|total|inconnu)
         // D - Droit
         // G - Gauche
         // B - Bilatéral
         // T - Total
         // I - Inconnu
         $cote = array("droit" => "D", "gauche" => "G", "bilatéral" => "B", "total" => "T", "inconnu" => "I", "haut" => "HT", "bas" => "BS");
         $this->addCodeLibelle($elParent, "cote", $cote[$operation->cote], CMbString::capitalize($operation->cote));
     }
 }
Beispiel #8
0
 /**
  * check if this need to update 'entree_prevue' and/or 'sortie_prevue' data in db for ambulatoire sejour
  *
  * @return bool does this need to be updated
  */
 function checkUpdateTimeAmbu()
 {
     $do_store_sejour = false;
     // check for conf and if sejour type is 'ambu'
     if (!CAppUI::conf('dPplanningOp CSejour entree_pre_op_ambu', CGroups::loadCurrent()->_guid) || $this->type != 'ambu') {
         return $do_store_sejour;
     }
     $this->loadRefsOperations();
     // we need only one operation = ambu
     if (count($this->_ref_operations) == 1) {
         /** @var COperation $interv */
         $interv = reset($this->_ref_operations);
         if ($interv->time_operation == '00:00:00') {
             $interv->time_operation = null;
         }
         if (isset($interv->presence_preop) && (isset($interv->horaire_voulu) || isset($interv->time_operation))) {
             $entree_prevue = $interv->date . ' ' . CMbDT::subTime($interv->presence_preop, CValue::first($interv->time_operation, $interv->horaire_voulu));
             if ($this->entree_prevue != $entree_prevue) {
                 $this->entree_prevue = $entree_prevue;
                 $do_store_sejour = true;
             }
         }
         if (isset($interv->presence_postop) && isset($interv->temp_operation) && (isset($interv->horaire_voulu) || isset($interv->time_operation))) {
             $time_postop = CMbDT::addTime($interv->temp_operation, $interv->presence_postop);
             $sortie_prevue = $interv->date . ' ' . CMbDT::addTime($time_postop, CValue::first($interv->time_operation, $interv->horaire_voulu));
             if ($this->sortie_prevue != $sortie_prevue) {
                 $this->sortie_prevue = $sortie_prevue;
                 $do_store_sejour = true;
             }
         }
         if ($do_store_sejour) {
             $this->updateFormFields();
         }
         return $do_store_sejour;
     }
     return null;
 }