Announcement

Collapse
No announcement yet.

Copying OBR field to OBX, mult. segments-I give up

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

  • Copying OBR field to OBX, mult. segments-I give up

    Goal:
    One LLP Source
    One LLP Destination
    Copy OBR.10.1 to OBX.15.1 in multiple segments.

    Using this code:
    Code:
    var techID = msg['OBR']['OBR.10']['OBR.10.1'].toString();
    var CountOBX=0;
    for each obx in msg..OBX)
        {
            msg['OBX']['OBX.15']['OBX.15.1'][CountOBX] = techID;
            CountOBX++;
        }
    works if the message has only one OBR/OBX family.

    If the message has multiple OBR segments with a varying number of OBX segments after each, it won't work - it spits out XML in the hl7 field. I can't figure out why it will spit out the value of OBX.15.1 in correct format when not looping, but in XML format when looping.

    I've been searching the forum for two days for a direction to go in. Here's what I've been trying to do:

    for every OBR segment in the message {

    Get the value of OBR.10.1, in string format, to 'variable'

    for every OBX segment under that OBR {

    write the value of 'variable' to OBX.15.1
    go to the next OBX segment
    }

    No more OBX's, go to the next OBR statement
    }

    I'm dyin here.

  • #2
    Re:Copying OBR field to OBX, mult. segments-I give up

    Hi,

    Here is a pointer for you:
    var techID = "";
    for each (segment in msg.children() ){
    if(segment.name() == "OBR"){
    techID = segment['OBR.10']['OBR.10.1'].toString();
    }
    else if(segment.name() == "OBX"){
    segment['OBX.15']['OBX.15.1'] = techID;
    }
    }

    Hope that helps!

    /Daniel
    Daniel Svanstedt
    Software Engineer
    Mirth Corporation

    Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
    Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

    Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!

    Comment


    • #3
      Re:Copying OBR field to OBX, mult. segments-I give

      Thanks,
      I'll play around with it.
      If it works I'll document it in the forums.

      Comment


      • #4
        Re:Copying OBR field to OBX, mult. segments-I give

        Oh good grief that was too easy. :silly: Thank you.

        In this case the forum actually made it more confusing. I didn't think that the engine just processed the message sequentially.

        Wanting to understand (so I can repeat it) - I'm not sure what msg.children() is doing.



        dans wrote:
        Hi,

        Here is a pointer for you:
        var techID = "";
        for each (segment in msg.children() ){
        if(segment.name() == "OBR"){
        techID = segment['OBR.10']['OBR.10.1'].toString();
        }
        else if(segment.name() == "OBX"){
        segment['OBX.15']['OBX.15.1'] = techID;
        }
        }

        Hope that helps!

        /Daniel

        Comment


        • #5
          Re:Copying OBR field to OBX, mult. segments-I give

          msg.children() returns a XMLList containing all the segments.

          Good reference for E4X commands: http://www.faqts.com/knowledge_base/...phtml/fid/1762
          Daniel Svanstedt
          Software Engineer
          Mirth Corporation

          Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
          Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

          Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!

          Comment


          • #6
            Re:Copying OBR field to OBX, mult. segments-I give

            Thanks again.

            One problem I've had (which means others are) is knowing whether things we see here in the forum like:

            channelMap.put
            something.children()

            etc...are proprietary to Mirth or standard E4X/ECMA/JavaScript syntax.


            dans wrote:
            msg.children() returns a XMLList containing all the segments.

            Good reference for E4X commands: http://www.faqts.com/knowledge_base/...phtml/fid/1762

            Comment

            Working...
            X