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 living will and your health care power of attorney 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 documents, you should store them in a secure place. However, do not stop there. Make sure that someone you trust knows where to find the documents. That person should be able to get them when needed to the doctors providing care for you.
Reference: New York Times (March 27, 2018) "You've Detailed Your Last Wishes, but Doctors May Not See Them."