There is a body of law for advanced directives.
There is also what is called a health care surrogate. If something happens THIS person makes the decisions. (BTW I have had all divorcing clients do those "just in case" because during the pendency of a divorce a soon to be ex is still a husband or wife with the authority to pull the plug.)
The problem is we have conflicting "heresay". But an exception to the heresay rule because the declarant is unavailable.
Hollywerid will make a movie of the week on Lyfetyme which will have teh judge as a hero (with far more hair, or perhaps just make it a woman or perhaps make it a woman whose husband wants to die and a wife fighting the family with a new baby from some other guy on the way)
If there´s doubt about the will of the patient, the patient shall not be killed. The parents, children and husband shall have a say in this, since they should know the patient at best.