Base64 encoding in an xlate

Clovertech Forums Cloverleaf Base64 encoding in an xlate

  • Creator
    Topic
  • #120894
    RICK L. PRITCHETT
    Participant

      Is there any way to do base64 ending in an xlate?  If I remember correctly there is a package required to do this.

    Viewing 7 reply threads
    • Author
      Replies
      • #120895
        Jeff Dinsmore
        Participant

          I’ve never done this specifically, but you could try something like this in an Xlate copy Tcl snippet:

          package require base64

          set str [lindex $xlateInVals 0]
          set xlateOutVals

            ]

            Jeff Dinsmore
            Chesapeake Regional Healthcare

          1. #120896
            Peter Heggie
            Participant

              yes there is a package

              ex: package require base64

              This would un-encode a base64 value:

              set code [catch {base64::decode “$base64string”} output1]

               

              Are you un-encoding a base64 string in OBX.5 ?

              Peter Heggie

            • #120897
              Jim Kosloskey
              Participant

                Yes, you can and like Jeff indicates you need to require the base64 package.

                I do the following (using Jeff’s example):

                set msg_data_encoded [base64::encode $str]

                set xlateOutVals [lreplace $xlateOutVals 0 0 $msg_data_encoded]

                BUT – if you are encoding the data in sructured message (HL/7, X12, etc.), what if encoding characters (HL/7 ‘| ^ ~, etc’) are in the data to be encoded? It is possible the inbound may not parse out correctly.

                Jim

                 

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

              • #120898
                Jeff Dinsmore
                Participant

                  Wow, re-reading my post, I see I did a pretty bad job checking my work…

                  It should read something like this:

                  package require base64

                  set str [lindex $xlateInVals 0]
                  set xlateOutVals

                    ]

                     

                    Jeff Dinsmore
                    Chesapeake Regional Healthcare

                  1. #120899
                    Jeff Dinsmore
                    Participant

                      … and now I see that it wasn’t me…  seems my coding confused the editor somehow.

                      my response was substantially like Jim’s, so we’ll just leave it at that.

                       

                       

                       

                      Jeff Dinsmore
                      Chesapeake Regional Healthcare

                    • #120900
                      Jim Kosloskey
                      Participant

                        Jeff, I bet it is your keyboard. For over 55 years I have not had one keyboard that can spell or convey my thoughts properly 🙂

                         

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

                      • #120901
                        Jeff Dinsmore
                        Participant

                          Yep, it’s definitely busted.

                          It’s also getting more apathetic as it gets older.

                          I’ll requisition a new one.

                          Jeff Dinsmore
                          Chesapeake Regional Healthcare

                        • #120902
                          Robert Kersemakers
                          Participant

                            Regarding possible (HL7) encoding characters in base64.
                            Base64 encodes into a-z, A-Z, 0-9, “+” and “/”. So no HL7 encoding characters, which means you can safely use a base64 encoded string inside a (normal) HL7 message.

                            EDIFact would have problems with this as + is a reserved character. Other structered messages may have problems with this as well.

                            Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

                        Viewing 7 reply threads
                        • You must be logged in to reply to this topic.