Announcement

Collapse
No announcement yet.

Decoding Special Characters

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

  • Decoding Special Characters

    How can I, using Javascript in a transformer, turn this:

    RUA CALLOUSTE GULBENKIAN N.\XBA\ 42 3\XBA\ ESQ
    into this:

    RUA CALLOUSTE GULBENKIAN N.º 42 3º ESQ
    Is there some method that does this? Because otherwise I would have to predict all the special characters that could appear to replace them.

  • #2
    I've created a code template for this, since it has been asked multiple times: http://www.mirthcorp.com/community/f...3206#post43206
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment


    • #3
      Using your template began to give this error
      TypeError: Cannot read property "PID" from undefined

      Comment


      • #4
        Can you post a sample message that reproduces it?
        Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

        Nicholas Rupley
        Work: 949-237-6069
        Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


        - How do I foo?
        - You just bar.

        Comment


        • #5
          Instead of applying to the all message I just applied to the address field and when the input is this
          RUA CALLOUSTE GULBENKIAN N.\XBA\ 42 3\XBA\ ESQ
          it results in this
          RUA CALLOUSTE GULBENKIAN
          isntead of decoding.

          Comment


          • #6
            Made a small tweak to the code template. Other than that, works perfectly for me.

            Input message:

            Code:
            MSH|^~\&|ADT1|SHM|SHMADT|SHM|200812091126|SECURITY|ADT^A01^ADT_A01|MSG00001|P|2.5|
            EVN|A01|200812091126||
            PID|1|1001|1001^5^M11^ADT1^MR^SHM~123456789^^^USSSA^SS||OHALLAHAN^COLLEEN^^||19850704|F||2106-3|\XB0\^^NEWPORT BEACH^CA^92660-1020^US^H|OC|(949) 555-1234|(949) 555-5678||S||PATID1001^2^M10^ADT1^AN^A|123456789|U1234567^CA|
            NK1|1|OHALLAHAN^BRITTANY^M|SIS^SISTER||||N^NEXT-OF-KIN
            PV1|1|I|2000^2012^01||||001122^ZOIDBERG^JOHN^|||SUR||||1|A0|
            Transformer:

            Code:
            unescapeXSequences(msg['PID']['PID.11'], 'windows-1251');
            Output:

            Code:
            MSH|^~\&|ADT1|SHM|SHMADT|SHM|200812091126|SECURITY|ADT^A01^ADT_A01|MSG00001|P|2.5|
            EVN|A01|200812091126||
            PID|1|1001|1001^5^M11^ADT1^MR^SHM~123456789^^^USSSA^SS||OHALLAHAN^COLLEEN^^||19850704|F||2106-3|°^^NEWPORT BEACH^CA^92660-1020^US^H|OC|(949) 555-1234|(949) 555-5678||S||PATID1001^2^M10^ADT1^AN^A|123456789|U1234567^CA|
            NK1|1|OHALLAHAN^BRITTANY^M|SIS^SISTER||||N^NEXT-OF-KIN
            PV1|1|I|2000^2012^01||||001122^ZOIDBERG^JOHN^|||SUR||||1|A0|
            Note the use of a charset. By default US-ASCII is used, and B0 is not defined, so you'll get the � replacement character instead most likely.
            Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

            Nicholas Rupley
            Work: 949-237-6069
            Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


            - How do I foo?
            - You just bar.

            Comment

            Working...
            X