model() public static method

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : Patient
return Patient the static model class
コード例 #1
0
 public function actionReconcile($args)
 {
     $hfa_cmd = Yii::app()->db_visualfields->createCommand();
     $hfa_cmd->select('imagelocation, Test_Date, TestTime, patkey');
     $hfa_cmd->from('hfa_data');
     $hfa_cmd->where('test_date >= :test_date', array(':test_date' => '2014-07-15'));
     $hfa_records = $hfa_cmd->queryAll();
     $matched = 0;
     foreach ($hfa_records as $hfa) {
         $patient = Patient::model()->noPas()->findByAttributes(array('pas_key' => $hfa['patkey']));
         $error = null;
         if (!$patient) {
             $error = 'Patient not found';
         } else {
             /*
                             $vf = OphInVisualfields_Field_Measurement::model()->with('patient_measurement')->findAllByAttributes(array(
                                             'patient_measurement.patient_id' => $patient->id,
                                             't.study_datetime' => $hfa['Test_Date'] . ' ' . $hfa['TestTime']));
             */
             $vf_cmd = Yii::app()->db->createCommand()->select('count(*) as ct')->from('ophinvisualfields_field_measurement')->join('patient_measurement', 'patient_measurement.id = ophinvisualfields_field_measurement.patient_measurement_id')->where('patient_measurement.patient_id = :patient_id AND ophinvisualfields_field_measurement.study_datetime = :dt', array(':patient_id' => $patient->id, ':dt' => $hfa['Test_Date'] . ' ' . $hfa['TestTime']));
             $vf_ct = $vf_cmd->queryRow();
             if ($vf_ct['ct'] == 0) {
                 $error = 'Missing VF';
             } elseif ($vf_ct['ct'] > 1) {
                 $error = 'Duplicate ' . $vf_ct['ct'] . 'VF';
             } else {
                 ++$matched;
             }
         }
         if ($error) {
             echo "{$error}: hosnum: {$hfa['patkey']} at " . $hfa['Test_Date'] . ' ' . $hfa['TestTime'] . '. File: ' . $hfa['imagelocation'] . "\n";
         }
     }
     echo 'MATCHED:' . $matched . "\n";
 }
コード例 #2
0
 public static function fromFhir($fhirObject)
 {
     $report = parent::fromFhir($fhirObject);
     $patient = \Patient::model()->find('id=?', array($report->patient_id));
     $report->patient_id = $patient->id;
     $eye = 'Right';
     if ($report->eye == 'L') {
         $eye = 'Left';
     } elseif ($report->eye == 'B') {
         $eye = 'Both';
     }
     $report->eye_id = \Eye::model()->find('name=:name', array(':name' => $eye))->id;
     if (isset($fhirObject->xml_file_data)) {
         $report->xml_file_data = base64_decode($fhirObject->xml_file_data);
     }
     $title = $report->file_reference;
     if (\ProtectedFile::model()->find('name = ?', array($title))) {
         throw new EverythingsFine("Duplicate filename: {$title} (patient ID {$report->patient_id})");
     }
     $protected_file = \ProtectedFile::createForWriting($title);
     $protected_file->name = $title;
     file_put_contents($protected_file->getPath(), base64_decode($report->image_scan_data));
     $protected_file->mimetype = 'image/gif';
     $protected_file->save();
     $cropped_file = \ProtectedFile::createForWriting($title);
     // all content is base64 encoded, so decode it:
     file_put_contents($cropped_file->getPath(), base64_decode($report->image_scan_crop_data));
     $cropped_file->mimetype = 'image/gif';
     $cropped_file->name = $title;
     $cropped_file->save();
     $report->scanned_field_id = $protected_file->id;
     $report->scanned_field_crop_id = $cropped_file->id;
     return $report;
 }
 /**
  * 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));
 }
コード例 #4
0
ファイル: PatientController.php プロジェクト: huynt57/soyba
 public function actionDetail()
 {
     $request = Yii::app()->request;
     $patient_id = StringHelper::filterString($request->getQuery("patient_id"));
     $patient_info = Patient::model()->findByAttributes(array('patient_id' => $patient_id));
     // $patient_info = Patient::model()->getPatientDetailAdmin($patient_id);
     // echo CJSON::encode($patient_info);
     $this->render('detail', array('patient_info' => $patient_info));
 }
コード例 #5
0
 /**
  * Initialisation function for specific patient id
  * Used for ajax actions.
  *
  * @param $patient_id
  *
  * @throws CHttpException
  */
 protected function initForPatient($patient_id)
 {
     if (!($this->patient = Patient::model()->findByPk($patient_id))) {
         throw new CHttpException(403, 'Invalid patient_id.');
     }
     if (!($this->episode = $this->getEpisode($this->firm, $patient_id))) {
         throw new CHttpException(403, 'Invalid request for this patient.');
     }
 }
