Advance Decisions to Refuse Treatment

We all like to make our own decisions. But what happens if for some reason a person is not able to make a decision about their own medical treatment because of illness or because they are unconscious?