Beispiel #1
0
  /* Called for updating master subjects only. * fires rules to all registrars on whose sites subject is registered */
  private void activateRulesForNewOrUpdatedCorrespondence(Correspondence correspondence) {

    List<Object> objects = new ArrayList<Object>();
    objects.add(correspondence);
    PlannedNotification plannedNotification = getPlannedNotificationsForCorrespondence().get(0);
    plannedNotification.getUserBasedRecipient().clear();
    if (correspondence.getPersonSpokenTo() != null) {
      String email = correspondence.getPersonSpokenTo().getEmail();
      if (!StringUtils.isBlank(email)) {
        UserBasedRecipient ubr = new UserBasedRecipient();
        ubr.setPersonUser(correspondence.getPersonSpokenTo());
        ubr.setEmailAddress(email);
        plannedNotification.getUserBasedRecipient().add(ubr);
      }
    }

    for (PersonUser notifiedPersonUser : correspondence.getNotifiedStudyPersonnel()) {
      String email = notifiedPersonUser.getEmail();
      if (!StringUtils.isBlank(email)) {
        UserBasedRecipient ubr = new UserBasedRecipient();
        ubr.setPersonUser(notifiedPersonUser);
        ubr.setEmailAddress(email);
        plannedNotification.getUserBasedRecipient().add(ubr);
      }
    }

    objects.add(plannedNotification);
    rulesDelegationService.activateRules(
        NotificationEventTypeEnum.CORRESPONDENCE_CREATED_OR_UPDATED_EVENT, objects);
    objects.remove(plannedNotification);
  }
Beispiel #2
0
  /**
   * Handle new study subject saved. Activates rules for the NEW_REGISTRATION_EVENT &
   * REGISTATION_STATUS_CHANGE
   *
   * @param previousState the previous state
   * @param currentState the current state
   * @param studySubject the study subject
   */
  public void handleNewStudySubjectSaved(
      final Object previousState, final Object currentState, final Object studySubject) {
    RegistrationWorkFlowStatus previousRegStatus = null;
    RegistrationWorkFlowStatus currentRegStatus = null;
    NotificationEventTypeEnum event = null;

    List<Object> objects = new ArrayList<Object>();
    objects.add(studySubject);

    if (previousState != null && previousState instanceof RegistrationWorkFlowStatus) {
      previousRegStatus = (RegistrationWorkFlowStatus) previousState;
    }
    if (currentState != null && currentState instanceof RegistrationWorkFlowStatus) {
      currentRegStatus = (RegistrationWorkFlowStatus) currentState;
    }

    // figure out the event and then fire the rules
    if (previousRegStatus != null
        && previousRegStatus.getCode().equals(currentRegStatus.getCode())) {
      // no status change...do nothing
    } else {
      // if the prev status is null or pendign and current status is registered then its a new
      // registration
      // else its a reg status change.
      if (currentRegStatus.equals(RegistrationWorkFlowStatus.ON_STUDY)
          && (previousRegStatus == null
              || previousRegStatus.equals(RegistrationWorkFlowStatus.PENDING)
              || previousRegStatus.equals(RegistrationWorkFlowStatus.PENDING_ON_STUDY)
              || previousRegStatus.equals(RegistrationWorkFlowStatus.RESERVED))) {
        event = NotificationEventTypeEnum.NEW_REGISTRATION_EVENT;
        // run rules seperately for the accruals use case
        activateRulesForAccruals(studySubject);
      } else if (currentRegStatus.equals(RegistrationWorkFlowStatus.OFF_STUDY)) {
        event = NotificationEventTypeEnum.SUBJECT_REMOVED_OFF_STUDY;
      } else {
        event = NotificationEventTypeEnum.REGISTATION_STATUS_CHANGE;
      }
      List<HealthcareSite> hcsList = getSites(studySubject);

      for (PlannedNotification pn : getPlannedNotifications(hcsList)) {
        if (pn.getEventName().equals(event)) {
          objects.add(pn);
          rulesDelegationService.activateRules(event, objects);
          objects.remove(pn);
        }
        // activate rules if the event occured is a new Registration event and we have a stored
        // planned notification for
        // registration status changes. In other words...new Reg event shud send out Reg status
        // changed notification.
        if (pn.getEventName().equals(NotificationEventTypeEnum.REGISTATION_STATUS_CHANGE)
            && event.equals(NotificationEventTypeEnum.NEW_REGISTRATION_EVENT)) {
          objects.add(pn);
          rulesDelegationService.activateRules(
              NotificationEventTypeEnum.REGISTATION_STATUS_CHANGE, objects);
          objects.remove(pn);
        }
      }
    }
    log.debug(this.getClass().getName() + ": exiting handleNewStudySubjectSaved()");
  }
