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

Is this possible?

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

  • Is this possible?

    Hello,

    I was wondering if it is possible, to retreive a message (with varied number of fields) via a file reader such as:

    MSH|^~\&|||||||||P|2.3.1
    PID|||123456789||||19000101|M

    and parse out all the data and put it into a table as follows:

    DB Table:
    LOCATION Field | DATA Field
    MSH.1 |
    MSH.2 ^~\&
    MSH.11.1 P
    MSH.12.1 2.3.1
    PID.3.1 123456789
    PID.7.1 19000101
    PID.8.1 M

    Any suggestions would be welcome!

  • #2
    Re:Is this possible?

    You may need to create a Transformer step, get the data items from the message, and insert into database. Refer:
    Channels
    http://www.mirthproject.org/index.ph...cman&Itemid=43
    Wiki
    http://www.mirthproject.org/index.ph...wiki&Itemid=44

    Also refer forum posts for sample code.

    Hope this helps!

    Post edited by: nshaik, at: 10/21/2008 08:07

    Comment


    • #3
      Re:Is this possible?

      Thank you for your reply. I was able to do what I was looking for by parsing the transformed HL7 message using a bit of javascript.

      Here's the code I placed in the transformer step:
      Code:
      importPackage(Packages.com.webreach.mirth.model); 
      var transformedOriginal = messageObject.getTransformedData();
      var transformedFixed = transformedOriginal.replace("&", "&"«»);
      
      var myConn = globalMap.get('dbConn');
      var i = 0;
      var myArray = transformedFixed.split("<"«»);
      var myResultArray = new Array();
      
      while(i != myArray.length-1) {	
      	// check if next element of array is closing tag (47 = /)
      	if (myArray[i+1].charCodeAt(0) == 47) {
      		var temp = myArray[i].split(">"«»);
      
      		if ((typeof(temp[0]) != "undefined"«») && (typeof(temp[1]) != "undefined"«»)) {
      			if ((temp[0].charCodeAt(0) != 47) && (temp[1].charCodeAt(0) != 47)) {
      				myResultArray[i] = temp[0] + " " + temp[1];
      				logger.info("myResultArray = " + myResultArray[i]);
      				var result = myConn.executeUpdate("INSERT into DataMine VALUES ('" + temp[0] + "', '" + temp[1] +"');"«»);
      			}
      		}
      	}
      	i++;
      }

      Comment

      Working...
      X