web stats
Break HL7 msg into several messages - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-22-2018, 05:26 PM
mmonisky mmonisky is offline
OBX.1 Kenobi
 
Join Date: Aug 2015
Posts: 26
mmonisky is on a distinguished road
Default Break HL7 msg into several messages

Need guidance on how to break an ORM message with several OBR|OBX|NTE's into separate messages for each OBR|OBX|NTE combo.
Each message will only have 1 each OBR|OBX|NTE combo


Original message:

MSH|^~\&|EMR^1ST FLOOR||PMD|TEST FACILITY - UTAH|20180510||ORM^O01|11867-6071-41|P|2.3.1
PID||16|||TEST09^JAX||20020101|M|||1002 NO WHERE ST^^SANDY^UT^84070||^^555^5550001||||||555550003|
NTE|1|DISPATCH NOTES||||||||||
ORC|NW|36||36||||||||1568438653^LALLY^THOMAS^^^^^^ ^^^^NPI||^^^^303^3799371|||||||||2|^^WHEAT RIDGE^CO^80033
OBR|1|36|788f6cd3-9c4d-4657-b2e5-37ca743cf101|74018^ABDOMEN^HCPC^1^PAIN LOCALIZED TO UPPER ABDOMEN|ASAP|20180510|
OBX|1|ST|R10.1^PATIENT COMPLAINT^ICD10||PAIN LOCALIZED TO UPPER ABDOMEN||||||R|
NTE|1|Something here||
OBR|2|36|c0799337-0f8c-4304-a4b6-36e8e9a06bd7|71046^CHEST 2 VIEWS^HCPC^1^CHEST PAIN ON BREATHING|ASAP|20180510|
OBX|1|ST|R07.1^PATIENT COMPLAINT^ICD10||CHEST PAIN ON BREATHING||||||R|
NTE|1|Something here||

First new msg with the first OBR|OBX|NTE combo copying MSH|PID|NTE|ORC

MSH|^~\&|EMR^1ST FLOOR^1ST FLOOR||PMD|TEST FACILITY - UTAH|20180510||ORM^O01|11867-6071-41|P|2.3.1
PID||16|||TEST09^JAX||20020101|M|||1002 NO WHERE ST^^SANDY^UT^84070||^^555^5550001||||||555550003|
NTE|1|DISPATCH NOTES||||||||||
ORC|NW|36||36||||||||1568438653^LALLY^THOMAS^^^^^^ ^^^^NPI||^^^^303^3799371|||||||||2|^^WHEAT RIDGE^CO^80033
OBR|1|36|788f6cd3-9c4d-4657-b2e5-37ca743cf101|74018^ABDOMEN^HCPC^1^PAIN LOCALIZED TO UPPER ABDOMEN|ASAP|20180510|
OBX|1|ST|R10.1^PATIENT COMPLAINT^ICD10||PAIN LOCALIZED TO UPPER ABDOMEN||||||R|
NTE|1|Something here||



2nd new msg with the 2nd OBR|OBX|NTE combo copying MSH|PID|NTE|ORC

MSH|^~\&|EMR^1ST FLOOR^1ST FLOOR||PMD|TEST FACILITY - UTAH|20180510||ORM^O01|11867-6071-41|P|2.3.1
PID||16|||TEST09^JAX||20020101|M|||1002 NO WHERE ST^^SANDY^UT^84070||^^555^5550001||||||555550003|
NTE|1|DISPATCH NOTES||||||||||
ORC|NW|36||36||||||||1568438653^LALLY^THOMAS^^^^^^ ^^^^NPI||^^^^303^3799371|||||||||2|^^WHEAT RIDGE^CO^80033
OBR|2|36|c0799337-0f8c-4304-a4b6-36e8e9a06bd7|71046^CHEST 2 VIEWS^HCPC^1^CHEST PAIN ON BREATHING|ASAP|20180510|
OBX|1|ST|R07.1^PATIENT COMPLAINT^ICD10||CHEST PAIN ON BREATHING||||||R|
NTE|1|Something here||
Reply With Quote
  #2  
Old 05-23-2018, 05:41 AM
AlexNeiva AlexNeiva is offline
Mirth Guru
 
Join Date: Oct 2013
Location: Portugal
Posts: 244
AlexNeiva is on a distinguished road
Default

Hello,


giving your HL7 example, i develop a JavaScript code in the Transformer in order to split and build up again the HL7 message. It can be done in another way and this is just a "quick fix"
Create a new channel that receives HL7 with name "HL7Receiver" and on the channel that receives the full HL7 to split, put this code on the Transformer:


Code:
var arrOBR=[];
var arrOBX=[];
var arrNTE=[];

var xml;

for each (var seg in msg.children())
{
    if(seg.name() == "OBR")
        arrOBR.push(seg);

    if(seg.name() == "OBX")
        arrOBX.push(seg);

    if(seg.name() == "NTE")
        arrNTE.push(seg);
}

for each(var i=0; i<arrOBR.length; i++)
{
    xml=new XML();
    
    xml="<HL7Message>" + 
            msg['MSH'].toString() + "\r\n" +
            msg['PID'].toString() + "\r\n" +
            msg['NTE'][0].toString() + "\r\n" +
            msg['ORC'].toString() + "\r\n" +
            arrOBR[i].toString() + "\r\n" +
            arrOBX[i].toString() + "\r\n" +
            arrNTE[i].toString() + 
        "</HL7Message>";

    tmp=xml;
    router.routeMessage('HL7Receiver', SerializerFactory.getSerializer('HL7V2').fromXML(tmp));
}
Note: in this code i assume that the same amount of OBR - OBX - NTE is the same. I'm not handling exceptions.
And the Transformer Outbound message type should be XML Type.
__________________
Best Regards,
Alex Neiva

Last edited by AlexNeiva; 05-23-2018 at 05:44 AM.
Reply With Quote
  #3  
Old 05-23-2018, 11:38 AM
mmonisky mmonisky is offline
OBX.1 Kenobi
 
Join Date: Aug 2015
Posts: 26
mmonisky is on a distinguished road
Default Thank you!!

This worked perfectly! I had to take out the .toString() but it works perfectly!
Thank you so much.
Reply With Quote
Reply

Tags
break, hl7, split

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 03:14 AM.


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