And it's worth noting that in medicine there's no fundamental boundary for 'may cost you your life', or if it is, the bar is very low. Taking an x-ray may cost you your life. Not taking an x-ray may cost you your life. Dentist's anaesthesia may cost you your life. Almost every noteworthy medical decision (including purely preventative things or running tests) has some life-or-death effect, there's only a difference in quantity, not a difference in kind. There are no life-saving procedures, there are only life-prolonging procedures. A widespread recommendation that patients meeting criteria X, Y and Z should do a particular diagnostic test will result in deaths of some people, and a widespread recommendation that they shouldn't will also result in deaths of some other people, and the main question is which number of deaths is larger.
On a large scale, medicine is mainly a resource allocation problem - almost everyone could and would live longer if we allocated more care towards them personally or towards that condition, however, the "price/performance ratio" of such procedures is very, very different. There are things like stopping bleeding from trauma, which are very cheap and prolong your life by as many years as you'd otherwise live, and there are drugs and procedures with a six figure price that give an average survival benefit of a few weeks over much cheaper alternatives; and for most of people who'll die in hospitals today we could extend their life by at least one day with extra care; it's just that it's currently physically impossible to do everything for everyone, even if our economy consisted 100% of doctors and nurses caring for each other, because now we can (attempt to) do so much more. So there has to be a line drawn somewhere; some care will inevitably have to be refused to some people, and the only debate can be about the criteria - whether it's medical criteria (e.g. being refused to be considered for an organ transplant since you'll likely die soon anyway for other reasons, and that transplant can give much more years to someone else), or the ability to pay for certain procedures, or some other ways. On a large scale metrics like $/QALY (price for a quality-adjusted life year) make sense, but on small scale it's difficult to judge.
So they'll treat your heart attack, but they're under no obligation to offer you free cancer treatment.