/** * Builds a {@link MessageRule} that 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. * * @return this instance to build more rules */ public MessageRuleBuilder choiceElementsRespected() { return test(prepareRule(ChoiceElementsRespectedRule.CHOICE_ELEMENTS_RESPECTED)); }
/** * Builds {@link MessageRule}s for the specified event types and triggers * * @param eventType Event type, e.g. "ADT", or "*" for all types * @param triggerEvents, e.g. "A01" or "A01,A04", or "*" for all trigger events * @return this instance to continue building rules */ public MessageRuleBuilder message(String eventType, String... triggerEvents) { return new MessageRuleBuilder(rules, versions, eventType, triggerEvents); }
/** * Builds a {@link MessageRule} that evaluates the message against the Conformance Profile * referred to in MSH-21. * * @return this instance to build more rules */ public MessageRuleBuilder conformance() { return conformance(null); }
.message().all().choiceElementsRespected() .message().all().onlyAllowableSegmentsInSuperStructure() .primitive("FT").leftTrim(maxLength(32000)) .primitive("ST").leftTrim() .primitive("TX").rightTrim()
/** * Configures the matching {@link CachingGazelleProfileRule} to be validated against */ @Override protected void configure() { super.configure(); forAllVersions() .message().all() .test(new CachingGazelleProfileRule(transaction)); } }
@Override protected Collection<RuleBinding<MessageRule>> getRuleBindings(MessageRule rule, String version) { List<RuleBinding<MessageRule>> bindings = new ArrayList<RuleBinding<MessageRule>>(); for (String triggerEvent : triggerEvents) { bindings.add(new MessageRuleBinding(version, messageType, triggerEvent, rule)); } return activate(bindings); }
.message().all().choiceElementsRespected() .message().all().onlyAllowableSegmentsInSuperStructure() .primitive("FT").leftTrim(maxLength(32000)) .primitive("ST").leftTrim() .primitive("TX").rightTrim()
@Override protected Collection<RuleBinding<MessageRule>> getRuleBindings(MessageRule rule, String version) { List<RuleBinding<MessageRule>> bindings = new ArrayList<RuleBinding<MessageRule>>(); for (String triggerEvent : triggerEvents) { bindings.add(new MessageRuleBinding(version, messageType, triggerEvent, rule)); } return activate(bindings); }
/** * Builds a {@link MessageRule} that disallows the existence of {@link ca.uhn.hl7v2.model.GenericSegment}s, i.e. * segments that are not defined in the structure of a message. * * @return this instance to build more rules */ public MessageRuleBuilder onlyKnownSegments() { return test(prepareRule(OnlyKnownSegmentsRule.ONLY_KNOWN_SEGMENTS)); }
/** * Builds {@link MessageRule}s for the specified event types and triggers * * @param eventType Event type, e.g. "ADT", or "*" for all types * @param triggerEvents, e.g. "A01" or "A01,A04", or "*" for all trigger events * @return this instance to continue building rules */ public MessageRuleBuilder message(String eventType, String... triggerEvents) { return new MessageRuleBuilder(rules, versions, eventType, triggerEvents); }
/** * Builds a {@link MessageRule} that evaluates the message against the Conformance Profile * referred to in MSH-21. * * @return this instance to build more rules */ public MessageRuleBuilder conformance() { return conformance(null); }
/** * Builds a {@link MessageRule} that disallows the existence of {@link ca.uhn.hl7v2.model.GenericSegment}s, i.e. * segments that are not defined in the structure of a message. * * @return this instance to build more rules */ public MessageRuleBuilder onlyKnownSegments() { return test(prepareRule(OnlyKnownSegmentsRule.ONLY_KNOWN_SEGMENTS)); }
/** * Builds a {@link MessageRule} that 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. * * @return this instance to build more rules */ public MessageRuleBuilder choiceElementsRespected() { return test(prepareRule(ChoiceElementsRespectedRule.CHOICE_ELEMENTS_RESPECTED)); }
/** * Builds a {@link MessageRule} that disallows the existence of segments which * are not alowed in a given message type when the message is an instance * of {@link ca.uhn.hl7v2.model.SuperStructure} (e.g. PID2 within an ADT^A01) * * @return this instance to build more rules */ public MessageRuleBuilder onlyAllowableSegmentsInSuperStructure() { return test(prepareRule(OnlyAllowableSegmentsInSuperstructureRule.ONLY_ALLOWABLE_SEGMENTS)); }
/** * Builds a {@link MessageRule} that disallows the existence of segments which * are not alowed in a given message type when the message is an instance * of {@link ca.uhn.hl7v2.model.SuperStructure} (e.g. PID2 within an ADT^A01) * * @return this instance to build more rules */ public MessageRuleBuilder onlyAllowableSegmentsInSuperStructure() { return test(prepareRule(OnlyAllowableSegmentsInSuperstructureRule.ONLY_ALLOWABLE_SEGMENTS)); }
/** * Builds a {@link MessageRule} that disallows the selected HL7 version(s). It is basically * equivalent with: * * <pre> * forAllVersions().message(....).terser("MSH-12", in(allowedVersions)) * </pre> * * However, when using this specific rule the builder expression and the resulting exception * message is more specific: * * <pre> * forVersion().except(allowedVersions).message(...).wrongVersion() * </pre> * * @return this instance to build more rules */ public MessageRuleBuilder wrongVersion() { return test(prepareRule(WrongVersionRule.WRONG_VERSION)); }
/** * Builds a {@link MessageRule} that disallows the selected HL7 version(s). It is basically * equivalent with: * * <pre> * forAllVersions().message(....).terser("MSH-12", in(allowedVersions)) * </pre> * * However, when using this specific rule the builder expression and the resulting exception * message is more specific: * * <pre> * forVersion().except(allowedVersions).message(...).wrongVersion() * </pre> * * @return this instance to build more rules */ public MessageRuleBuilder wrongVersion() { return test(prepareRule(WrongVersionRule.WRONG_VERSION)); }
/** * Builds a {@link MessageRule} that extracts a primitive value using a {@link ca.uhn.hl7v2.util.Terser} * expression and evaluates the specified {@link Predicate}. * * @param spec Terser expression * @param predicate Predicate to evaluate against the value * @return this instance to build more rules */ public MessageRuleBuilder terser(String spec, Predicate predicate) { return test(prepareRule(new TerserMessageRule(spec, predicate))); }
/** * Builds a {@link MessageRule} that runs a * {@link ca.uhn.hl7v2.validation.builder.support.ValidatingMessageVisitor ValidatingMessageVisitor} * over the message that collects {@link ca.uhn.hl7v2.validation.ValidationException ValidationExceptions} * in a single pass. * * @param visitorFactory MessageVisitorFactory that creates ValidatingMessageVisitor instances * @return this instance to build more rules */ public MessageRuleBuilder inspect(MessageVisitorFactory<? extends ValidatingMessageVisitor> visitorFactory) { return test(prepareRule(new VisitorMessageRule(visitorFactory))); }
/** * Builds a {@link MessageRule} that extracts a primitive value using a {@link ca.uhn.hl7v2.util.Terser} * expression and evaluates the specified {@link Predicate}. * * @param spec Terser expression * @param predicate Predicate to evaluate against the value * @return this instance to build more rules */ public MessageRuleBuilder terser(String spec, Predicate predicate) { return test(prepareRule(new TerserMessageRule(spec, predicate))); }