web stats
URL Encoded - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-21-2012, 08:55 AM
RIMrules RIMrules is offline
Mirth Newb
 
Join Date: Jan 2011
Location: Boston, MA
Posts: 14
RIMrules is on a distinguished road
Default URL Encoded

Need to URL encode the HL7 message within the "data" parameter:

https://updatecert.drfirst.com/servlet/rcopia.servlet.ParserServlet?action=upload&version =&practice_id=1234&username=vendor&password=blahba lh&system_name=vendor&data_format=hl7&name=loadADT &data=MSH|^~\&|||||20110902122428||ADT^A01|1774811 |P|2.1|||||EVN|A01|20110902121900|PID|1|34473|3447 3||TEST^TEST^M||19860101|M||P|1111%20TEST%20DRIVE^ ^TEST^NV^99999||1234567890|||M||0||PV1|1|O|||||JYR |||DIA|||||||||||||||||||||||||||||SA|||||20070204 |

thus, the "data" will appeare as

data=MSH%7C%5E~%5C%26%7C%7C%7C%7C%7C20110902122428 %7C%7CADT%5EA01%7C1774811%7CP%7C2.1%7C%7C%7C%7C%7C EVN%7CA01%7C20110902121900%7CPID%7C1%7C34473%7C344 73%7C%7CTEST%5ETEST%5EM%7C%7C19860101%7CM%7C%7CP%7 C1111%2520TEST%2520DRIVE%5E%5ETEST%5ENV%5E99999%7C %7C1234567890%7C%7C%7CM%7C%7C0%7C%7CPV1%7C1%7CO%7C %7C%7C%7C%7CJYR%7C%7C%7CDIA%7C%7C%7C%7C%7C%7C%7C%7 C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C%7C% 7C%7C%7C%7C%7CSA%7C%7C%7C%7C%7C20070204%7CNK1%7C1% 7C

Is there a funtion in Mirth to URL encode parameters? Cant seem to find it...

Thanks
Reply With Quote
  #2  
Old 02-21-2012, 09:20 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

There probably is one out there, but I didn't feel like searching for it so I just whipped one up:

Code:
function encodeURL(URL) {
	return (URL+'')
		.replace(/\%/g,'%25')
		.replace(/\x0A/g,'')
		.replace(/\x0D/g,'%0D%0A')
		.replace(/\x20/g,'%20')
		.replace(/\!/g,'%21')
		.replace(/\"/g,'%22')
		.replace(/\#/g,'%23')
		.replace(/\$/g,'%24')
		.replace(/\&/g,'%26')
		.replace(/\'/g,'%27')
		.replace(/\(/g,'%28')
		.replace(/\)/g,'%29')
		.replace(/\*/g,'%2A')
		.replace(/\+/g,'%2B')
		.replace(/\,/g,'%2C')
		.replace(/\-/g,'%2D')
		.replace(/\./g,'%2E')
		.replace(/\//g,'%2F')
		.replace(/\:/g,'%3A')
		.replace(/\;/g,'%3B')
		.replace(/\</g,'%3C')
		.replace(/\=/g,'%3D')
		.replace(/\>/g,'%3E')
		.replace(/\?/g,'%3F')
		.replace(/\@/g,'%40')
		.replace(/\[/g,'%5B')
		.replace(/\\/g,'%5C')
		.replace(/\]/g,'%5D')
		.replace(/\^/g,'%5E')
		.replace(/\_/g,'%5F')
		.replace(/\`/g,'%60')
		.replace(/\{/g,'%7B')
		.replace(/\|/g,'%7C')
		.replace(/\}/g,'%7D')
		.replace(/\~/g,'%7E');
}
Not the most elegant way, but hey, it works.
Reply With Quote
  #3  
Old 02-21-2012, 09:57 AM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default

You can use the Java URL encoder/decoder:
http://docs.oracle.com/javase/1.4.2/...RLEncoder.html
http://docs.oracle.com/javase/1.4.2/...RLDecoder.html
__________________
Daniel Svanstedt
Software Engineer
Mirth Corporation

Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!
Reply With Quote
  #4  
Old 02-21-2012, 11:35 AM
RIMrules RIMrules is offline
Mirth Newb
 
Join Date: Jan 2011
Location: Boston, MA
Posts: 14
RIMrules is on a distinguished road
Default

Also, looks like the JavaScript functions would work:

var URLEncoded = escape(messageObject.getRawData());

or encodeURIComponent() and encodeURI()

Thanks for the responses!
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 10:26 PM.


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