It is a difficult problem. Heck, there ARE people who shouldn’t be walking the streets, and society once DID find a way to get them off the streets. I think everyone can agree that there are indeed people who shouldn’t be living at large in society.
The question is, where does one draw the line at “YOU can live in society” and “You CANNOT live in society”...
But, as another poster said, it is also true that giving the government powers of incarceration for mental status CAN (and did) end up with tyrannical states like the Soviet Union using it for their own ends.
We were taking people off the streets at one time in this country without being the Soviet Union, and while it is true that the conditions in many of those places were bad, it was also true that it likely wouldn’t be worse than what many of those people had on the street, except that someone else was paying for it.
But in the final analysis some human must be given the power to make that decision, and in our society, for better or worse, we have this whole bit about due process.
Some doctor's hunch or opinion is at best problematic as a way of deciding who gets locked up for years.