Help – convert encoding character "|"

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Help – convert encoding character "|"

  • Creator
    Topic
  • #54336
    Shu Chen
    Participant

      Dear Clovertecher:

      I have a request for conver encoding character for NTE:3 field.

      I wrote a script in TCL and can convert all encoding characters except Pipe “|”. My code is below. my code is below.

      if there is a Pipe “|” inside the field value, is it possible to convert it?

      is there a way we could do it?

      thank you for your help as always!!!!

      run {

         # ‘run’ mode always has a MSGID; fetch and process it

                 keylget args MSGID mh

       set msg [msgget $mh]

       set segmentList [split $msg r]

       set newSegmentList “”

       set compsep [crange $msg 4 4]

       set fieldSeparator [crange $msg 3 3 ]

       foreach segment $segmentList {

      if {[crange $segment 0 2] == “NTE”} {

         set fieldList [split $segment $fieldSeparator]

         set f3 [lindex $fieldList 3]

         regsub {|} $f3 {\F\} f3

         regsub {~} $f3 {\R\} f3

         regsub {^} $f3 {\S\} f3  

         regsub {\} $f3 {\E\} f3

         regsub {&} $f3 {\T\} f3

         set fieldList [lreplace $fieldList 3 3 $f3]    

         set segment [join $fieldList $fieldSeparator]

       

      } else {

         # no change

      }

          set newSegmentList [lappend newSegmentList $segment]

         }

         set msg [join $newSegmentList r]

    Viewing 1 reply thread
    • Author
      Replies
      • #81057
        Robert Kersemakers
        Participant

          Hi Shu,

          You can’t solve this problem in Cloverleaf yourself as you can’t decide whether a ‘|’ is a field-separator or part of value.

          If the sender/sending system is sending an HL7 message with a pipe ‘|’ as part of a value/text, then this is just plain wrong and not conforming to the HL7 standard. You will need to ask the sending system to correct this. Same goes for all other special HL7 characters.

          Hope this helps.

          Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

        • #81058
          Robert Milfajt
          Participant

            Although if for your data, NTE-3 was the last field sent, i.e., they don’t send NTE-4 or beyond (or trailing | characters), you could script it in such a way that you grab all the data after the third | into a variable, then run your transform.

            Robert Milfajt
            Northwestern Medicine
            Chicago, IL

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