When is it ok to go to the ER in Spain and when is it not?

When is it ok to go to the ER in Spain and when is it not?
Spaniards often go to ‘urgencias’ (the ER) even when it’s not a serious medical emergency. So when is it really acceptable to turn up at A&E and when do you need to book an appointment first?