Announcement

Collapse
No announcement yet.

Move and convert date from OBX line to OBR

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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, 10:42 AM.

    Comment


    • #3
      Brilliant! Thank you for this. It works flawlessly. Regards

      Comment

      Working...
      X