public function actionDelete() { $request = Yii::app()->request; $user_id = $request->getQuery("user_id"); $delete_user = User::model()->findByAttributes(array("user_id" => $user_id)); $delete_user->delete(); $patients = UserPatient::model()->findAllByAttributes(array("user_id" => $user_id)); foreach ($patients as $patient) { $patient_del = Patient::model()->findByAttributes(array("patient_id" => $patient->patient_id)); $patient_del->delete(); $patient_sick_del = PatientSick::model()->findByAttributes(array("patient_id" => $patient->patient_id)); $patient_sick_del->delete(); $patient_inject_del = PatientInjection::model()->findByAttributes(array("patient_id" => $patient->patient_id)); $patient_inject_del->delete(); } $this->redirect(Yii::app()->createUrl('admin/user')); }
public function actionGetSickPatient() { $this->retVal = new stdClass(); $request = Yii::app()->request; if ($request->isPostRequest && isset($_POST)) { try { $patient_id = StringHelper::filterString($request->getPost('patient_id')); $sick_data = PatientSick::model()->findAll(array('select' => 'sick_id', 'condition' => 'patient_id = ' . $patient_id . '')); $this->retVal->sick_data = $sick_data; } catch (exception $e) { $this->retVal->message = $e->getMessage(); } header('Content-type: application/json'); echo CJSON::encode($this->retVal); Yii::app()->end(); } }
public function actionCreatePatientAndSick() { $this->retVal = new stdClass(); $request = Yii::app()->request; if ($request->isPostRequest && isset($_POST)) { try { $name = StringHelper::filterString($request->getPost('name')); $dob = StringHelper::filterString($request->getPost('dob')); $gender = StringHelper::filterString($request->getPost('gender')); $user_id = StringHelper::filterString($request->getPost('user_id')); $relation = StringHelper::filterString($request->getPost('relationshipWithUser')); $blood = StringHelper::filterString($request->getPost('bloodType')); $sicks = StringHelper::filterString($request->getPost('sicks')); $patient_model = new Patient(); $patient_model->name = $name; $patient_model->dob = $dob; $patient_model->gender = $gender; $patient_model->last_updated = time(); $patient_model->bloodType = $blood; $patient_model->relationshipWithUser = $relation; $patient_model->save(FALSE); $user_patient = new UserPatient(); $user_patient->user_id = $user_id; $user_patient->patient_id = $patient_model->patient_id; $user_patient->save(FALSE); $sick_arr = json_decode($sicks); foreach ($sick_arr as $sick) { $model = new PatientSick(); $model->patient_id = $user_patient->patient_id; $model->sick_id = $sick; $model->save(FALSE); $this->createScheduleSick($sick, $patient_id); } $this->retVal->message = "Success"; $this->retVal->patient_id = $patient_model->patient_id; } catch (exception $e) { $this->retVal->message = $e->getMessage(); } header('Content-type: application/json'); echo CJSON::encode($this->retVal); Yii::app()->end(); } }
public function getPatientData($user_id) { $patient_data = Patient::model()->getPatientInfo($user_id); $sick_data = array(); $inject_data = array(); $remind_data = array(); foreach ($patient_data as $patient) { $sick = PatientSick::model()->findAllByAttributes(array('patient_id' => $patient["patient_id"])); $inject = PatientInjection::model()->findAllByAttributes(array('patient_id' => $patient["patient_id"])); $remind = MedicineRemind::model()->getMedicineRemindOfPatient($patient["patient_id"]); array_push($inject_data, $inject); array_push($sick_data, $sick); foreach ($remind as $item) { array_push($remind_data, $item); } } $returnArr = array("patient_data" => $patient_data, "sick_data" => $sick_data, "inject_data" => $inject_data, "remind_data" => $remind_data); return $returnArr; }
public function deletePatient($id) { $patient = Patient::model()->findByAttributes(array('patient_id' => $id)); $patient->delete(); $patient_injection = PatientInjection::model()->findAllByAttributes(array('patient_id' => $id)); $patient_remind = MedicineRemind::model()->findAllByAttributes(array('patient_id' => $id)); foreach ($patient_remind as $item) { $item->delete(); } foreach ($patient_injection as $patient) { $patient->delete(); } $patient_sick = PatientSick::model()->findAllByAttributes(array('patient_id' => $id)); foreach ($patient_sick as $patient) { $patient->delete(); } $patient_user = UserPatient::model()->findAllByAttributes(array('patient_id' => $id)); foreach ($patient_user as $patient) { $patient->delete(); } }
public function updateSickPatient($sicks, $patient_id) { $sick_del = PatientSick::model()->findAllByAttributes(array('patient_id' => $patient_id)); foreach ($sick_del as $sick) { $sick->delete(); } $sick_arr = json_decode($sicks); foreach ($sick_arr as $sick) { $model = new PatientSick(); $model->patient_id = $patient_id; $model->sick_id = $sick; $model->save(FALSE); $this->createScheduleSick($sick, $patient_id); } }