Advance directives in electronic health records reduce hospital deaths and burdensome end-of-life care for older patients.