From: Tripp, B. <Bry...@uh...> - 2002-10-11 16:44:30
|
Hi Everyone, I've been speaking with Alan Shields and Neal Acharya about a new validation model for HAPI. This seems like a good candidate for a new sub-project, so if anyone is interested in working on this please let us know. Currently, the only run-time message validation HAPI performs is within the setValue() methods of the Primitive datatype classes. For example when you call setValue() on a DT an exception is thrown if the String arg is not in the correct DT format. This has served pretty well so far but it leaves us with the following limitations: 1. Sometimes validation is inappropriate. This is the problem Alan ran into -- the TN class was rejecting his perfectly valid UK telephone numbers because they didn't conform to the North American format. 2. Can't add further optional constraints (such as all timestamps must have a time zone). 3. Can't turn off validation to improve performance. 3. Other forms of validation (e.g. conformance profiles, standard DTDs) are not covered. We're considering expanding run-time validation and making it configurable. In a nutshell, the idea is to implement each validation rule as a Rule object with a test() method that could be invoked or not, depending on run-time configuration. Three types of rules seem appropriate: 1. DataTypeRule: Called when the values of simple datatypes are set, like the existing hard-coded datatype validations (e.g. TNFollowsNorthAmericanFormat). 2. MessageRule: Called when complete message content is to be checked on a parsed message (e.g. conformance profile). 3. EncodingRule: Applied to an encoded message (e.g. validation against a 2.xml Schema, a rule that prohibits empty tags, etc.). We would attempt to ship HAPI with all the rules identified by the HL7 standard, enabled by default, and called at logical points in message processing. Users could disable the rules, call the rules programmatically at different points in their own code, and create their own rules if they wish. Rules could be turned on and off at run-time, possibly by editing a property file with one entry per class, like this (the entries below refer to implementations of DataTypeRule): ca.uhn.hl7v2.validation.datatype.TNFollowsNorthAmericanFormat = off ca.uhn.hl7v2.validation.datatype.TNFollowsUKFormat = on The beginnings of a suggested class structure are attached. Is anyone else interested in working on this? Feedback is most welcome. Thanks, Bryan This e-mail may contain confidential and/or privileged information for the sole use of the intended recipient. Any review or distribution by anyone other than the person for whom it was originally intended is strictly prohibited. If you have received this e-mail in error, please contact the sender and delete all copies. Opinions, conclusions or other information contained in this e-mail may not be that of the organization. |