web stats
Example Lab Report - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-21-2019, 12:00 AM
ASIFM786 ASIFM786 is offline
Mirth Newb
 
Join Date: Oct 2008
Posts: 17
ASIFM786
Smile Example Lab Report

Hello Guys,

Does any one have a example Lab Report with OBR , OBX and NTE combined?

Thanks in advance
Reply With Quote
  #2  
Old 06-21-2019, 12:02 AM
ASIFM786 ASIFM786 is offline
Mirth Newb
 
Join Date: Oct 2008
Posts: 17
ASIFM786
Smile

currently i have used this layout... but i cannot combine them all together :-

var results = new XML('<tbody></tbody>');
var tr;

for each (mOBX in msg..OBX) {

tr = new XML('<tr></tr>');

tr['td'][0] = '';
if (mOBX['OBX.8']['OBX.8.1'].toString() != "N") {
tr['td'][0]['img']['@src'] = '/mirth/graphics/flag_red.png';
}
// Test Name
tr['td'][1] = mOBX['OBX.3']['OBX.3.2'].toString();
// Result
tr['td'][2] = mOBX['OBX.5']['OBX.5.1'].toString() + " "+ mOBX['OBX.6']['OBX.6.1'].toString();
// Flag - Red if not N = normal
tr['td'][3] = mOBX['OBX.8']['OBX.8.1'].toString();
// Reference range
tr['td'][4] = mOBX['OBX.7']['OBX.7.1'].toString() + " " + mOBX['OBX.6']['OBX.6.1'].toString();

results[''] += tr;
}

channelMap.put("Results",results);
Reply With Quote
  #3  
Old 07-05-2019, 10:48 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,027
agermano is on a distinguished road
Default

This code template should help.

https://github.com/nextgenhealthcare...ular%20Segment
Reply With Quote
  #4  
Old 07-23-2019, 12:08 PM
ASIFM786 ASIFM786 is offline
Mirth Newb
 
Join Date: Oct 2008
Posts: 17
ASIFM786
Post

thanks for this, but having diffculty incorporating this into the script. having looked through all the material but still having difficulty.

I am a mirth newbie and trying to get this transformer : -

// Test Name
tr['td'][1] = mOBX['OBX.3']['OBX.3.2'].toString();
// Result
tr['td'][2] = mOBX['OBX.5']['OBX.5.1'].toString() + " "+ mOBX['OBX.6']['OBX.6.1'].toString();
// Flag - Red if not = normal
tr['td'][3] = mOBX['OBX.8']['OBX.8.1'].toString();
// Reference range
tr['td'][4] = mOBX['OBX.7']['OBX.7.1'].toString() + " " + mOBX['OBX.6']['OBX.6.1'].toString();

followed by the NTE comments

thanks in advance
Reply With Quote
  #5  
Old 07-24-2019, 09:35 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,027
agermano is on a distinguished road
Default

I set the outbound type to xml and the outbound template to <tbody/>. Then you can modify tmp (instead of results) and it will become the encoded data (i.e. actually transform the message) so you don't have to stick your results in the channelMap.

For each OBR/OBX/NTE grouping I add them to a new xml object called group to make accessing them easier. This isn't necessary, and if you don't want to do it that way, at least you can see how getSegmentsAfter can be used.

I used e4x templating to create the new row in one step. The way you were doing it will work, but I wanted to show an alternative way that some may prefer.

I didn't know how you wanted to use fields from OBR and NTE, so I just picked a random field from each and added them to a new column in your table. The NTE value is wrapped in a <div> tag by passing it to another function. It will support multiple NTE segments for the same group, wrapping each value separately.

Code:
const red_flag = <img src="/mirth/graphics/flag_red.png"/>;

