added code to write death date when patient has died