/**
  * Mise  àjour d une fiche
  * @param $id the ID of the model to be displayed
  */
 public function actionUpdate($id)
 {
     $model = Questionnaire::model()->findByPk(new MongoID($id));
     $questionForm = new QuestionForm();
     $questionGroup = new QuestionGroup();
     // collect user input data
     if (isset($_POST['QuestionForm'])) {
         $questionForm->attributes = $_POST['QuestionForm'];
         //traitement ajout de question
         if ($questionForm->validate()) {
             $model = $this->saveQuestionnaireNewQuestion($model, $questionForm);
         }
     }
     if (isset($_POST['QuestionGroup'])) {
         $questionGroup->attributes = $_POST['QuestionGroup'];
         //copie du titre sur l option fr
         $questionGroup->title_fr = $questionGroup->title;
         if ($questionGroup->validate()) {
             $model = $this->saveQuestionnaireNewGroup($model, $questionGroup);
         }
     }
     //set du model sur la questionForm pour generer l arborescende de position de question
     $questionForm->questionnaire = $model;
     $this->render('update', array('model' => $model, 'questionForm' => $questionForm, 'questionGroup' => $questionGroup));
 }
 /**
  * testing method return array type
  */
 public function testTypeFunction()
 {
     $model = new QuestionBlocForm();
     $criteria = new EMongoCriteria();
     $criteria->id = "demenceform";
     $questionnaire = Questionnaire::model()->find($criteria);
     $this->assertInternalType('array', $model->rules());
     $this->assertInternalType('array', $model->attributeLabels());
     $this->assertFalse($model->validatewithId($questionnaire));
 }
Esempio n. 3
0
<?php

Yii::app()->clientScript->registerScript('formulaire_view', "\n\$(document).ready(function() {\n    var inputs = document.getElementsByTagName('input');\n    var textareas = document.getElementsByTagName('textarea');\n    var selectlist = document.getElementsByTagName('select');\n    var len_inputs = inputs.length;\n    var len_textareas = textareas.length;\n    var len_selectlist = selectlist.length;\n\n    for (var i = 0; i < len_inputs; i++) {\n        inputs[i].disabled = true;\n    }\n    for (var i = 0; i < len_textareas; i++) {\n        textareas[i].disabled = true;\n    }\n    for (var i = 0; i < len_selectlist; i++) {\n        selectlist[i].disabled = true;\n    }\n});\n");
?>

<h3 align="center"><?php 
echo Yii::t('common', 'form') . $model->name;
?>
</h3>
<p><b>Description: </b><?php 
echo $model->description;
?>
</p>
<?php 
if ($model->last_modified != null && $model->last_modified != "") {
    $q = Questionnaire::model()->findByPk(new MongoId($_GET['id']));
    echo "<p><b>" . Yii::t('common', 'lastModifiedDate') . ": </b>" . date('d/m/Y', strtotime($q->last_modified['date'])) . "</p>";
}
?>
<p><b><?php 
echo Yii::t('common', 'createdBy');
?>
: </b><?php 
echo $model->creator;
?>
</p>
<hr />