for each (var obr in msg.OBR) {
    var group = <group>{obr}</group>;
    getSegmentsAfter(msg, obr, /OBX|NTE/, true).forEach(function(seg) {group.appendChild(seg)});
    var obx8 = group['OBX']['OBX.8']['OBX.8.1'].toString();
    var tr = <tr>
        <td>{obx8 != 'N' ? red_flag : ''}</td>
        <td>{group.OBX['OBX.3']['OBX.3.2'].toString()}</td>
        <td>{group.OBX['OBX.5']['OBX.5.1'].toString() + " "+ group.OBX['OBX.6']['OBX.6.1'].toString()}</td>
        <td>{obx8}</td>
        <td>{group.OBX['OBX.7']['OBX.7.1'].toString() + " " + group.OBX['OBX.6']['OBX.6.1'].toString()}</td>
        <td>{group.OBR['OBR.2']['OBR.2.1'].toString()}</td>
        <td>{divWrap(group.NTE['NTE.2']['NTE.2.1'])}</td>
    </tr>;
    tmp.appendChild(tr);
}

// takes an XMLList and returns a new list of the string value of each list item
// wrapped in div tags
function divWrap(list) {
    var ret = <></>;
    for each (var e in list) {
        ret += <div>{e.toString()}</div>
    }
    return ret;
}

Last edited by agermano; 07-24-2019 at 10:01 PM.
Reply With Quote
  #6  
Old 07-25-2019, 11:43 PM
ASIFM786 ASIFM786 is offline
Mirth Newb
 
Join Date: Oct 2008
Posts: 17
ASIFM786
Default

thanks for this ageramo,

just a quick question is i change the output to xml would this code go as a javascript in the transformer?
Reply With Quote
  #7  
Old 08-06-2019, 12:23 PM
ASIFM786 ASIFM786 is offline
Mirth Newb
 
Join Date: Oct 2008
Posts: 17
ASIFM786
Default confused

I have added and used this script: -
var results5 = new XML('<tbody></tbody>');
var tr;

const red_flag = <img src="/mirth/graphics/flag_red.png"/>;

for each (var obr in msg.OBR) {
var group = <group>{obr}</group>;
getSegmentsAfter(msg, obr, /OBX|NTE/, true).forEach(function(seg) {group.appendChild(seg)});
var obx8 = group['OBX']['OBX.8']['OBX.8.1'].toString();
var tr = <tr>
<td>{obx8 != 'N' ? red_flag : ''}</td>
<td>{group.OBX['OBX.3']['OBX.3.2'].toString()}</td>
<td>{group.OBX['OBX.5']['OBX.5.1'].toString() + " "+ group.OBX['OBX.6']['OBX.6.1'].toString()}</td>
<td>{obx8}</td>
<td>{group.OBX['OBX.7']['OBX.7.1'].toString() + " " + group.OBX['OBX.6']['OBX.6.1'].toString()}</td>
<td>{group.OBR['OBR.2']['OBR.2.1'].toString()}</td>
<td>{divWrap(group.NTE['NTE.2']['NTE.2.1'])}</td>
</tr>;
tmp.appendChild(tr);
}

// takes an XMLList and returns a new list of the string value of each list item
// wrapped in div tags
function divWrap(list) {
var ret = <></>;
for each (var e in list) {
ret += <div>{e.toString()}</div>
}
return ret;
}
channelMap.put("Results5",results5);

but it does not do anything just returns an blank, is there something i have missed?
Reply With Quote
  #8  
Old 08-07-2019, 01:45 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,027
agermano is on a distinguished road
Default

Quote:
Originally Posted by agermano View Post
I set the outbound type to xml and the outbound template to <tbody/>. Then you can modify tmp (instead of results) and it will become the encoded data (i.e. actually transform the message) so you don't have to stick your results in the channelMap.
I think you missed this part.

If you need to build multiple tables or something and that's why you're putting the results into the channelMap rather than transforming the message, change tmp.appendChild(tr) to results5.appendChild(tr).

Last edited by agermano; 08-07-2019 at 01:48 PM.
Reply With Quote
  #9  
Old 08-07-2019, 02:45 PM
ASIFM786 ASIFM786 is offline
Mirth Newb
 
Join Date: Oct 2008
Posts: 17
ASIFM786
Unhappy

hey thanks for that, it works now, but still doesnt produce the OBX followed by the NTE........
Reply With Quote
  #10  
Old 08-07-2019, 05:08 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 1,027
agermano is on a distinguished road
Default

I showed in my example how to include fields from OBR, OBX, and multiple NTE segments. You never provided sample messages or sample output, so I just made something up.
Reply With Quote
Reply

Tags
lab, nte, obr, obx, report

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 07:39 PM.


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