Do-Not-Attempt-Resuscitate (DNAR) orders

Who decides what medical treatment we should receive when we lose mental capacity?