Beispiel #1
0
  /**
   * Validate the Participant info The participant identifiers should be unique per subject's site.
   */
  @Override
  protected void validate(
      T command, BeanWrapper commandBean, Map<String, InputFieldGroup> fieldGroups, Errors errors) {
    DateValue dob = command.getParticipant().getDateOfBirth();

    if (dob.checkIfDateIsInValid()) {
      errors.rejectValue("participant.dateOfBirth", "PT_010", "Incorrect Date Of Birth");
    }

    if (!command.getAdditionalParameters().containsKey("DO_PARTIAL_VALIDATION")) {
      if (command.getAssignment() == null) errors.reject("PT_002", "Select one assignment please.");
    } else {
      command.getAdditionalParameters().remove("DO_PARTIAL_VALIDATION");
    }

    // Check uniqueness of Study Subject identifier across study
    for (StudyParticipantAssignment assignment : command.getAssignments()) {
      validateUniqueStudySubjectIdentifiersInStudy(
          assignment.getStudySite().getStudy(),
          errors,
          assignment.getStudySubjectIdentifier(),
          assignment.getId());
    }

    // CHECK Participant Identifiers
    List<Identifier> siteIdentifiers =
        participantDao.getSiteIdentifiers(command.getOrganization().getId().intValue());
    for (int i = 0; i < siteIdentifiers.size(); i++) {
      Identifier sID = siteIdentifiers.get(i);
      if (sID == null || sID.getValue() == null) continue;

      for (int j = 0; j < command.getParticipant().getIdentifiers().size(); j++) {
        Identifier pID = command.getParticipant().getIdentifiers().get(j);
        if (pID == null || pID.getValue() == null) return;

        if ((sID.getValue().toLowerCase().equals(pID.getValue().toLowerCase())
                && StringUtils.equals(sID.getType(), pID.getType()))
            && (sID.getId() == null || sID.getId().intValue() != pID.getId().intValue())) {
          errors.reject(
              "ERR_DUPLICATE_SITE_IDENTIFIER",
              new Object[] {command.getOrganization().getName(), pID.getValue()},
              "Duplicate identifiers for the same site.");
        }
      }
    }
  }
Beispiel #2
0
  public static DateValue parseDateString(String dateString) {
    if (dateString == null) return null;
    DateValue dv = new DateValue();

    if (dateString.length() == 4) {
      dv.setYearString(dateString);
      return dv;
    }

    if (dateString.indexOf('/') < 0)
      throw new RuntimeException(
          "Unknown format, expected format is 'mm/dd/yyyy' or 'mm/yyyy' or 'yyyy'");

    String[] dateParts = dateString.split("/");
    int size = dateParts.length;
    // validate year
    if (dateParts[size - 1].length() != 4)
      throw new RuntimeException(
          "Unknown format, expected format is 'mm/dd/yyyy' or 'mm/yyyy' or 'yyyy'");

    if (size == 2) {
      if (dateParts[0].length() != 2)
        throw new RuntimeException(
            "Unknown format, expected format is 'mm/dd/yyyy' or 'mm/yyyy' or 'yyyy'");

      dv.setMonthString(dateParts[0]);
      dv.setYearString(dateParts[1]);

    } else if (size == 3) {
      if (dateParts[0].length() != 2)
        throw new RuntimeException(
            "Unknown format, expected format is 'mm/dd/yyyy' or 'mm/yyyy' or 'yyyy'");
      if (dateParts[1].length() != 2)
        throw new RuntimeException(
            "Unknown format, expected format is 'mm/dd/yyyy' or 'mm/yyyy' or 'yyyy'");

      dv.setMonthString(dateParts[0]);
      dv.setDayString(dateParts[1]);
      dv.setYearString(dateParts[2]);
    } else {
      return null;
    }

    return dv;
  }
Beispiel #3
0
 public static boolean isValidDate(DateValue d) {
   if (d.isNull() || d.isEmpty()) return true;
   return isValidDate(d.toString());
 }