HELP replace encoding char with special string

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf HELP replace encoding char with special string

  • Creator
    Topic
  • #54380
    Shu Chen
    Participant

      hi clovertecher:

      is it possible to convert hl7 “|^~&” to those speical char F , E..etc for OBX:5 report field?

      it is free text field for my client. I have a hard time to convert them espiecially for “|”.

      I would greatly appreciate it if someone kindly give me some feedback on this request

      shu

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

          Hi Shu,

          That depends on the situation.

          Is your inbound message HL7? And in OBX-5 there are special characters that have not been escaped? Then it is virtually impossible to correct this. You will need to have the sending system escape the HL7 special characters.

          If your inbound is not HL7, but a different format (XML, FRL, VRL or whatever) then you can escape the text that you’re putting into OBX-5. You should have some generic HL7 tcl procs for that.

          Hope this helps.

          Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

        • #81246
          Sergey Sevastyanov
          Participant

            Hi Shu,

            I did something like that. It is possible to do in Tcl with some assumptions:

            1. If you know for sure that OBX-5 is not a repeating filed and does not have any subfields; In this case you can assume that any special character within OBX-5 is just a character that should be escaped.

            In this case you should start with escaping “” – otherwise you will end with escaping escaped characters.

            2. If you know for sure that OBX-5 is the very last field in the segment; then you can treat all OBX fields starting with OBX-5 to the end of the segment as one filed that has embedded “|”. (If this is not the case then there is no way to know which “|” is part of OBX-5 and which is a field separator).

            For example, if your OBX segment looks something like:

            Code:


            OBX|1|TX|||This is OBX-5 field with , ~, & and | embedded as part of the field. This is another | within the same OBX-5|

            then the whole string “This is OBX-5 field with , ~, & and | embedded as part of the field. This is another | within the same OBX-5” should be treated as one field.

            So, if both assumptions above are true you can do it like this (the code below may be not the best code but it worked in my tests; still you should test it):

            Code:


            # the next command is for testing purposes only
            set obx {OBX|1|TX|||This is OBX-5 field with , ~, & and | embedded as part of the field. This is another | within the same OBX-5|}

            set sep “|”
            set fields [split $obx $sep]
            set obx5 [string trimright [join [lrange $fields 5 end] $sep] $sep]
            #  start with escaping “” – otherwise you will end with escaping escaped characters
            regsub -all  — {(\)} $obx5 {\E\} obx5
            # other escapes can go in any order
            regsub -all  — {(&)} $obx5 {\T\} obx5
            regsub -all  — {(~)} $obx5 {\R\} obx5
            regsub -all  — {(|)} $obx5 {\F\} obx5
            regsub -all  — {(^)} $obx5 {\S\} obx5]

            set obx [join [lreplace $fields 5 end $obx5] $sep]

            # debug only:
            echo $obx

            The code above produces the following output:

            Code:


            OBX|1|TX|||This is OBX-5 field with E, R, T and F embedded as part of the field. This is another F within the same OBX-5

            Hope it helps,

            Sergey

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