Creating multiple messages from one

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Creating multiple messages from one

  • Creator
    Topic
  • #48881
    Carl Duff
    Participant

      Hello,

      I have an inbound ORU message that I need to loop on and generate multiple outbound messages. I’ve been testing several days and apparently my pea brain can’t come up with the proper solution. I’m sure I’m making it more complicated that it really is. A message fragment is below.

      MSH|^~&|||||||ORU^R01|20052381448688|P|2.1||||

      PID|||0000^^^1||DOE^JOHN^A||19430204|F|

      PV1||||||||^||||||||||

      ORC|RE||D63718|||||||||

      OBR|||D63718|4010762^TYPE AND SCREEN|||

      OBX|1|CE|%ABR^ABO/Rh|1|A||||||F|||

      OBX|2|CE|%ABR^ABO/Rh|2| NEGATIVE||||

      OBX|3|CE|BT^BLOOD TYPE|1|A NEGATIVE|||

      OBX|4|CE|%AS^ANTIBODY SCREEN|1|NEGATIVE|||||

      OBX|5|CE|COMM^BLOOD BANK COMMENTS|1|BLOOD IS RELEASED AT

      OBX|6|FT|COMM^BLOOD BANK COMMENTS|2|CALLED TO AT 0100. MJ|

      OBX|7|ST|%UN^UNIT NUMBER|1|A164961838LFR||||||

      OBX|8|CE|%CT^COMPONENT TYPE|1|LEUKOCYTE FILTERED RBC’S|

      OBX|9|CE|%ST^STATUS OF UNIT|1|ALLOCATED||||||I|||200610280602

      OBX|10|CE|%TS^TRANSFUSION STATUS|1|OK TO TRANSFUSE||||||F|||

      OBX|11|CE|%XM^CROSSMATCH|1|COMPATIBLE||||||F|||200610280602|

      OBX|12|ST|%UN^UNIT NUMBER|1|B164961838LFR|||||||||200610280602

      OBX|13|CE|%CT^COMPONENT TYPE|1|LEUKOCYTE  RBC’S||||||F|

      OBX|14|CE|%ST^STATUS OF UNIT||ALLOCATED||||||I|||200610280602|

      OBX|15|CE|%TS^TRANSFUSION STATUS|1|OK TO TRANSFUSE||||||F|||

      OBX|16|CE|%XM^CROSSMATCH|1|COMPATIBLE||||||F|||200610280602

      I need to loop on the OBX until OBX3.2 = “UNIT NUMBER” and then send the previous message out. Using the above example I need the MSH, PID, OBR and OBX1-6 in message 1.

      MSH, PID, OBR and OBX7-11 in message 2.

      MSH, PID, OBR and OBX12-16 in message 3 and so on.

      I can get it close but can’t seem to get the entire solution.

      I have found some great help here and appreciate any assistance given.

      Thanks!!

      Carl

    Viewing 2 reply threads
    • Author
      Replies
      • #59990
        David Barr
        Participant

          I’d do it in a TCL proc.  Something like this should work:

          Code:

          proc fix_oru { args } {
             keylget args MODE mode

             set dispList {}

             switch -exact — $mode {
                 run {
                     keylget args MSGID mh
                     set preobx 1
                     set preobx_segs {}
                     set obx_segs {}
                     foreach seg [split [msgget $mh] r] {
                         # save all pre-obx segments
                         if { $preobx == 1 } {
                             if { [regexp {^OBX} $seg] } {
                                 set preobx 0
                             } else {
                                 lappend preobx_segs $seg
                             }
                         }
                         # process the obx segments
                         if { $preobx == 0 } {
                             lappend obx_segs $seg
                             if {[cequal [lindex [split $seg |] 3] “%UN^UNIT NUMBER”]} {
                                 lappend obx_segs “”
                                 set mh2 [msgcopy $mh]
                                 msgset $mh2 [join [concat $preobx_segs $obx_segs] r]
                                 lappend dispList “CONTINUE $mh2”
                                 set obx_segs {}
                             }
                         }
                     }
                     msgset $mh [join [concat $preobx_segs $obx_segs] “r”]
                     lappend dispList “CONTINUE $mh”
                 }
             }
             return $dispList
          }

          I was a little lazy by assuming that the field separator is a pipe (instead of copying it from the MSH).  Also, this code assumes that the last segments in the message are OBX’s, but it should be good enough to get you started.

        • #59991
          James Cobane
          Participant

            Carl,

            You should be able to do this within the Xlate, using conditional logic and manipulating your own iteration variable.

          • #59992
            Mark Gathers
            Participant

              Hi Carl,

              You may also be able to use the Suppress & Continue commands.  Suppress allows you to generate multiple outbound messages from a single inbound message.

          Viewing 2 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.