コード例 #6
0
ファイル: PracticeService.php プロジェクト: openeyes/openeyes
 /**
  * Delete the practice from the database, first unassociating it with any patients.
  *
  * @param int $id
  */
 public function delete($id)
 {
     if (!($prac = $this->model->findByPk($id))) {
         throw new NotFound("Practice with ID '{$id}' not found");
     }
     $crit = new \CDbCriteria();
     $crit->compare('practice_id', $id);
     \Patient::model()->updateAll(array('practice_id' => null), $crit);
     $prac->delete();
 }
コード例 #7
0
 /**
  * Collate the data and persist it to the table.
  *
  * @param $id
  *
  * @throws CHttpException
  * @throws Exception
  */
 public function loadData($id)
 {
     $booking = Element_OphTrOperationbooking_Operation::model()->find('event_id=?', array($id));
     $eye = Eye::model()->findByPk($booking->eye_id);
     if ($eye->name === 'Both') {
         throw new CHttpException(400, 'Can\'t display whiteboard for dual eye bookings');
     }
     $eyeLabel = strtolower($eye->name);
     $event = Event::model()->findByPk($id);
     $episode = Episode::model()->findByPk($event->episode_id);
     $patient = Patient::model()->findByPk($episode->patient_id);
     $contact = Contact::model()->findByPk($patient->contact_id);
     $biometryCriteria = new CDbCriteria();
     $biometryCriteria->addCondition('patient_id = :patient_id');
     $biometryCriteria->params = array('patient_id' => $patient->id);
     $biometryCriteria->order = 'last_modified_date DESC';
     $biometryCriteria->limit = 1;
     $biometry = Element_OphTrOperationnote_Biometry::model()->find($biometryCriteria);
     $examination = $event->getPreviousInEpisode(EventType::model()->findByAttributes(array('name' => 'Examination'))->id);
     //$management = new \OEModule\OphCiExamination\models\Element_OphCiExamination_Management();
     //$anterior = new \OEModule\OphCiExamination\models\Element_OphCiExamination_AnteriorSegment();
     $risks = new \OEModule\OphCiExamination\models\Element_OphCiExamination_HistoryRisk();
     if ($examination) {
         //$management = $management->findByAttributes(array('event_id' => $examination->id));
         //$anterior = $anterior->findByAttributes(array('event_id' => $examination->id));
         $risks = $risks->findByAttributes(array('event_id' => $examination->id));
     }
     $labResult = Element_OphInLabResults_Inr::model()->findPatientResultByType($patient->id, '1');
     $allergies = Yii::app()->db->createCommand()->select('a.name as name')->from('patient_allergy_assignment pas')->leftJoin('allergy a', 'pas.allergy_id = a.id')->where("pas.patient_id = {$episode->patient_id}")->order('a.name')->queryAll();
     $allergyString = 'None';
     if ($allergies) {
         $allergyString = implode(',', array_column($allergies, 'name'));
     }
     $operation = Yii::app()->db->createCommand()->select('proc.term as term')->from('et_ophtroperationbooking_operation op')->leftJoin('ophtroperationbooking_operation_procedures_procedures opp', 'opp.element_id = op.id')->leftJoin('proc', 'opp.proc_id = proc.id')->where("op.event_id = {$id}")->queryAll();
     $this->event_id = $id;
     $this->booking = $booking;
     $this->eye_id = $eye->id;
     $this->eye = $eye;
     $this->predicted_additional_equipment = $booking->special_equipment_details;
     $this->comments = '';
     $this->patient_name = $contact['title'] . ' ' . $contact['first_name'] . ' ' . $contact['last_name'];
     $this->date_of_birth = $patient['dob'];
     $this->hos_num = $patient['hos_num'];
     $this->procedure = implode(',', array_column($operation, 'term'));
     $this->allergies = $allergyString;
     $this->iol_model = $biometry ? $biometry->attributes['lens_description_' . $eyeLabel] : 'Unknown';
     $this->iol_power = $biometry ? $biometry->attributes['iol_power_' . $eyeLabel] : 'none';
     $this->predicted_refractive_outcome = $biometry ? $biometry->attributes['predicted_refraction_' . $eyeLabel] : 'Unknown';
     $this->alpha_blockers = $patient->hasRisk('Alpha blockers');
     $this->anticoagulants = $patient->hasRisk('Anticoagulants');
     $this->alpha_blocker_name = $risks ? $risks->alpha_blocker_name : '';
     $this->anticoagulant_name = $risks ? $risks->anticoagulant_name : '';
     $this->inr = $labResult ? $labResult : 'None';
     $this->save();
 }
