Looking for TCL to break on 60 characters in OBX-5

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Looking for TCL to break on 60 characters in OBX-5

  • Creator
    Topic
  • #52313
    Shelbi Engle
    Participant

      Hi,

      We are receiving a large blob of text for a pathology result in OBX-5.  Our receiving HIS system is not displaying the result as the client would like.  Is there a TCL to insert a line break (or other character) at 60 characters  in the OBX-5 field WITHOUT breaking in the middle of a word?

      Thanks in Advance!

      Shelbi

    Viewing 5 reply threads
    • Author
      Replies
      • #73767
        Tim Pancost
        Participant

          Hey, Shelbi,  we do something like that here for a PACS system that doesn’t like lines greater than 70 characters.  Here’s the xlt proc we use.  I’m sure there’s a more elegant way to do it, but it works for us.  It splits the field on a space character, then builds lines word by word until it reaches the max line length(which you’d need to change).  If adding a word to the line exceeds the max line length, it starts a new line.

          HTH,

          TIM

          #############################################################################

          #       Title:          Rad_DR_BI_Format_Result_Text

          #       Purpose:        This translation operation proc formats

          #                       result fields into textual results with

          #                       standard lengths to make a more uniform display in  

          #                       Meditech

          #       Author:         Tim Pancost

          #       Date:           December 2010

          #

          #       Input:          result

          #       Output:         result

          #

          proc Rad_DR_BI_Format_Result_Text {} {

                 upvar xlateInVals xlateInVals xlateOutVals xlateOutVals

                 upvar xlateInList xlateInList xlateOutList xlateOutList

                 upvar xlateId myxpmId

                 #  Set internal variables

                 set newResult “”

                 set result [lindex $xlateInVals 0]

                 if {[string length $result] > 70} {

                     set resultList [split $result ” “]

                     set resultLine “”

                     set resultLineLength 0

                     foreach word $resultList {

                         set wordLength [string length $word]

                         if {[expr $resultLineLength + $wordLength] > 69} {

                             lappend newResultList $resultLine

                             set resultLine $word

                             set resultLineLength $wordLength

                         } else {

                             append resultLine ” ” $word

                             incr resultLineLength [expr $wordLength + 1]

                         }

                     }

                     lappend newResultList $resultLine

                     set newResult [join $newResultList ~]

                     set newResult [string trimleft $newResult]

                 } else {

                    set newResult $result

                 }

                 xpmstore $myxpmId [lindex $xlateOutList 0] c $newResult

          }

          Tim Pancost
          Trinity Health

        • #73768
          Shelbi Engle
          Participant

            Thanks, I’ll take a look and see if this works.

          • #73769
            Jeff Dinsmore
            Participant

              check out “string wordstart” – it simplifies breaking at word boundaries

              Jeff Dinsmore
              Chesapeake Regional Healthcare

            • #73770
              David Barr
              Participant

                “::textutil::adjust::adjust -length 70” might be even easier.

                http://tcllib.sourceforge.net/doc/adjust.html

              • #73771
                Jeff Dinsmore
                Participant

                  Slick!

                  It appears I’ve been working way too hard…

                  Note that the documentation at the above URL shows

                  package require textutil::adjust

                  but this is what works (on my Linux machine anyway)

                  package require textutil

                  Jeff Dinsmore
                  Chesapeake Regional Healthcare

                • #73772
                  Robert Kersemakers
                  Participant

                    Very slick!

                    I made a ‘format’-proc similar to Tim’s to format large pieces of text. I should have a better look at these standard libraries. If I ever find time for that… 👿

                    Thanks David!

                    Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

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