Sidebar

Is this double cdata tag with encoded data something that Qvera can handle?

0 votes
76 views
asked Feb 29 by gwendoline-s-1248 (160 points)
The HL7 that is sent in XML looks something like this:

<Content><![CDATA[MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20120411070545||ORU^R01|59689|P|2.3|||AL|NE|
PID|1|12345|12345^^^MIE&1.2.840.114398.1.100&ISO^MR||MOUSE^MINNIE^S||19240101|F|||123 MOUSEHOLE LN^^FORT WAYNE^IN^46808|||||||||||||||||||
PV1|1|O|||||71^DUCK^DONALD||||||||||||12376|||||||||||||||||||||||||20120410160227||||||
ORC|RE||12376|||||||100^DUCK^DASIY||71^DUCK^DONALD|^^^||20120411070545|||||
OBR|1||12376|cbc^CBC|R||20120410160227|||22^GOOF^GOOFY|||Fasting: No|201204101625||71^DUCK^DONALD||||||201204101630|||F||^^^^^R|||||||||||||||||85025|
OBX|1|NM|wbc^Wbc^Local^6690-2^Wbc^LN||<![CDATA[ ||<![CDATA[ MIX OF RTF FORMATING, ACTUAL PATINT DATA, ZIP FILES IN HEXADECIMAL FORMAT,OTHER METADATA  ]]>SPM|1||||||||||P^Patient^HL7000|||||||
]]></Content>

 

The messages error out immediately in the XML source node. Is this something that can be handled in Qvera or does the fault lie in the message being sent to us?

1 Answer

0 votes

Embedded CDATA tags are not allowed in XML. This is not a Qvera limitation but a rule in the XML specification. However, we can use a preprocessing script to remove the extra CDATA tags. This should only be a temporary workaround and whoever is sending the data should correct the payload being sent. 

Here is how to use the preprocess script:

1. Set the source to use the preprocess script on failed messages

2. Use the following script in the script window:

//Convert bytes to string;
var messageString = new java.lang.String(bytesIn);
qie.debug('messageString: ' + messageString);

//Get the content
var content = StringUtils.substringBetween(messageString, '<Content>', '</Content>');
qie.debug('content: ' + content);

//remove all CDATA entries
content = StringUtils.replace(content, '<![CDATA[', '');
content = StringUtils.replace(content, ']]>', '');

//Put one CDATA tag around the content
content = '<![CDATA[' + content + ']]>';

//build bytesOut with new content
var newMessageString = new java.lang.String(StringUtils.substringBefore(messageString, '<Content>') + '<Content>' + content + '</Content>' + StringUtils.substringAfter(messageString, '</Content>'));
bytesOut = newMessageString.getBytes();

if (bytesOut === null) {  //When null, the message is discarded and no further processing is done
   //todo: when bytesOut = null, set responseBytes to acknowledge the receipt of discarded messages as needed
   responseBytes = new java.lang.String('Replace with valid acknowledgement').getBytes(qie.getChannelEncoding());
}

answered Mar 1 by brandon-w-8204 (33,270 points)
...