public class DefaultValidator extends HapiContextSupport implements Validator
| Constructor and Description |
|---|
DefaultValidator()
Creates a new instance of DefaultValidator
|
DefaultValidator(HapiContext context) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addTableTestResult(String profileID,
String codeSystem,
String value,
List<HL7Exception> exList) |
protected void |
checkConstantValue(String value,
String encoded,
List<HL7Exception> exList) |
protected void |
checkDataType(String dataType,
Type type,
List<HL7Exception> exList) |
protected void |
checkEventType(String evType,
StaticDef profile,
List<HL7Exception> exList) |
protected void |
checkExtraComponents(Composite comp,
int numInProfile,
List<HL7Exception> exList)
Tests for extra components (ie any not defined in the profile)
|
protected void |
checkForExtraFields(Segment segment,
List<Integer> allowedFields,
List<HL7Exception> exList)
Checks a segment against a list of allowed fields (ie those mentioned in the profile with
usage other than X).
|
protected void |
checkForExtraStructures(Group group,
List<String> allowedStructures,
List<HL7Exception> exList)
Checks a group's children against a list of allowed structures for the group (ie those
mentioned in the profile with usage other than X).
|
protected void |
checkLength(long length,
String name,
String encoded,
List<HL7Exception> exList) |
protected void |
checkMessageStructure(String msgStruct,
StaticDef profile,
List<HL7Exception> exList) |
protected void |
checkMessageType(String msgType,
StaticDef profile,
List<HL7Exception> exList) |
protected List<HL7Exception> |
doTestComponent(Type type,
Component profile,
String profileID,
boolean theValidateChildren) |
protected List<HL7Exception> |
doTestField(Type type,
Field profile,
boolean escape,
String profileID,
boolean theValidateChildren) |
protected List<HL7Exception> |
doTestGroup(Group group,
AbstractSegmentContainer profile,
String profileID,
boolean theValidateChildren) |
protected List<HL7Exception> |
doTestSegment(Segment segment,
Seg profile,
String profileID,
boolean theValidateChildren) |
static void |
main(String[] args) |
void |
setCodeStore(CodeStore theCodeStore)
Provides a code store to use to provide the code tables which will be used to validate coded
value types.
|
void |
setValidateChildren(boolean validateChildren)
If set to false (default is true), each testXX and validateXX method will only test the
direct object it is responsible for, not its children.
|
protected HL7Exception |
testCardinality(int reps,
int min,
int max,
String usage,
String name,
List<HL7Exception> exList)
Checks cardinality and creates an appropriate exception if out of bounds.
|
List<HL7Exception> |
testComponent(Type type,
Component profile,
String profileID) |
List<HL7Exception> |
testField(Type type,
Field profile,
boolean escape,
String profileID) |
List<HL7Exception> |
testGroup(Group group,
SegGroup profile,
String profileID)
Tests a group against a group section of a profile.
|
HL7Exception |
testLength(Type type,
int maxLength)
Tests whether the given type falls within a maximum length.
|
List<HL7Exception> |
testSegment(Segment segment,
Seg profile,
String profileID)
Tests a segment against a segment section of a profile.
|
List<HL7Exception> |
testStructure(Structure s,
ProfileStructure profile,
String profileID)
Tests a structure (segment or group) against the corresponding part of a profile.
|
List<HL7Exception> |
testType(Type type,
AbstractComponent<?> profile,
String encoded,
String profileID)
Tests a Type against the corresponding section of a profile.
|
protected void |
testTypeAgainstTable(Type type,
AbstractComponent<?> profile,
String profileID,
List<HL7Exception> exList)
Tests table values for ID, IS, and CE types.
|
protected void |
testUsage(String encoded,
String usage,
String name,
List<HL7Exception> exList)
Tests an element against the corresponding usage code.
|
protected void |
testValueAgainstTable(String profileID,
String codeSystem,
String value,
List<HL7Exception> exList) |
HL7Exception[] |
validate(Message message,
StaticDef profile)
Validates the given message against the given static definition from
a conformance profile.
|
getHapiContext, setHapiContextpublic DefaultValidator()
public DefaultValidator(HapiContext context)
public void setValidateChildren(boolean validateChildren)
public void setCodeStore(CodeStore theCodeStore)
Provides a code store to use to provide the code tables which will be used to validate coded
value types. If a code store has not been set (which is the default),
ProfileStoreFactory will be checked for an appropriate code store, and if none is
found then coded values will not be validated.
public HL7Exception[] validate(Message message, StaticDef profile) throws ProfileException, HL7Exception
Validatorvalidate in interface ValidatorProfileException - if a problem is encountered that interferes with evaluationHL7ExceptionValidator.validate(ca.uhn.hl7v2.model.Message, ca.uhn.hl7v2.conf.spec.message.StaticDef)protected void checkEventType(String evType, StaticDef profile, List<HL7Exception> exList) throws HL7Exception
HL7Exceptionprotected void checkMessageType(String msgType, StaticDef profile, List<HL7Exception> exList) throws HL7Exception
HL7Exceptionprotected void checkMessageStructure(String msgStruct, StaticDef profile, List<HL7Exception> exList)
public List<HL7Exception> testGroup(Group group, SegGroup profile, String profileID) throws ProfileException
ProfileExceptionprotected List<HL7Exception> doTestGroup(Group group, AbstractSegmentContainer profile, String profileID, boolean theValidateChildren) throws ProfileException
ProfileExceptionprotected void checkForExtraStructures(Group group, List<String> allowedStructures, List<HL7Exception> exList) throws ProfileException
ProfileExceptionprotected HL7Exception testCardinality(int reps, int min, int max, String usage, String name, List<HL7Exception> exList)
reps - the number of repsmin - the minimum number of repsmax - the maximum number of reps (-1 means *)usage - the usage codename - the name of the repeating structure (used in exception msg)public List<HL7Exception> testStructure(Structure s, ProfileStructure profile, String profileID) throws ProfileException
ProfileExceptionpublic List<HL7Exception> testSegment(Segment segment, Seg profile, String profileID) throws ProfileException
ProfileExceptionprotected List<HL7Exception> doTestSegment(Segment segment, Seg profile, String profileID, boolean theValidateChildren) throws ProfileException
ProfileExceptionprotected void checkForExtraFields(Segment segment, List<Integer> allowedFields, List<HL7Exception> exList) throws ProfileException
allowedFields - an array of Integers containing field #s of allowed fieldsProfileExceptionpublic List<HL7Exception> testType(Type type, AbstractComponent<?> profile, String encoded, String profileID)
encoded - optional encoded form of type (if you want to specify this -- if null, default
pipe-encoded form is used to check length and constant val)protected void checkConstantValue(String value, String encoded, List<HL7Exception> exList)
protected void checkLength(long length, String name, String encoded, List<HL7Exception> exList)
protected void checkDataType(String dataType, Type type, List<HL7Exception> exList)
public HL7Exception testLength(Type type, int maxLength)
protected void testUsage(String encoded, String usage, String name, List<HL7Exception> exList)
encoded - the pipe-encoded message elementusage - the usage code (e.g. "CE")name - the name of the element (for use in exception messages)protected void testTypeAgainstTable(Type type, AbstractComponent<?> profile, String profileID, List<HL7Exception> exList)
protected void addTableTestResult(String profileID, String codeSystem, String value, List<HL7Exception> exList)
protected void testValueAgainstTable(String profileID, String codeSystem, String value, List<HL7Exception> exList)
public List<HL7Exception> testField(Type type, Field profile, boolean escape, String profileID) throws ProfileException, HL7Exception
ProfileExceptionHL7Exceptionprotected List<HL7Exception> doTestField(Type type, Field profile, boolean escape, String profileID, boolean theValidateChildren) throws ProfileException, HL7Exception
ProfileExceptionHL7Exceptionpublic List<HL7Exception> testComponent(Type type, Component profile, String profileID) throws ProfileException, HL7Exception
ProfileExceptionHL7Exceptionprotected List<HL7Exception> doTestComponent(Type type, Component profile, String profileID, boolean theValidateChildren) throws ProfileException, HL7Exception
ProfileExceptionHL7Exceptionprotected void checkExtraComponents(Composite comp, int numInProfile, List<HL7Exception> exList) throws ProfileException
ProfileExceptionCopyright © 2001–2017 University Health Network. All rights reserved.