web stats
NTE to OBX Pairing and Conversion - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-18-2019, 09:57 PM
Golfmachine Golfmachine is offline
Mirth Newb
 
Join Date: Jun 2019
Posts: 13
Golfmachine is on a distinguished road
Default NTE to OBX Pairing and Conversion

Hello! Recently just learned how to start iterating but I am now facing a problem. This is part of the file I'm working on:

OBR|1|LB00869554|19060935|URINES^URINALYSIS|R|2019 1015000300||||||||20191015000300||00^N/A||OPD^OPD||||20191015001745||||||OPD^OPD
OBX|1|ST|UMACE^Physical Examination||""||||||F
OBX|2|ST|UCOLOR^ Color||Yellow|||N|||F|||20191015001740|CTRLAB^CENT RAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|3|ST|UAPP^ Appearance||Slightly Turbid|||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|4|ST|UPH^ Reaction / pH||5.0|||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|5|ST|USG^ Specific Gravity||1.015|||N|||F|||20191015001740|CTRLAB^CEN TRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|6|ST|UPRO^ Protein||Negative|||N|||F|||20191015001740|CTRLAB^ CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|7|ST|USU^ Sugar||Negative|||N|||F|||20191015001740|CTRLAB^CE NTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|8|ST|HUMICH^Microscopic||""||||||F
OBX|9|ST|FPC^ Pus Cells||0-1|/HPF||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|10|ST|SMRBC^ RBC||4-6|/HPF||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
NTE|1||\.br\RBC Morphology: 15% Normocytic, 85% Dysmorphic
OBX|11|ST|UYC^ Yeast Cells||!|/HPF||N|||D|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638

I need to do some mapping and use an outbound template as so:
MSH|^~\&|||||||^|||2.5
PID|||||^^|||
PV1|||||||||||||||||||||||||||||||||||||||||||||
ORC||||||||||^^^||^^^^|||||||||||
OBR||||^||||||||||||^^^||||||||||||||||&&&^^|&&&^^ |&&&^^|&&&^^||||||||||||||||^^|^^|^^|^^|^^|^^|^^|| ||

Currently, I map OBX using the following javascript:
var i = 0;

for each (seg in msg..OBX)
{
var obx = createSegment('OBX', tmp, i);
obx['OBX.1']['OBX.1.1'] = seg['OBX.1']['OBX.1.1'].toString();
obx['OBX.2']['OBX.2.1'] = seg['OBX.2']['OBX.2.1'].toString();
obx['OBX.3']['OBX.3.1'] = seg['OBX.3']['OBX.3.1'].toString();
obx['OBX.3']['OBX.3.2'] = seg['OBX.3']['OBX.3.2'].toString();
obx['OBX.5']['OBX.5.1'] = seg['OBX.5']['OBX.5.1'].toString();
obx['OBX.6']['OBX.6.1'] = seg['OBX.6']['OBX.6.1'].toString();
obx['OBX.7']['OBX.7.1'] = seg['OBX.7']['OBX.7.1'].toString();
obx['OBX.11']['OBX.11.1'] = seg['OBX.11']['OBX.11.1'].toString();
obx['OBX.19']['OBX.19.1'] = msg['OBR']['OBR.22']['OBR.22.1'].toString();
i++;
}

I am now tasked with converting NTE segments into OBX segments, with the conditions that:
NTE-1 will continue the OBX-1 numbering
NTE-3 will become OBX-5
Succeeding OBX-1 will continue the numbering scheme

