public void testEnactReportWorkflow() {
    long processId = 5;
    StudyParticipantAssignment assignment = Fixtures.createAssignment();
    ExpeditedAdverseEventReport aeReport = Fixtures.createSavableExpeditedReport();
    Report report = Fixtures.createReport("testReport");
    aeReport.setId(55);
    AdverseEventReportingPeriod reportingPeriod = Fixtures.createReportingPeriod();
    WorkflowConfig workflowConfig = Fixtures.createWorkflowConfig("test");
    StudySite site = assignment.getStudySite();
    StudySiteWorkflowConfig ssWfCfg = new StudySiteWorkflowConfig("report", site, workflowConfig);
    site.addStudySiteWorkflowConfig(ssWfCfg);
    reportingPeriod.addAeReport(aeReport);
    aeReport.setAssignment(assignment);
    aeReport.addReport(report);

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(WorkflowService.VAR_STUDY_ID, site.getStudy().getId());
    variables.put(WorkflowService.VAR_WF_TYPE, Report.class.getName());
    variables.put(WorkflowService.VAR_REPORT_ID, report.getId());
    variables.put(WorkflowService.VAR_EXPEDITED_REPORT_ID, aeReport.getId());
    variables.put(WorkflowService.VAR_WF_STUDY_NAME, reportingPeriod.getStudy().getDisplayName());
    variables.put(
        WorkflowService.VAR_WF_SUBJECT_NAME, reportingPeriod.getParticipant().getFullName());
    variables.put(WorkflowService.VAR_WF_COURSE_NAME, reportingPeriod.getName());

    EasyMock.expect(wfService.createProcessInstance("test", variables)).andReturn(processInstance);
    EasyMock.expect(processInstance.getId()).andReturn(processId).anyTimes();
    reportDao.save(report);
    replayMocks();
    impl.enactReportWorkflow(report);
    verifyMocks();
  }
  public void testEnactReportingPeriodWorkflow() {
    long processId = 5;
    StudyParticipantAssignment assignment = Fixtures.createAssignment();
    AdverseEventReportingPeriod reportingPeriod = Fixtures.createReportingPeriod();
    reportingPeriod.setId(44);
    WorkflowConfig workflowConfig = Fixtures.createWorkflowConfig("test");
    StudySite site = assignment.getStudySite();
    StudySiteWorkflowConfig ssWfCfg =
        new StudySiteWorkflowConfig("reportingPeriod", site, workflowConfig);
    site.addStudySiteWorkflowConfig(ssWfCfg);
    reportingPeriod.setAssignment(assignment);

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(WorkflowService.VAR_STUDY_ID, site.getStudy().getId());
    variables.put(WorkflowService.VAR_WF_TYPE, AdverseEventReportingPeriod.class.getName());
    variables.put(WorkflowService.VAR_WF_STUDY_NAME, reportingPeriod.getStudy().getDisplayName());
    variables.put(
        WorkflowService.VAR_WF_SUBJECT_NAME, reportingPeriod.getParticipant().getFullName());
    variables.put(WorkflowService.VAR_WF_COURSE_NAME, reportingPeriod.getName());
    variables.put(WorkflowService.VAR_REPORTING_PERIOD_ID, reportingPeriod.getId());

    EasyMock.expect(wfService.createProcessInstance("test", variables)).andReturn(processInstance);
    EasyMock.expect(processInstance.getId()).andReturn(processId).anyTimes();
    rpDao.modifyOrSaveReviewStatusAndComments(reportingPeriod);
    replayMocks();
    impl.enactReportingPeriodWorkflow(reportingPeriod);
    verifyMocks();
  }
Beispiel #3
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.");
        }
      }
    }
  }