public function getAppointments($respondentId, $organizationId, $patientNr = null, $where = null)
    {
        $select = $this->_getAppointmentSelect();

        if ($where) {
            $select->where($where);
        }

        if ($respondentId) {
            $select->where('gap_id_user = ?', $respondentId)
                    ->where('gap_id_organization = ?', $organizationId);
        } else {
            // Join might have been created in _getAppointmentSelect
            $from = $select->getPart(\Zend_Db_Select::FROM);
            if (! isset($from['gems__respondent2org'])) {
                $select->joinInner(
                        'gems__respondent2org',
                        'gap_id_user = gr2o_id_user AND gap_id_organization = gr2o_id_organization',
                        array()
                        );
            }

            $select->where('gr2o_patient_nr = ?', $patientNr)
                    ->where('gr2o_id_organization = ?', $organizationId);
        }

        // \MUtil_Echo::track($select->__toString());
        $rows = $this->db->fetchAll($select);

        if (! $rows) {
            return array();
        }

        $results = array();
        foreach ($rows as $row) {
            $results[$row['gap_id_appointment']] = $this->getAppointmentDisplay($row);
        }
        return $results;
    }
public function getAppointments($respondentId, $organizationId, $patientNr = null, $where = null)
    {
        $select = $this->_getAppointmentSelect();

        if ($where) {
            $select->where($where);
        }

        if ($respondentId) {
            $select->where('gap_id_user = ?', $respondentId)
                    ->where('gap_id_organization = ?', $organizationId);
        } else {
            // Join might have been created in _getAppointmentSelect
            $from = $select->getPart(\Zend_Db_Select::FROM);
            if (! isset($from['gems__respondent2org'])) {
                $select->joinInner(
                        'gems__respondent2org',
                        'gap_id_user = gr2o_id_user AND gap_id_organization = gr2o_id_organization',
                        array()
                        );
            }

            $select->where('gr2o_patient_nr = ?', $patientNr)
                    ->where('gr2o_id_organization = ?', $organizationId);
        }

        // \MUtil_Echo::track($select->__toString());
        $rows = $this->db->fetchAll($select);

        if (! $rows) {
            return array();
        }

        $results = array();
        foreach ($rows as $row) {
            $results[$row['gap_id_appointment']] = $this->getAppointmentDisplay($row);
        }
        return $results;
    }
public function getAppointments ( $ respondentId , $ organizationId , $ patientNr = null , $ where = null ) { $ select = $ this -> _getAppointmentSelect ( ) ; if ( $ where ) { $ select -> where ( $ where ) ; } if ( $ respondentId ) { $ select -> where ( 'gap_id_user = ?' , $ respondentId ) -> where ( 'gap_id_organization = ?' , $ organizationId ) ; } else { // Join might have been created in _getAppointmentSelect $ from = $ select -> getPart ( \ Zend_Db_Select :: FROM ) ; if ( ! isset ( $ from [ 'gems__respondent2org' ] ) ) { $ select -> joinInner ( 'gems__respondent2org' , 'gap_id_user = gr2o_id_user AND gap_id_organization = gr2o_id_organization' , array ( ) ) ; } $ select -> where ( 'gr2o_patient_nr = ?' , $ patientNr ) -> where ( 'gr2o_id_organization = ?' , $ organizationId ) ; } // \MUtil_Echo::track($select->__toString()); $ rows = $ this -> db -> fetchAll ( $ select ) ; if ( ! $ rows ) { return array ( ) ; } $ results = array ( ) ; foreach ( $ rows as $ row ) { $ results [ $ row [ 'gap_id_appointment' ] ] = $ this -> getAppointmentDisplay ( $ row ) ; } return $ results ; }
Get all appointments for a respondent

@param int $respondentId When null $patientNr is required
@param int $organizationId
@param string $patientNr Optional for when $respondentId is null
@param string $where Optional extra where statement
@return array appointmentId => appointment description
Get all appointments for a respondent