web stats
Mirth Connect HL7 to XML, multiple MSH problem - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-13-2017, 04:47 PM
bluechen bluechen is offline
What's HL7?
 
Join Date: Aug 2017
Posts: 5
bluechen is on a distinguished road
Default Mirth Connect HL7 to XML, multiple MSH problem

I am a beginner of Mirth Connect and recently learning how to use Mirth Connect in our project.

We have a case that hospital could send multiple MSH in one file. We must transfer to one XML file.

MSH|^~\&|xxx|PHARM|3M|HL7GATE|20170811100757|1/865308|RDE^O01|20170811100757108;5061618|P|2.2
PID|||0001195409||James||19530908|M
PV1|||0417^^007^^575302_100646^^^^Dept1
ORC|NW|496882750
RXE|^^^201708110000^201708112359^6^^^^0800|Y000000 12567|||||^10.0mg&P.O|||1|||||||||||||||||||UD
MSH|^~\&|xxx|PHARM|3M|HL7GATE|20170811100834|3/865309|RDE^O01|20170811100834470;5061621|P|2.2
PID|||0001195045||Smith||19730211|M
PV1|||0407^^045^^575303_100724^^^^Dept1
ORC|NW|496887639
RXE|^^^201708110000^201708112359^6^^^^0800|Y000000 01531|||||^1.0g&P.O|||2|||||||||||||||||||UD

We need to transfer the above message into one XML output.
<MSH>
xxxxx
</MSH>
<MSH>
xxxxx
</MSH>

I tried to use batch in Mirth Connect, however, it seems that Mirth Connect will transfer to 2 different XML outputs.

Is it possible to realize? If so, how to deal with it?

Thank you.
Reply With Quote
  #2  
Old 08-14-2017, 06:58 AM
mcalKno mcalKno is offline
 
Join Date: Apr 2015
Location: Pennsylvania
Posts: 247
mcalKno is on a distinguished road
Default

Couldn't you process as batch on the source and have it build a single appended file on the outbound destination?
Reply With Quote
  #3  
Old 08-15-2017, 12:15 AM
bluechen bluechen is offline
What's HL7?
 
Join Date: Aug 2017
Posts: 5
bluechen is on a distinguished road
Default

Quote:
Originally Posted by mcalKno View Post
Couldn't you process as batch on the source and have it build a single appended file on the outbound destination?
Yes, I can use 'append' to make a single XML file. Nevertheless, I also have another channel, same source with webservice destination. Our scenario is Mirth Connect calls webservice only once for multiple MSH message.

Is it feasible?
Reply With Quote
  #4  
Old 09-05-2017, 01:42 AM
bluechen bluechen is offline
What's HL7?
 
Join Date: Aug 2017
Posts: 5
bluechen is on a distinguished road
Default

Can anyone help me?
Reply With Quote
  #5  
Old 09-05-2017, 03:33 AM
aTom aTom is offline
OBX.3 Kenobi
 
Join Date: Feb 2016
Location: Lake Geneva Area
Posts: 113
aTom is on a distinguished road
Default

Not sure if I understand your problem.

If you pass a message with 2 MSH segments, Mirth will parse it as one single message if you disable "batch process" from source controller :

<HL7Message>
<MSH> <!-- 1st MSH-->
......
</MSH>
<EVN>
...
</EVN>
<PID>
...
</PID>
and so on

<MSH><!-- 2nd MSH>
<EVN>
...
</EVN>
and so on
</HL7Message>

It seems that it's what you are looking for.

Now if your problem is you cannot handle each message individually while keeping the whole message, you can use getSegmentsAfter() function on each MSH segment and build your own atomic message; code would look like this (I haven't tested it!):

Code:
var mshArray = msg['MSH'];
for each (var msh in mshArray) {
   var singleMsg = <HL7Message/>;
   var segmentArray = getSegmentsAfter(msg, msh, /.*/, true, "MSH"); // here you should get all segments that are part of that MSH segment
   for each (var segment in segmentArray) {
     singleMsg.appendChild(segment);
   }
   // now you should have a atomic message you can handle as you need
}
You have to import that function in your code templates, it's available here : http://www.mirthcorp.com/community/f...4608#post24608
__________________
Tom
Reply With Quote
  #6  
Old 09-05-2017, 07:20 PM
bluechen bluechen is offline
What's HL7?
 
Join Date: Aug 2017
Posts: 5
bluechen is on a distinguished road
Default

Quote:
Originally Posted by aTom View Post
Not sure if I understand your problem.

If you pass a message with 2 MSH segments, Mirth will parse it as one single message if you disable "batch process" from source controller :

<HL7Message>
<MSH> <!-- 1st MSH-->
......
</MSH>
<EVN>
...
</EVN>
<PID>
...
</PID>
and so on

<MSH><!-- 2nd MSH>
<EVN>
...
</EVN>
and so on
</HL7Message>

It seems that it's what you are looking for.

Now if your problem is you cannot handle each message individually while keeping the whole message, you can use getSegmentsAfter() function on each MSH segment and build your own atomic message; code would look like this (I haven't tested it!):

Code:
var mshArray = msg['MSH'];
for each (var msh in mshArray) {
   var singleMsg = <HL7Message/>;
   var segmentArray = getSegmentsAfter(msg, msh, /.*/, true, "MSH"); // here you should get all segments that are part of that MSH segment
   for each (var segment in segmentArray) {
     singleMsg.appendChild(segment);
   }
   // now you should have a atomic message you can handle as you need
}
You have to import that function in your code templates, it's available here : http://www.mirthcorp.com/community/f...4608#post24608
Thank you so much for the suggestion.

I will check whether it is suitable for us.
Reply With Quote
Reply

Tags
multiple messages, xml

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:47 AM.


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