How to escape the ampersand (&) character in an Xlate

Clovertech Forums Cloverleaf How to escape the ampersand (&) character in an Xlate

  • Creator
    Topic
  • #122272
    Darrell Glover
    Participant

      I need to set a URL that includes an ampersand to a variable and then concat it with patient/accession values.  It appears that Cloverleaf considers the & as a delimiter, so the concat is not working correctly.  Does anyone know how to escape the ampersand.  For example, & is used for XML.

      Thanks!

      Attachments:
      You must be logged in to view attached files.
    Viewing 9 reply threads
    • Author
      Replies
      • #122274
        David Barr
        Participant

          You can use \T\.

        • #122275
          Darrell Glover
          Participant

            Thanks for the quick reply, David!  When I try using \T\, it just puts it in as plain text.  See my screenshots below from the xlate and the result in the testing tool.   Did I do something wrong?

            Attachments:
            You must be logged in to view attached files.
          • #122277
            Jerry Sawa
            Participant

              Try using “concat”

              first parameter will be everything in the URL up to “/mdweb”

              second parameter “=&”

              third parameter will be everything after”PatientID”

               

              • This reply was modified 4 days, 1 hour ago by Jerry Sawa.
            • #122278
              Jerry Sawa
              Participant

                Or create a variable called @ampersand, value as “=&”, then plug the variable into the URL.

              • #122280
                Darrell Glover
                Participant

                  Every time I try to use =& (either by itself or as a variable) Cloverleaf thinks it’s a delimiter and breaks the segment.

                  • #122281
                    Darrell Glover
                    Participant

                      See the attached screenshots of the xlate and results from the testing tool.  Thanks!

                      Attachments:
                      You must be logged in to view attached files.
                  • #122283
                    Jim Kosloskey
                    Participant

                      The idea for the \T\ is the receiving system should revert that back to an & if it is following the HL/7 standard. So, you see it as the \T\ in the message you send and then the receiving system changes that back to &.

                      Try that and see if the receiving system behaves properly. If not, let us know.

                      email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.

                      • #122284
                        Darrell Glover
                        Participant

                          Thank you for the clarification!  I will give that a try.

                      • #122285
                        Dirk Engels
                        Participant

                          If you use a url you will have to use url encoding. This replaces special character by a % notation.

                          https://www.w3schools.com/tags/ref_urlencode.ASP

                           

                           

                        • #122286
                          Charlie Bursell
                          Participant

                            Did you check to see if the recipient supports escape characters?  If they do then they should interpret the \T\ as an ampersand.  If not, then one of the suggested work arounds.

                            Its amazing that after all this time Cloverleaf does not recognize HL7 escape characters.

                            See this web page: https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=EHL72_escape_sequences

                             

                          • #122288
                            Jay Hammond
                            Participant

                              What do you see if you change the Detail level to 1?

                              I see what you’re talking about with the ampersand being removed when I have Detail level set to 4, but if I change it to 1 I see the following:

                              (0).OBR(0) : >|1|271538248^HNAM_ORDERID|20066091^EPC|343023^PLATELET|||20190926092700||https://server.local/mdweb/LauncherInterface.aspx?host=https://server.local.webmd&PatientID=3000837&accesionnum=271538248|||||20190926093100|BLOOD&Blood|0000819^Test^An^K^^MD^^^Doctor #||||000002019269005004^HNA_ACCN~18295341^HNA_ACCNID||20190926092500||LA|||1^^0^20190926093000^^S~^^^^^ST|||||||||20190926093000<0xa><

                              This is what I see with Detail level set to 4:

                              0(0).OBR(0).#9(0).[0].[0] : >https://server.local/mdweb/LauncherInterface.aspx?host=https://server.local.webmd&lt;
                              0(0).OBR(0).#9(0).[0].[1] : >PatientID=3000837<
                              0(0).OBR(0).#9(0).[0].[2] : >accesionnum=271538248<

                              We’re on Cloverleaf 2022.09.03.01

                            • #122289
                              Charlie Bursell
                              Participant

                                A method I should have mentioned which I used many times in the past.  Simply modify the encoding characters in the MSH.  Change the ampersand to an exclamation point or something.  I have even used unprintable characters for encoding.

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