web stats
Compare PV1.44.1 to today's date - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 02-24-2020, 09:23 AM
KBanks KBanks is offline
OBX.1 Kenobi
 
Join Date: Sep 2010
Posts: 41
KBanks is on a distinguished road
Default Compare PV1.44.1 to today's date

I am trying to figure out the best way to compare the date that is contained within PV1.44.1 with today's date and if PV1.44.1 is less than today's date, send an e-mail notification.

What I am trying to do is capture our observation patients who are here past midnight and become an inpatient. So I am looking at an ADT-A06 message where PV1.2.1 contains a "1" and if PV1.44.1 contains a date that is less than today's date, send an e-mail notification to our Case Managers.

I am able to get my e-mail notification to send. I am also filtering out everything except an A06 with a PV1.2.1 value of "1" but I am having issues writing the javascript code that will perform the comparison.

Any assistance would be appreciated.
Reply With Quote
  #2  
Old 02-24-2020, 09:33 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 am going to assume that your PV1.44 is in the yyyymmdd format.

var pv1 = msg['PV1']['PV1.44']['PV1.44.1'].toString().substring(0,8); //removes hours, minutes, seconds, ect.

var today = new Date();//this will give current date
var dateString = today.getFullYear().toString() + (tdoay.getMonth().toString() + 1) + today.getDate().toString()//Note that Month is 0 based.

Then you can do a compare
Reply With Quote
  #3  
Old 02-26-2020, 02:39 AM
KBanks KBanks is offline
OBX.1 Kenobi
 
Join Date: Sep 2010
Posts: 41
KBanks is on a distinguished road
Default

Thank you for your assistance with this. I am going to give this a try.
Reply With Quote
  #4  
Old 02-26-2020, 06:23 AM
odo odo is offline
OBX.3 Kenobi
 
Join Date: Feb 2017
Location: Luxembourg
Posts: 165
odo is on a distinguished road
Default

Code:
if(DateUtil.getDate('yyyyMMddHHmmss', msg['PV1']['PV1.44']['PV1.44.1'].toString()).getTime() < Math.floor(Date.now()/86400000)){
     logger.warn('Mail has to be sent'); 
}
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 02:52 AM.


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