Researchers said more needs to be done to retain nurses and doctors in the NHS to ensure safe patient care.