コード例 #8
0
 /**
  * @param $patientId
  * @param $side
  * @param $element
  * @return array
  */
 public function getPCRData($patientId, $side, $element)
 {
     $pcr = array();
     $this->patient = \Patient::model()->findByPk((int) $patientId);
     $patientAge = $this->patient->getAge();
     $ageGroup = 0;
     if ($patientAge < 60) {
         $ageGroup = 1;
     } elseif ($patientAge >= 60 && $patientAge < 70) {
         $ageGroup = 2;
     } elseif ($patientAge >= 70 && $patientAge < 80) {
         $ageGroup = 3;
     } elseif ($patientAge >= 80 && $patientAge < 90) {
         $ageGroup = 4;
     } elseif ($patientAge >= 90) {
         $ageGroup = 5;
     }
     $gender = ucfirst($this->patient->getGenderString());
     $is_diabetic = 'N';
     if ($this->patient->getDiabetes()) {
         $is_diabetic = 'Y';
     }
     $is_glaucoma = 'N';
     if (strpos($this->patient->getSdl(), 'glaucoma') !== false) {
         $is_glaucoma = 'Y';
     }
     $risk = \PatientRiskAssignment::model()->findByAttributes(array("patient_id" => $patientId));
     $user = Yii::app()->session['user'];
     $user_id = $user->id;
     if (strpos(get_class($element), 'OphTrOperationnote') !== false) {
         $user_id = $this->getOperationNoteSurgeonId($patientId);
     }
     $user_data = \User::model()->findByPk($user_id);
     $doctor_grade_id = $user_data['originalAttributes']['doctor_grade_id'];
     $pcr['patient_id'] = $patientId;
     $pcr['side'] = $side;
     $pcr['age_group'] = $ageGroup;
     $pcr['gender'] = $gender;
     $pcr['diabetic'] = $is_diabetic;
     $pcr['glaucoma'] = $is_glaucoma;
     $pcr['lie_flat'] = $this->getCannotLieFlat($patientId);
     $no_view = 'N';
     $no_view_data = $this->getOpticDisc($patientId, $side);
     if (count($no_view_data) >= 1) {
         $no_view = 'Y';
     }
     $pcr['noview'] = $no_view;
     $pcr['allod'] = $this->getOpticDisc($patientId, $side, true);
     $pcr['anteriorsegment'] = $this->getPatientAnteriorSegment($patientId, $side);
     $pcr['doctor_grade_id'] = $doctor_grade_id;
     $pcr['axial_length_group'] = $this->getAxialLength($patientId, $side);
     return $pcr;
 }
コード例 #9
0
ファイル: HistoryRemind.php プロジェクト: huynt57/soyba
 public function getHistoryByPatient($patient_id)
 {
     $patient = Patient::model()->findByPk($patient_id);
     if ($patient) {
         $reminds = MedicineRemind::model()->findAllByAttributes(array('patient_id' => $patient->patient_id));
         $returnArr = array();
         if ($reminds) {
             foreach ($reminds as $remind) {
                 $history = HistoryRemind::model()->findAllByAttributes(array('remind_id' => $remind->id));
                 $returnArr[] = $history;
             }
             return $returnArr;
         }
     }
 }
コード例 #10
0
 public function actionCreate($patientId)
 {
     $patient = Patient::model()->findByPk($patientId);
     $model = new MedicalRecord();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['MedicalRecord'])) {
         $model->attributes = $_POST['MedicalRecord'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', '儲存成功.');
             $this->redirect($this->createUrl('/patient/update/', array('id' => $patient->id)));
         }
     }
     $this->render('create', array('patient' => $patient, 'model' => $model));
 }
