public function countTracks($patientId, $organizationId, $respondentId = null, $active = false)
    {
        $db = $this->getAdapter();
        $select = $db->select();
        $select->from('gems__respondent2track', array('COALESCE(COUNT(*), 0)'));

        if (null === $respondentId) {
            $respondentId = $this->util->getDbLookup()->getRespondentId($patientId, $organizationId);
        }

        $select->where('gr2t_id_user = ?', $respondentId);

        if (null !== $organizationId) {
            $select->where('gr2t_id_organization = ?', $organizationId);
        }

        if ($active) {
            $select->joinInner('gems__reception_codes', 'gr2t_reception_code = grc_id_reception_code')
                    ->where('grc_success = 1');
        }

        return $db->fetchOne($select);
    }
public function countTracks($patientId, $organizationId, $respondentId = null, $active = false)
    {
        $db = $this->getAdapter();
        $select = $db->select();
        $select->from('gems__respondent2track', array('COALESCE(COUNT(*), 0)'));

        if (null === $respondentId) {
            $respondentId = $this->util->getDbLookup()->getRespondentId($patientId, $organizationId);
        }

        $select->where('gr2t_id_user = ?', $respondentId);

        if (null !== $organizationId) {
            $select->where('gr2t_id_organization = ?', $organizationId);
        }

        if ($active) {
            $select->joinInner('gems__reception_codes', 'gr2t_reception_code = grc_id_reception_code')
                    ->where('grc_success = 1');
        }

        return $db->fetchOne($select);
    }
public function countTracks ( $ patientId , $ organizationId , $ respondentId = null , $ active = false ) { $ db = $ this -> getAdapter ( ) ; $ select = $ db -> select ( ) ; $ select -> from ( 'gems__respondent2track' , array ( 'COALESCE(COUNT(*), 0)' ) ) ; if ( null === $ respondentId ) { $ respondentId = $ this -> util -> getDbLookup ( ) -> getRespondentId ( $ patientId , $ organizationId ) ; } $ select -> where ( 'gr2t_id_user = ?' , $ respondentId ) ; if ( null !== $ organizationId ) { $ select -> where ( 'gr2t_id_organization = ?' , $ organizationId ) ; } if ( $ active ) { $ select -> joinInner ( 'gems__reception_codes' , 'gr2t_reception_code = grc_id_reception_code' ) -> where ( 'grc_success = 1' ) ; } return $ db -> fetchOne ( $ select ) ; }
Count the number of tracks the respondent has for this organization

@param string $patientId   Can be empty if $respondentId is passed
@param int $organizationId When null looks at all organizations
@param int $respondentId   Pass when at hand, is looked up otherwise
@param boolean $active     When true only tracks with a success code are returned
@return boolean
Count the number of tracks the respondent has for this organization