AC-10: Updated avtive visit query.