NHS workers who suffer from poor mental health, are over 50 or are from a minority ethnic background are more likely to be considering leaving.