For the given sample, it should become
OBR|1|LB00869554|19060935|URINES^URINALYSIS|R|2019 1015000300||||||||20191015000300||00^N/A||OPD^OPD||||20191015001745||||||OPD^OPD
OBX|1|ST|UMACE^Physical Examination||""||||||F
OBX|2|ST|UCOLOR^ Color||Yellow|||N|||F|||20191015001740|CTRLAB^CENT RAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|3|ST|UAPP^ Appearance||Slightly Turbid|||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|4|ST|UPH^ Reaction / pH||5.0|||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|5|ST|USG^ Specific Gravity||1.015|||N|||F|||20191015001740|CTRLAB^CEN TRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|6|ST|UPRO^ Protein||Negative|||N|||F|||20191015001740|CTRLAB^ CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|7|ST|USU^ Sugar||Negative|||N|||F|||20191015001740|CTRLAB^CE NTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|8|ST|HUMICH^Microscopic||""||||||F
OBX|9|ST|FPC^ Pus Cells||0-1|/HPF||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|10|ST|SMRBC^ RBC||4-6|/HPF||N|||F|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638
OBX|11||||\.br\RBC Morphology: 15% Normocytic, 85% Dysmorphic
OBX|12|ST|UYC^ Yeast Cells||!|/HPF||N|||D|||20191015001740|CTRLAB^CENTRAL LAB|JMDELACRUZ^Jessica May E. Dela Cruz PRC 0078638

Messages I receive may have any number of OBX and NTE lines. Any help or hints towards a good solution are very much appreciated. Thanks!

Last edited by Golfmachine; 11-18-2019 at 10:48 PM.
Reply With Quote
  #2  
Old 11-19-2019, 01:23 AM
Golfmachine Golfmachine is offline
Mirth Newb
 
Join Date: Jun 2019
Posts: 13
Golfmachine is on a distinguished road
Default

If anyone is interested, I got this to work but I needed both transformers. In source:

var i = 0;

for each(seg in msg.children()){
if(seg.name() == "OBX"){
var obx = createSegment('OBX', tmp, i);
obx['OBX.1']['OBX.1.1'] = seg['OBX.1']['OBX.1.1'].toString();
obx['OBX.2']['OBX.2.1'] = seg['OBX.2']['OBX.2.1'].toString();
obx['OBX.3']['OBX.3.1'] = seg['OBX.3']['OBX.3.1'].toString();
obx['OBX.3']['OBX.3.2'] = seg['OBX.3']['OBX.3.2'].toString();
obx['OBX.5']['OBX.5.1'] = seg['OBX.5']['OBX.5.1'].toString();
obx['OBX.6']['OBX.6.1'] = seg['OBX.6']['OBX.6.1'].toString();
obx['OBX.7']['OBX.7.1'] = seg['OBX.7']['OBX.7.1'].toString();
obx['OBX.11']['OBX.11.1'] = seg['OBX.11']['OBX.11.1'].toString();
obx['OBX.19']['OBX.19.1'] = msg['OBR']['OBR.22']['OBR.22.1'].toString();
i++;
}
if(seg.name() == "NTE") {
var obx = createSegment('OBX', tmp, i);
obx['OBX.2']['OBX.2.1'] = "ST";
obx['OBX.3']['OBX.3.1'] = "NOTES";
obx['OBX.3']['OBX.3.2'] = "Comment";
obx['OBX.5']['OBX.5.1'] = seg['NTE.3']['NTE.3.1'].toString();
obx['OBX.19']['OBX.19.1'] = msg['OBR']['OBR.22']['OBR.22.1'].toString();
i++;
}
}

In destination:
var i = 0;

for each (seg in msg..OBX)
{
seg['OBX.1']['OBX.1.1'] = i+1;
i++;
}
Reply With Quote
  #3  
Old 11-19-2019, 01:13 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,037
agermano is on a distinguished road
Default

Add this to the bottom of your source transformer, and you shouldn't need the destination. You need to iterate over tmp instead of msg since that's where you want to do your renumbering.
Code:
for (var i = 0; i < tmp.OBX.length(); i++) {
    tmp['OBX'][i]['OBX.1']['OBX.1.1'] = i+1;
}

Last edited by agermano; 11-20-2019 at 08:20 AM.
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 11:16 PM.


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