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);
    }