How to loop through insurance field in TCL

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf How to loop through insurance field in TCL

  • Creator
    Topic
  • #53572
    Yamil Velez
    Participant

    Hi

        I am trying to create a TCL that loops through the insurance segments and checks for a certain insurance.   I know I need to use a for loop but I am unable to write it.

    This is what I have so far.

    set msg [msgget $mh]

    set segments [split $msg r]

    This is where I can’t figure out.  I am doing the following for my loop

    set seg1 $segments

    foreach segment $seg{

    if {[cequal [crange $seg1 0 2]IN1]} {

      lappend seg $segment

    }

    }

    Thank you for your help

    Yamil

Viewing 2 reply threads
  • Author
    Replies
    • #78162
      Robert Milfajt
      Participant

      Try this:

      set msg [msgget $mh]
      set segments [split $msg r]

      foreach segment $segments {
      [code]set msg [msgget $mh]
      set segments [split $msg r]

      foreach segment $segments {

      Robert Milfajt
      Northwestern Medicine
      Chicago, IL

    • #78163
      Charlie Bursell
      Participant

      Too much work Bob.  Loop through all segments?  ðŸ˜€

      foreach IN1 [lsearch -inline -all -regexp $segments {^IN1}] {

                          Examine each IN1 here

      }

      The above works if making no changes since you do not care where the IN1 is located.  If changes are required:

      foreach loc [lsearch -all -regexp $srgments {^IN1}} {

          set IN1 [split [lindex $segments $loc] $fldSep]

               Now you have the location of each and  can modify then replace

      }

      lsearch is probably the best tool we have for dealing with HL7

    • #78164
      gricelda lopez
      Participant

      Thanks Charlie. I used your sample and it worked great.

      My goal was to filter out normal lab results but some ORU obx segments had combination of abnormal/normal flags.

      This is what I used in case it helps anyone out there:

      foreach loc [lsearch -all -regexp $segments {^OBX}] {

         set OBX [split [lindex $segments $loc] $fldSep]

                               

                   

         set obx_8 [lindex $OBX 8]      

         set abnormal_value [lindex $obx_8]        

         echo Abnormal Value = $abnormal_value

         

                         set tableName Valid_Abnormal_Values

         set abnormalflag [tbllookup $tableName $abnormal_value]

         echo The Flag =$abnormalflag          

             

      } ;# foreach

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

Forum Statistics

Registered Users
5,129
Forums
28
Topics
9,301
Replies
34,447
Topic Tags
288
Empty Topic Tags
10