How to catch multiple hexa char in HL7 msg and replace it ?

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf How to catch multiple hexa char in HL7 msg and replace it ?

  • Creator
    Topic
  • #48300
    Ga
    Participant

      Hi everyone,

      I tried a lot of things and I did’nt resolve my big problem. I have to send HL7 messages to an outbound system it can accept particular characters in ISO 8859-1 characters list…

      That vendor asked me to precede  every special characters in the message by the character ” and pass him, the hexa value.

      For example, ‘Syst

    Viewing 8 reply threads
    • Author
      Replies
      • #58282
        Jim Kosloskey
        Participant

          Gaetan,

          Try the ‘string map’ function.

          Jim Kosloskey

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #58283
          Charlie Bursell
          Participant

            An easier method might be something like:

            Assume the string is in a variable called str

            if {[regsub -all — {[^x00-x7F]} $str

                                            {\x0[format %02x [scan & %c]]} tmp]} {

               set str [subst $tmp]

            }

            If the string has non-ascii characters they get converted, else not

          • #58284
            Rentian Huang
            Participant

              Charlie, I tried your code but looks it always replace the char with a hardcoded 26 ??


              set name
              [code]
              set name

            • #58285
              Charlie Bursell
              Participant

                You didn’t try the whole thing as I sent it to you.  Use the curl braces where I have used them and then use the subst command.

                What my code does is replace each instance of a non-ascii code with the string:  x0[format %02x [scan %c]]

                Where above is the character found.

                You then run the subst command to cause the commands to execute

                regsub -all — {[^x00-x7F]} $name {\x0[format %02x [scan & %c]]} tmp

                set result [subst $tmp]

                I would put the regsub in an if statement and only execute the subst if a change was made.

              • #58286
                Rentian Huang
                Participant

                  Perfect, I got it!  Thanks Charlie!!

                • #58287
                  Ga
                  Participant

                    Thank you so much Charlie and to Jim, for your answer, it help me a lot. I want to ask you again, something else. in my HL7 msg, how could I replace ‘T’ and only when the T is beetween ”.  I want to replace by ‘/T/’. My regsub do’nt work good.

                    For example :

                    set name

                  • #58288
                    Jim Kosloskey
                    Participant

                      Gaetan,

                      Regsub is not my forte but…

                      I used regsub -all — {\T\} $name {/T/} tmp and that seemed to work OK.

                      By the way, the T is correct notation in an HL/7 text field to represent imbedded subcomponent separator, /T/ is not.

                      If the receiving system wants the latter, they are not following the standard and, in my opinion, should change their code.

                      Jim Kosloskey

                      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                    • #58289
                      Ga
                      Participant

                        Hi Jim,

                        I tried your suggestion and It ‘s not working unfortunately … but I’ m agree with you about the receiving system.

                        I need to do that translate command because just before, I do that first command :

                        if {[regsub -all — {[x7f-x9fxa0-xff]} $msg {\\0x[format %2x\ [scan & %c]]} tmp]} {

                          puts “tmp = $tmp”  

                          set msg [subst $tmp]

                        }

                        to catch all the special characters in hexadecimal code in my HL7 msg and change those because the receiving system as problems with that hexa char.  But when I pass that first command, I lose all the ” and I could’nt find a method to bypass that problem…

                        The receiving system asked me to pass those hexa char as ‘x…’

                        For example, ‘Syst

                      • #58290
                        Ga
                        Participant

                          Hi Jim,

                          Your command is OK when I pass it in Cloverleaf. in my previous email, I was only testing with HCITCL….

                          Thanks a lot, it’s perfect !

                          Ga

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