web stats
Getting XML error reading HL7 from database - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-06-2018, 09:17 AM
peterd peterd is offline
What's HL7?
 
Join Date: Nov 2018
Posts: 1
peterd is on a distinguished road
Default Getting XML error reading HL7 from database

I am VERY new to using MIRTH.

I have been tasked with getting HL7 messages out of a MySQL database in our AWS cloud and
forwarding them on to another MIRTH server outside of our AWS cloud.

Our schema for storing the inbound messages is:

CREATE TABLE hl7_message
(
message_id INT NOT NULL AUTO_INCREMENT,
stream VARCHAR(40),
sending_facility VARCHAR(40),
message_type VARCHAR(10),
event_type VARCHAR(10),
event_datetime_str VARCHAR(16),
message MEDIUMTEXT,
update_username VARCHAR(30),
update_datetime TIMESTAMP,
create_datetime TIMESTAMP,
PRIMARY KEY (message_id)
)
ENGINE=InnoDB;

The select statement that I am using to test my Source Database Reader is:

SELECT m.message_id AS messageId,
m.message_type AS messageType,
m.stream AS stream,
m.message AS message
FROM HL7_message m
WHERE m.message_id = 48287384
AND m.stream = 'DAQ'
ORDER BY m.message_id ASC

When I query the source database and copy and past the message into a text file I get each segment on it's own row with the corresponding data. Since all I have is data with PHI I have removed everything to the right of the segment headers.

MSH|^~\}|
EVN|A08|
PID|1|
PD1|
ZEI|
NK1|
PV1|
PV2|
GT1|
IN1|
ACC|

When I run my MIRTH project I get a error on the source database reader channel. Reviewing the error I noticed that MIRTH inserted a at the end of each segment.
MIRTH also inserted a  at the end of the file.

It looks something like this.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<result>
<message>MSH|^~\}|... EVN|A08|... PID|1|... PD1|.. . ZEI|... NK1|... PV1|... PV2|... GT1|... IN1|... ACC|... </message> </result>

With the follwing error:

Transformer error
ERROR MESSAGE: Error evaluating transformer
com.mirth.connect.server.MirthJavascriptTransforme rException:
CHANNEL: Outbound Select HL7_message CSM Clone 1
CONNECTOR: sourceConnector
SCRIPT SOURCE:
SOURCE CODE:
106: eval('importPackage(' + Packages.java.lang.Class.forName(className).getPac kage().getName() + ')');
107: }
108: }
109: function doScript() {
110: msg = new XML(connectorMessage.getTransformedData());
111: if (msg.namespace('') != undefined) { default xml namespace = msg.namespace(''); } else { default xml namespace = ''; }
112: function doFilter() { phase[0] = 'filter'; return true; }function doTransform() { phase[0] = 'transformer'; logger = Packages.org.apache.log4j.Logger.getLogger(phase[0]);
113:
114:
115: var mapping;
LINE NUMBER: 111
DETAILS: TypeError: Character reference "&#28" is an invalid XML character.
at cc7c6c06-4547-449e-abb2-83fbece8860b:110 (doScript)
at cc7c6c06-4547-449e-abb2-83fbece8860b:179
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:154)
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.doCall(JavaS criptFilterTransformer.java:119)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
at java.util.concurrent.FutureTask.run(FutureTask.jav a:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)


Not really sure how to fix this. I have searched the the support archives but not really seeing anything like this.

Thanks for help
Peter
Reply With Quote
  #2  
Old 11-06-2018, 06:12 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 530
agermano is on a distinguished road
Default

I can't tell what the characters are that you are referring to, but there's a good chance they are actually in the data, but don't show up when you manually query then copy/paste.

The segment delimiter in hl7 is a carriage return (\r) but that is not the typical newline character in any modern OS. Windows uses carriage return + line feed (\r\n) and everything else uses just a line feed (\n)

ASCII Character 28 that is mentioned in your error output is the File Separator control character, so it makes complete sense that it is showing up at the end of the file. This is actually the first time that I'm aware of anyone using it correctly in a production scenario, but mirth definitely did not insert it in there.

If the other characters you are noticing are 29, 30, or 31, those are also ascii delimiter control characters.

You can get rid of them in the pre-processor.
Code:
// Get rid of File Separators (ASCII 28) (or 1C in hex) 
message = message.replace(/\x1c/, '');
return message;
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 08:26 PM.


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