public function actionAllocDoctorCase()
 {
     $this->authenUser();
     $formAllocDoctorCase = new formAllocDoctorCase();
     if (isset($_REQUEST['caseId'])) {
         $caseId = $_REQUEST['caseId'];
         if (!is_numeric($caseId)) {
             $this->redirect($statusCode = 404);
         } else {
             if (isset($_POST['formAllocDoctorCase'])) {
                 $doctorId = $_POST['formAllocDoctorCase']['doctors'];
                 echo $doctorId;
                 // Yii::app ()->end();
                 $criteria = new CDbCriteria();
                 $criteria->condition = "doctor_did=" . $doctorId . " AND hms_patient_case_cid=" . $caseId;
                 if (DoctorHasHmsPatient::model()->find($criteria) == null) {
                     $addDoctAllocPat = new DoctorHasHmsPatient();
                     $addDoctAllocPat->doctor_did = $doctorId;
                     $addDoctAllocPat->appointment_date = $_POST['formAllocDoctorCase']['appointment_date'];
                     $addDoctAllocPat->hms_patient_case_cid = $caseId;
                     $addDoctAllocPat->save();
                     $this->redirect(array('manage/selectPatient'));
                 } else {
                     Yii::app()->end();
                 }
             }
         }
     }
     $getDoctorsAndSpeciality = $this->getDoctorAndSpeciality();
     $this->render('allocDoctorCase', array('formAllocDoctorCase' => $formAllocDoctorCase, 'doctorAndSpeciality' => $getDoctorsAndSpeciality));
 }
 public function actionView()
 {
     $this->authenUser();
     $caseId = null;
     $patientId = null;
     $caseData = null;
     $patientData = null;
     $caseResponses = null;
     $caseMedData = NULL;
     if (isset($_REQUEST['caseId'])) {
         $caseId = $_REQUEST['caseId'];
         if (!is_numeric($caseId)) {
             $this->redirect($statusCode = 404);
         }
         // invalid request redirected to 404 not found page
     }
     if (isset($_REQUEST['patientId'])) {
         $patientId = $_REQUEST['patientId'];
         if (!is_numeric($patientId)) {
             $this->redirect($statusCode = 404);
         }
         // invalid request redirected to 404 not found page
     }
     if ($patientId != NULL) {
         $patientData = Patient::model()->find('pid=?', array($patientId));
     }
     if ($caseId != Null) {
         $caseData = PatientCase::model()->find('cid=?', array($caseId));
         $criteria = new CDbCriteria();
         $criteria->condition = "doctor_did=" . $this->userId . " AND hms_patient_case_cid=" . $caseId;
         if (DoctorHasHmsPatient::model()->find($criteria) == null) {
             $this->redirect($statusCode = 404);
         }
         // invalid request redirected to 404 not found page
         $dbConnection = Yii::app()->db;
         $command = $dbConnection->createCommand("SELECT id,response,name,rec_date  FROM hms_patient_case_doc_responses , hms_doctor WHERE \n                    hms_patient_case_cid=" . $caseId . " \n                    AND hms_doctor_did=did ORDER BY rec_date DESC ");
         $caseResponses = $command->queryAll();
         $caseMedData = PatientCaseMed::model()->findAll('patient_case_cid=?', array($caseId));
     }
     $formAddCaseResponse = new formAddCaseResponse();
     $this->render('view', array('patientData' => $patientData, 'caseData' => $caseData, 'caseResponses' => $caseResponses, 'caseMedData' => $caseMedData, 'formAddCaseResponse' => $formAddCaseResponse));
 }