Announcement

Collapse
No announcement yet.

Sort OBX statements in numerical order

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

  • Sort OBX statements in numerical order

    I am having an issue sorting a Set of OBX statements.
    Mirth version 3.3.2.7911 if the sort order is updated in newer versions i can download and deploy.


    OBX Examples

    code being used

    copy Segment OBX.3.1 numbers to OBX.4.1
    sort on OBX.4.1


    // then place the numbers in OBX.4.1 then Sort the OBX's by OBX.4.1
    //This reads OBX.3.1
    for each (seg in msg.OBX) {

    if(seg['OBX.3']['OBX.3.1'].toString() != '')
    {
    var temp=seg['OBX.3']['OBX.3.1'].toString();
    seg['OBX.4']['OBX.4.1'] = temp.replace(/[^0-9.]/g,""); //save results to OBX.4.1 (~r/[^\d]/, "" "[^0-9]"
    }
    }


    // Create an Array
    var OBXArray = new Array()

    // initial variables
    var i = 0;

    // Loop thru OBX
    for each(seg in msg..OBX){
    // Build Array
    OBXArray[i] = {
    value : seg['OBX.4']['OBX.4.1'].toString(), // sort by the new field extracted and placed in OBX.4.1
    seg : seg
    };

    // Delete OBX
    delete (msg.children()[seg.childIndex()]);

    // Add 1 to i
    i++;
    }



    var obxList = new java.util.ArrayList();
    for each (obx in msg.OBX)
    obxList.add(obx);

    java.util.Collections.sort(obxList,new java.util.Comparator({compare:function(o1, o2) {
    function getIDValue(node) {
    var obsId = node['OBX.4']['OBX.4.1'].toint();
    return parseInt(obsId.substr(0,obsId.indexOf('-')),10);
    }
    return getIDValue(o1) - getIDValue(o2);
    }}));

    for (var i = 0; i <= obxList.size()-1; i++) {
    msg.OBX[i] = obxList.get(i);
    msg.OBX[i]['OBX.1']['OBX.1.1'] = i+1;
    }



    OBX|10||Statement 20|20|Date: mmddyyyy||||||AS
    OBX|11||Statement 21|21|Time: hh:mm:ss||||||AS
    OBX|12||Statement 22|22|User: N/A||||||AS
    OBX|13||Statement 23|23|Computer: <ComputerName>||||||AS
    OBX|14||Statement 24|24|Description:||||||AS
    OBX|15||Statement 25|25|The Windows Installer service entered the stopped state.||||||AS
    OBX|16||Statement 26|26|For more information, see Help and Support Center at <http://go.microsoft.com/fwlink/events.asp>.||||||AS
    OBX|17||Statement 27|27|||||||AS
    OBX|18||Statement 28|28|larry||||||AS
    OBX|19||Statement 29|29|Seieroe||||||AS
    OBX|20||Statement 30|30|||||||AS
    OBX|21||Statement 31|31|was here today||||||AS
    OBX|22||Statement 1|1|||||||AS
    OBX|23||Statement 2.1|2.1|The system Event log will show that the Windows Installer Service is starting and stopping||||||AS
    OBX|24||Statement 2.2|2.2|automatically.||||||AS
    OBX|25||Statement 3|3|||||||AS
    OBX|26||Statement 4|4|Event Type: Information||||||AS
    OBX|27||Statement 5|5|Event Source: Service Control Manager||||||AS
    OBX|28||Statement 6|6|Event Category: None||||||AS
    OBX|29||Statement 7|7|Event ID: 7035||||||AS
    OBX|30||Statement 8|8|Date: mmddyyyy||||||AS
    OBX|31||Statement 9|9|Time: hh:mm:ss||||||AS
    OBX|32||Statement 10|10|User: NT AUTHORITY\SYSTEM||||||AS
    OBX|33||Statement 11|11|Computer: <ComputerName>||||||AS
    OBX|34||Statement 12|12|Description:||||||AS
    OBX|35||Statement 13|13|The Windows Installer service was successfully sent a start control.||||||AS
    OBX|36||Statement 14|14|For more information, see Help and Support Center at <http://go.microsoft.com/fwlink/events.asp>.||||||AS
    OBX|37||Statement 15|15|||||||AS
    OBX|38||Statement 16|16|Event Type: Information||||||AS
    OBX|39||Statement 17|17|Event Source: Service Control Manager||||||AS
    OBX|40||Statement 18|18|Event Category: None||||||AS
    OBX|41||Statement 19|19|Event ID: 7036||||||AS
    Larry aka(Skippy)
Working...
X