Announcement

Collapse
No announcement yet.

Change order of OBR - ORC segments

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

  • Change order of OBR - ORC segments

    Hi all,

    for a subsystem i'm trying to change the order of the OBR and ORC segments, our labsystem sends an hl7v2.5 OUL^R22 in the order: MSH-PID-PV1-SPM-OBR-ORC-TQ1-OBX. The receiving side doesn't like an OBR before ORC.
    Is there a way to swap the position of the segments? Do i have to use an outbound message template? Or can i use javascript (my coding skills are not that good....) the javascript version which came in my mind was to read all OBR/ORC segments into corresponding vars and rebuild in the correct order. i'm stuck on the rebuild part...
    Please advice on how to achieve this.

    Kind regards

  • #2
    Code:
    var reordered = new XMLList();
    for (var i = 0; i < msg.children().length(); i++) {
        if (msg.child(i).localName() == 'OBR') {
            if (msg.child(i+1).localName() == 'ORC') {
                reordered += msg.child(i+1) + msg.child(i);
                i++; // skip the next one since we already included it
            }
            else {
                throw "ORC does not directly follow OBR"
            }
        }
        else {
            reordered += msg.child(i);
        }
    }
    
    msg.setChildren(reordered);

    Comment


    • #3
      Hi Agermano,
      Thanks!
      I found this one: http://www.mirthcorp.com/community/f...d.php?t=214079
      But the double swap confused me.

      Comment

      Working...
      X