updated the query which pull all patient encounters