Announcement

Collapse
No announcement yet.

How do I pull this XML field into a mapped variable

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

  • How do I pull this XML field into a mapped variable

    I have an incoming message that is getting parsed into XML like this:

    <PID>
    <PID.1>
    <PID.1.1>1</PID.1.1>
    </PID.1>
    <PID.2/>
    <PID.3>
    <PID.3.1>NumberOne</PID.3.1>
    <PID.3.2/>
    <PID.3.3/>
    <PID.3.4/>
    <PID.3.5>CODE~NumberTwo</PID.3.5>
    <PID.3.6/>
    <PID.3.7/>

    I want to pull NumberTwo in a transformer and set it to a channel variable.

    Based on previous experience with mirth, I would think that I would do something like...

    Mapping: msg['PID']['PID.3']['PID.3.5']['PID.3.5.2'].toString() but this is throwing an error.

    Can somebody help me out with this simple syntax issue? Thanks!

  • #2
    Assuming your encoding characters are "^~\&", then your field repetition marker is "~", and your subcomponent marker is "&". So to retrieve "NumberTwo" (which is in the first component of the second repetition of PID.3, not the second subcomponent of PID.3.5), you need to check "Parse Field Repetitions" on the inbound protocol (Source Inbound if transforming on the source, Source Outbound if on the destination), and then use the following syntax:

    Code:
    msg['PID']['PID.3'][1]['PID.3.1'].toString()
    Note that using that syntax is assuming that there are always at least two repetitions of PID.3. An ECMAError will be thrown if there aren't, so make sure to do proper validation, etc.
    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
      Thanks

      Comment

      Working...
      X