コード例 #11
0
ファイル: UserController.php プロジェクト: huynt57/soyba
 public function actionDetail()
 {
     $this->retVal = new stdClass();
     $request = Yii::app()->request;
     if ($request->isPostRequest && isset($_POST)) {
         try {
             $id = StringHelper::filterString($request->getPost('id'));
             $patient_info = Patient::model()->getPatientInfo($id);
             $this->retVal->patient_info = $patient_info;
         } catch (exception $e) {
             $this->retVal->message = $e->getMessage();
         }
         echo CJSON::encode($this->retVal);
         Yii::app()->end();
     }
 }
コード例 #12
0
 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     if ($this->user_type == 1 || $this->user_type == 2) {
         $criteria = new CDbCriteria();
         $criteria->condition = 'LOWER(mid)=' . strtolower($this->username) . ' AND management_user_level_id=' . $this->user_type;
         $user = Management::model()->find($criteria);
     } else {
         if ($this->user_type == 4) {
             $user = Doctor::model()->find('LOWER(did)=?', array(strtolower($this->username)));
         } else {
             if ($this->user_type == 3) {
                 $user = Patient::model()->find('LOWER(pid)=?', array(strtolower($this->username)));
             } else {
                 $user = Nurses::model()->find('LOWER(nid)=?', array(strtolower($this->username)));
             }
         }
     }
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!($user->pass == $this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($this->user_type == 1 || $this->user_type == 2) {
                 $this->_id = $user->mid;
                 $this->username = $user->mid;
             } else {
                 if ($this->user_type == 4) {
                     $this->_id = $user->did;
                     $this->username = $user->did;
                 } else {
                     if ($this->user_type == 3) {
                         $this->_id = $user->pid;
                         $this->username = $user->pid;
                     } else {
                         $this->_id = $user->nid;
                         $this->username = $user->nid;
                     }
                 }
             }
             $this->_type = $this->user_type;
             $this->errorCode = self::ERROR_NONE;
             $this->setState("type", $this->_type);
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }
 /**
  * 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));
 }
コード例 #14
0
ファイル: CalendarController.php プロジェクト: huynt57/soyba
 public function actionUpdateDetailCalendar()
 {
     $this->retVal = new stdClass();
     $request = Yii::app()->request;
     if ($request->isPostRequest && isset($_POST)) {
         try {
             $id = StringHelper::filterString($request->getPost('id'));
             //   $name = StringHelper::filterString($request->getPost('name'));
             $date = StringHelper::filterString($request->getPost('date'));
             $note = StringHelper::filterString($request->getPost('note'));
             $done = StringHelper::filterString($request->getPost('done'));
             Patient::model()->updatePatientCalendar($id, $done, $date, $note);
         } catch (Exception $ex) {
             $this->retVal->message = $ex->getMessage();
         }
     }
     echo CJSON::encode($this->retVal);
     Yii::app()->end();
 }
 /**
  * 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));
 }
コード例 #16
0
 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));
         $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));
 }
コード例 #17
0
 /**
  * @dataProvider update_Provider
  *
  * @param $initial
  * @param $update
  * @param $expected_values
  */
 public function testUpdate($initial, $update, $expected_values)
 {
     $this->put('Update', $initial);
     $id = $this->xPathQuery('/Success//Id')->item(0)->nodeValue;
     $patient = Patient::model()->findByPk($id);
     $this->assertNotNull($patient);
     $this->put('Update', $update);
     $patient = Patient::model()->findByPk($id);
     $this->assertExpectedValuesMatch($expected_values, $patient);
 }
コード例 #18
0
 public function actionAddNewEpisode()
 {
     if (!($patient = Patient::model()->findByPk(@$_POST['patient_id']))) {
         throw new Exception("Patient not found: " . @$_POST['patient_id']);
     }
     if (!empty($_POST['firm_id'])) {
         $firm = Firm::model()->findByPk($_POST['firm_id']);
         if (!($episode = $patient->getOpenEpisodeOfSubspecialty($firm->getSubspecialtyID()))) {
             $episode = $patient->addEpisode($firm);
         }
         $this->redirect(array('/patient/episode/' . $episode->id));
     }
     return $this->renderPartial('//patient/add_new_episode', array('patient' => $patient, 'firm' => Firm::model()->findByPk(Yii::app()->session['selected_firm_id'])), false, true);
 }
コード例 #19
0
 public static function getGenders()
 {
     $genders = ZHtml::enumItem(Patient::model(), 'gender');
     $genders[''] = '';
     asort($genders);
     return $genders;
 }
