Announcement

Collapse
No announcement yet.

CreateSegmentAfter Errors 1.8.0

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

  • CreateSegmentAfter Errors 1.8.0

    I can't seem to get createSegmentAfter function to work in 1.8.0 RC2. I would like to create HL7 messages from scratch.

    I have the following in the destination transformer:

    Code:
    var MSH = createSegment('MSH', tmp);
    MSH['MSH.1'] = "|";						
    MSH['MSH.2'] = "^~\&";
    
    var PID = createSegment('PID', tmp);
    PID['PID.1'] = "";
    
    var ORC = createSegment('ORC', tmp);
    ORC['ORC.1']['ORC.1.1'] = "BLA";
    
    var OBR = createSegment('OBR', tmp);
    OBR['OBR.3']['OBR.3.1'] = "123456789";
    
    var OBX = createSegment('OBX', tmp);
    
    for (var i=0; i<3; i++){
    	OBX['OBX.1'] = "";
    	OBX['OBX.1']['OBX.1.1'] = i+2;
    	OBX['OBX.2'] = "";
    	OBX['OBX.2']['OBX.2.1'] = "2";
    	OBX['OBX.3'] = "";
    	OBX['OBX.3']['OBX.3.1'] = i;
    	tmp['OBX'][i] = OBX;
    }
    How do I insert for example a ZZ segment after ORC?
    The following works:
    Code:
    var ZZ = createSegment('ZZ');
    ZZ['ZZ.1']['ZZ.1.1'] = "Hello World";
    tmp['ORC'] +=  ZZ;
    However, the following doesn't:
    Code:
    var ZZ = createSegmentAfter('ZZ', 'ORC');
    ZZ['ZZ.1']['ZZ.1.1'] = "Hello World"
    
    Error: TypeError: Cannot read property "ZZ.1" from undefined
    Am I using the function properly?

  • #2
    Re:CreateSegmentAfter Errors 1.8.0

    Create segment *was* changed in version 1.8, so I'm wondering if your code worked in a previous version. Let me know if it did or not.

    Either way though, you are using it incorrectly. You should do something like:
    Code:
    var ZZ = createSegmentAfter('ZZ', msg['ORC']);
    Jacob Brauer
    Director, Software Development
    NextGen Healthcare

    sigpic

    Comment


    • #3
      Re:CreateSegmentAfter Errors 1.8.0

      I haven't tried that code on the previous version. So, I am not sure. Hmm, still can't get it to work. I tried two ways below, but no luck.

      I tried:
      Code:
      var ZZ = createSegmentAfter('ZZ', msg['ORC']);
      ZZ['ZZ.1']['ZZ.1.1'] = "Hello World";
      
      TypeError: Cannot read property "ZZ.1" from undefined
      and I thought it would be more like, so then I tried:
      Code:
      var ZZ = createSegmentAfter('ZZ', tmp['ORC']);
      ZZ['ZZ.1']['ZZ.1.1'] = "Hello World";
      
      Error: java.lang.IllegalArgumentException: Cursors not in same document

      Comment


      • #4
        Re:CreateSegmentAfter Errors 1.8.0

        ┬┐Does exist the ORC segment in the template ?

        If you're having problems with the createSegment function, you could try adding the ZZ segment in the template (and if you doesn't neeed it, you can remove it with "delete tmp['ZZ']; command)

        Comment


        • #5
          Re:CreateSegmentAfter Errors 1.8.0

          Create segment doesn't return anything. It modifies the current msg object, so you would have to say msg['ZZ'] afterward to use your added segment.

          See http://www.mirthproject.org/fisheye/...ansformer.java for further reference.
          Jacob Brauer
          Director, Software Development
          NextGen Healthcare

          sigpic

          Comment


          • #6
            Re:CreateSegmentAfter Errors 1.8.0

            In addition to my last post, we are adding a parameter right now for you to pass in the msg object that it adds the new segment to. This way you will be able to pass in either msg or tmp.
            Jacob Brauer
            Director, Software Development
            NextGen Healthcare

            sigpic

            Comment


            • #7
              Re:CreateSegmentAfter Errors 1.8.0

              No, the ORC segment didn't exist in the template. My template was empty. Also, deleting the segments that I don't need from a template, is a good idea. I'll keep that in mind. That's great if you are adding that parameter. I'll look forward to seeing it in one of your future releases. For the time being, I'll just stick with what works for me now.

              Anywhoo, thank you for your quick responses. I'd like to add that I'm quite pleased with Mirth so far. I've tried other open source applications and this one in particular is one of my favourites. It's well written. Great work!

              Comment

              Working...
              X