web stats
Building/Creating new OBXs - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 12-02-2015, 04:08 PM
fchang fchang is offline
Mirth Newb
 
Join Date: Jan 2013
Location: Southern California
Posts: 13
fchang is on a distinguished road
Send a message via Yahoo to fchang
Default Building/Creating new OBXs

I am trying to create OBXs based on repeating values in OBR-20.

I've done that but the problem I am having now is attaching the incoming
OBXs to the end of that. I've attached a simplified HL7 message for clarity.

Inbound :

MSH|...
PID|...
PV1|...
ORC|...
OBR|||||5|||||10|||||15||||19|G7~G8~G9~R11|...
OBX|1||||obx1comment|...
OBX|2||||obx2comment|...
OBX|3||||obx3comment|...
OBX|4||||obx4comment|...

Outbound :

MSH|...
PID|...
PV1|...
ORC|...
OBR|||||5|||||10|||||15||||19|G7~G8~G9~R11|...
OBX|1||||G7|...
OBX|2||||G8|...
OBX|3||||G9|...
OBX|4||||R11|...
OBX|5||||obx1comment|...
OBX|6||||obx2comment|...
OBX|7||||obx3comment|...
OBX|8||||obx4comment|...

When I tried to create a new OBX, I am getting an error.

Here is a portion of my code. I have a loop where i=0 and OBR20Length is 4 for this example. countOBX = 4 in this example for the number of incoming OBXs.


for each (var i=0;i<=countOBX-1;i++)
{
if (i >=(OBR20Length+1))
{
tmp['OBX'][i+OBR20Length+1] = new XML("<OBX/>");
tmp['OBX'][i+OBR20Length+1]['OBX.1']['OBX.1.1'] = i+OBR20Length+2;
.....
}
else
{
msg['OBX'][i+OBR20Length+1]['OBX.1']['OBX.1.1'] = i+OBR20Length+2;
msg['OBX'][i+OBR20Length+1]['OBX.2']['OBX.2.1'] = "TX";
......
}


I am using Mirth v3.2.0.7628 on Windows Server.

Thanks in advance.
Reply With Quote
  #2  
Old 12-03-2015, 03:40 AM
mcalKno mcalKno is offline
 
Join Date: Apr 2015
Location: Pennsylvania
Posts: 247
mcalKno is on a distinguished road
Default

I'm sure there are other ways to accomplish this, but the below code works...

Code:
for each(obr in msg.OBR)
{
	if(obr['OBR.20'].length() > 1)
	{
		for(var i=obr['OBR.20'].length()-1; i >= 0; i--)
		{
			var obrValue = SerializerFactory.getSerializer('HL7V2').fromXML(obr['OBR.20'][i].toString());
			var newOBX = createSegmentAfter('OBX', obr);
			newOBX['OBX.1']['OBX.1.1'] = i+1;
			newOBX['OBX.2']['OBX.2.1'] = '';
			newOBX['OBX.3']['OBX.3.1'] = obrValue;
		}
	}
	for each(obx in msg.OBX){
		var obxGroup = getSegmentsAfter(msg,obr,'OBX');
		for (var o = 0; o <= obxGroup.length-1; o++)
			msg.children()[obxGroup[o].childIndex()]['OBX.1']['OBX.1.1'] = o+1;
	}
}
Reply With Quote
Reply

Tags
creating, obx, segment, 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:19 PM.


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