how does the emergency department work?