Healthcare trajectories and costs in the last year of life: a retrospective primary care and hospital analysis