web stats
Mirth giving error for a filter on Date - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-24-2017, 12:37 AM
akash_agl akash_agl is offline
What's HL7?
 
Join Date: Jul 2017
Posts: 3
akash_agl is on a distinguished road
Default Mirth giving error for a filter on Date

I need to put in a filter to not process messages before a certain date.
I put down the filter as

if(msg['PV1']['PV1.44']['PV1.44.1'].toString() >= '20170501000000') {
return true;
}
return false;

When ever I am trying to process a HL7 transaction with date after 1st May 2017, I am getting the following error

ER7Serializer error
ERROR MESSAGE: Error converting XML to ER7
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(Unknown Source)
at com.mirth.connect.plugins.datatypes.hl7v2.XMLEncod edHL7Handler.endElement(XMLEncodedHL7Handler.java: 200)
at org.apache.xerces.parsers.AbstractSAXParser.endEle ment(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParse r.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.sc anStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source)
at com.mirth.connect.plugins.datatypes.hl7v2.ER7Seria lizer.fromXML(ER7Serializer.java:277)
at com.mirth.connect.donkey.server.channel.FilterTran sformerExecutor.processConnectorMessage(FilterTran sformerExecutor.java:123)
at com.mirth.connect.donkey.server.channel.Channel.pr ocess(Channel.java:1542)
at com.mirth.connect.donkey.server.channel.Channel.di spatchRawMessage(Channel.java:1198)
at com.mirth.connect.donkey.server.channel.SourceConn ector.dispatchRawMessage(SourceConnector.java:192)
at com.mirth.connect.server.controllers.DonkeyEngineC ontroller.dispatchRawMessage(DonkeyEngineControlle r.java:1053)
at com.mirth.connect.server.controllers.DonkeyMessage Controller.reprocessMessages(DonkeyMessageControll er.java:442)
at com.mirth.connect.server.api.servlets.MessageServl et$3.run(MessageServlet.java:208)
at java.lang.Thread.run(Unknown Source)
========================
I have tried to put down filter by converting to a date object and comparing the date objects, but the error is not going away. Am running out of option.
It works in one Interface but does not work in another.
Can some one guide me as to what could be issue with the filter?

Thanks & Regards,
Akash
Reply With Quote
  #2  
Old 07-24-2017, 04:58 PM
pacmano pacmano is offline
OBX.2 Kenobi
 
Join Date: Oct 2009
Location: Texas
Posts: 96
pacmano is on a distinguished road
Default

Can you post a sample message that succeeds and one that fails ?
__________________
Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
Diridium Technologies, Inc.
https://diridium.com
Reply With Quote
  #3  
Old 07-25-2017, 12:55 AM
aTom aTom is offline
OBX.3 Kenobi
 
Join Date: Feb 2016
Location: Lake Geneva Area
Posts: 113
aTom is on a distinguished road
Default

I think your filter works as expected and your message gets processed, the error is fired because the outgoing message (tmp? msg?) could not be parsed back to HL7.

Just note that here you are comparing 2 strings : is my <pv1-44 date string> greater than '20170501000000'. This works here because both date have same pattern so your pv1-44 string is or isn't greater than '20170501000000'. If you want to compare <real dates>, then convert both values into Date objects first then compare them using their getTime() method.
__________________
Tom
Reply With Quote
  #4  
Old 07-25-2017, 03:07 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 835
siddharth is on a distinguished road
Default

+1 to aTom.

You need to parse the string date, make it a date object and then do a comparison. This condition of comparing 2 date strings will always return true...or should I say a false positive.
Reply With Quote
  #5  
Old 07-25-2017, 04:47 AM
akash_agl akash_agl is offline
What's HL7?
 
Join Date: Jul 2017
Posts: 3
akash_agl is on a distinguished road
Default

Thanks Tom and Siddharth,
I was able to figure out the error. Apparently, the incoming HL7 message had encoding characters misplaced by 2 fields (encoding characters were coming in 4th field instead of 2nd field in MSH segment).
I hardcoded the values in 2nd field and it worked.
Reply With Quote
  #6  
Old 07-25-2017, 07:14 AM
pacmano pacmano is offline
OBX.2 Kenobi
 
Join Date: Oct 2009
Location: Texas
Posts: 96
pacmano is on a distinguished road
Default

The original question said at the bottom:

Quote:
I have tried to put down filter by converting to a date object and comparing the date objects, but the error is not going away. Am running out of option.
So I'd guess this is some other message related problem, not a string (or date) comparison problem.

(Oops, posted a bit out of order!)
__________________
Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
Diridium Technologies, Inc.
https://diridium.com

Last edited by pacmano; 07-25-2017 at 07:24 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 09:59 PM.


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