Very ill or aged folk can have delirium
triggered by minor additional symptoms and pain is a common one.
Management can be difficult w/out extreme sedation and that can risk or hasten death. But it can pass - it is a mental state - not a disease in itself. Try to keep the situation as calm and peaceful as possible. Try to recall the good times and stories of such a long life - that might help.