Announcement

Collapse
No announcement yet.

Mapping Multiple Segments in JavaScipt

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

  • Mapping Multiple Segments in JavaScipt

    Can someone please help me? I'm trying to map multiple segments from a repeating segment of AIP, and I'm having trouble with the for () statement. In a nutshell what I'm trying to do is map every repetition of AIP segment, and map these three sub elements. Do to a variety of messages we receive and process, I'm building the messages at the end. I need to be able to build the segments into a variable, which at a later stage will help me construct the full HL7 message. Can someone please tell me what I need to enter in the for () to be able to accomplish this for-loop? None of the other threads have helped me, so I thought I'd write my problem and see if anyone can give me a specific answer?

    var count = 1;
    var aipSeg = "";
    var segCount = 0;

    for ()
    {
    var aip_3_1 = msg['AIP'][segCount]['AIP.3']['AIP.3.1'].toString();
    var aip_3_2 = msg['AIP'][segCount]['AIP.3']['AIP.3.2'].toString();
    var aip_3_3 = msg['AIP'][segCount]['AIP.3']['AIP.3.3'].toString();

    var aipSeg = aipSeg+"AIP|"+count+"||"+aip_3_1+"^"+aip_3_2+"^"+a ip_3_3+"\\x0d";

    var count = count + 1;
    var segCount = segCount + 1;
    }
    channelMap.put('aipSeg', aipSeg);

    Post edited by: aht75, at: 11/21/2008 08:15

    Post edited by: aht75, at: 11/21/2008 08:16

  • #2
    Re:Mapping Multiple Segments in JavaScipt

    I figured it out. Here is how I resolved it, just in case anyone else comes across such an issue:

    var count = 1;
    var aipSeg = "";
    var segCount = 0;

    for each (segment in msg.children() ){
    if(segment.name() == "AIP"){

    var aip_3_1 = msg['AIP'][segCount]['AIP.3']['AIP.3.1'].toString();
    var aip_3_2 = msg['AIP'][segCount]['AIP.3']['AIP.3.2'].toString();
    var aip_3_3 = msg['AIP'][segCount]['AIP.3']['AIP.3.3'].toString();

    var aipSeg = aipSeg+"AIP|"+count+"||"+aip_3_1+"^"+aip_3_2+"^"+a ip_3_3+"\x0d";
    var count = count + 1;
    var segCount = segCount + 1;

    }
    }

    channelMap.put('aipSeg', aipSeg);

    Comment

    Working...
    X