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));
Constructor and Description |
---|
ProfileParser(boolean alwaysValidate)
Creates a new instance of ProfileParser
|
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] args) |
RuntimeProfile |
parse(String profileString)
Parses an XML profile string into a RuntimeProfile object.
|
RuntimeProfile |
parseClasspath(String classPath)
Parses an XML profile string into a RuntimeProfile object.
|
public ProfileParser(boolean alwaysValidate)
alwaysValidate
- if true, validates all profiles against a local copy of the
profile XSD; if false, validates against declared grammar (if any)public RuntimeProfile parseClasspath(String classPath) throws ProfileException, IOException
IOException
- If the resource can't be readProfileException
public RuntimeProfile parse(String profileString) throws ProfileException
ProfileException
Copyright © 2001–2017 University Health Network. All rights reserved.