Updated the appointment retrival query