Normally, source.getCount() would be used to find the number of fields, but it currently does not work on subfields. The solution, then, is to use a split() on the field.
The following solution will modify the FT1-19 subfields to add "I9" to FT1-19.3 for each diagnosis value.
var ft119Count = source.getNode('FT1-19').split('~').length;
for (var x=1; x <= ft119Count; x++) {
message.setNode('FT1-19[' + x + '].3', 'I9');
}