Add code to fix optimistic locking issue.
- change relationship between table to encounter to OneToMany