Where this is written down in a document it is known as a living will or advance decision. Its purpose is to make your wishes clear if you are unable to communicate yourself. Because it is a legal document, there are some differences in the requirements of individual countries. The following paragraphs explain the purpose of the advance decision; but you will need to check exactly what the provisions are in your own country.
The document must explain exactly which treatments you want to refuse, and in what circumstances (if you might not want to refuse them in all situations). It can be helpful to discuss with a doctor what treatments you might need in future, and what would happen if you refuse them. If you might die as a result of refusing such treatment, the document must state clearly that the advance decision is to apply to the specific treatment even if life is at risk or shortened as a result. An advance decision cannot be used to ask for specific treatments, or to ask for help to end your life.
To make your wishes legally valid, they must be written down and signed and dated by yourself and by a witness. To be put into action, your wishes must be applicable to your situation and the treatments available, if you are not able to make your own decisions about your treatment, e.g. if you are unconscious, and if there is no reason to suspect that you might have changed your mind since the document was signed.