Patients seeking mental health treatment have gotten stuck in hospital emergency departments because there weren’t enough beds to treat them.