Beispiel #3
0
  /**
   * Activate rules for accruals. Called for new registrations only. Checks if accrual notifications
   * are configured. Fires rules if thresholds are met.
   *
   * @param studySubjectObj the study subject obj
   */
  private void activateRulesForAccruals(Object studySubjectObj) {
    StudySubject studySubject = null;
    StudyOrganization studyOrg = null;
    StudySite studySite = null;

    if (studySubjectObj instanceof StudySubject) {
      studySubject = (StudySubject) studySubjectObj;
    } else {
      return;
    }

    List<Object> objects = new ArrayList<Object>();
    objects.add(studySubject);
    int studyAccruals = 0;
    int threshold = 0;
    List<HealthcareSite> hcsList = getSites(studySubject);
    for (PlannedNotification pn : getPlannedNotifications(hcsList)) {
      if (pn.getEventName().equals(NotificationEventTypeEnum.STUDY_ACCRUAL_EVENT)) {
        Iterator<StudyOrganization> iter =
            studySubject.getStudySite().getStudy().getStudyOrganizations().iterator();
        while (iter.hasNext()) {
          studyOrg = iter.next();
          // ensure that the host org is in the studyOrg list for the study
          if (studyOrg
              .getHealthcareSite()
              .getPrimaryIdentifier()
              .equalsIgnoreCase(configuration.get(Configuration.LOCAL_NCI_INSTITUTE_CODE))) {
            studyAccruals = calculateStudyAccrual(studySubject);
            threshold = studySubject.getStudySite().getStudy().getTargetAccrualNumber().intValue();
            // if accruals exceed specified threshold value then send out email
            if (studyAccruals * 100 / threshold >= pn.getStudyThreshold()) {
              objects.add(pn);
              rulesDelegationService.activateRules(
                  NotificationEventTypeEnum.STUDY_ACCRUAL_EVENT, objects);
            }
          }
        }
      }
      if (pn.getEventName().equals(NotificationEventTypeEnum.STUDY_SITE_ACCRUAL_EVENT)) {
        studySite = studySubject.getStudySite();
        // ensure that the host org is in the studySite list for the study
        if (studySite
            .getHealthcareSite()
            .getPrimaryIdentifier()
            .equalsIgnoreCase(configuration.get(Configuration.LOCAL_NCI_INSTITUTE_CODE))) {
          studyAccruals = calculateStudySiteAccrual(studySubject);
          threshold = studySubject.getStudySite().getTargetAccrualNumber().intValue();
          // if accruals exceed specified threshold value then send out email
          if ((studyAccruals / threshold) * 100 >= pn.getStudySiteThreshold()) {
            objects.add(pn);
            rulesDelegationService.activateRules(
                NotificationEventTypeEnum.STUDY_SITE_ACCRUAL_EVENT, objects);
          }
        }
      }
    }
  }
