Announcement

Collapse
No announcement yet.

Deleting empty fields

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

  • Deleting empty fields

    Hi folks.

    Has anyone had problems with something like this:
    Code:
    PID||1234|| |TEST^TEST^ ^ ^ ^||19700130|M||Chinese|1234 S MAIN ST^ ^TESTTOWN^TX^77777^ ^||123-456-7890^^^[email protected]^| |Norwegian|Married|||222-25-2222|||2||||||||
    I am sending this segment from Mirth but my receiving app chokes on the empty fields (e.g '^ ^' and '| |')

    The transformed message looks like:
    Code:
            <PID.5>
                <PID.5.1>TEST</PID.5.1>
                <PID.5.2>TEST</PID.5.2>
                <PID.5.3/>
                <PID.5.4/>
                <PID.5.5/>
                <PID.5.6/>
            </PID.5>
    Are there any ideas how to remove the empty fields that the result will look like this:
    Code:
    PID||1234|||TEST^TEST||19700130|M||Chinese|1234 S MAIN ST^ ^TESTTOWN^TX^77777||123-456-7890^^^[email protected]| |Norwegian|Married|||222-25-2222|||2||||||||
    I thought iterating over the xml and removing everything that is empty would not be a good idea because there might come payoad data behind the currently checked element.

    Thanks for you input,
    Moritz

  • #2
    I've updated the stripEmptyNodes code template I wrote so that you can easily replace blank nodes with empty nodes, and delete blank/empty nodes, but only the trailing ones.

    http://www.mirthcorp.com/community/f...2179#post32179

    In your case, you'd want to use:

    Code:
    stripEmptyNodes(msg,true,true);
    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
      That works like charm.
      Wired that I have not found that on my search through the forum.

      But anyway hopefully that also helps other people to find this great function.

      Comment

      Working...
      X