Announcement

Collapse
No announcement yet.

Building/Creating new OBXs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #2
    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;
    	}
    }

    Comment

    Working...
    X