Beispiel #4
0
  /**
   * Handle study status change. Activates rules for the NEW_STUDY_SAVED_EVENT &
   * STUDY_STATUS_CHANGED_EVENT
   *
   * @param previousState the previous state
   * @param currentState the current state
   * @param entity the entity
   */
  public void handleStudyStatusChange(
      final Object previousState, final Object currentState, final Object entity) {

    log.debug(this.getClass().getName() + ": Entering handleStudyStatusChange()");
    CoordinatingCenterStudyStatus previousCoordinatingCenterStudyStatus = null;
    CoordinatingCenterStudyStatus currentCoordinatingCenterStudyStatus = null;
    NotificationEventTypeEnum event = null;

    List<Object> objects = new ArrayList<Object>();
    objects.add(entity);

    if (previousState != null && previousState instanceof CoordinatingCenterStudyStatus) {
      previousCoordinatingCenterStudyStatus = (CoordinatingCenterStudyStatus) previousState;
    }
    if (currentState != null && currentState instanceof CoordinatingCenterStudyStatus) {
      currentCoordinatingCenterStudyStatus = (CoordinatingCenterStudyStatus) currentState;
    }

    // figure out the event and then fire the rules
    // removed......currentCoordinatingCenterStudyStatus.equals(CoordinatingCenterStudyStatus.PENDING) ||
    if (currentCoordinatingCenterStudyStatus != null
        && currentCoordinatingCenterStudyStatus.equals(previousCoordinatingCenterStudyStatus)) {
      log.debug("There is no change in the study's status");
      // do nothing if the final status is same as the previous status.
    } else {
      // if the prev status is ready to open and current status is active then its a new study
      // else its a study status change.
      if (currentCoordinatingCenterStudyStatus.equals(CoordinatingCenterStudyStatus.OPEN)
          && (previousCoordinatingCenterStudyStatus == null
              || previousCoordinatingCenterStudyStatus.equals(
                  CoordinatingCenterStudyStatus.READY_TO_OPEN)
              || previousCoordinatingCenterStudyStatus.equals(
                  CoordinatingCenterStudyStatus.PENDING))) {
        event = NotificationEventTypeEnum.NEW_STUDY_SAVED_EVENT;
        log.debug("Creating a new study event in the interceptor");
      } else {
        event = NotificationEventTypeEnum.STUDY_STATUS_CHANGED_EVENT;
        log.debug("Creating a study status changed event in the interceptor");
      }
      List<HealthcareSite> hcsList = getSites(entity);
      for (PlannedNotification pn : getPlannedNotifications(hcsList)) {
        // there is some status change and event is configured in plannedNotifs...activate
        // RulesService
        if (pn.getEventName().equals(event)) {
          objects.add(pn);
          rulesDelegationService.activateRules(event, objects);
          objects.remove(pn);
        }
      }
    }
    log.debug(this.getClass().getName() + ": exiting handleStudyStatusChange()");
  }
Beispiel #5
0
  /**
   * Handle study site status change. Actives rules for the STUDY_SITE_STATUS_CHANGED_EVENT
   *
   * @param previousState the previous state
   * @param currentState the current state
   * @param entity the entity
   */
  public void handleStudySiteStatusChange(
      final Object previousState, final Object currentState, final Object entity) {

    SiteStudyStatus previousSiteStudyStatus = null;
    SiteStudyStatus currentSiteStudyStatus = null;
    NotificationEventTypeEnum event = null;

    List<Object> objects = new ArrayList<Object>();
    objects.add(entity);

    if (previousState != null && previousState instanceof SiteStudyStatus) {
      previousSiteStudyStatus = (SiteStudyStatus) previousState;
    }
    if (currentState != null && currentState instanceof SiteStudyStatus) {
      currentSiteStudyStatus = (SiteStudyStatus) currentState;
    }

    // don't do anything when the study site is newly created in which case it's previous state will
    // be null
    if (previousSiteStudyStatus == null
        || (previousSiteStudyStatus != null
            && previousSiteStudyStatus.getCode().equals(currentSiteStudyStatus.getCode()))) {
      // no status change...do nothing
    } else {
      // there is some status change and event is configured in plannedNotifs
      // for study site we only have ths study site status changed event
      event = NotificationEventTypeEnum.STUDY_SITE_STATUS_CHANGED_EVENT;
      List<HealthcareSite> hcsList = getSites(entity);
      for (PlannedNotification pn : getPlannedNotifications(hcsList)) {
        if (pn.getEventName().equals(event)) {
          objects.add(pn);
          rulesDelegationService.activateRules(event, objects);
          objects.remove(pn);
        }
      }
    }
  }