Package ca.uhn.hl7v2.validation.builder
Class MessageRuleBuilder
java.lang.Object
ca.uhn.hl7v2.validation.builder.BuilderSupport
ca.uhn.hl7v2.validation.builder.RuleTypeBuilder<MessageRuleBuilder,MessageRule>
ca.uhn.hl7v2.validation.builder.MessageRuleBuilder
- All Implemented Interfaces:
Serializable
Rule Builder for MessageRules
- Author:
- Christian Ohr
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class ca.uhn.hl7v2.validation.builder.RuleTypeBuilder
RuleTypeBuilder.MessageExpressionBuilder -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMessageRuleBuilder(List<RuleBinding<? extends Rule<?>>> rules, Set<Version> versions, String messageType, String... triggerEvents) -
Method Summary
Modifier and TypeMethodDescriptionBuilds aMessageRulethat enforces choice elements.Builds aMessageRulethat evaluates the message against the Conformance Profile referred to in MSH-21.conformance(String profileId) Builds aMessageRulethat evaluates the message against the Conformance Profile referred to by the profileId parameterprotected Collection<RuleBinding<MessageRule>>getRuleBindings(MessageRule rule, String version) Builder implementation must overwrite this method to return allRuleBindings for rules that have been built.inspect(MessageVisitorFactory<? extends ValidatingMessageVisitor> visitorFactory) Builds aMessageRulethat runs aValidatingMessageVisitorover the message that collectsValidationExceptionsin a single pass.Builds aMessageRulethat disallows the existence of segments which are not alowed in a given message type when the message is an instance ofSuperStructure(e.g.Builds aMessageRulethat disallows the existence ofGenericSegments, i.e.Builds aMessageRulethat extracts a primitive value using aTerserexpression and evaluates the specifiedPredicate.Builds aMessageRulethat disallows the selected HL7 version(s).Methods inherited from class ca.uhn.hl7v2.validation.builder.RuleTypeBuilder
activate, active, addRuleBindings, description, encoding, getRules, instance, message, message, prepareRule, primitive, refersToSection, severity, testMethods inherited from class ca.uhn.hl7v2.validation.builder.BuilderSupport
allOf, allOf, always, alwaysFails, anyOf, anyOf, date, dateTime, dateTime25, empty, emptyOr, in, in, isEqual, isEqualIgnoreCase, matches, matches, matches, maxLength, nonNegativeInteger, not, number, oid, startsWith, time, usPhoneNumber, uuid, withdrawn
-
Constructor Details
-
MessageRuleBuilder
protected MessageRuleBuilder(List<RuleBinding<? extends Rule<?>>> rules, Set<Version> versions, String messageType, String... triggerEvents)
-
-
Method Details
-
terser
Builds aMessageRulethat extracts a primitive value using aTerserexpression and evaluates the specifiedPredicate.- Parameters:
spec- Terser expressionpredicate- Predicate to evaluate against the value- Returns:
- this instance to build more rules
-
inspect
public MessageRuleBuilder inspect(MessageVisitorFactory<? extends ValidatingMessageVisitor> visitorFactory) Builds aMessageRulethat runs aValidatingMessageVisitorover the message that collectsValidationExceptionsin a single pass.- Parameters:
visitorFactory- MessageVisitorFactory that creates ValidatingMessageVisitor instances- Returns:
- this instance to build more rules
-
onlyKnownSegments
Builds aMessageRulethat disallows the existence ofGenericSegments, i.e. segments that are not defined in the structure of a message.- Returns:
- this instance to build more rules
-
onlyAllowableSegmentsInSuperStructure
Builds aMessageRulethat disallows the existence of segments which are not alowed in a given message type when the message is an instance ofSuperStructure(e.g. PID2 within an ADT^A01)- Returns:
- this instance to build more rules
-
choiceElementsRespected
Builds aMessageRulethat enforces choice elements. This means that if several segments are listed as being a possible choice for the first segment in a group, only one of them may have content.- Returns:
- this instance to build more rules
-
wrongVersion
Builds aMessageRulethat disallows the selected HL7 version(s). It is basically equivalent with:forAllVersions().message(....).terser("MSH-12", in(allowedVersions))However, when using this specific rule the builder expression and the resulting exception message is more specific:forVersion().except(allowedVersions).message(...).wrongVersion()- Returns:
- this instance to build more rules
-
conformance
Builds aMessageRulethat evaluates the message against the Conformance Profile referred to in MSH-21.- Returns:
- this instance to build more rules
-
conformance
Builds aMessageRulethat evaluates the message against the Conformance Profile referred to by the profileId parameter- Parameters:
profileId- conformance profile id (file name)- Returns:
- this instance to build more rules
-
getRuleBindings
Description copied from class:RuleTypeBuilderBuilder implementation must overwrite this method to return allRuleBindings for rules that have been built.- Overrides:
getRuleBindingsin classRuleTypeBuilder<MessageRuleBuilder,MessageRule> - Parameters:
rule- the rule for which bindings shall be retrievedversion- the HL7 version for which bindings shall be retrieved- Returns:
- a collection of
RuleBindings
-