Japanese 2000s movie

I’m looking for a movie in which a japanese teenage girl manages to talk through a writer/poet (that lived in the past). She tells him that in some days he s gonna die from unknown reasons and he starts being very careful,but in the end, the guy dies in a like trying to save a kid.