modified the insert encounter query