/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     LoginForm::checkLogin();
     $this->pageTitle = "Create Maternal Health Record";
     if (!Patient::model()->findByPk($id)) {
         Alert::alertMessage('danger', 'Patient does not exist.');
         Yii::app()->getController()->redirect(array('patient/index'));
     }
     if (MaternalHealth::model()->findByAttributes(array('patient_id' => $id))) {
         Alert::alertMessage('danger', 'Maternal Health Record for this patient already exists.');
         Yii::app()->getController()->redirect(array('patient/view', 'id' => $id));
     }
     $model = new MaternalHealth();
     $patient_model = Patient::model()->findByPk($id);
     $model->patient_id = $patient_model->id;
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['MaternalHealth'])) {
         $model->attributes = $_POST['MaternalHealth'];
         if (isset($_POST['MaternalHealth']['checklist']) && $_POST['MaternalHealth']['checklist'] !== "") {
             $model->checklist = implode(';', $_POST['MaternalHealth']['checklist']);
         }
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     if (isset($model->checklist) && $model->checklist !== '') {
         $model->checklist = explode(';', $model->checklist);
     }
     $this->render('create', array('model' => $model, 'patient_model' => $patient_model));
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     LoginForm::checkLogin();
     $this->pageTitle = "Update Patient";
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['Patient'])) {
         $model->attributes = $_POST['Patient'];
         if ($model->save()) {
             Alert::alertMessage('success', 'Patient record updated successfully.');
         }
     }
     $this->render('update', array('model' => $model));
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     LoginForm::checkAdminOrSelf($id);
     $this->pageTitle = "Update User";
     $model = $this->loadModel($id);
     $this->performAjaxValidation($model);
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         if ($model->save()) {
             $model->password = LoginForm::encrypt($model->password);
             $model->password_repeat = $model->password;
             $model->save();
             Alert::alertMessage('success', 'Account updated successfully.');
         }
     }
     $this->render('update', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     LoginForm::checkLogin();
     $this->pageTitle = "Create NTP Treatment Card";
     if (!Patient::model()->findByPk($id)) {
         Alert::alertMessage('danger', 'Patient does not exist.');
         Yii::app()->getController()->redirect(array('patient/index'));
     }
     $model = new NtpTreatmentCard();
     $patient_model = Patient::model()->findByPk($id);
     $model->patient_id = $patient_model->id;
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['NtpTreatmentCard'])) {
         $model->attributes = $_POST['NtpTreatmentCard'];
         if (isset($_POST['NtpTreatmentCard']['type_of_patient']) && $_POST['NtpTreatmentCard']['type_of_patient'] !== "") {
             $model->type_of_patient = implode(';', $_POST['NtpTreatmentCard']['type_of_patient']);
         }
         if (isset($_POST['NtpTreatmentCard']['category_1']) && $_POST['NtpTreatmentCard']['category_1'] !== "") {
             $model->category_1 = implode(';', $_POST['NtpTreatmentCard']['category_1']);
         }
         if (isset($_POST['NtpTreatmentCard']['category_2']) && $_POST['NtpTreatmentCard']['category_2'] !== "") {
             $model->category_2 = implode(';', $_POST['NtpTreatmentCard']['category_2']);
         }
         if (isset($_POST['NtpTreatmentCard']['category_3']) && $_POST['NtpTreatmentCard']['category_3'] !== "") {
             $model->category_3 = implode(';', $_POST['NtpTreatmentCard']['category_3']);
         }
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     if (isset($model->type_of_patient) && $model->type_of_patient !== '') {
         $model->type_of_patient = explode(';', $model->type_of_patient);
     }
     if (isset($model->category_1) && $model->category_1 !== '') {
         $model->category_1 = explode(';', $model->category_1);
     }
     if (isset($model->category_2) && $model->category_2 !== '') {
         $model->category_2 = explode(';', $model->category_2);
     }
     if (isset($model->category_3) && $model->category_3 !== '') {
         $model->category_3 = explode(';', $model->category_3);
     }
     $this->render('create', array('model' => $model, 'patient_model' => $patient_model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     LoginForm::checkLogin();
     $this->pageTitle = "Create NTP Laboratory Request";
     if (!Patient::model()->findByPk($id)) {
         Alert::alertMessage('danger', 'Patient does not exist.');
         Yii::app()->getController()->redirect(array('patient/index'));
     }
     $model = new NtpLaboratoryRequest();
     $patient_model = Patient::model()->findByPk($id);
     $model->patient_id = $patient_model->id;
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['NtpLaboratoryRequest'])) {
         $model->attributes = $_POST['NtpLaboratoryRequest'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'patient_model' => $patient_model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     LoginForm::checkLogin();
     $this->pageTitle = "Create Family Planning Service Record";
     if (!Patient::model()->findByPk($id)) {
         Alert::alertMessage('danger', 'Patient does not exist.');
         Yii::app()->getController()->redirect(array('patient/index'));
     }
     if (FamilyPlanningService::model()->findByAttributes(array('patient_id' => $id))) {
         Alert::alertMessage('danger', 'Family Planning Service Record for this patient already exists.');
         Yii::app()->getController()->redirect(array('patient/view', 'id' => $id));
     }
     $model = new FamilyPlanningService();
     $medical_history_model = new MedicalHistory();
     $obstetrical_history_model = new ObstetricalHistory();
     $physical_examination_model = new PhysicalExamination();
     $pelvic_examination_model = new PelvicExamination();
     $patient_model = Patient::model()->findByPk($id);
     $model->patient_id = $patient_model->id;
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['FamilyPlanningService'])) {
         $model->attributes = $_POST['FamilyPlanningService'];
         if (isset($_POST['FamilyPlanningService']['method_accepted']) && $_POST['FamilyPlanningService']['method_accepted'] !== "") {
             $model->method_accepted = implode(';', $_POST['FamilyPlanningService']['method_accepted']);
         }
         if ($model->save()) {
             $medical_history_model->family_planning_service_id = $model->id;
             $obstetrical_history_model->family_planning_service_id = $model->id;
             $physical_examination_model->family_planning_service_id = $model->id;
             $pelvic_examination_model->family_planning_service_id = $model->id;
             if (isset($_POST['MedicalHistory'])) {
                 $medical_history_model->attributes = $_POST['MedicalHistory'];
                 if (isset($_POST['MedicalHistory']['heent']) && $_POST['MedicalHistory']['heent'] !== "") {
                     $medical_history_model->heent = implode(';', $_POST['MedicalHistory']['heent']);
                 }
                 if (isset($_POST['MedicalHistory']['chest_heart']) && $_POST['MedicalHistory']['chest_heart'] !== "") {
                     $medical_history_model->chest_heart = implode(';', $_POST['MedicalHistory']['chest_heart']);
                 }
                 if (isset($_POST['MedicalHistory']['abdomen']) && $_POST['MedicalHistory']['abdomen'] !== "") {
                     $medical_history_model->abdomen = implode(';', $_POST['MedicalHistory']['abdomen']);
                 }
                 if (isset($_POST['MedicalHistory']['genital']) && $_POST['MedicalHistory']['genital'] !== "") {
                     $medical_history_model->genital = implode(';', $_POST['MedicalHistory']['genital']);
                 }
                 if (isset($_POST['MedicalHistory']['extremities']) && $_POST['MedicalHistory']['extremities'] !== "") {
                     $medical_history_model->extremities = implode(';', $_POST['MedicalHistory']['extremities']);
                 }
                 if (isset($_POST['MedicalHistory']['skin']) && $_POST['MedicalHistory']['skin'] !== "") {
                     $medical_history_model->skin = implode(';', $_POST['MedicalHistory']['skin']);
                 }
                 if (isset($_POST['MedicalHistory']['other_history']) && $_POST['MedicalHistory']['other_history'] !== "") {
                     $medical_history_model->other_history = implode(';', $_POST['MedicalHistory']['other_history']);
                 }
             }
             if (isset($_POST['ObstetricalHistory'])) {
                 $obstetrical_history_model->attributes = $_POST['ObstetricalHistory'];
                 if (isset($_POST['ObstetricalHistory']['other_history']) && $_POST['ObstetricalHistory']['other_history'] !== "") {
                     $obstetrical_history_model->other_history = implode(';', $_POST['ObstetricalHistory']['other_history']);
                 }
             }
             if (isset($_POST['PhysicalExamination'])) {
                 $physical_examination_model->attributes = $_POST['PhysicalExamination'];
                 if (isset($_POST['PhysicalExamination']['conjunctiva']) && $_POST['PhysicalExamination']['conjunctiva'] !== "") {
                     $physical_examination_model->conjunctiva = implode(';', $_POST['PhysicalExamination']['conjunctiva']);
                 }
                 if (isset($_POST['PhysicalExamination']['neck']) && $_POST['PhysicalExamination']['neck'] !== "") {
                     $physical_examination_model->neck = implode(';', $_POST['PhysicalExamination']['neck']);
                 }
                 if (isset($_POST['PhysicalExamination']['breast']) && $_POST['PhysicalExamination']['breast'] !== "") {
                     $physical_examination_model->breast = implode(';', $_POST['PhysicalExamination']['breast']);
                 }
                 if (isset($_POST['PhysicalExamination']['thorax']) && $_POST['PhysicalExamination']['thorax'] !== "") {
                     $physical_examination_model->thorax = implode(';', $_POST['PhysicalExamination']['thorax']);
                 }
                 if (isset($_POST['PhysicalExamination']['abdomen']) && $_POST['PhysicalExamination']['abdomen'] !== "") {
                     $physical_examination_model->abdomen = implode(';', $_POST['PhysicalExamination']['abdomen']);
                 }
                 if (isset($_POST['PhysicalExamination']['extremities']) && $_POST['PhysicalExamination']['extremities'] !== "") {
                     $physical_examination_model->extremities = implode(';', $_POST['PhysicalExamination']['extremities']);
                 }
             }
             if (isset($_POST['PelvicExamination'])) {
                 $pelvic_examination_model->attributes = $_POST['PelvicExamination'];
                 if (isset($_POST['PelvicExamination']['perenium']) && $_POST['PelvicExamination']['perenium'] !== "") {
                     $pelvic_examination_model->perenium = implode(';', $_POST['PelvicExamination']['perenium']);
                 }
                 if (isset($_POST['PelvicExamination']['v****a']) && $_POST['PelvicExamination']['v****a'] !== "") {
                     $pelvic_examination_model->v****a = implode(';', $_POST['PelvicExamination']['v****a']);
                 }
                 if (isset($_POST['PelvicExamination']['cervix']) && $_POST['PelvicExamination']['cervix'] !== "") {
                     $pelvic_examination_model->cervix = implode(';', $_POST['PelvicExamination']['cervix']);
                 }
                 if (isset($_POST['PelvicExamination']['cervix_color']) && $_POST['PelvicExamination']['cervix_color'] !== "") {
                     $pelvic_examination_model->cervix_color = implode(';', $_POST['PelvicExamination']['cervix_color']);
                 }
                 if (isset($_POST['PelvicExamination']['cervix_consistency']) && $_POST['PelvicExamination']['cervix_consistency'] !== "") {
                     $pelvic_examination_model->cervix_consistency = implode(';', $_POST['PelvicExamination']['cervix_consistency']);
                 }
                 if (isset($_POST['PelvicExamination']['uterus_position']) && $_POST['PelvicExamination']['uterus_position'] !== "") {
                     $pelvic_examination_model->uterus_position = implode(';', $_POST['PelvicExamination']['uterus_position']);
                 }
                 if (isset($_POST['PelvicExamination']['uterus_size']) && $_POST['PelvicExamination']['uterus_size'] !== "") {
                     $pelvic_examination_model->uterus_size = implode(';', $_POST['PelvicExamination']['uterus_size']);
                 }
                 if (isset($_POST['PelvicExamination']['uterus_adnexa']) && $_POST['PelvicExamination']['uterus_adnexa'] !== "") {
                     $pelvic_examination_model->uterus_adnexa = implode(';', $_POST['PelvicExamination']['uterus_adnexa']);
                 }
             }
             $medical_history_model->save();
             $obstetrical_history_model->save();
             $physical_examination_model->save();
             $pelvic_examination_model->save();
             $this->redirect(array('index'));
         }
     }
     if (isset($model->method_accepted) && $model->method_accepted !== '') {
         $model->method_accepted = explode(';', $model->method_accepted);
     }
     if (isset($medical_history_model->heent) && $medical_history_model->heent !== '') {
         $medical_history_model->heent = explode(';', $medical_history_model->heent);
     }
     if (isset($medical_history_model->chest_heart) && $medical_history_model->chest_heart !== '') {
         $medical_history_model->chest_heart = explode(';', $medical_history_model->chest_heart);
     }
     if (isset($medical_history_model->abdomen) && $medical_history_model->abdomen !== '') {
         $medical_history_model->abdomen = explode(';', $medical_history_model->abdomen);
     }
     if (isset($medical_history_model->genital) && $medical_history_model->genital !== '') {
         $medical_history_model->genital = explode(';', $medical_history_model->genital);
     }
     if (isset($medical_history_model->extremities) && $medical_history_model->extremities !== '') {
         $medical_history_model->extremities = explode(';', $medical_history_model->extremities);
     }
     if (isset($medical_history_model->skin) && $medical_history_model->skin !== '') {
         $medical_history_model->skin = explode(';', $medical_history_model->skin);
     }
     if (isset($medical_history_model->other_history) && $medical_history_model->other_history !== '') {
         $medical_history_model->other_history = explode(';', $medical_history_model->other_history);
     }
     if (isset($obstetrical_history_model->other_history) && $obstetrical_history_model->other_history !== '') {
         $obstetrical_history_model->other_history = explode(';', $obstetrical_history_model->other_history);
     }
     if (isset($physical_examination_model->conjunctiva) && $physical_examination_model->conjunctiva !== '') {
         $physical_examination_model->conjunctiva = explode(';', $physical_examination_model->conjunctiva);
     }
     if (isset($physical_examination_model->neck) && $physical_examination_model->neck !== '') {
         $physical_examination_model->neck = explode(';', $physical_examination_model->neck);
     }
     if (isset($physical_examination_model->breast) && $physical_examination_model->breast !== '') {
         $physical_examination_model->breast = explode(';', $physical_examination_model->breast);
     }
     if (isset($physical_examination_model->thorax) && $physical_examination_model->thorax !== '') {
         $physical_examination_model->thorax = explode(';', $physical_examination_model->thorax);
     }
     if (isset($physical_examination_model->abdomen) && $physical_examination_model->abdomen !== '') {
         $physical_examination_model->abdomen = explode(';', $physical_examination_model->abdomen);
     }
     if (isset($physical_examination_model->extremities) && $physical_examination_model->extremities !== '') {
         $physical_examination_model->extremities = explode(';', $physical_examination_model->extremities);
     }
     if (isset($pelvic_examination_model->perenium) && $pelvic_examination_model->perenium !== '') {
         $pelvic_examination_model->perenium = explode(';', $pelvic_examination_model->perenium);
     }
     if (isset($pelvic_examination_model->v****a) && $pelvic_examination_model->v****a !== '') {
         $pelvic_examination_model->v****a = explode(';', $pelvic_examination_model->v****a);
     }
     if (isset($pelvic_examination_model->cervix) && $pelvic_examination_model->cervix !== '') {
         $pelvic_examination_model->cervix = explode(';', $pelvic_examination_model->cervix);
     }
     if (isset($pelvic_examination_model->cervix_color) && $pelvic_examination_model->cervix_color !== '') {
         $pelvic_examination_model->cervix_color = explode(';', $pelvic_examination_model->cervix_color);
     }
     if (isset($pelvic_examination_model->cervix_consistency) && $pelvic_examination_model->cervix_consistency !== '') {
         $pelvic_examination_model->cervix_consistency = explode(';', $pelvic_examination_model->cervix_consistency);
     }
     if (isset($pelvic_examination_model->uterus_position) && $pelvic_examination_model->uterus_position !== '') {
         $pelvic_examination_model->uterus_position = explode(';', $pelvic_examination_model->uterus_position);
     }
     if (isset($pelvic_examination_model->uterus_size) && $pelvic_examination_model->uterus_size !== '') {
         $pelvic_examination_model->uterus_size = explode(';', $pelvic_examination_model->uterus_size);
     }
     if (isset($pelvic_examination_model->uterus_adnexa) && $pelvic_examination_model->uterus_adnexa !== '') {
         $pelvic_examination_model->uterus_adnexa = explode(';', $pelvic_examination_model->uterus_adnexa);
     }
     $this->render('create', array('model' => $model, 'patient_model' => $patient_model, 'medical_history_model' => $medical_history_model, 'obstetrical_history_model' => $obstetrical_history_model, 'physical_examination_model' => $physical_examination_model, 'pelvic_examination_model' => $pelvic_examination_model));
 }