updated the query which is checking if patients already exist