Stormont departments have paid out almost £19m to external consultants in recent years, it can be revealed.