Пример #1
0
 /**
  * Checks cardinality and creates an appropriate exception if out of bounds. The usage code is
  * needed because if min cardinality is > 0, the min # of reps is only required if the usage code
  * is 'R' (see HL7 v2.5 section 2.12.6.4).
  *
  * @param reps the number of reps
  * @param usage usage info
  * @return exceptions
  */
 protected List<ValidationException> testCardinality(int reps, UsageInfo usage) {
   List<ValidationException> violations = new ArrayList<>();
   profileViolatedWhen(
       reps < usage.min && usage.required(),
       violations,
       LESS_THAN_MINIMUM_CARDINALITY,
       usage.name,
       usage.min,
       reps);
   profileViolatedWhen(
       usage.max > 0 && reps > usage.max,
       violations,
       MORE_THAN_MAXIMUM_CARDINALITY,
       usage.name,
       usage.max,
       reps);
   profileViolatedWhen(
       reps > 0 && usage.disallowed(), violations, NOT_SUPPORTED_ELEMENT_PRESENT, usage.name);
   return violations;
 }
Пример #2
0
 /**
  * Tests an element against the corresponding usage code. The element is required in its encoded
  * form.
  *
  * @param encoded the pipe-encoded message element
  * @param usage the usage code (e.g. "CE")
  */
 protected void testUsage(List<ValidationException> exList, String encoded, UsageInfo usage) {
   if (usage.required()) {
     profileViolatedWhen(encoded.isEmpty(), exList, REQUIRED_ELEMENT_MISSING, usage.name);
   } else if (usage.disallowed()) {
     profileViolatedWhen(!encoded.isEmpty(), exList, NOT_SUPPORTED_ELEMENT_PRESENT, usage.name);
   } else if (usage.nullContext()) {
     profileViolatedWhen(!encoded.isEmpty(), exList, NO_ELEMENTS_AFTER_NULL, usage.name);
   }
   /*
   else if (usage.equalsIgnoreCase("RE")) {
       // can't test anything
   } else if (usage.equalsIgnoreCase("O")) {
       // can't test anything
   } else if (usage.equalsIgnoreCase("C")) {
       // can't test anything yet -- wait for condition syntax in v2.6
   } else if (usage.equalsIgnoreCase("CE")) {
       // can't test anything
   } else if (usage.equalsIgnoreCase("B")) {
       // can't test anything
   }
   */
 }