Announcement

Collapse

Mirth Connect 4.3.0 Released!

Mirth Connect 4.3.0 is now available as an appliance update and on our GitHub page.

This is a major release containing new features like adding new functionality to the Mirth Connect Setup Wizard, adding the ability for resource and channel-specific classloaders to load child-first or parent-first, and added a default implementation of the getObjectsForSwaggerExamples() method in the ServicePlugin class. This release also contains enhancements for the Mirth Connect Administrator Launcher, the Mirth Connect Docker images, and several bug fixes and security improvements.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Fixing incoming HL7 data

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

  • Fixing incoming HL7 data

    Here is some JavaScript that I put inside of a destination transformer. It traverses every OBR segment and whenever there is a blank Observation date, it copies the Speciment date to the Observation date. Pretty simple requirements. Everything works except the assignment from OBR-14 to OBR-7:

    Code:
    	var CountOBR=0;
    	for each (x in tmp..OBR)
            {
    	    if ( tmp['OBR']['OBR.7']['OBR.7.1'][CountOBR]==undefined)
    	    {
    		// Set the Observation date equal to the Specimen date
    		tmp['OBR']['OBR.7']['OBR.7.1'][CountOBR]=tmp['OBR']['OBR.14']['OBR.14.1'][CountOBR];
    	    }
    	    CountOBR++;
    	}
    It took a while to figure out that "undefined" is a keyword similar to what null is to a SQL database and should not be placed in quotes. Got that working.

    Based on other code examples I expected to use x['OBR']['OBR.7']['OBR.7.1'] to reference this HL7 but this does not work so I used tmp['OBR']['OBR.7']['OBR.7.1'][CountOBR] instead. Why are some able to get this to work and others have not?

    The assignment also doesn't work:
    tmp['OBR']['OBR.7']['OBR.7.1'][CountOBR]=tmp['OBR']['OBR.14']['OBR.14.1'][CountOBR];

    What changes are needed to make this work?

    Thanks,
    John

  • #2
    Re:Fixing incoming HL7 data

    Hi jlehew

    You could try the next one:
    Code:
    tmp['OBR'][CountOBR]['OBR.7']={};
    tmp['OBR'][CountOBR]['OBR.7']['OBR.7.1']=tmp['OBR'][CountOBR]['OBR.14']['OBR.14.1'].toString();

    Comment


    • #3
      Re:Fixing incoming HL7 data

      That is closer, but it puts "[object Object]" in the output HL7 file:

      OBR|2|6604330|HL373244W|%SBNOCULI^REFLEXIVE CULTURE^^%SBNOCULI^REFLEXIVE CULTURE|||[object Object]20071201213201|||||||20071201213201||^^^|||||RGA^Q uest Diagnostics-Houston^5850 Rogerdale Road^Houston^TX^77072-1602^John G Buick MD|20071202180500|||F|||||||||||||||||||

      I tried this:
      tmp['OBR'][CountOBR]['OBR.7']['OBR.7.1']={};
      instead of this:
      tmp['OBR'][CountOBR]['OBR.7']={};
      and it worked!!



      What does the ={}; syntax do?

      Thanks,
      John

      Comment


      • #4
        Re:Fixing incoming HL7 data

        Happy it works.

        the '{}' sytax is a JavsScript trick to assign an Object to a var. I thought the problem related with you code was than there were no OBR.7 structure created.

        I think you can remove safely the line 'tmp['OBR'][CountOBR]['OBR.7']['OBR.7.1']={};'

        Regards.

        Comment


        • #5
          Re:Fixing incoming HL7 data

          You're right. That line is not needed.

          Do you know the syntax to access the variable "x" from the "for each" statement? I tried to print the value but it never returns anything. Assignments also don't seem to work on the variable "x".

          Code:
             // This doesn't print the values
             logger.info("x['OBR']['OBR.7']['OBR.7.1'] = " + x['OBR']['OBR.7']['OBR.7.1']);
             logger.info("x['OBR']['OBR.14']['OBR.14.1'] = " + x['OBR']['OBR.14']['OBR.14.1']);
          
             // This doesn't assign properly
             x['OBR']['OBR.7']['OBR.7.1'] = x['OBR']['OBR.14']['OBR.14.1'];
             logger.info("x['OBR']['OBR.7']['OBR.7.1'] = " + x['OBR']['OBR.7']['OBR.7.1']);

          Thanks,
          John

          Comment


          • #6
            Re:Fixing incoming HL7 data

            You're right. That line is not needed.

            Do you know the syntax to access the variable "x" from the "for each" statement? I tried to print the value but it never returns anything. Assignments also don't seem to work on the variable "x".

            Code:
               // This doesn't print the values
               logger.info("x['OBR']['OBR.7']['OBR.7.1'] = " + x['OBR']['OBR.7']['OBR.7.1']);
               logger.info("x['OBR']['OBR.14']['OBR.14.1'] = " + x['OBR']['OBR.14']['OBR.14.1']);
            
               // This doesn't assign properly
               x['OBR']['OBR.7']['OBR.7.1'] = x['OBR']['OBR.14']['OBR.14.1'];
               logger.info("x['OBR']['OBR.7']['OBR.7.1'] = " + x['OBR']['OBR.7']['OBR.7.1']);

            Thanks,
            John

            Comment

            Working...
            X