replaceHL7Field tcl proc

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf replaceHL7Field tcl proc

  • Creator
    Topic
  • #48631
    Jonathan Presnell
    Participant

      Can someone provide me a copy of the replaceHL7Field tcl script?

      Thanks.

    Viewing 1 reply thread
    • Author
      Replies
      • #59230
        Rick Martin
        Participant

          Hi Johnathan,

          Here’s what I have for that script:

          Code:


          ######################################################################
          # replaceHL7Field – generic routine to replace the data in an HL7 field
          # Args: msg       the entire HL7 message
          #       segmentID the name of the segment containing the field to replace
          #       fieldID   the index of the field to replace
          #       data      the data that will replace the current contents of the field
          #
          # Returns: the an entire HL7 message
          #
          proc replaceHL7Field {msg segmentID fieldID data {fieldSeparator “|”} } {

             set segmentList [split $msg r]
             set newSegmentList “”
             foreach segment $segmentList {
                 if {[crange $segment 0 2] == $segmentID} {
                     set fieldList [split $segment $fieldSeparator]
                     set fieldList [lreplace $fieldList $fieldID $fieldID $data]
                     set segment [join $fieldList $fieldSeparator]
                 }
                 set newSegmentList [lappend newSegmentList $segment]
             }
             return [join $newSegmentList r]
          }

        • #59231
          Jonathan Presnell
          Participant

            Thank you Rick!

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