コード例 #20
0
ファイル: SuperController.php プロジェクト: huynt57/soyba
 public function createScheduleSick($sick_id, $patient_id)
 {
     $sick_infos = InjectionScheduler::model()->findAllByAttributes(array('sick_id' => $sick_id));
     $patient_info = Patient::model()->findByAttributes(array('patient_id' => $patient_id));
     foreach ($sick_infos as $sick_info) {
         $model = new PatientInjection();
         $model->sick_id = $sick_id;
         $model->patient_id = $patient_id;
         $model->number = $sick_info->number;
         $model->done = 0;
         $model->month = $sick_info->month;
         $date = new DateTime($patient_info->dob);
         $date->modify('+' . $sick_info->month . ' month');
         $model->inject_day = $date->format('d-m-Y');
         $model->last_updated = time();
         $model->save(FALSE);
     }
 }
コード例 #21
0
 /**
  * Display form to change site/firm
  * @throws CHttpException
  */
 public function actionChangeSiteAndFirm()
 {
     if (!($return_url = @$_GET['returnUrl'])) {
         if (!($return_url = @$_POST['returnUrl'])) {
             throw new CHttpException(500, 'Return URL must be specified');
         }
     }
     if (@$_GET['patient_id']) {
         $patient = Patient::model()->findByPk(@$_GET['patient_id']);
     }
     $this->renderPartial('/site/change_site_and_firm', array('returnUrl' => $return_url), false, true);
 }
コード例 #22
0
	<div class="row field-row">
		<div class="large-<?php 
echo $layoutColumns['label'];
?>
 column">
			<?php 
