We are using HAPI to parse ADT and ORDER messages at UHN, and because of
some "lack of std. compliance" by our HIS, we are getting invalid messages
(not at the message structure level, but at the primitive level). For ex.:
some components that are meant to be numeric are alphanumeric.
My proposal is simple and easy to implement. We'll be adding an event
handler to the parser to be invoked whenever such parsing error occurs, and
the code in the event will try to recover from that error, by marking the
parsed component as recovered and assigning a valid value to it.
Right now this functionality will have to be added at the PipeParser level,
I propose to perform some refactoring in the future, such a way we can make
this sort of functionality common to all parser impls.
Some pseudo-code implementing the described feature.
class PipeParser {
boolean parse(
Type destination,
String data,
EncodingCharacters encodingChars,
boolean subComponents) {
...
else if (destination instanceof Primitive) {
Primitive prim = (Primitive) destination;
try {
prim.setValue( Escape.unescape(data, encodingChars) );
}
catch (DataTypeException e) {
//try to recover
boolean recovered = invokeRecoveryHandler( data, destination, e );
if (recovered==true) {
//we must change the primitive intf. a bit
prim.setRecovered( true );
}
else {
throw e;
}
}
isLeaf = true;
}
...
}
}
MailFiler <http://www.mailfiler.com> [AG-JU4UEF4]
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.476 / Virus Database: 273 - Release Date: 24/04/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.476 / Virus Database: 273 - Release Date: 24/04/2003
|