Announcement

Collapse
No announcement yet.

Is this error actually expected behavior?

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

  • Is this error actually expected behavior?

    Hello Mirth Community,

    I assume I have committed a faux pas in my transformer and the end result was expected just not desirable.

    Server: Windows Server 2012 R2 Standard
    Version of Java: Java 8 111 x64
    Version of Mirth: 3.4.2.8129
    Database: Postgres 3.6
    I have cleared the Java Cache

    Issue appears under the Destination Transformer:

    I need to move data from 1 field in a custom segment into FT1.20. Prior to this code running their isn't any values in fields past FT1.10. By assigning values to FT1.20 I am creating those fields. If the source string contains a comma it also is moved into FT1.20.2. Here is my code that caused the unexpected behavior.


    Code:
    var testStr = msg['ZLQ']['ZLQ.8']['ZLQ.8.1'].toString();
    
    // if a comma exists the field is 'lastname, firstname' and thus
    // belongs in ft1.20.2 which is the full name of the user
    if(/,/.test(testStr)){
    	msg['FT1']['FT1.20']['FT1.20.2'] = testStr;
    }
    
    // ft1 20.1 is username and is limited in length in the result system. 
    msg['FT1']['FT1.20']['FT1.20.1'] = testStr.slice(0, 20);

    that runs but here is the resulting xml and actual hl7 of the FT1 sent. The value of ZLQ.8 is Hope, Bob for this example.
    <FT1>
    <FT1.20>
    <FT1.20.2>Hope, Bob</FT1.20.2>
    <FT1.20.1>Hope, Bob</FT1.20.1>
    </FT1.20>
    </FT1>

    FT1||||||||||||||||||||^Hope, Bob^Hope, Bob
    The result is FT1.20.2 and somehow FT1.20.3 are populated. 20.1 is blank even though there is code to populate it. And where did 20.3 come from? To correct this error I just run my if statement after my slice statement it comes out as I expected.

    So, is this a bug or expected behavior because I created the fields in reverse order? Is there a proper way to code this behavior?


    Thank you for your time,
    confused interface programmer

  • #2
    I have had unexpected results when acting on the XML out of sequence.
    try this.

    var testStr = msg['ZLQ']['ZLQ.8']['ZLQ.8.1'].toString();

    // ft1 20.1 is username and is limited in length in the result system.
    msg['FT1']['FT1.20']['FT1.20.1'] = testStr.slice(0, 20);

    // if a comma exists the field is 'lastname, firstname' and thus
    // belongs in ft1.20.2 which is the full name of the user
    if(/,/.test(testStr)){
    msg['FT1']['FT1.20']['FT1.20.2'] = testStr;
    }
    Best,

    Kirby

    Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

    Appliance Version 3.11.4
    Mirth Connect Version 3.8.0
    Java Version 1.6.0_45-b06
    Java (64 bit) Version 1.6.0_45-b06
    Java 7 (64 bit) Version 1.7.0_151-b15
    Java 8 (64 bit) Version 1.8.0_181-b13
    PostgreSQL Version 9.6.8

    Comment


    • #3
      Thank you kirbykn2,
      That is actually the solution I went with. I am also glad to see others in the community have had weird behavior when working with the fields out of sequence.

      But is this an error in Mirth that would deserve a bug report?

      Comment


      • #4
        I would think yes.
        Best,

        Kirby

        Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

        Appliance Version 3.11.4
        Mirth Connect Version 3.8.0
        Java Version 1.6.0_45-b06
        Java (64 bit) Version 1.6.0_45-b06
        Java 7 (64 bit) Version 1.7.0_151-b15
        Java 8 (64 bit) Version 1.8.0_181-b13
        PostgreSQL Version 9.6.8

        Comment

        Working...
        X