<?php 
echo CHtml::errorSummary($model, null, null, array('class' => 'alert alert-error'));
?>
Esempio n. 4
0
 public function init()
 {
     parent::init();
     $app = Yii::app();
     if (isset($_GET['lang'])) {
         $app->language = $_GET['lang'];
         $app->session['_lang'] = $app->language;
     } elseif (isset($app->session['_lang'])) {
         $app->language = $app->session['_lang'];
     }
     if (isset($_GET['id']) && Yii::app()->controller->id == "questionnaire") {
         $criteria = new EMongoCriteria();
         $ficheQuestion = Questionnaire::model()->findByPk(new MongoId($_GET['id']));
         $_SESSION['idQuestion'] = $ficheQuestion;
         if (isset($_SESSION['activeProfil'])) {
             if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "questionnaire/update") {
                 if ($_SESSION['idQuestion']->type == "clinique") {
                     if (!Yii::app()->user->isAuthorizedCreate($_SESSION['activeProfil'], "clinique")) {
                         Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowCreateClinicalPatientForm'));
                         $this->redirect(array('answer/affichepatient'));
                     }
                 }
                 if ($_SESSION['idQuestion']->type == "genetique") {
                     if (!Yii::app()->user->isAuthorizedCreate($_SESSION['activeProfil'], "genetique")) {
                         Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowCreateGeneticPatientForm'));
                         $this->redirect(array('answer/affichepatient'));
                     }
                 }
                 if ($_SESSION['idQuestion']->type == "neuropathologique") {
                     if (!Yii::app()->user->isAuthorizedCreate($_SESSION['activeProfil'], "neuropathologique")) {
                         Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowCreateNeuropathologicalPatientForm'));
                         $this->redirect(array('answer/affichepatient'));
                     }
                 }
             }
         }
     }
     if (isset($_GET['id']) && Yii::app()->controller->id == "answer") {
         $criteria = new EMongoCriteria();
         $fiche = Answer::model()->findByPk(new MongoId($_GET['id']));
         $_SESSION['id'] = $fiche;
         if (isset($_SESSION['activeProfil'])) {
             if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/view" || Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/update") {
                 if ($_SESSION['id']->type == "clinique") {
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/view") {
                         if (!Yii::app()->user->isAuthorizedView($_SESSION['activeProfil'], "clinique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowViewClinicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         } elseif ($_SESSION['activeProfil'] == "clinicien" && Yii::app()->user->id != $_SESSION['id']->login) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowViewSelfClinicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         }
                     }
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/update") {
                         if (!Yii::app()->user->isAuthorizedUpdate($_SESSION['activeProfil'], "clinique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowUpdateClinicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         }
                     }
                 }
                 if ($_SESSION['id']->type == "neuropathologique") {
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/view") {
                         if (!Yii::app()->user->isAuthorizedView($_SESSION['activeProfil'], "neuropathologique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowViewNeuropathologicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         }
                     }
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/update") {
                         if (!Yii::app()->user->isAuthorizedUpdate($_SESSION['activeProfil'], "neuropathologique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowUpdateNeuropathologicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         }
                     }
                 }
                 if ($_SESSION['id']->type == "genetique") {
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/view") {
                         if (!Yii::app()->user->isAuthorizedView($_SESSION['activeProfil'], "genetique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowViewGeneticPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         }
                     }
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/update") {
                         if (!Yii::app()->user->isAuthorizedUpdate($_SESSION['activeProfil'], "genetique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowUpdateGeneticPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         }
                     }
                 }
             }
         }
     }
     if (isset($_POST['activeProfil'])) {
         if ($_POST['activeProfil'] === "newProfil") {
             $this->redirect('index.php?r=site/updatesubscribe');
         } else {
             $app->user->setState('activeProfil', $_POST['activeProfil']);
             $_SESSION['activeProfil'] = $_POST['activeProfil'];
             if (Yii::app()->controller->id == "rechercheFiche" && Yii::app()->user->getActiveProfil() == "clinicien") {
                 Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowSearchPatientForm'));
                 $this->redirect('index.php?r=site/index');
             }
             if (Yii::app()->controller->id == "user" || Yii::app()->controller->id == "formulaire" || Yii::app()->controller->id == "fiche" || Yii::app()->controller->id == "questionBloc" || Yii::app()->controller->id == "administration" || Yii::app()->controller->id == "auditTrail" || Yii::app()->urlManager->parseUrl(Yii::app()->request) == "admin/admin") {
                 if (Yii::app()->user->getActiveProfil() != "administrateur") {
                     Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowManagement'));
                     $this->redirect('index.php?r=site/index');
                 }
             }
             if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/view" || Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/update") {
                 if ($_SESSION['id']->type == "clinique") {
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/view") {
                         if (!Yii::app()->user->isAuthorizedView($_SESSION['activeProfil'], "clinique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowViewClinicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         } elseif ($_SESSION['activeProfil'] == "clinicien" && Yii::app()->user->id != $_SESSION['id']->login) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowViewSelfClinicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         }
                         $this->redirect('index.php?r=answer/view&id=' . $_SESSION['id']->_id);
                     }
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/update") {
                         if (!Yii::app()->user->isAuthorizedUpdate($_SESSION['activeProfil'], "clinique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowUpdateClinicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         } else {
                             $this->redirect('index.php?r=answer/update&id=' . $_SESSION['id']->_id);
                         }
                     }
                 }
                 if ($_SESSION['id']->type == "neuropathologique") {
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/view") {
                         if (!Yii::app()->user->isAuthorizedView($_SESSION['activeProfil'], "neuropathologique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowViewNeuropathologicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         } else {
                             $this->redirect('index.php?r=answer/view&id=' . $_SESSION['id']->_id);
                         }
                     }
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/update") {
                         if (!Yii::app()->user->isAuthorizedUpdate($_SESSION['activeProfil'], "neuropathologique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowUpdateNeuropathologicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         } else {
                             $this->redirect('index.php?r=answer/update&id=' . $_SESSION['id']->_id);
                         }
                     }
                 }
                 if ($_SESSION['id']->type == "genetique") {
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/view") {
                         if (!Yii::app()->user->isAuthorizedView($_SESSION['activeProfil'], "genetique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowViewGeneticPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         } else {
                             $this->redirect('index.php?r=answer/view&id=' . $_SESSION['id']->_id);
                         }
                     }
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "answer/update") {
                         if (!Yii::app()->user->isAuthorizedUpdate($_SESSION['activeProfil'], "genetique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowUpdateGeneticPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         } else {
                             $this->redirect('index.php?r=answer/update&id=' . $_SESSION['id']->_id);
                         }
                     }
                 }
             }
             if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "questionnaire/update") {
                 if ($_SESSION['idQuestion']->type == "clinique") {
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "questionnaire/update") {
                         if (!Yii::app()->user->isAuthorizedCreate($_SESSION['activeProfil'], "clinique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowCreateClinicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         } else {
                             $this->redirect('index.php?r=questionnaire/update&id=' . $_SESSION['idQuestion']->_id);
                         }
                     }
                 }
                 if ($_SESSION['idQuestion']->type == "neuropathologique") {
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "questionnaire/update") {
                         if (!Yii::app()->user->isAuthorizedCreate($_SESSION['activeProfil'], "neuropathologique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowCreateNeuropathologicalPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         } else {
                             $this->redirect('index.php?r=questionnaire/update&id=' . $_SESSION['idQuestion']->_id);
                         }
                     }
                 }
                 if ($_SESSION['idQuestion']->type == "genetique") {
                     if (Yii::app()->urlManager->parseUrl(Yii::app()->request) == "questionnaire/update") {
                         if (!Yii::app()->user->isAuthorizedCreate($_SESSION['activeProfil'], "genetique")) {
                             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'notAllowCreateGeneticPatientForm'));
                             $this->redirect(array('answer/affichepatient'));
                         } else {
                             $this->redirect('index.php?r=questionnaire/update&id=' . $_SESSION['idQuestion']->_id);
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 5
0
<div class="wide form">

    <?php 
$form = $this->beginWidget('CActiveForm', array('action' => Yii::app()->createUrl($this->route), 'method' => 'get'));
?>

    <div class="row">
        <div class="col-lg-6">
            <?php 
echo $form->label($model, 'name');
?>
            <?php 
echo $form->dropDownList($model, 'name', Questionnaire::model()->getNomsFiches(), array('prompt' => '----', "multiple" => "multiple"));
?>
        </div>
    </div>

    <div class="row buttons">
        <div class="col-lg-6">
            <?php 
echo CHtml::submitButton(Yii::t('common', 'search'), array('name' => 'rechercher', 'class' => 'btn btn-default', 'style' => 'margin-top: 8px; padding-bottom: 23px;'));
?>
            <?php 
echo CHtml::resetButton(Yii::t('common', 'reset'), array('class' => 'btn btn-default', 'style' => 'margin-top: 8px; padding-bottom: 23px;'));
?>
        </div>
    </div>

    <?php 
$this->endWidget();
?>
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Questionnaire the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Questionnaire::model()->findByPk(new MongoID($id));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 7
0
 public function actionPushQuestionnaireEnd()
 {
     $student_id = Yii::app()->request->getPost("student_id", NULL);
     $session_id = Yii::app()->request->getPost("session_id", NULL);
     /*
     	next session
     */
     $session = Session::model()->find('session_id=:session_id', array(':session_id' => $session_id));
     $mod_id = $session->mod_id;
     $next_order = $session->session_order + 1;
     $next_session = Session::model()->find('mod_id=:mod_id AND session_order=:session_order', array(':mod_id' => $mod_id, ':session_order' => $next_order));
     $current = Current::model()->find('student_id=:student_id', array(':student_id' => $student_id));
     //error_log(print_r($current,1));
     //error_log("\n");
     //error_log(print_r($next_session,1));
     if ($this->getMaxOrder($student_id) < $next_order) {
     }
     if ($current && $next_session) {
         $session_listening = SessionListening::model()->find('session_id=:session_id', array('session_id' => $next_session->session_id));
         $current->session_id = $next_session->session_id;
         if ($current->save()) {
             $current->listening_id = $session_listening->listening_id;
             $current->save();
         }
     }
     $end_questionnaire_answer = Yii::app()->request->getPost("end_questionnaire_answer", NULL);
     $questionnaire = Questionnaire::model()->find('student_id=:student_id AND session_id=:session_id', array(':student_id' => $student_id, ':session_id' => $session_id));
     if ($questionnaire) {
         $questionnaire->end_questionnaire_answer = $end_questionnaire_answer;
         if (!$questionnaire->save()) {
             $this->renderJSON($questionnaire->getErrors());
         } else {
             $this->renderJSON(array('status' => 1, 'message' => 'Successfully saved!'));
         }
     } else {
         $this->renderJSON(array('status' => 0, 'message' => 'Given Questionnaire could not be found!'));
     }
 }
 /**
  * action pour afficher dynamiquement la liste de questions dans le formulaire
  * d ajout de question pour gerer le positionnement
  * @param id is questionnaire id
  */
 public function actionDynamicquestions($id)
 {
     Yii::log("dynamic question", CLogger::LEVEL_TRACE);
     $questionForm = new QuestionForm();
     $questionForm->attributes = $_POST['QuestionForm'];
     $questionnaire = Questionnaire::model()->findByPk(new MongoID($id));
     $data = $questionnaire->getArrayQuestions($questionForm->idQuestionGroup);
     Yii::log("count questions:" . count($data), CLogger::LEVEL_TRACE);
     //add the empty option si l on veut mettre la question au debut
     echo CHtml::tag('option', array('value' => ''), CHtml::encode("----"), true);
     foreach ($data as $value => $name) {
         echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
     }
 }
?>

<?php 
if (Yii::app()->user->getState('activeProfil') != "chercheur" && Yii::app()->user->getState('activeProfil') != "administrateur") {
    $form = $this->beginWidget('CActiveForm', array('action' => Yii::app()->createUrl('questionnaire/index'), 'enableAjaxValidation' => false));
    ?>

    <div class="row" id="liste_fiche">
        <div class="span3">
            <p><?php 
    echo Yii::t('common', 'insertPatientForm');
    ?>
 : </p>
        </div>
        <div class="span3" style="margin:-5px;">
            <?php 
    echo CHtml::dropDownList('form', '', Questionnaire::model()->getFiche(Yii::app()->user->getActiveProfil(), $neuropath, $genetique), array('prompt' => '---' . Yii::t('common', 'choosePatientForm') . '---'));
    ?>
        </div>

        <div class="span3" style="margin:-5px;">
            <?php 
    echo CHtml::submitButton(Yii::t('common', 'insert'), array('class' => 'btn btn-default'));
    ?>
        </div>
        <?php 
    $this->endWidget();
    ?>
    </div>
    <?php 
}
Esempio n. 10
0
?>

    <p class="note"><?php 
echo Yii::t('common', 'requiredField');
?>
</p>

    <?php 
echo $form->errorSummary($model, null, null, array('class' => 'alert alert-error'));
?>
    <div class="row">
        <?php 
echo $form->labelEx($model, 'type');
?>
        <?php 
echo $form->dropDownList($model, 'type', Questionnaire::model()->getArrayTypeSorted(), array('prompt' => '---' . Yii::t('common', 'formType') . '---'));
?>
        <?php 
echo $form->error($model, 'type');
?>
    </div>
    <div class="row">
        <p><?php 
echo Yii::t('common', 'uniqueIdForm');
?>
</p>
        <?php 
echo $form->labelEx($model, 'id');
?>
        <?php 
echo $form->textField($model, 'id', array('size' => 5, 'maxlength' => 45));
Esempio n. 11
0
            <?php 
echo $form->label($model, 'user');
?>
            <?php 
echo $form->dropDownList($model, 'user', Answer::model()->getNamesUsers(), array("multiple" => "multiple"));
?>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-6">
            <?php 
echo $form->label($model, 'type');
?>
            <?php 
echo $form->dropDownList($model, 'type', Questionnaire::model()->getArrayType(), array("multiple" => "multiple"));
?>
        </div>

        <div class="col-lg-6">
            <?php 
echo $form->label($model, 'name');
?>
            <?php 
echo $form->dropDownList($model, 'name', Answer::model()->getNomsFiches(), array("multiple" => "multiple"));
?>
        </div>
    </div>

    <div class ="row">
        <div class="col-lg-6">
Esempio n. 12
0
 protected function getSessionQuestionnaire($session_id)
 {
     $questionnaire = Questionnaire::model()->find('session_id=:session_id', array('session_id' => $session_id));
     if ($questionnaire) {
         return "<strong>Başlangıç:</strong>" . $questionnaire->begin_questionnaire_answer . " - " . $questionnaire->end_questionnaire_answer;
     }
     return "<strong>Henüz anket girişi yapılmadı!</strong>";
 }
 public function actionAffichepatient()
 {
     $model = new PatientForm();
     $patient = (object) null;
     if (isset($_SESSION['datapatient'])) {
         $patient = $_SESSION['datapatient'];
         $model->copyPatient($patient);
     }
     if (isset($_POST['PatientForm'])) {
         $actionForm = $_POST['PatientForm']['action'];
         $model = new PatientForm();
         $model->attributes = $_POST['PatientForm'];
         if ($_POST['PatientForm']['prenom'] == "" || $_POST['PatientForm']['nom_naissance'] == "" || $_POST['PatientForm']['date_naissance'] == "") {
             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'missingFields'));
             $this->redirect(array('site/patient'));
         }
         if ($model->dateFormat($model->date_naissance) == false) {
             Yii::app()->user->setFlash('error', Yii::t('common', 'unvalidDate'));
             $this->redirect(array('site/patient'));
         }
         $patient->id = null;
         $patient->source = null;
         //à identifier en fonction de l'app
         $patient->sourceId = null;
         $patient->birthName = $model->nom_naissance;
         if ($model->nom != "") {
             $patient->useName = $model->nom;
         } else {
             $patient->useName = null;
         }
         $patient->firstName = $model->prenom;
         $patient->birthDate = $model->date_naissance;
         if ($model->sexe != "") {
             $patient->sex = $model->sexe;
         } else {
             $patient->sex = null;
         }
         if ($actionForm == 'create') {
             $patient->source = $model->source == "1" ? "1" : "2";
             $patientest = CommonTools::wsGetPatient($patient);
             if ($patientest == 'NoPatient') {
                 $patient = CommonTools::wsAddPatient($patient);
             } else {
                 $patient = $patientTest;
             }
         } else {
             $patient = CommonTools::wsGetPatient($patient);
         }
     }
     switch ($patient) {
         case "NoPatient":
             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'noPatient'));
             Yii::app()->user->setState('patientModel', $model);
             $model->scenario = 'create';
             $this->render('patient_bis', array('model' => $model, 'actionForm' => 'create'));
             exit;
             break;
         case "PatientNotSaved":
             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'patientNotSaved'));
             Yii::app()->user->setState('patientModel', $model);
             $model->scenario = 'create';
             $this->render('patient_bis', array('model' => $model, 'actionForm' => 'create'));
             exit;
             break;
         case "ManyPatient":
             Yii::app()->user->setFlash(TbAlert::TYPE_ERROR, Yii::t('common', 'manyPatient'));
             Yii::app()->user->setState('patientModel', $model);
             $this->render('patient_bis', array('model' => $model, 'actionForm' => 'search'));
             exit;
             break;
         default:
     }
     if ($model->validate() && isset($patient->id)) {
         $model->id = $patient->id;
         $criteria = new EMongoCriteria();
         $criteria->id_patient = (string) $model->id;
         $criteriaCliniques = new EMongoCriteria($criteria);
         if (Yii::app()->user->getState('activeProfil') == "clinicien") {
             $criteriaCliniques->login = Yii::app()->user->id;
         }
         $criteriaCliniques->type = "clinique";
         $criteriaNeuropathologiques = new EMongoCriteria($criteria);
         $criteriaNeuropathologiques->type = "neuropathologique";
         $neuropath = Answer::model()->findAll($criteriaNeuropathologiques);
         $criteriaGenetiques = new EMongoCriteria($criteria);
         $criteriaGenetiques->type = "genetique";
         $genetique = Answer::model()->findAll($criteriaGenetiques);
         $dataProviderCliniques = new EMongoDocumentDataProvider('Answer');
         $dataProviderCliniques->setId('dpCli');
         $dataProviderNeuropathologiques = new EMongoDocumentDataProvider('Answer');
         $dataProviderCliniques->setId('dpNeuPa');
         $dataProviderGenetiques = new EMongoDocumentDataProvider('Answer');
         $dataProviderCliniques->setId('dpGen');
         $dataProviderCliniques->setCriteria($criteriaCliniques);
         $dataProviderNeuropathologiques->setCriteria($criteriaNeuropathologiques);
         $dataProviderGenetiques->setCriteria($criteriaGenetiques);
         $questionnaire = Questionnaire::model()->findAll();
         $_SESSION['datapatient'] = $patient;
         if (isset($_SESSION['datapatient'])) {
             $this->render('affichepatient', array('model' => $model, 'dataProviderCliniques' => $dataProviderCliniques, 'dataProviderNeuropathologiques' => $dataProviderNeuropathologiques, 'dataProviderGenetiques' => $dataProviderGenetiques, 'questionnaire' => $questionnaire, 'patient' => $patient, 'neuropath' => $neuropath, 'genetique' => $genetique));
         } elseif (isset($_POST['PatientForm'])) {
             $this->render('affichepatient', array('model' => $model, 'dataProviderCliniques' => $dataProviderCliniques, 'dataProviderNeuropathologiques' => $dataProviderNeuropathologiques, 'dataProviderGenetiques' => $dataProviderGenetiques, 'patient' => $patient));
         } else {
             $this->redirect(array('site/patient'));
         }
     } else {
         $this->redirect(array('site/patient'));
     }
 }
Esempio n. 14
0
 public function getFormsByName($nameForm)
 {
     $criteria = new EMongoCriteria();
     $criteria->name = $nameForm;
     $form = Questionnaire::model()->findAll($criteria);
     return $form;
 }