The system of medical records used in the U.S. does not make it easy for doctors to know that you have a medical directive and that you have expressed your wishes ahead of time, according to The New York Times in "You've Detailed Your Last Wishes, but Doctors May Not See Them."
There is a potential way to mitigate the possibility that this problem will happen to you. Get your Health Care Proxy ahead of time by going to an estate planning attorney. These documents are routinely created as part of the estate planning process.
Once you have created the document, you should store the originals in a secure place and give copies to your doctors and your agents. It is equally important that your agents fully understand and are willing to carry out your wishes, particularly with regard to life-sustaining and life-ending treatments. An estate planning attorney can be helpful in discussing your options and guiding you in creating effective advance directives.
Reference: New York Times (March 27, 2018) "You've Detailed Your Last Wishes, but Doctors May Not See Them."