Announcement

Collapse

Mirth Connect 3.12.0 Released!

Mirth Connect 3.12.0 is now available as an appliance update and on our GitHub page. This release includes database performance improvements, improves visual HL7 representation, message pruning, keystore handling, PDF generation, community contributions, and fixes several security vulnerabilities. This release also contains many improvements to commercial extensions. See the release notes for the list of fixes and updates.

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

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

Access global function

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

  • Access global function

    I have 2 functions that are located in my global script. How can I call those functions from a transformer?

    Here is what I'm trying to do:
    tempMRN = "'" + MrnID(msg['PID']['PID.3'].toString()) + "'";
    tempPID = "'" + PatID(msg['PID']['PID.3'].toString()) + "'";

    Here are the functions:
    Code:
    function PatID(sValue) {
    	var PI;
    	var mySplitPID = sValue.split("~"«»);
    	for(i = 0; i < mySplitResult.length; i++){
    		var mySplitOcc = mySplitResult[i];
    		if (mySplitOcc[5] == 'PI'){
    			PI = mySplitOcc[1].tostring();
    		}
    	}
    	return PI.trim();
    }
    
    function MrnID(sValue) {
    	var MRN;
    	var mySplitPID = sValue.split("~"«»);
    	for(i = 0; i < mySplitResult.length; i++){
    		var mySplitOcc = mySplitResult[i];
    		if (mySplitOcc[5] == 'MR'){
    			MRN = mySplitOcc[1].tostring();
    		}
    	}
    	return MRN.trim();
    }
    Reid Hospital and Healthcare

  • #2
    Re:Access global function / Mirth HL7 Parser

    On a side note with regards to the HL7 parser in Mirth:

    I have viewed the same transaction in Mirth, NeoBrowse, and HL7Browser (http://www.nule.org/wp/?page_id=62)

    MSH encoding characters:
    MSH|^[email protected]|

    This is the data in PID 3:
    1234567^8^M10^RNZ^PN~658947^^^RNZ^MR~123456789^^^U S GOVT^SS~321654^^^RNZ^PI~987654321^^^RHHCS^EE


    In both NeoBrowse and HL7Browser, I can view each occurrence of PID 3:
    In example:
    PID.3(1).1 1234567^8^M10^RNZ^PN
    ___PID.3(1).1 - 1234567
    ___PID.3(1).2 - 8
    ___PID.3(1).3 - M10
    ___PID.3(1).4 - RNZ
    ___PID.3(1).5 - PN
    PID.3(2).2 658947^^^RNZ^MR
    PID.3(3).3 123456789^^^US GOVT^SS
    PID.3(4).4 321654^^^RNZ^PI
    PID.3(5).5 987654321^^^RHHCS^EE


    This is the information I am getting in Mirth:

    mySplit: <PID.3><PID.3.1>1234567</PID.3.1><PID.3.2>8</PID.3.2><PID.3.3>M10</PID.3.3><PID.3.4>RNZ</PID.3.4><PID.3.5>PN,658947</PID.3.5><PID.3.6/><PID.3.7/><PID.3.8>RNZ</PID.3.8><PID.3.9>MR,123456789</PID.3.9><PID.3.10/><PID.3.11/><PID.3.12>US GOVT</PID.3.12><PID.3.13>SS,321654</PID.3.13><PID.3.14/><PID.3.15/><PID.3.16>RNZ</PID.3.16><PID.3.17>PI,987654321</PID.3.17><PID.3.18/><PID.3.19/><PID.3.20>RHHCS</PID.3.20><PID.3.21>EE</PID.3.21></PID.3>
    mySplit[0]: <PID.3><PID.3.1>1234567</PID.3.1><PID.3.2>8</PID.3.2><PID.3.3>M10</PID.3.3><PID.3.4>RNZ</PID.3.4><PID.3.5>PN
    mySplit[1]: 658947</PID.3.5><PID.3.6/><PID.3.7/><PID.3.8>RNZ</PID.3.8><PID.3.9>MR
    mySplit[2]: 123456789</PID.3.9><PID.3.10/><PID.3.11/><PID.3.12>US GOVT</PID.3.12><PID.3.13>SS
    mySplit[3]: 321654</PID.3.13><PID.3.14/><PID.3.15/><PID.3.16>RNZ</PID.3.16><PID.3.17>PI
    mySplit[4]: 987654321</PID.3.17><PID.3.18/><PID.3.19/><PID.3.20>RHHCS</PID.3.20><PID.3.21>EE</PID.3.21></PID.3>


    Is there a way to loop through each occurence in the actual HL7 message, rather than the XML data?

    Post edited by: afterdark23, at: 02/08/2008 15:18
    Reid Hospital and Healthcare

    Comment


    • #3
      Re:Access global function / Mirth HL7 Parser

      Anyone know how can I split by a carriage return?

      These are the regular expressions that I have tried:

      //var re = /\r/
      //var re = /[rn]/g
      var re = /[rn]/;
      //var crRetLnFeed = "rn"
      //re = /\s*\r\s*/ ;


      //Split raw HL7 message by Carriage Return
      myRawMessage = messageObject.getRawData().split(re)
      Reid Hospital and Healthcare

      Comment


      • #4
        Re:Access global function / Mirth HL7 Parser

        Code:
        var lines = messageObject.getRawData().split('\\r')
        Post edited by: albertosaez, at: 02/14/2008 15:29

        Comment


        • #5
          Re:Access global function / Mirth HL7 Parser

          that worked. I found a way to loop through each occurrence and get the proper MRN and Visit Number.

          Back to my original question:

          How do I access the PatID function located in the global script from a transformer?
          Reid Hospital and Healthcare

          Comment

          Working...
          X