Filtering based on specialty and top referrals correction for union
query