web stats
Move and convert date from OBX line to OBR - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-28-2019, 10:59 AM
Jaypell22 Jaypell22 is offline
OBX.1 Kenobi
 
Join Date: Jul 2011
Location: Upstate NY
Posts: 33
Jaypell22 is on a distinguished road
Default Move and convert date from OBX line to OBR

Good afternoon. I am trying to grab the date located in OBX.5 which will always follow "DATE OF SERVICE:" and convert it to YYYYMMDDHHMM date format finally inserting it into OBR.6.2. Can someone guide me in the right direction? Thanks! - Jay

OBX|1||||Referring Physician: TEST REFERRING||||||F|||20190820071530
OBX|2||||||||||F|||20190820071530
OBX|3||||Patient Name: TEST PATIENT||||||F|||20190820071530
OBX|4||||||||||F|||20190820071530
OBX|5||||RADIOLOGY REPORT:||||||F|||20190820071530
OBX|6||||||||||F|||20190820071530
OBX|7||||DATE OF SERVICE: 2019-08-20 02:56:53||||||F|||20190820071530
OBX|8||||||||||F|||20190820071530
OBX|9||||IMAGES: 2||||||F|||20190820071530
OBX|10||||||||||F|||20190820071530
OBX|11||||EXAM: XR CHEST 2V||||||F|||20190820071530
OBX|12||||||||||F|||20190820071530
Reply With Quote
  #2  
Old 08-28-2019, 11:40 AM
ISLITM ISLITM is offline
Mirth Newb
 
Join Date: Jun 2016
Posts: 6
ISLITM is on a distinguished road
Default

This should work for you, Mirth has a built in date converter which is handy
Code:
//Loop through all OBX segments
for each (seg in msg..OBX)
{
	//Find the "DATE OF SERVICE:" line
	if (seg['OBX.5']['OBX.5.1'].toString().indexOf("DATE OF SERVICE:") != -1)
	{
		//Just get the last portion of the line
		var rawDate = seg['OBX.5']['OBX.5.1'].toString().slice(-19);

		//Convert the date
		var modifiedDate = DateUtil.convertDate("yyyy-MM-dd HH:mm:ss", "yyyyMMddHHmm", rawDate);

		//Insert the date into OBR-6.2
		msg['OBR']['OBR.6']['OBR.6.2'] = modifiedDate;

		//Exit the loop
		break;
	}
}

Last edited by ISLITM; 08-28-2019 at 11:42 AM.
Reply With Quote
  #3  
Old 08-28-2019, 11:57 AM
Jaypell22 Jaypell22 is offline
OBX.1 Kenobi
 
Join Date: Jul 2011
Location: Upstate NY
Posts: 33
Jaypell22 is on a distinguished road
Default

Brilliant! Thank you for this. It works flawlessly. Regards
Reply With Quote
Reply

Tags
convert, date, format, obx

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 03:00 AM.


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