OEModule\OphCiExamination\components\RefractiveOutcomeReport::queryData PHP Method

queryData() protected method

protected queryData ( $surgeon, $dateFrom, $dateTo, integer $months, array $procedures = [] ) : array | CDbDataReader
$surgeon
$dateFrom
$dateTo
$months integer
$procedures array
return array | CDbDataReader
    protected function queryData($surgeon, $dateFrom, $dateTo, $months = 0, $procedures = array())
    {
        $this->getExaminationEvent();
        $this->command->select('post_examination.episode_id, note_event.episode_id, note_event.event_date as op_date, note_event.id, op_procedure.eye_id,
        post_examination.event_date as post_exam_date, post_examination.event_date as post_exam_date, post_examination.id as post_id, patient.id as patient_id,
        left_sphere, right_sphere, left_cylinder, right_cylinder, predicted_refraction')->from('et_ophtroperationnote_surgeon')->join('event note_event', 'note_event.id = et_ophtroperationnote_surgeon.event_id')->join('et_ophtroperationnote_procedurelist op_procedure', 'op_procedure.event_id = note_event.id #And the operation notes procedures')->join('episode', 'note_event.episode_id = episode.id')->join('patient', 'episode.patient_id = patient.id')->join('event post_examination', 'post_examination.episode_id = note_event.episode_id
               AND post_examination.event_type_id = :examination
               AND post_examination.event_date >= note_event.event_date
               AND post_examination.created_date > note_event.created_date', array('examination' => $this->examinationEvent['id']))->join('et_ophciexamination_refraction', 'post_examination.id = et_ophciexamination_refraction.event_id')->join('et_ophtroperationnote_cataract', 'note_event.id = et_ophtroperationnote_cataract.event_id')->where('surgeon_id = :surgeon', array('surgeon' => $surgeon))->andWhere('post_examination.deleted <> 1 and note_event.deleted <> 1')->order('post_exam_date desc');
        if ($dateFrom) {
            $this->command->andWhere('note_event.event_date >= :dateFrom', array('dateFrom' => $dateFrom));
        }
        if ($dateTo) {
            $this->command->andWhere('note_event.event_date <= :dateTo', array('dateTo' => $dateTo));
        }
        if ($months) {
            $this->command->andWhere('post_examination.event_date BETWEEN DATE_ADD(note_event.event_date, INTERVAL :monthsBefore MONTH) AND DATE_ADD(note_event.event_date, INTERVAL :monthsAfter MONTH)', array('monthsBefore' => $months - 1, 'monthsAfter' => $months + 1));
        }
        if ($procedures) {
            $this->command->join('ophtroperationnote_procedurelist_procedure_assignment proc_ass', 'proc_ass.procedurelist_id = op_procedure.id')->join('ophtroperationnote_procedure_element opnote', 'opnote.procedure_id = proc_ass.proc_id and proc_ass.proc_id in (:procedures)', array('procedures' => implode(',', $procedures)));
        }
        return $this->command->queryAll();
    }