web stats
OBX Filtering - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-10-2019, 04:18 PM
tommyung08 tommyung08 is offline
What's HL7?
 
Join Date: Apr 2018
Posts: 4
tommyung08 is on a distinguished road
Default OBX Filtering

Hi All,

I'm wondering if anyone have ever done OBX filtering. Here is what i like to accomplish.

Original message with multiple obx segment.

MSH|^~\&|TES|TEST|HIS|HIS|20190109105752||ORU^R01| 20190109105752664|P|2.5
PID|||0911||TEST^PATIENT^^^^||19810911|M||Caucasia n|^^^^|||||||
OBR|1||000000000003||||20170808111129||||||||||||| ||20190109105735|||P|||||||^^^
OBX|1|ED|Report^..ATS_COMPLETE||SeS^application^Pd f^Base64^JVBERi0xLjMNJf////8NMSAwIG9iag08PA0vVGl0bGUgKP7/ADAAOQAxA
OBX|2|CF|FEV10PRE^FEV1_PRE|Results|4.32|L|4.10-5.91|N|||F|||20170808111256|||||20190109105751
OBX|3|CF|FEV1LLN^FEV1_LLN|Results|4.10||||||F|||20 170808111129|||||20190109105751
OBX|4|CF|FEV1ZSCORE^FEV1_Z-Score|Results|-1.24||||||F|||20170808111129|||||20190109105751
OBX|5|CF|FEV1PREREF^FEV1_Pre%Ref|Results|86.3|%||| ||F|||20170808111129|||||20190109105751
OBX|6|CF|FEV1ZSCORE^FEV1_Z-Score|Results|-1.24||||||F|||20170808111129|||||20190109105751
OBX|7|CF|FEV1FVC0PRE^FEV1/FVC_PRE|Results|66.06|%|71.16-90.51|L|||F|||20170808111256|||||20190109105751
OBX|8|CF|FEV1FVCLLN^FEV1/FVC_LLN|Results|71||||||F|||20170808111129|||||201 90109105751
OBX|9|CF|FEV1FVCZSCORE^FEV1/FVC_Z-Score|Results|-2.51||||||F|||20170808111129|||||20190109105751
OBX|10|CF|FEV1FVCPREREF^FEV1/FVC_Pre%Ref|Results|81.7|%|||||F|||20170808111129| ||||20190109105751
OBX|11|CF|FEV1FVCZSCORE^FEV1/FVC_Z-Score|Results|-3||||||F|||20170808111129|||||20190109105751
OBX|12|CF|FVC0PRE^FVC_PRE|Results|6.54|L|5.20-7.33|N|||F|||20170808111256|||||20190109105751
OBX|13|CF|FVCLLN^FVC_LLN|Results|5.20||||||F|||201 70808111129|||||20190109105751
OBX|14|CF|FVCZSCORE^FVC_Z-Score|Results|0.42||||||F|||20170808111129|||||201 90109105751


End Result would be something like this:

Multiple OBX segment with only what match OBX3.1 criteria and output the result with renumbering the OBX segment as well.

Only output the obx segment at are required to be sent.

MSH|^~\&|TES|TEST|HIS|HIS|20190109105752||ORU^R01| 20190109105752664|P|2.5
PID|||0911||TEST^PATIENT^^^^||19810911|M||Caucasia n|^^^^|||||||
OBR|1||000000000003||||20170808111129||||||||||||| ||20190109105735|||P|||||||^^^
OBX|1|ED|Report^..ATS_COMPLETE||SeS^application^Pd f^Base64^JVBERi0xLjMNJf////8NMSAwIG9iag08PA0vVGl0bGUgKP7/ADAAOQAxA
OBX|2|CF|FEV10PRE^FEV1_PRE|Results|4.32|L|4.10-5.91|N|||F|||20170808111256|||||20190109105751
OBX|3|CF|FVC0PRE^FVC_PRE|Results|6.54|L|5.20-7.33|N|||F|||20170808111256|||||20190109105751
OBX|4|CF|PEF0PRE^PEF_PRE|Results|10.47|L/s|8.75-14.07|N|||F|||20170808111256|||||20190109105751


Thank you.

Much appreciated.

I'm running Mirth 3.5.2

Last edited by tommyung08; 01-10-2019 at 04:27 PM.
Reply With Quote
  #2  
Old 01-10-2019, 09:28 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 598
agermano is on a distinguished road
Default

Code:
var filteredOBX = new XMLList();

for each (var obx in msg.OBX) {
    var keep = false;
    // change if statements to meet your criteria
    if (obx['OBX.2']['OBX.2.1'].toString() == 'ED') {
        keep = true;
    }
    else if (obx['OBX.2']['OBX.2.1'].toString() == 'CF' &&
      obx['OBX.3']['OBX.3.1'].toString().match(/PRE$/)) {
        keep = true;
    }
    
    if (keep) {
        filteredOBX += obx;
        obx['OBX.1']['OBX.1.1'] = filteredOBX.length();
    }
}

msg.OBX = filteredOBX;
Reply With Quote
Reply

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:02 PM.


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