web stats
Best practises - How do I ... ? - DateTime conversion - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 09-14-2006, 07:10 AM
nshaik nshaik is offline
Mirth Guru
 
Join Date: Sep 2006
Posts: 302
nshaik
Default Best practises - How do I ... ? - DateTime conversion

Message: ADT - A04

=======================
Transformer for Patient's Date of Birth:

Variable: patDOB
Mapping: msg['PID']['PID.7']['TS.1']
=======================

Data in msg['PID']['PID.7']['TS.1'] is like "19460130000000"

and needs to be converted to "01/30/1946" (mm/dd/yyyy format).

How do I do the conversion ?

Thanks in advance!
Reply With Quote
  #2  
Old 09-14-2006, 11:02 AM
chrisl chrisl is offline
Mirth Employee
 
Join Date: Aug 2006
Posts: 967
chrisl is an unknown quantity at this point
Default Re: Best practises - How do I ... ? - DateTime conversion

There are three options:

1. Using a regular expressions to break apart the string and building the date manually
2. Using the JAVA data functions
3. Parsing the string manually

The *best* practice would be to use the first option:
**************************
Code:
var dob = msg['PID']['PID.7']['TS.1'].text()[0];
var ar = dob.match(/(\d\d\d\d)(\d\d)(\d\d)/);
var dobstr = RegExp.$2 + '/' + RegExp.$3 + '/' + RegExp.$1;
localMap.put('patDOB', dobstr);
**************************
Do note that you need to use a Javascript step, not a mapping step to do this.
-Chris
__________________
Chris Lang
Reply With Quote
  #3  
Old 10-22-2009, 06:29 AM
kashif kashif is offline
OBX.1 Kenobi
 
Join Date: Jan 2008
Location: Aga Khan Universitiy Hospital
Posts: 41
kashif
Default RegExp is better

I tried using Date conversion utility , but failed.

//Incoming format 2009031823180000
//Required Output format 2009-18-08 23:18:00

//Method that failed

//channelMap.put('STUDY_TIME', DateUtil.convertDate( 'yyyyMMddhhmmss', 'yyyy-dd-MM hh:mm:ss', msg['ORC']['ORC.15']['ORC.15.1'].toString() ));


//Method that is a success

var dob = msg['ORC']['ORC.15']['ORC.15.1'].text()[0];
var ar = dob.match(/(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/);

var dobstr = RegExp.$1 + '-' + RegExp.$3 + '-' + RegExp.$2 + ' ' + RegExp.$4 + ':' + RegExp.$5 + ':' + RegExp.$6 ;
channelMap.put('STUDY_TIME', dobstr);
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion failed when converting datetime doc4child General Discussion 3 06-02-2019 11:06 PM
Conversion to from HPRIM dbarber Development 8 01-03-2012 06:26 AM
Conversion without templates ??? rahulrocks Support 2 01-12-2009 04:46 AM
please help me in conversion into HL7 message Vgupta Development 0 12-03-2007 12:56 PM
mapping help, convert HL7 datetime to SOAP dateTime jbartels Support 4 11-06-2006 11:41 AM


All times are GMT -8. The time now is 02:11 AM.


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