I cannot remember title nor author, but a plot summary is:
A man wakes up in a strange room, goes to the door and find it locked. There is a computer terminal in the room. He sits at the terminal and quickly finds out that it contains a psychological diagnostic "artificial intelligence" program. He is a psychologist, and the program is based on his own theories, which he has since repudiated.
That repudiation is a threat to his colleagues and the reason he's in the cell. He attempts to fool the program by remembering his own work, but the stress of keeping his answers consistent is too much for him and he is sedated again.
I think I read it in the early 1980s.