Announcement

Collapse
No announcement yet.

Delete OBX Segments to END

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

  • Delete OBX Segments to END

    I am trying to delete ALL OBX segments in a message from one starting point where defined text is found to the end (All OBX Segments from this one point ... including the found segment, to the end of the message).

    Mirth Connect: v3.1.1.7461

    This code thus far will delete the segment with the found string, but no segments following this line.


    var deleteSeg = false;
    for each(seg in msg.children()) {
    if(seg.name() == "OBX") {
    var strOBXID = seg['OBX.5']['OBX.5.1'].toString();
    if(strOBXID.substring(0,26)== "PM******** ORIGINAL REPORT"){
    deleteSeg = true;
    } else {
    deleteSeg = false;
    }
    }
    if(deleteSeg == true ){
    var segType = seg.name();
    var segCnt = 0;
    for(var i=0;i<seg.childIndex();i++){
    if(msg.children()[i].name() == seg.name()) {
    segCnt++;
    }
    }
    delete msg[segType][segCnt];
    }}

  • #2
    This seems to work. Once the OBX in question is found it records the sequence and then deletes any further OBX segments with a higher sequence ID.

    Code:
    for each(obx in msg.OBX)
    {
    	if(obx['OBX.5']['OBX.5.1'].toString().substring(0, 26) == 'PM******** ORIGINAL REPORT')
    	{
    		var obxCount = obx['OBX.1']['OBX.1.1'];
    		delete (msg.children()[obx.childIndex()]);
    	}
    	else if(obx['OBX.1']['OBX.1.1'].toString() > obxCount)
    	{
    		delete (msg.children()[obx.childIndex()]);
    	}
    }

    Comment


    • #3
      This works, but only for the following 5 OBX segments from the deletion point. It deletes the found text and segment at OBX|5| and OBX|6| through OBX|9| as well, but stops there. OBX|10| through OBX|34| remain. I tried stepping through the code to see why it is stopping at this point, but could not find a problem. The first segment that did not delete at OBX|10| is as follows:

      OBX|10|FT|93930&BODY^US Bilateral UE Arterial Doppler/Duplex||TECHNIQUE: Axial images of the chest were obtained including sagittal and||||||A|||20151001123352||

      Just to be certain, I changed the found text code to be exact for OBX.5.1

      if(obx['OBX.5']['OBX.5.1'].toString().substring() == 'PM******** ORIGINAL REPORT ********')

      Thanks for the help with this!

      Comment


      • #4
        Originally posted by nikoli View Post
        This works, but only for the following 5 OBX segments from the deletion point. It deletes the found text and segment at OBX|5| and OBX|6| through OBX|9| as well, but stops there. OBX|10| through OBX|34| remain. I tried stepping through the code to see why it is stopping at this point, but could not find a problem. The first segment that did not delete at OBX|10| is as follows:

        OBX|10|FT|93930&BODY^US Bilateral UE Arterial Doppler/Duplex||TECHNIQUE: Axial images of the chest were obtained including sagittal and||||||A|||20151001123352||

        Just to be certain, I changed the found text code to be exact for OBX.5.1

        if(obx['OBX.5']['OBX.5.1'].toString().substring() == 'PM******** ORIGINAL REPORT ********')

        Thanks for the help with this!

        try this...

        Code:
        for each(obx in msg.OBX)
        {
        	if(obx['OBX.5']['OBX.5.1'].toString().substring(0, 26) == 'PM******** ORIGINAL REPORT')
        	{
        		var obxCount = obx['OBX.1']['OBX.1.1'];
        		delete (msg.children()[obx.childIndex()]);
        	}
        	else if(parseInt(obx['OBX.1']['OBX.1.1'].toString()) > obxCount)
        	{
        		delete (msg.children()[obx.childIndex()]);
        	}
        }
        Had to force the string to an Int for the compare
        Last edited by mcalKno; 10-23-2015, 05:02 AM.

        Comment


        • #5
          That did the trick! Thanks again for the help!

          Comment

          Working...
          X