What could help is determining the mental cycle and then cross training the employee for different work in the office and during a bad cycle change them to low stress work, and during a normal cycle back to regular work and having other employees work on projects with them that can take over due to a bad cycle and then give control back once that cycle ends. Also educating the coworkers and employees not to treat the employee bad during the bad cycles and avoid stressing them out.
Some things they could do instead of programming:
Documentation of software and requirements.
Quantity Assurance testing of software.
Database design and maintenance.
Doing research into new technology and beta testing products and filing reports on them.
Monitoring print queues and servers for potential problems and reading log files for errors and crashes and reporting on them.