TCL Comparing to a subfield

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCL Comparing to a subfield

  • Creator
    Topic
  • #48651
    Ron Schwarz
    Participant

      I’m attempting to route lab results based on the ordering provider in the ORC segment, field 12, and cannot determine how to split out the provider id number, which is 3 to 5 digits. Appreciate any help.

      Here’s my tcl code I’m attempting to use.

    Viewing 3 reply threads
    • Author
      Replies
      • #59281
        garry r fisher
        Participant

          Hi,

          I’d use the genericHL7 library and code something like:

             set HL7msg [msgget $mh]

             set fieldSeparator [crange $HL7msg 3 3]

             set subfieldSeparator [crange $HL7msg 4 4]

             set orcSegment [getHL7Segment $HL7msg OBC]

             set orcField12 [getHL7Field $orcSegment 12 $fieldSeparator]

          This would give you the ordering provider in the variable ‘orcField12’.

          Hope this helps.

          Garry

        • #59282
          Greg Eriksen
          Participant

            I’m still a novice at tcl coding, so probably not the best person to help you, but I was curious because it looked like your code should work, so I tried it in interactive tcl:

            hcitcl>set field “1234^567^890”

            hcitcl>echo $field

            1234^567^890

            hcitcl>echo [lindex [split $field “^”] 1]

            567

            hcitcl>

            Seems to do what you’d expect, if in fact what you wanted was the second subfield.  Remember, the counting for the index number in a list starts at zero in tcl, so if you wanted the ID number of the Ordering Provider field you probably want to use:

            set filter [lindex [split $orc_fld12 “^”] 0]

            If that isn’t the problem, perhaps you could post an example ORC segment from one of your test messages, in case there is something about the formatting of that field that is throwing this off.

          • #59283
            garry r fisher
            Participant

              Hi,

              Missed a bit:

                set HL7msg [msgget $mh]

                set fieldSeparator [crange $HL7msg 3 3]

                set subfieldSeparator [crange $HL7msg 4 4]

                set orcSegment [getHL7Segment $HL7msg ORC]

                set orcField12 [getHL7Field $orcSegment 12 $fieldSeparator]

                set ordProv [lindex [split $orcField12 ^] 1]

              Not quite sure why you were using “^” but the above works fine in a number of scripts I’ve writtren.

              G

            • #59284
              Ron Schwarz
              Participant

                Thanks Garry and Greg,

                I found my problem yesterday and it was as Greg discribed, I was off on my index, once changed to 0, its now picking out the correct providers. I added cmdtrace to my script, which quickly showed what was wrong.

                Is it possible for the receiving thread to also ftp these lab results in an outbound? Would this need to be setup then as a route using tcl, perhaps using the sample ftp tcl code in the tcl library? Or can it all be done on the Protocol-Fileset-FTP options?

                Thanks,

                Ron

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