How do I record IRA contribution and rollover when w/d was in 12/16, roll over in 1/17 & IRA '16 contribution b4 filing return and both are greater than SE income?

Spouse made multiple withdrawals from IRA in 2016, but the last withdrawal was $5,000 made in 12/2016. This was rolled over into a new IRA account within 45 days.  Spouse also had Schedule C income of about 4,000. and will make 2016 IRA contribution in 2017 before filing 2016 return.