public function getSqlAppointmentsWhere()
    {
        $where = $this->getSqlEpisodeWhere();

        if (($where == parent::NO_MATCH_SQL) || ($where == parent::MATCH_ALL_SQL)) {
            return $where;
        }

        return sprintf(
                "gap_id_episode IN (SELECT gec_episode_of_care_id FROM gems__episodes_of_care WHERE %s)",
                $where
                );
    }