The frequency and clinical course of cognitive impairment in patients with terminal cancer