Example #1
0
 /**
  * renvoie un objet watcher sur le patient
  * @param <type> $patient
  * @return clTuFormxTriggerWatcher
  */
 static function getWatcher($patient)
 {
     return clTuFormxTriggerWatcher::getInstance($patient);
 }
Example #2
0
 function genBlocEtatCivil($nomBloc, $mod, $droit, $date = '', $sortie = '')
 {
     global $session;
     global $options;
     // Initialisation des objets et des variables utilisées.
     // Pour générer des formulaires plus loin.
     $form = new clForm();
     // Date d'exécution.
     $now = new clDate();
     // Récupération des options.
     $retourmax = $options->getOption("Dates Patient");
     $tranches = $options->getOption("DatesDécoup Patient");
     // Récupération de la valeur actuelle du bloc.
     $res = '';
     eval("\$res = \$this->patient->get{$nomBloc} ( ) ;");
     // Si une date a été transmise et qu'elle n'est pas nulle, on initialise $res avec cette valeur.
     if ($date) {
         if ($res != "0000-00-00 00:00:00") {
             $res = $date->getDate("d-m-Y H:i");
         } else {
             $res = '';
         }
     }
     // Si toutes ces conditions sont réunies, alors on fait transiter le patient sorti vers la table des patients présents.
     if ($session->getNavi(3) == "mod" . $nomBloc and ($_POST['AnnulerSortie'] or $_POST['AnnulerSortie_x']) and $session->getDroit($this->type . "_EtatCivil", $droit)) {
         $modif = "0000-00-00 00:00:00";
         $this->patient->setAttribut($nomBloc, $modif);
         $this->patient = new clPatient($this->idpatient, "Sortis");
         $this->patient->entrerPatient();
         if ($options->getOption("Module_CCAM")) {
             $ccam = new clCCAMCotationActesDiags($this->paramCCAM);
             $ccam->deleteBAL();
             if ($options->getOption('HprimXML_Actif')) {
                 $hprimXml = new clHprimXML();
             }
         }
         $res = "";
         // Si ces conditions sont réunies, alors on change la date du champs avec la valeur transmise.
     } elseif ($session->getNavi(3) == "mod" . $nomBloc and ($_POST['Valider'] or $_POST['Valider_x']) and $session->getDroit($this->type . "_EtatCivil", $droit)) {
         if ($date) {
             if ($_POST['ValiderMaintenant'] or $_POST['ValiderMaintenant_x']) {
                 $newdate = new clDate();
             } elseif ($_POST["mod" . $nomBloc] == "now") {
                 $newdate = new clDate();
             } else {
                 $newdate = new clDate($_POST["mod" . $nomBloc]);
             }
             $modif = $newdate->getDatetime();
             $res = $newdate->getDate("d-m-Y H:i");
             // Si le paramètre $sortie est vrai, alors on fait transiter le patient présent vers la table des patients sortis.
             if ($sortie) {
                 $this->patient->setAttribut($nomBloc, $modif);
                 $this->patient = new clPatient($this->idpatient, "Presents");
                 clFoRmX_manip::rangerDossMedChrono($this->patient);
                 clFoRmX_manip::rangerDossMedAEV($this->patient);
                 $this->patient->sortirPatient();
                 if ($options->getOption("Module_CCAM")) {
                     $this->paramCCAM["dtFinInterv"] = $this->patient->getDateSortie();
                     $ccam = new clCCAMCotationActesDiags($this->paramCCAM);
                     $ccam->writeBALSorti();
                     if ($options->getOption('HprimXML_Actif')) {
                         $hprimXml = new clHprimXML();
                     }
                 }
                 $this->rien = "sortie";
             }
             // Dans le dernier cas, il s'agit d'un bloc de type "textarea" tout simple à mettre à jour.
         } else {
             $modif = $_POST["mod" . $nomBloc];
             $res = $modif;
         }
         // Mise à jour du patient.
         $session->setLogSup("Modification du bloc {$nomBloc}");
         $this->patient->setAttribut($nomBloc, $modif);
         $this->patient = new clPatient($this->idpatient, $this->type);
         // Dans ce cas, nous devons afficher le formulaire adéquate à la modification du bloc.
     } elseif ($session->getNavi(3) == "mod" . $nomBloc and !$_POST['Annuler'] and !$_POST['Annuler_x']) {
         // Cas des champs de type date.
         $session->setLogSup("Demande de modification du bloc {$nomBloc}");
         if ($date) {
             if ($sortie and $this->patient->getDateExamen() != '0000-00-00 00:00:00') {
                 $dateMin = new clDate($this->patient->getDateExamen());
             } else {
                 $dateMin = new clDate($this->patient->getDateAdmission());
             }
             $dateNow = new clDate();
             if ($tranches >= 5) {
                 $minutes = $dateNow->getMinutes();
                 $minutesless = $minutes % 5;
                 $dateNow->addMinutes(-$minutesless);
             }
             $data[now] = 'Maintenant';
             $min = $dateMin->getTimestamp();
             $t = $dateNow->getTimestamp();
             $data[$t] = $dateNow->getDate("d-m-Y H:i");
             // On limite la taille du select
             $d1 = new clDate();
             $d2 = new clDate($dateMin->getDatetime());
             $duree = new clDuree($d1->getDifference($d2));
             $duree->invertNegatif();
             //if ( $duree->getDays() > 50 ) {
             //    $d1 -> addDays ( -50 ) ;
             //    $min = $d1 -> getTimestamp ( ) ;
             //}
             // On parcourt les dates en fonctions des options.
             for ($i = 0; $dateNow->getTimestamp() >= $min; $i += $tranches) {
                 $t = $dateNow->getTimestamp();
                 $data[$t] = $dateNow->getDate("d-m-Y H:i");
                 $dateNow->addMinutes(-$tranches);
             }
             $f .= $res . "<br />" . $form->genForm(URL);
             /*
             // Préparation de la première date de la liste.
             $now -> addHours ( -$retourmax ) ;
             $min = $now -> getTimestamp ( ) ;
             $now -> addHours ( $retourmax ) ;
             if ( $tranches >= 5 ) {
             	  		$minutes = $now -> getMinutes ( ) ;
             	  		$minutesless = ( $minutes % 5 ) ;
             	  		$now -> addMinutes ( -$minutesless ) ;
             }
             $data[now] = 'Maintenant' ;
             $t = $now -> getTimestamp ( ) ;
             $data[$t] = $now -> getDate ( "d-m-Y H:i" ) ;
             // On parcourt les dates en fonctions des options.
             for ( $i = 0 ; $now -> getTimestamp ( ) >= $min ; $i += $tranches ) {
             	  		$t = $now -> getTimestamp ( ) ;
             	  		$data[$t] = $now -> getDate ( "d-m-Y H:i" ) ;
             	  		$now -> addMinutes ( -$tranches ) ;
             }
             $f .= $res."<br />".$form -> genForm ( URL ) ;
             */
             // S'il ne s'agit pas de la date de sortie et que le patient est sorti,
             // alors on affiche le select contenant la liste des dates possibles.
             if (!($this->type == "Sortis" and $sortie)) {
                 $f .= $form->genSelect("mod" . $nomBloc, 1, $data);
             }
         } else {
             // Cas d'un formulaire de type "textarea" tout simple.
             $f .= $form->genForm(URL);
             $f .= $form->genTextArea("mod" . $nomBloc, $res) . "<br /><center>";
         }
         // Cas d'une date.
         if ($date) {
             // Cas de la date de sortie.
             if ($sortie) {
                 // Cas d'un patient déjà sorti : On affiche seulement un bouton d'annulation de sortie.
                 if ($this->type == "Sortis") {
                     $f .= $form->genImage("AnnulerSortie", "Annuler la sortie", URLIMG . "annulerSortie.gif");
                     $f .= $form->genHidden("navi", $session->genNavi("Liste_Presents", $session->getNavi(1), $session->getNavi(2), "mod" . $nomBloc));
                     $f .= $form->genEndForm();
                     // $f .= $form -> genForm ( URL ) ;
                     // $f .= $form -> genImage ( "RetourPatient", "Retour du patient", URLIMGRET ) ;
                     // $f .= $form -> genHidden ( "navi", $session->genNavi ( "Liste_Presents", $this->patient->getID ( ) ) ) ;
                     // Dans les autres cas, on affiche les boutons de validation / annulation de la sortie.
                 } else {
                     $contraintes = new clContraintes($this->patient->getID(), $this->paramCCAM);
                     //formulaire(s) à remplir bloquant la sortie ( pré-contraintes ) ?
                     if (clTuFormxTrigger::getWatcher($this->patient)->isTriggersOnOut()) {
                         $enquetes = clTuFormxTriggerWatcher::getInstance($this->patient);
                         $enquetes->launchTriggersOnOut();
                         //eko("trigers lances, sortie de la fenetre bloquante");
                         return '';
                     } else {
                         if (clTuFormxTrigger::getWatcher($this->patient)->isTriggersWaitingForLauch()) {
                             //eko("watchers en cours, sortie de la fenetre bloquante");
                             return '';
                         } else {
                             if ($contraintes->runCheck()) {
                                 $f .= $form->genImage("Valider", "Valider", URLIMGVAL, 'style="border: 0px; background-color: #FFFF99;"');
                                 $f .= $form->genHidden("navi", $session->genNavi($session->getNavi(0), $session->getNavi(1), $session->getNavi(2), "mod" . $nomBloc));
                                 $f .= $form->genEndForm();
                                 $f .= $form->genForm(URL);
                                 $f .= $form->genImage("Annuler", "Annuler", URLIMGANN, 'style="border: 0px; background-color: #FFFF99;"');
                                 $f .= $form->genHidden("navi", $session->genNavi($session->getNavi(0), $session->getNavi(1), $session->getNavi(2), "mod" . $nomBloc));
                             } else {
                                 $session->setLogSup('Contraintes non respectées pour la sortie');
                                 $this->af .= $contraintes->getContraintes();
                             }
                         }
                     }
                 }
                 // Cas d'un champs date normal : affichage des boutons valider et annuler.
             } else {
                 $f .= $form->genImage("Valider", "Valider", URLIMGVAL, 'style="border: 0px; background-color: #FFFF99;"');
                 $f .= $form->genHidden("navi", $session->genNavi($session->getNavi(0), $session->getNavi(1), $session->getNavi(2), "mod" . $nomBloc));
                 $f .= $form->genEndForm();
                 $f .= $form->genForm(URL);
                 $f .= $form->genImage("Annuler", "Annuler", URLIMGANN, 'style="border: 0px; background-color: #FFFF99;"');
                 $f .= $form->genHidden("navi", $session->genNavi($session->getNavi(0), $session->getNavi(1), $session->getNavi(2), "mod" . $nomBloc));
             }
             // Cas d'un champs normal : affichage des boutons valider et annuler.
         } else {
             $f .= $form->genImage("Valider", "Valider", URLIMGVAL, 'style="border: 0px; background-color: #FFFF99;"');
             $f .= $form->genHidden("navi", $session->genNavi($session->getNavi(0), $session->getNavi(1), $session->getNavi(2), "mod" . $nomBloc));
             $f .= $form->genEndForm();
             $f .= $form->genForm(URL);
             $f .= $form->genImage("Annuler", "Annuler", URLIMGANN, 'style="border: 0px; background-color: #FFFF99;"');
             $f .= $form->genHidden("navi", $session->genNavi($session->getNavi(0), $session->getNavi(1), $session->getNavi(2), "mod" . $nomBloc));
         }
         // On ferme la balise du formulaire.
         $f .= "</center>" . $form->genEndForm();
         // On modifie le bloc ModeliXe passé en paramètres.
         $mod->MxText($nomBloc, $f);
         // On signale que le bloc a été modifié.
         $af = 1;
     }
     // S'il n'y a pas eu d'affichage jusqu'à maintenant, il ne s'agit que d'afficher la valeur contenue dans ce bloc.
     if (!$af) {
         // Si le droit de modification est présent, alors nous affichons le lien pour modifier le bloc.
         if ($session->getDroit($this->type . "_EtatCivil", $droit)) {
             if ($date) {
                 $image = URLIMGHOR;
             } else {
                 $image = URLIMGMOD;
             }
             if ($nomBloc == "DateExamen" and $_POST['Medecin'] and $this->patient->getDateExamen() == "0000-00-00 00:00:00" and !$this->patient->getMedecin()) {
                 $date = new clDate();
                 $dateA = new clDate($this->patient->getDateAdmission());
                 if ($date->getTimestamp() > $dateA->getTimestamp()) {
                     $this->patient->setAttribut("DateExamen", $date->getDatetime());
                     $res = $date->getDate("d-m-Y H:i");
                 } else {
                     $dateA->addSeconds(1);
                     $this->patient->setAttribut("DateExamen", $dateA->getDatetime());
                     $res = $dateA->getDate("d-m-Y H:i");
                 }
             }
             if ($nomBloc == "DateExamen" and isset($_POST['Medecin']) and !$_POST['Medecin']) {
                 $this->patient->setAttribut("DateExamen", "0000-00-00 00:00:00");
                 $res = "--";
             }
             if (!$this->export) {
                 if ($nomBloc == "DateSortie") {
                     $retour = '';
                     if ($options->getOption('EnqueteRadio')) {
                         $retour = clListeRadios::getRetour($this->patient->getID(), IDAPPLICATION);
                     }
                     if ($retour) {
                         $mod->MxText("retourRadio", $retour);
                     } else {
                         $questionSortie = $this->getQuestionSortie();
                         if ($questionSortie) {
                             $mod->MxText("retourRadio", $questionSortie);
                         } else {
                             $mod->MxImage("imgModifier" . $nomBloc, $image, "Modifier {$nomBloc}");
                             $mod->MxUrl("lien" . $nomBloc, URLNAVI . $session->genNavi($session->getNavi(0), $session->getNavi(1), $session->getNavi(2), "mod" . $nomBloc));
                         }
                     }
                 } else {
                     $mod->MxImage("imgModifier" . $nomBloc, $image, "Modifier {$nomBloc}");
                     $mod->MxUrl("lien" . $nomBloc, URLNAVI . $session->genNavi($session->getNavi(0), $session->getNavi(1), $session->getNavi(2), "mod" . $nomBloc));
                 }
             }
         }
         // Affichage du contenu du bloc s'il existe sinon on affiche la valeur par défaut.
         if ($res) {
             $mod->MxText($nomBloc, nl2br($res));
         } else {
             $mod->MxText($nomBloc, VIDEDEFAUT);
         }
     }
 }