예제 #1
0
 private String validateChangeUsage(String hl7Version, Usage referenceUsage, Usage currentUsage) {
   try {
     if (!this.validUsages(hl7Version).contains(currentUsage.value())) {
       return "Invalid usage value.";
     } else if (!this.allowedChangesUsage(hl7Version, referenceUsage.value())
         .contains(currentUsage.value())) {
       return "Selected usage of "
           + currentUsage.value()
           + " is non-compatible with base usage "
           + referenceUsage.value();
     }
   } catch (IOException e) {
     return "Rules file not found";
   }
   return "ok";
 }
예제 #2
0
  private String allowedChangesCardinality(int currentMin, String currentMax, Usage currentUsage) {
    String message = "";
    // card vs usage
    int toBeMax = 0;
    if ("*".equalsIgnoreCase(currentMax)) {
      toBeMax = Integer.MAX_VALUE;
    } else {
      toBeMax = Integer.valueOf(currentMax);
    }

    // if X usage, then cardinality min and max have to be 0
    if (currentUsage.value().equalsIgnoreCase(Usage.X.value())) {
      if (currentMin != 0 || toBeMax != 0) {
        message += "Cardinality Min and Max must be 0 when Usage is: X.\n";
      }
    }

    // if R usage, then cardinality min has to be greater than zero
    if (currentUsage.value().equalsIgnoreCase(Usage.R.value())) {
      if (!(currentMin > 0)) {
        message += "Cardinality Min can not be less than 1 when Usage is: R.\n";
      }
      if (!(toBeMax > 0)) {
        message += "Cardinality Max can not be less than 1 when Usage is: R.\n";
      }
    }

    // if RE usage, then cardinality min has to be greater than zero
    if (currentUsage.value().equalsIgnoreCase(Usage.RE.value())) {
      if (!(currentMin >= 0)) {
        message += "Cardinality Min must be 0 when Usage is: RE.\n";
      }
    }

    // if C,CE,O, or C(a/b) usage, min must be zero
    // and cardinality max has to be greater than 1
    if (currentUsage.value().equalsIgnoreCase(Usage.O.value())
        || currentUsage.value().equalsIgnoreCase(Usage.C.value())
        || currentUsage.value().equalsIgnoreCase(Usage.CE.value())
        || this.isConditionalUsage(currentUsage)) {

      if (!(currentMin == 0) && !(toBeMax >= 1)) {
        message += "Cardinality Min must be 0 when Usage is: " + currentUsage.value() + ".\n";
      }
    }
    return message;
  }
예제 #3
0
 private boolean isConditionalUsage(Usage usage) {
   return usage.value().contains("C(");
 }