NHS staff who become apprentices with the employer will not suffer a pay cut under a deal struck with trade unions.