Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   Building/Creating new OBXs (http://www.mirthcorp.com/community/forums/showthread.php?t=215193)

fchang 12-02-2015 04:08 PM

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.

mcalKno 12-03-2015 03:40 AM

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;
        }
}



All times are GMT -8. The time now is 02:24 AM.

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