The opiate detox center around here has alot of folks by self admittance and a few by law/authority. They don't necisarilly make you go cold turkey therem you check yourself inm given mental health check by a doctor and a social worker will also talk to you. After this you'd be sent to a room, and would be given meds daily to ween off the heroin, they'd also help you just focus on tasks like getting sleep, eating, socializing, bathing, etc.
The er would do a mental health examination, possibly give you something to relax, you'd talk with a social worker and together they'd decide if you needed to be admitted to a psyche ward, if not they'd just give you a room and not sure about the rest.