A bug doctor is a psychologist or psychiatrist, also called a shrink, that works with the inmates of a prison. They're generally hardy folk, considering how specialized the fields of forensic psychiatry and forensic psychology are.
Inmate 1: Are you seeing the bug doctor today?
Inmate 2: Yea, she's been helping me out a lot.
Inmate 1: Right on.