web stats
Deleting empty fields - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-24-2013, 02:12 PM
moritz moritz is offline
Mirth Newb
 
Join Date: Sep 2012
Posts: 15
moritz is on a distinguished road
Default 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^^^test@test.com^| |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^^^test@test.com| |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
Reply With Quote
  #2  
Old 04-24-2013, 03:49 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,116
narupley is on a distinguished road
Default

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.
Reply With Quote
  #3  
Old 04-25-2013, 07:15 AM
moritz moritz is offline
Mirth Newb
 
Join Date: Sep 2012
Posts: 15
moritz is on a distinguished road
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:49 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation