web stats
Deleting unwanted fields from HL7 message - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 06-07-2018, 07:41 AM
donsls donsls is offline
OBX.2 Kenobi
Join Date: Feb 2010
Posts: 71
donsls is on a distinguished road
Default Deleting unwanted fields from HL7 message

The ADT FL7 messages that we are receiving from the main ADT system to Mirth connect 3.5 contains fields that we don't require in the downstream systems. These fields start from msg['PID']['PID.5']['PID.5.7'] to msg['PID']['PID.5']['PID.5.101']. Almost 100 fields.
We want to delete these fields before Mirth sends them to the downstream systems.
I would like to know whether someone could help me with a code sample for this.
For ex. to iterate through the IN1 segments, we use the following :

var IN1s = msg['IN1'];

for (var i=0; i < IN1s.length(); i++)
var in21 = IN1s[i]['IN1.2']['IN1.2.1'].toString();
//Do something here

Is there a similar way to do this for fields from ['PID.5.7'] to ['PID.5.101']
Reply With Quote
Old 06-07-2018, 09:06 AM
agermano agermano is offline
Mirth Guru
Join Date: Apr 2017
Location: Indiana, USA
Posts: 435
agermano is on a distinguished road

// for each in case PID-5 is repeating
for each (var pid5 in msg['PID']['PID.5']) {
  // create empty list of components we want to keep
  var newPID5 = new XMLList();
  for (var i = 1; i < 7; i++) {
    // add these to the component list of keepers
    newPID5 += pid5['PID.5.' + i];
  // set the component list to only those we want to keep
You can also use the delete command to remove individual xml elements, but since you are only keeping a known set that is a small percentage of the total, it's easier to specify what you want to keep rather than what you want to remove.
Reply With Quote
Old 06-07-2018, 10:50 AM
kirbykn2's Avatar
kirbykn2 kirbykn2 is offline
Mirth Guru
Join Date: Sep 2014
Location: Michigan
Posts: 548
kirbykn2 is on a distinguished road

You might consider using an outbound message template, and only send what you want too.

Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

Appliance Version 3.10.4
Mirth Connect Version
Java Version 1.6.0_45-b06
Java (64 bit) Version 1.6.0_45-b06
Java 7 (64 bit) Version 1.7.0_79-b15
Java 8 (64 bit) Version 1.8.0_121-b13
PostgreSQL Version 9.4.5
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -8. The time now is 02:13 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Mirth Corporation