Announcement

Collapse
No announcement yet.

Dealing with a simple array (sent by POST)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dealing with a simple array (sent by POST)

    Hi,

    I am sending from my Application to MIRTH an array with samples IDs.

    From my Application:

    App::import('Core', 'HttpSocket');
    $HttpSocket = new HttpSocket();
    $results = $HttpSocket->post('http://xxx.x.x.x:yyyy/new_sample/', array('sendAp' => 'LINK',
    'sendFac' => 'HOSPITAL',
    'recAp' => 'DEP',
    'recFac' => 'SYS',
    'PID' => $pat_id['MirthLog']['rgh'],
    'pName' => $pat_name['MirthLog']['nome'],
    'pBirth' => $pat_bir['MirthLog']['nasc'],
    'pGend' => 'F',
    'bcode' => $sample, // array with samples ID***
    'ncode' => $n_amostra, // number of samples
    'orcID' => $exam_id['MirthLog']['codigo_coleta'],
    'sender' => 'APPLIC'));

    I am getting all this parameters in MIRTH, except the array "bcode"

    From MIRTH side:

    //NOT WORKING - empty array
    var barCode = sourceMap.get('parameters').get('bcode');

    // WORKS WHEN I GET ELEMENTS INDIVIDUALLY
    var barCode0 = sourceMap.get('parameters').get('bcode[0]');
    var barCode1 = sourceMap.get('parameters').get('bcode[0]');

    // NOT WORKING USING FOR - EMPTY ARRAY
    var barCode = [];
    var nCode = sourceMap.get('parameters').get('ncode'); // number of samples
    for (var i = 0; i < nCode; i++){
    var i2=i.toString();
    barCode[i] = sourceMap.get('parameters').get('bcode[i2]'); // SPM (samples)
    }

    What is wrong???
    Sorry, for this basic question, but I got stuck here since yesterday.

    Thanks a lot.

    Henrique Amaral

  • #2
    barCode[i] = sourceMap.get('parameters').get('bcode[i2]'); // SPM (samples)
    i2 is a literal the way you have it. try

    barCode[i] = sourceMap.get('parameters').get('bcode' + [i2]); // SPM (samples)

    Comment


    • #3
      Thanks cory cole!
      You helped me a lot.
      I just had to make slightly changes from your suggestion to get it working:

      var barCode = [];//initialize array
      var nCode = sourceMap.get('parameters').get('ncode'); // number of samples
      for (var i = 0; i < nCode; i++){
      var i2 = i.toString();
      barCode[i] = sourceMap.get('parameters').get('bcode'+'['+i2+']');
      }

      Henrique Amaral-SIlva

      Comment

      Working...
      X