title: Can't seem to move segment into repeating field
body: <p>I have a piece of code that I'm trying to get to work on an interface. Basically we take some fields and drop into other segments. The problem seems to be that it leaves the data where it is instead of moving it to the indexed PID segment. Also the CP variable is returning 'undefined' for some reason.</p>
  
  <pre><code>var i = msg['PID']['PID.13'].length(); 
  var homeNum;
  var netNum;
  var cpNum;
  
  while(i--)
  {
  if (msg['PID']['PID.13'][i]['PID.13.2'].toString() == "PRN")
  {
      homeNum = msg['PID']['PID.13'][i]['PID.13.9'];
  }
  
  if (msg['PID']['PID.13'][i]['PID.13.2'].toString() == "NET")
  {
      netNum = msg['PID']['PID.13'][i]['PID.13.4'];
  }
  
  if (msg['PID']['PID.13'][i]['PID.13.2'].toString() == "CP")
  {
      cpNum = msg['PID']['PID.13'][i]['PID.13.9'];
  }
  
  msg['PID']['PID.13'][i] = "";
  }
  
  msg['PID']['PID.13'][0]['PID.13.1'] = homeNum;
  msg['PID']['PID.13'][0]['PID.13.4'] = netNum;
  msg['PID']['PID.13'][1]['PID.13.1'] = cpNum;
  </code></pre>
  
  <p>Sample HL7 msg I am using before transforms (from our test system, NOT live data)</p>
  
  <p>It should resemble this instead:</p>
  
  <p>|9999999999^^^test@test.com~99999999999~~~|</p>
  
  <p>Any ideas/pointers on why it's not moving?</p>