TCL Help

  • Creator
    Topic
  • #49251
    Daniel Bantaa
    Participant

      I have a TCL proc that I want to kill ADT messages if the patient type in the PV1 segement is not equal to a certain parameter.  I past procs, I would count the fields until I reached the desired field and check the value.  This does not work when the ADT has multiple NK1 segments.  I’m trying to locate the PV1 segement and then move to the position that I want to check.  The only problem that I seem to be having is in my if condition when check the field for “PV1”.  Below is my code.

                set field_sep [csubstr $msg 3 1]     ;# HL7 field

                set sub_sep [csubstr $msg 4 1]       ;# HL7 subfield

                set fieldList [split $msg $field_sep]

                #find pv1 segment

        set x 0

        set pos 0

        while {$x < 1} { set xfield [lindex $fieldList $pos]        set xfieldList [split $xfield $sub_sep]        set xtype [lindex $xfieldList 0] if {$xtype == “PV1”}   incr x } else {   incr pos }    }           set pos [expr {$pos + 17}]   set pv1_17 [lindex $fieldList $pos]   set subfieldList [split $pv1_17 $sub_sep]   set pttype [lindex $subfieldList 0]           if {$pttype == $type} {               lappend dispList “CONTINUE $msgId”            } else {               lappend dispList “KILL $msgId”              }           }

    Viewing 1 reply thread
    • Author
      Replies
      • #61260
        Anonymous
        Participant

          Hi Daniel,

          Try this:

          set msg [msgget $mh]

          set seglist [split $msg r]

          set segPV1 [lindex [lregexp $seglist {^PV1}] 0 ] ; grabs PV1 segment

          set PV1_flds [split $segPV1 “|”]  ; splits the fields into a list

          set PV1_17 [ lindex $PV1_flds 17]  ; grap PV1-17 field.

          if [string equal $PV1-17 $type] {

               lappend dispList “CONTINUE $mh”

          } else {

               lappend dispList “KILL $mh”

          }

          Let me know if this is what you were looking for.

          Tom Rioux

        • #61261
          Daniel Bantaa
          Participant

            Thanks for the help, that works great.

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