Announcement

Collapse
No announcement yet.

Creating New Segments

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

  • Creating New Segments

    I am thinking that I need to use the create segments after or before for this, but I am trying to figure out how to do that exactly. I am iterating through the OBX and saving the OBX's I need to a variable. I then need to make those become OBX|1| and OBX|2|. Well, I am doing this, but it is placing my new OBX's at the bottom. They should be placed after PV2 and before AL1. Can someone help me with that part??

    Here is what I have so far:

    Code:
    for each(obx in msg..OBX)
    {
    if(obx['OBX.3']['OBX.3.2'].toString()=="WEIGHT")
    {
    var obxA= msg.children()[obx.childIndex()];
    }
    }
    
    for each(obx in msg..OBX)
    {
    if(obx['OBX.3']['OBX.3.2'].toString()=="HEIGHT")
    {
    var obxB=msg.children()[obx.childIndex()];
    }
    }
    
    delete msg['OBX'];
    
    
    msg['OBX'][0]=obxA;
    msg['OBX'][1]=obxB;

  • #2
    The createSegmentAfter function (in the References tab) should accomplish what you're looking for. Also, I created similar functions: createSegmentBefore, insertSegmentBefore, and insertSegmentAfter. Between the four of those you'll be able to create/insert wherever you want.
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment


    • #3
      Originally posted by narupley View Post
      The createSegmentAfter function (in the References tab) should accomplish what you're looking for. Also, I created similar functions: createSegmentBefore, insertSegmentBefore, and insertSegmentAfter. Between the four of those you'll be able to create/insert wherever you want.
      I know this is an old post, but Mr Rupley, you mentioned (in the References Tab) in response. Can you explain? I'm new to Mirth and I cannot find the Reference Tab you have mentioned. The createSegmentAfter function is the only function of yours I have not been able to find the code for. I see many references to this function, but not the actual coded function. If you could help, I would greatly appreciate it.
      thanks

      Comment


      • #4
        Originally posted by rkMC View Post
        I know this is an old post, but Mr Rupley, you mentioned (in the References Tab) in response. Can you explain? I'm new to Mirth and I cannot find the Reference Tab you have mentioned. The createSegmentAfter function is the only function of yours I have not been able to find the code for. I see many references to this function, but not the actual coded function. If you could help, I would greatly appreciate it.
        thanks
        It's on the left of the message tree part. In the transformer/filters
        Attached Files

        Comment


        • #5
          Those are the commands. I need the code for the function itself. I assume these are not built into Mirth Connect. When I have ran a message thru my channel with this command included, it comes back and says the command is undefined. Thanks again for your help.
          Mirth 3.5.0.8232

          Comment


          • #6
            Originally posted by rkMC View Post
            I know this is an old post, but Mr Rupley, you mentioned (in the References Tab) in response. Can you explain? I'm new to Mirth and I cannot find the Reference Tab you have mentioned. The createSegmentAfter function is the only function of yours I have not been able to find the code for. I see many references to this function, but not the actual coded function. If you could help, I would greatly appreciate it.
            thanks
            Try the link: http://www.mirthcorp.com/community/f...2&postcount=16

            Comment


            • #7
              I appreciate the link. Only thing is this just has 3 routines, CreateSegmentBefore, InsertSegmentAfter, InsertSegmentBefore. The function I am looking for is not on this link, createSegmentAfter.

              Comment


              • #8
                PHP Code:
                [2017-07-24 08:46:19,819]  INFO  (deploy:?): 
                function 
                createSegmentAfter(namesegment) {
                    var 
                msgObj segment;
                    while (
                msgObj.parent() != undefined) {
                        
                msgObj msgObj.parent();
                    }
                    
                msgObj.insertChildAfter(segment[0], new XML("<" name "></" name ">"));
                    return 
                msgObj.child(segment[0].childIndex() + 1);

                I just put some script in the deploy script of a blank channel:

                PHP Code:
                var fBody createSegmentAfter.toString();
                logger.info(fBody); 
                Last edited by amble; 07-23-2017, 11:55 PM.

                Comment

                Working...
                X