$firm = Firm::model()->with('serviceSubspecialtyAssignment')->findByPk(Yii::app()->session['selected_firm_id']);
$event_types = array();
foreach (EventType::model()->with('elementTypes')->findAll() as $event_type) {
    $event_types[$event_type->class_name] = array();
    foreach ($event_type->elementTypes as $elementType) {
        $event_types[$event_type->class_name][] = $elementType->class_name;
    }
}
if (isset($_GET['patient_id'])) {
    $patient = Patient::model()->findByPk($_GET['patient_id']);
} else {
    $patient = Yii::app()->getController()->patient;
}
$with = array('firmLetterStrings' => array('condition' => 'firm_id is null or firm_id = :firm_id', 'params' => array(':firm_id' => $firm->id), 'order' => 'firmLetterStrings.display_order asc'), 'subspecialtyLetterStrings' => array('condition' => 'subspecialty_id is null', 'order' => 'subspecialtyLetterStrings.display_order asc'), 'siteLetterStrings' => array('condition' => 'site_id is null or site_id = :site_id', 'params' => array(':site_id' => Yii::app()->session['selected_site_id']), 'order' => 'siteLetterStrings.display_order'));
if ($firm->getSubspecialtyID()) {
    $with['subspecialtyLetterStrings']['condition'] = 'subspecialty_id is null or subspecialty_id = :subspecialty_id';
    $with['subspecialtyLetterStrings']['params'] = array(':subspecialty_id' => $firm->getSubspecialtyID());
}
foreach (LetterStringGroup::model()->with($with)->findAll(array('order' => 't.display_order')) as $string_group) {
    $strings = $string_group->getStrings($patient, $event_types);
    ?>
				<div class="field-row">
					<?php 
    echo $form->dropDownListNoPost(strtolower($string_group->name), $strings, '', array('empty' => '- ' . $string_group->name . ' -', 'nowrapper' => true, 'class' => 'stringgroup full-width', 'disabled' => empty($strings)));
    ?>
 public function setDefaultOptions()
 {
     if (in_array(Yii::app()->getController()->getAction()->id, array('created', 'ElementForm'))) {
         if ($api = Yii::app()->moduleAPI->get('OphTrOperationnote')) {
             if (!($patient = \Patient::model()->findByPk(@$_GET['patient_id']))) {
                 throw new Exception('Patient not found: ' . @$_GET['patient_id']);
             }
             if ($api->getOpnoteWithCataractElementInCurrentEpisode($patient)) {
                 $this->eye_id = OphCiExamination_CataractSurgicalManagement_Eye::model()->find('name=?', array('Second eye'))->id;
             } else {
                 $this->eye_id = OphCiExamination_CataractSurgicalManagement_Eye::model()->find('name=?', array('First eye'))->id;
             }
         }
     }
 }
コード例 #24
0
 /**
  * @covers Patient::model
  * @todo   Implement testModel().
  */
 public function testModel()
 {
     $this->assertEquals('Patient', get_class(Patient::model()), 'Class name should match model.');
 }
コード例 #25
0
 public function testGetEdr_NotSet()
 {
     Yii::app()->session['selected_firm_id'] = 1;
     $patient = Patient::model()->findByPk(1);
     $episode = Episode::model()->findByPk(1);
     $episode->setPrincipalDiagnosis(1, Eye::LEFT);
     $this->assertEquals($patient->getEdr(), 'No diagnosis');
 }
コード例 #26
0
 protected function getPatient($patient_id)
 {
     if (!@$this->_patient_cache[$patient_id]) {
         $this->_patient_cache[$patient_id] = Patient::model()->noPas()->findByPk($patient_id);
     }
     return $this->_patient_cache[$patient_id];
 }
コード例 #27
0
 public function getSelectedEye()
 {
     if (Yii::app()->getController()->getAction()->id == 'create') {
         // Get the procedure list and eye from the most recent booking for the episode of the current user's subspecialty
         if (!($patient = Patient::model()->findByPk(@$_GET['patient_id']))) {
             throw new SystemException('Patient not found: ' . @$_GET['patient_id']);
         }
         if ($episode = $patient->getEpisodeForCurrentSubspecialty()) {
             if ($booking = $episode->getMostRecentBooking()) {
                 return $booking->elementOperation->eye;
             }
         }
     }
     if (isset($_GET['eye'])) {
         return Eye::model()->findByPk($_GET['eye']);
     }
     return new Eye();
 }
コード例 #28
0
 /**
  * Ajax method for viewing previous elements
  * @param integer $element_type_id
  * @param integer $patient_id
  * @throws CHttpException
  */
 public function actionViewPreviousElements($element_type_id, $patient_id)
 {
     $element_type = ElementType::model()->findByPk($element_type_id);
     if (!$element_type) {
         throw new CHttpException(404, 'Unknown ElementType');
     }
     $this->patient = Patient::model()->findByPk($patient_id);
     if (!$this->patient) {
         throw new CHttpException(404, 'Unknown Patient');
     }
     // Clear script requirements as all the base css and js will already be on the page
     Yii::app()->assetManager->reset();
     $this->episode = $this->getEpisode();
     $elements = $this->episode->getElementsOfType($element_type);
     $this->renderPartial('_previous', array('elements' => $elements), false, true);
 }
コード例 #29
0
 /**
  * Use the examination API to retrieve findings for the patient and element type.
  *
  * @param $patient_id
  * @param $element_type_id
  *
  * @return mixed
  *
  * @throws Exception
  */
 public function process_examination_findings($patient_id, $element_type_id)
 {
     if ($api = Yii::app()->moduleAPI->get('OphCiExamination')) {
         if (!($patient = Patient::model()->findByPk($patient_id))) {
             throw new Exception('Unable to find patient: ' . $patient_id);
         }
         if (!($element_type = ElementType::model()->findByPk($element_type_id))) {
             throw new Exception("Unknown element type: {$element_type_id}");
         }
         if (!($episode = $patient->getEpisodeForCurrentSubspecialty())) {
             throw new Exception('No Episode available for patient: ' . $patient_id);
         }
         return $api->getLetterStringForModel($patient, $episode, $element_type_id);
     }
 }
コード例 #30
0
 /**
  * Output the report in CSV format.
  *
  * @return string
  */
 public function toCSV()
 {
     $output = $this->description() . "\n\n";
     $output .= Patient::model()->getAttributeLabel('hos_num') . ',' . Patient::model()->getAttributeLabel('dob') . ',' . Patient::model()->getAttributeLabel('first_name') . ',' . Patient::model()->getAttributeLabel('last_name') . ',' . Patient::model()->getAttributeLabel('gender') . ",Consultant's name,Site,Date,Type,Link\n";
     foreach ($this->letters as $letter) {
         $output .= "\"{$letter['hos_num']}\",\"" . ($letter['dob'] ? date('j M Y', strtotime($letter['dob'])) : 'Unknown') . "\",\"{$letter['first_name']}\",\"{$letter['last_name']}\",\"{$letter['gender']}\",\"{$letter['cons_first_name']} {$letter['cons_last_name']}\",\"" . (isset($letter['name']) ? $letter['name'] : 'N/A') . '","' . date('j M Y', strtotime($letter['created_date'])) . '","' . $letter['type'] . '","' . $letter['link'] . "\"\n";
     }
     return $output;
 }