web stats
Strip Quote Marks From PID Segment - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 06-03-2012, 10:40 PM
randyl randyl is offline
OBX.1 Kenobi
 
Join Date: Jun 2012
Location: Oregon Country
Posts: 31
randyl is on a distinguished road
Default Strip Quote Marks From PID Segment

Hi,

I have HL7 v.3.2.1 ADT messages where the creator puts double quotes in the PID segment and the consumer must have them removed.

Not every field always has double quotes so I need to iterate over the whole PID and strip them out.

I am pretty new to mirth and don't understand yet how to do this using drag and drop message builder or Javascript (all my attempts at both don't do anything or just ruin the PID segment). Either way would be fine with me. I am looking for an explanation or suggestions on how to go about removing the double quotes from the message segment.

Thanks!

edit: I thought I would add what I have attempted so far. Here is the Javascript I've tried. It does remove the quotes, but it mangles the HL7 into XML and I don't understand why.
Code:
msg['PID'] = msg['PID'].toString().replace(/\"/g, '');
This is the resulting PID (all fields have test data in them):
Code:
PID|<PID><PID.1><PID.1.1>1</PID.1.1></PID.1><PID.2><PID.2.1>99999</PID.2.1></PID.2><PID.3><PID.3.1>99999</PID.3.1></PID.3><PID.4><PID.4.1>EMR</PID.4.1></PID.4><PID.5><PID.5.1>Man</PID.5.1><PID.5.2>Super</PID.5.2><PID.5.3>J</PID.5.3><PID.5.4/><PID.5.5/><PID.5.6/></PID.5><PID.6/><PID.7><PID.7.1>20100125</PID.7.1></PID.7><PID.8><PID.8.1>M</PID.8.1></PID.8><PID.9/><PID.10><PID.10.1>W</PID.10.1></PID.10><PID.11><PID.11.1>999 Super Ave S Apt N</PID.11.1><PID.11.2></PID.11.2><PID.11.3>Eugene</PID.11.3><PID.11.4>OR</PID.11.4><PID.11.5>99999</PID.11.5><PID.11.6/></PID.11><PID.12><PID.12.1>Miss</PID.12.1></PID.12><PID.13><PID.13.1>(555)555-1234</PID.13.1><PID.13.2/><PID.13.3/><PID.13.4>N/A</PID.13.4><PID.13.5/><PID.13.6>555</PID.13.6><PID.13.7>3306203</PID.13.7></PID.13><PID.14><PID.14.1>(555)555-1234</PID.14.1></PID.14><PID.15><PID.15.1>English</PID.15.1></PID.15><PID.16><PID.16.1>S</PID.16.1></PID.16><PID.17/><PID.18/><PID.19><PID.19.1>000-00-0000</PID.19.1></PID.19><PID.20/><PID.21/><PID.22><PID.22.1>N</PID.22.1></PID.22><PID.23/><PID.24/><PID.25/><PID.26/><PID.27/><PID.28/><PID.29/><PID.30><PID.30.1>N</PID.30.1></PID.30></PID>

Last edited by randyl; 06-03-2012 at 11:11 PM.
Reply With Quote
  #2  
Old 06-04-2012, 05:23 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

Quote:
Originally Posted by randyl View Post
Hi,

I have HL7 v.3.2.1 ADT messages where the creator puts double quotes in the PID segment and the consumer must have them removed.

Not every field always has double quotes so I need to iterate over the whole PID and strip them out.

I am pretty new to mirth and don't understand yet how to do this using drag and drop message builder or Javascript (all my attempts at both don't do anything or just ruin the PID segment). Either way would be fine with me. I am looking for an explanation or suggestions on how to go about removing the double quotes from the message segment.

Thanks!

edit: I thought I would add what I have attempted so far. Here is the Javascript I've tried. It does remove the quotes, but it mangles the HL7 into XML and I don't understand why.
Code:
msg['PID'] = msg['PID'].toString().replace(/\"/g, '');
This is the resulting PID (all fields have test data in them):
Code:
PID|<PID><PID.1><PID.1.1>1</PID.1.1></PID.1><PID.2><PID.2.1>99999</PID.2.1></PID.2><PID.3><PID.3.1>99999</PID.3.1></PID.3><PID.4><PID.4.1>EMR</PID.4.1></PID.4><PID.5><PID.5.1>Man</PID.5.1><PID.5.2>Super</PID.5.2><PID.5.3>J</PID.5.3><PID.5.4/><PID.5.5/><PID.5.6/></PID.5><PID.6/><PID.7><PID.7.1>20100125</PID.7.1></PID.7><PID.8><PID.8.1>M</PID.8.1></PID.8><PID.9/><PID.10><PID.10.1>W</PID.10.1></PID.10><PID.11><PID.11.1>999 Super Ave S Apt N</PID.11.1><PID.11.2></PID.11.2><PID.11.3>Eugene</PID.11.3><PID.11.4>OR</PID.11.4><PID.11.5>99999</PID.11.5><PID.11.6/></PID.11><PID.12><PID.12.1>Miss</PID.12.1></PID.12><PID.13><PID.13.1>(555)555-1234</PID.13.1><PID.13.2/><PID.13.3/><PID.13.4>N/A</PID.13.4><PID.13.5/><PID.13.6>555</PID.13.6><PID.13.7>3306203</PID.13.7></PID.13><PID.14><PID.14.1>(555)555-1234</PID.14.1></PID.14><PID.15><PID.15.1>English</PID.15.1></PID.15><PID.16><PID.16.1>S</PID.16.1></PID.16><PID.17/><PID.18/><PID.19><PID.19.1>000-00-0000</PID.19.1></PID.19><PID.20/><PID.21/><PID.22><PID.22.1>N</PID.22.1></PID.22><PID.23/><PID.24/><PID.25/><PID.26/><PID.27/><PID.28/><PID.29/><PID.30><PID.30.1>N</PID.30.1></PID.30></PID>
The "appropriate" thing to do would be to replace double quotes with an escape sequence:

Code:
msg.PID = new XML(msg.PID.toString().replace(/"/g,'\\X22\\'));
However, if the client is unable to accept proper HL7, or you just want to get rid of the double quotes and be done with it, do this:

Code:
msg.PID = new XML(msg.PID.toString().replace(/"/g,''));
__________________
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 06-04-2012, 06:31 AM
randyl randyl is offline
OBX.1 Kenobi
 
Join Date: Jun 2012
Location: Oregon Country
Posts: 31
randyl is on a distinguished road
Default

Thank you very much for the timely reply. I agree about the proper formatting. However, according to the lab receiving the message a v2.3.1 HL7 should already be escaped so their software doesn't parse out and remove the quotes. I felt it was easier to remove the quotes for them than press the issue.

I also really appreciate you showing me the escape sequence substitution. I like that and will use it in another interface I have.
Reply With Quote
  #4  
Old 06-04-2012, 07:57 AM
randyl randyl is offline
OBX.1 Kenobi
 
Join Date: Jun 2012
Location: Oregon Country
Posts: 31
randyl is on a distinguished road
Default [solved]

I have tested this and it solves my problem. Thank you again.
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 06:02 AM.


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