Police forced to hold mental health patient illegally over lack of beds