Announcement

Collapse
No announcement yet.

How to translate/escape & character?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to translate/escape & character?

    We have a system sending us an ampersand character and it's causing issues downstream.

    I am trying to write a transformer to translate the "&" to something else ("and" or "-", whatever...) but when I write Javascript to catch the value in AIS.3.1 it is not catching anything. It's as if the & is causing the field to be missed, so it seems.


    The transformer below already existed and was written by a Mirth employee a while back. You'd think this would work based on that ,but like my JS it seems to be ignored by the channel.

    Neither are throwing errors. The message just goes through and the field does not get translated at all.

    This is the problematic segment:

    AIS|1||Rapid Arc H & N^Rapid Arc H \T\ N|20191206100000|||30|


    This is the code from the Mirth rep:

    Code:
    switch (msg['AIS']['AIS.3']['AIS.3.1'].toString() + "") {
                    case "Rapid Arc H & N":
                                    msg['AIS']['AIS.3']['AIS.3.1'] = "Rapid Arc H and N";
                                    break;                  
    
                   default: break;
    
    }

    This is my JS:

    Code:
    if
    
    (
    msg['AIS']['AIS.3']['AIS.3.1'] == "Rapid Arc H & N"
    )
    {msg['AIS']['AIS.3']['AIS.3.1'] == "Rapid Arc H and N"
    )
    }
    Can anybody explain why neither of these are working? The "&" appears to make the field unreadable, but I'm not sure how to catch it within the field otherwise. I tried adding the 2nd subcomponent (^Rapid Arc H \T\ N) but that didn't make a difference. I didn't think it would since I'm looking specifically to AIS.3.1 in the first place, but had to try.

  • #2
    Maybe check the Data Types tab and see if you are parsing subcomponents. If you are, that treats the & like a |. If you disable this, it will treat & like a normal text character and you can manipulate the field at will.

    -= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
    -= [email protected]
    -= Mirth Connect (Advanced)-certified
    -= Gold member of HL7.org
    -= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines

    Comment


    • #3
      Well that definitely worked! Thanks, I wasn't familiar w/that setting.

      Now that is pretty good for now, though I have to consider future needs and whether or not we'll actually want to parse the & separator. I can't imagine the needs would change on his interface, but you never know.

      Considering either sets of code I provided above, is there any way I could expand on either to catch that & character while parsing subcomponents? *If* I could have it both ways, I think that would be best.

      Comment


      • #4
        Most channels either need it, or they don't. When it IS parsed, and an & exists, it splits msg['AIS']['AIS.3']['AIS.3.1'] to msg['AIS']['AIS.3']['AIS.3.1']['AIS.3.1.1'] and msg['AIS']['AIS.3']['AIS.3.1']['AIS.3.1.2']. You could always leave it default, then check for the length of msg['AIS']['AIS.3']['AIS.3.1'] and if it's > 1, do what you need to with it, but it rarely worth all that... Your call though!

        -= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
        -= [email protected]
        -= Mirth Connect (Advanced)-certified
        -= Gold member of HL7.org
        -= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines

        Comment


        • #5
          Originally posted by jackwhaines View Post
          Most channels either need it, or they don't. When it IS parsed, and an & exists, it splits msg['AIS']['AIS.3']['AIS.3.1'] to msg['AIS']['AIS.3']['AIS.3.1']['AIS.3.1.1'] and msg['AIS']['AIS.3']['AIS.3.1']['AIS.3.1.2']. You could always leave it default, then check for the length of msg['AIS']['AIS.3']['AIS.3.1'] and if it's > 1, do what you need to with it, but it rarely worth all that... Your call though!
          Right, I was thinking right now it would be fine but with the future..."who knows!"

          Could always cross that bridge when I come to it, but I can't help but wonder how I could make it work the other way too. For now, it solves the problem though. Thanks again!

          Comment


          • #6
            Turning off that setting is the easiest solution if that works for you. I did write a code template to join them back together if you decide to leave parse subcomponents turned on.

            https://github.com/nextgenhealthcare...0Subcomponents

            Comment

            Working...
            X