/** * 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."); } } } }