web stats
Dateutil in hl7 iterations - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-05-2019, 06:44 AM
Golfmachine Golfmachine is offline
Mirth Newb
 
Join Date: Jun 2019
Posts: 13
Golfmachine is on a distinguished road
Default Dateutil in hl7 iterations

Hello! I am new to mirth and I have a question which I am sure would be easy for most to figure out. I have a message with multiple OBR lines as such:

OBR|1|CTN0024511||4033883^LUNG W/ CONTRAST||20180730000000||||||||||||CT|N|||||||||a ||||||
OBR|2|CTN0024511||4033884^BRAIN||20180830000000||| |||||||||CT|N|||||||||a||||||
OBR|3|CTN0024511||4033885^WHOLE ABDOMEN||20180970000000||||||||||||CT|N|||||||||a| |||||

I want to convert all OBR-6 from yyyyMMddHHmmss format to yyyy-MM-dd format.

This is the javascript I used but seems to not be working:
for each (obr in msg.OBR)
msg.children()[obr.childIndex()]['OBR.6']['OBR.6.1'].toString();
var date = msg.children()[obr.childIndex()]['OBR.6']['OBR.6.1'].toString();
date = DateUtil.convertDate('yyyyMMddHHmmss', 'yyyy-MM-dd', date);

Hope someone could help. Thanks!
Reply With Quote
  #2  
Old 11-05-2019, 06:47 AM
jackwhaines jackwhaines is offline
 
Join Date: May 2011
Location: Kansas City, Missouri
Posts: 255
jackwhaines is on a distinguished road
Send a message via Skype™ to jackwhaines
Default

Try:

Code:
for each (seg in msg..OBR)
	{
	seg['OBR.6']['OBR.6.1'] = DateUtil.convertDate('yyyyMMddHHmmss', 'yyyy-MM-dd', seg['OBR.6']['OBR.6.1'].toString());
	}
__________________

-= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
-= jack.haines@HealthcareIntegrations.com
-= Mirth Connect (Advanced)-certified
-= Gold member of HL7.org
-= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines
Reply With Quote
  #3  
Old 11-05-2019, 06:49 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

I want to convert all OBR-6 from yyyyMMddHHmmss format to yyyy-MM-dd format.

for each (obr in msg.OBR)
{
obr['OBR.6']['OBR.6.1'] = obr['OBR.6']['OBR.6.1'].toString().substring(0,4) + '-' + obr['OBR.6']['OBR.6.1'].toString().substring(5,6) + '-' + obr['OBR.6']['OBR.6.1'].toString().substring(7,8);
}
Reply With Quote
  #4  
Old 11-05-2019, 06:50 AM
Golfmachine Golfmachine is offline
Mirth Newb
 
Join Date: Jun 2019
Posts: 13
Golfmachine is on a distinguished road
Default

I used jackwhaines' suggestion of

for each (seg in msg..OBR)
{
seg['OBR.6']['OBR.6.1'] = DateUtil.convertDate('yyyyMMddHHmmss', 'yyyy-MM-dd', seg['OBR.6']['OBR.6.1'].toString());
}

Works perfectly! Thanks a lot!

cory_cole yours also worked. Thank you too!

Last edited by Golfmachine; 11-05-2019 at 06:52 AM.
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 01:22 AM.


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