001    /**
002    The contents of this file are subject to the Mozilla Public License Version 1.1 
003    (the "License"); you may not use this file except in compliance with the License. 
004    You may obtain a copy of the License at http://www.mozilla.org/MPL/ 
005    Software distributed under the License is distributed on an "AS IS" basis, 
006    WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the 
007    specific language governing rights and limitations under the License. 
008    
009    The Original Code is "Rule.java".  Description: 
010    "A testable rule to which HL7 messages should conform" 
011    
012    The Initial Developer of the Original Code is University Health Network. Copyright (C) 
013    2002.  All Rights Reserved. 
014    
015    Contributor(s): ______________________________________. 
016    
017    Alternatively, the contents of this file may be used under the terms of the 
018    GNU General Public License (the  �GPL�), in which case the provisions of the GPL are 
019    applicable instead of those above.  If you wish to allow use of your version of this 
020    file only under the terms of the GPL and not to allow others to use your version 
021    of this file under the MPL, indicate your decision by deleting  the provisions above 
022    and replace  them with the notice and other provisions required by the GPL License.  
023    If you do not delete the provisions above, a recipient may use your version of 
024    this file under either the MPL or the GPL. 
025     */
026    
027    package ca.uhn.hl7v2.validation;
028    
029    import java.io.Serializable;
030    
031    /**
032     * <p>
033     * A testable rule to which HL7 messages (at least certain specific message)
034     * should conform. This is the central interface of the new HAPI validation
035     * model (as of HAPI 0.4). Previously, the only run-time message validation HAPI
036     * performs is within the setValue() methods of the Primitive datatype classes.
037     * For example when you called setValue() on a DT an exception was thrown if the
038     * String arg was not in the correct DT format. This method served well
039     * initially but left us with the following limitations:
040     * <ol>
041     * <li>Sometimes validation is inappropriate (e.g. some of the standard rules,
042     * like phone number format, don't make sense in some regions).</li>
043     * <li>Couldn't add further optional constraints (such as all timestamps must
044     * have a time zone).</li>
045     * <li>Couldn't turn off validation to improve performance.</li>
046     * <li>Other forms of validation (e.g. conformance profiles, standard DTDs) were
047     * not covered.</li>
048     * </ol>
049     * </p>
050     * <p>
051     * Thus the new validation model is broader in scope, and is based on validation
052     * rules implemented as Rule objects, which can be configured to run or not, as
053     * needed, depending on run-time configuration.
054     * </p>
055     * <p>
056     * There are three kinds of rules:
057     * <ol>
058     * <li>PrimitiveTypeRule: Called when the values of simple datatypes are set,
059     * like the existing hard-coded datatype validations (e.g.
060     * TNFollowsNorthAmericanFormat).</li>
061     * <li>MessageRule: Called when complete message content is to be checked on a
062     * parsed message (e.g. conformance profile).</li>
063     * <li>EncodingRule: Applied to an encoded message (e.g. validation against a
064     * 2.xml Schema, a rule that prohibits empty tags, etc.).</li>
065     * </ol>
066     * </p>
067     * 
068     * @author Bryan Tripp
069     */
070    public interface Rule extends Serializable {
071    
072            /**
073             * Returns a text description of the rule. This description may be used as a
074             * message in exceptions generated if validation against the rule fails, or
075             * in a user interface for rule configuration.
076             */
077            public String getDescription();
078    
079            /**
080             * A string indicating the section of the HL7 standard from which this rule
081             * is derived (if applicable). Like the description, this may be used in an
082             * exception message or configuration UI.
083             */
084            public String getSectionReference();
085                    
086    
087    }