We already have an answer to this, it’s literally how hospitals work in every Universal healthcare country. It’s generally decided on using a base of the factors you mentioned, plus a few more (like the resources available in the region). Doctors also generally get a say as a group at the hospital, they all take ethics classes at school for a reason.