Class ProfileParser

java.lang.Object
ca.uhn.hl7v2.conf.parser.ProfileParser

public class ProfileParser extends Object

Parses a Message Profile XML document into a RuntimeProfile object. A Message Profile is a formal description of additional constraints on a message (beyond what is specified in the HL7 specification), usually for a particular system, region, etc. Message profiles are introduced in HL7 version 2.5 section 2.12. The RuntimeProfile object is simply an object representation of the profile, which may be used for validating messages or editing the profile.

Example usage:

                // Load the profile from the classpath
      ProfileParser parser = new ProfileParser(false);
      RuntimeProfile profile = parser.parseClasspath("ca/uhn/hl7v2/conf/parser/example_ack.xml");
 
      // Create a message to validate
      String message = "MSH|^~\\&|||||||ACK^A01|1|D|2.4|||||CAN|wrong|F^^HL70001^x^^HL78888|\r"; //note HL7888 doesn't exist
      ACK msg = (ACK) (new PipeParser()).parse(message);
                
      // Validate
                HL7Exception[] errors = new DefaultValidator().validate(msg, profile.getMessage());
                
                // Each exception is a validation error
                System.out.println("Validation errors: " + Arrays.asList(errors));
 

Author:
Bryan Tripp
  • Constructor Details

    • ProfileParser

      public ProfileParser(boolean alwaysValidate)
      Creates a new instance of ProfileParser
      Parameters:
      alwaysValidate - if true, validates all profiles against a local copy of the profile XSD; if false, validates against declared grammar (if any)
  • Method Details