コード例 #1
0
  @Override
  public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    String action = request.getParameter("action");

    if (StringUtil.isBlank(action)) {
      if (currentStudy.getParentStudyId() > 0) {
        addPageMessage(respage.getString("you_cannot_create_site_itself_site"));

        forwardPage(Page.SITE_LIST_SERVLET);
      } else {
        StudyBean newStudy = new StudyBean();
        newStudy.setParentStudyId(currentStudy.getId());
        // get default facility info from property file
        newStudy.setFacilityName(SQLInitServlet.getField(CreateStudyServlet.FAC_NAME));
        newStudy.setFacilityCity(SQLInitServlet.getField(CreateStudyServlet.FAC_CITY));
        newStudy.setFacilityState(SQLInitServlet.getField(CreateStudyServlet.FAC_STATE));
        newStudy.setFacilityCountry(SQLInitServlet.getField(CreateStudyServlet.FAC_COUNTRY));
        newStudy.setFacilityContactDegree(
            SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_DEGREE));
        newStudy.setFacilityContactEmail(
            SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_EMAIL));
        newStudy.setFacilityContactName(
            SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_NAME));
        newStudy.setFacilityContactPhone(
            SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_PHONE));
        newStudy.setFacilityZip(SQLInitServlet.getField(CreateStudyServlet.FAC_ZIP));

        ArrayList parentConfigs = currentStudy.getStudyParameters();
        // logger.info("parentConfigs size:" + parentConfigs.size());
        ArrayList configs = new ArrayList();

        for (int i = 0; i < parentConfigs.size(); i++) {
          StudyParamsConfig scg = (StudyParamsConfig) parentConfigs.get(i);
          if (scg != null) {
            // find the one that sub study can change
            if (scg.getValue().getId() > 0 && scg.getParameter().isOverridable()) {
              logger.info("parameter:" + scg.getParameter().getHandle());
              logger.info("value:" + scg.getValue().getValue());
              // YW 10-12-2007, set overridable study parameters
              // for a site
              if (scg.getParameter().getHandle().equalsIgnoreCase("interviewerNameRequired")) {
                scg.getValue().setValue(fp.getString("interviewerNameRequired"));
              } else if (scg.getParameter()
                  .getHandle()
                  .equalsIgnoreCase("interviewerNameDefault")) {
                scg.getValue().setValue(fp.getString("interviewerNameDefault"));
              } else if (scg.getParameter().getHandle().equalsIgnoreCase("interviewDateRequired")) {
                scg.getValue().setValue(fp.getString("interviewDateRequired"));
              } else if (scg.getParameter().getHandle().equalsIgnoreCase("interviewDateDefault")) {
                scg.getValue().setValue(fp.getString("interviewDateDefault"));
              }
              // YW >>
              configs.add(scg);
            }
          }
        }

        newStudy.setStudyParameters(configs);

        // YW 10-12-2007 <<
        newStudy
            .getStudyParameterConfig()
            .setInterviewerNameRequired(fp.getString("interviewerNameRequired"));
        newStudy
            .getStudyParameterConfig()
            .setInterviewerNameDefault(fp.getString("interviewerNameDefault"));
        newStudy
            .getStudyParameterConfig()
            .setInterviewDateRequired(fp.getString("interviewDateRequired"));
        newStudy
            .getStudyParameterConfig()
            .setInterviewDateDefault(fp.getString("interviewDateDefault"));
        // YW >>

        session.setAttribute("newStudy", newStudy);
        request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
        request.setAttribute("statuses", Status.toActiveArrayList());

        forwardPage(Page.CREATE_SUB_STUDY);
      }

    } else {
      if ("confirm".equalsIgnoreCase(action)) {
        confirmStudy();

      } else if ("back".equalsIgnoreCase(action)) {
        request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
        request.setAttribute("statuses", Status.toActiveArrayList());

        forwardPage(Page.CREATE_SUB_STUDY);
      } else if ("submit".equalsIgnoreCase(action)) {
        submitStudy();
      }
    }
  }
コード例 #2
0
  /**
   * Constructs study bean from request
   *
   * @param request
   * @return
   */
  private StudyBean createStudyBean() {
    FormProcessor fp = new FormProcessor(request);
    StudyBean study = (StudyBean) session.getAttribute("newStudy");
    study.setName(fp.getString("name"));
    study.setIdentifier(fp.getString("uniqueProId"));
    study.setSecondaryIdentifier(fp.getString("secondProId"));
    study.setSummary(fp.getString("description"));
    study.setPrincipalInvestigator(fp.getString("prinInvestigator"));
    study.setExpectedTotalEnrollment(fp.getInt("expectedTotalEnrollment"));
    java.util.Date startDate = null;
    java.util.Date endDate = null;
    try {
      local_df.setLenient(false);
      startDate = local_df.parse(fp.getString("startDate"));

    } catch (ParseException fe) {
      startDate = study.getDatePlannedStart();
      logger.info(fe.getMessage());
    }
    study.setDatePlannedStart(startDate);

    try {
      local_df.setLenient(false);
      endDate = local_df.parse(fp.getString("endDate"));

    } catch (ParseException fe) {
      endDate = study.getDatePlannedEnd();
    }
    study.setDatePlannedEnd(endDate);

    study.setFacilityCity(fp.getString("facCity"));
    study.setFacilityContactDegree(fp.getString("facConDrgree"));
    study.setFacilityName(fp.getString("facName"));
    study.setFacilityContactEmail(fp.getString("facConEmail"));
    study.setFacilityContactPhone(fp.getString("facConPhone"));
    study.setFacilityContactName(fp.getString("facConName"));
    study.setFacilityContactDegree(fp.getString("facConDegree"));
    study.setFacilityCountry(fp.getString("facCountry"));
    // study.setFacilityRecruitmentStatus(fp.getString("facRecStatus"));
    study.setFacilityState(fp.getString("facState"));
    study.setFacilityZip(fp.getString("facZip"));
    study.setStatus(Status.get(fp.getInt("statusId")));

    ArrayList parameters = study.getStudyParameters();

    for (int i = 0; i < parameters.size(); i++) {
      StudyParamsConfig scg = (StudyParamsConfig) parameters.get(i);
      String value = fp.getString(scg.getParameter().getHandle());
      logger.info("get value:" + value);
      scg.getValue().setParameter(scg.getParameter().getHandle());
      scg.getValue().setValue(value);
    }

    // YW 10-12-2007 <<
    study
        .getStudyParameterConfig()
        .setInterviewerNameRequired(fp.getString("interviewerNameRequired"));
    study
        .getStudyParameterConfig()
        .setInterviewerNameDefault(fp.getString("interviewerNameDefault"));
    study.getStudyParameterConfig().setInterviewDateRequired(fp.getString("interviewDateRequired"));
    study.getStudyParameterConfig().setInterviewDateDefault(fp.getString("interviewDateDefault"));
    // YW >>

    return study;
  }
コード例 #3
0
  /** Inserts the new study into database */
  private void submitStudy() {
    FormProcessor fp = new FormProcessor(request);
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    StudyBean study = (StudyBean) session.getAttribute("newStudy");

    ArrayList parameters = study.getStudyParameters();
    logger.info("study bean to be created:\n");
    logger.info(
        study.getName()
            + "\n"
            + study.getIdentifier()
            + "\n"
            + study.getParentStudyId()
            + "\n"
            + study.getSummary()
            + "\n"
            + study.getPrincipalInvestigator()
            + "\n"
            + study.getDatePlannedStart()
            + "\n"
            + study.getDatePlannedEnd()
            + "\n"
            + study.getFacilityName()
            + "\n"
            + study.getFacilityCity()
            + "\n"
            + study.getFacilityState()
            + "\n"
            + study.getFacilityZip()
            + "\n"
            + study.getFacilityCountry()
            + "\n"
            + study.getFacilityRecruitmentStatus()
            + "\n"
            + study.getFacilityContactName()
            + "\n"
            + study.getFacilityContactEmail()
            + "\n"
            + study.getFacilityContactPhone()
            + "\n"
            + study.getFacilityContactDegree());

    study.setOwner(ub);
    study.setCreatedDate(new Date());
    StudyBean parent = (StudyBean) sdao.findByPK(study.getParentStudyId());
    study.setType(parent.getType());
    // YW 10-10-2007, enable setting site status
    study.setStatus(study.getStatus());
    // YW >>

    study.setGenetic(parent.isGenetic());
    study = (StudyBean) sdao.create(study);

    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    for (int i = 0; i < parameters.size(); i++) {
      StudyParamsConfig config = (StudyParamsConfig) parameters.get(i);
      StudyParameterValueBean spv = config.getValue();
      spv.setStudyId(study.getId());
      spv = (StudyParameterValueBean) spvdao.create(config.getValue());
    }

    // YW << here only "collectDob" and "genderRequired" have been corrected
    // for sites.
    StudyParameterValueBean spv = new StudyParameterValueBean();
    StudyParameterValueBean parentSPV = spvdao.findByHandleAndStudy(parent.getId(), "collectDob");
    spv.setStudyId(study.getId());
    spv.setParameter("collectDob");
    spv.setValue(parentSPV.getValue());
    spvdao.create(spv);

    parentSPV = spvdao.findByHandleAndStudy(parent.getId(), "genderRequired");
    spv.setParameter("genderRequired");
    spv.setValue(parentSPV.getValue());
    spvdao.create(spv);
    // YW >>

    // switch user to the newly created site
    session.setAttribute("study", session.getAttribute("newStudy"));
    currentStudy = (StudyBean) session.getAttribute("study");

    session.removeAttribute("newStudy");
    addPageMessage(respage.getString("the_new_site_created_succesfully_current"));
    forwardPage(Page.SITE_LIST_SERVLET);
  }
コード例 #4
0
  @Override
  public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    String action = request.getParameter("action");
    session.setAttribute("sdvOptions", this.setSDVOptions());

    if (StringUtil.isBlank(action)) {
      if (currentStudy.getParentStudyId() > 0) {
        addPageMessage(respage.getString("you_cannot_create_site_itself_site"));

        forwardPage(Page.SITE_LIST_SERVLET);
      } else {
        StudyBean newStudy = new StudyBean();
        newStudy.setParentStudyId(currentStudy.getId());
        // get default facility info from property file
        newStudy.setFacilityName(SQLInitServlet.getField(CreateStudyServlet.FAC_NAME));
        newStudy.setFacilityCity(SQLInitServlet.getField(CreateStudyServlet.FAC_CITY));
        newStudy.setFacilityState(SQLInitServlet.getField(CreateStudyServlet.FAC_STATE));
        newStudy.setFacilityCountry(SQLInitServlet.getField(CreateStudyServlet.FAC_COUNTRY));
        newStudy.setFacilityContactDegree(
            SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_DEGREE));
        newStudy.setFacilityContactEmail(
            SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_EMAIL));
        newStudy.setFacilityContactName(
            SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_NAME));
        newStudy.setFacilityContactPhone(
            SQLInitServlet.getField(CreateStudyServlet.FAC_CONTACT_PHONE));
        newStudy.setFacilityZip(SQLInitServlet.getField(CreateStudyServlet.FAC_ZIP));

        List<StudyParamsConfig> parentConfigs = currentStudy.getStudyParameters();
        // logger.info("parentConfigs size:" + parentConfigs.size());
        ArrayList configs = new ArrayList();

        for (StudyParamsConfig scg : parentConfigs) {
          // StudyParamsConfig scg = (StudyParamsConfig)
          // parentConfigs.get(i);
          if (scg != null) {
            // find the one that sub study can change
            if (scg.getValue().getId() > 0 && scg.getParameter().isOverridable()) {
              logger.info("parameter:" + scg.getParameter().getHandle());
              logger.info("value:" + scg.getValue().getValue());
              // YW 10-12-2007, set overridable study parameters
              // for a site
              if (scg.getParameter().getHandle().equalsIgnoreCase("interviewerNameRequired")) {
                scg.getValue().setValue(fp.getString("interviewerNameRequired"));
              } else if (scg.getParameter()
                  .getHandle()
                  .equalsIgnoreCase("interviewerNameDefault")) {
                scg.getValue().setValue(fp.getString("interviewerNameDefault"));
              } else if (scg.getParameter().getHandle().equalsIgnoreCase("interviewDateRequired")) {
                scg.getValue().setValue(fp.getString("interviewDateRequired"));
              } else if (scg.getParameter().getHandle().equalsIgnoreCase("interviewDateDefault")) {
                scg.getValue().setValue(fp.getString("interviewDateDefault"));
              }
              // YW >>
              configs.add(scg);
            }
          }
        }
        newStudy.setStudyParameters(configs);

        // YW 10-12-2007 <<
        newStudy
            .getStudyParameterConfig()
            .setInterviewerNameRequired(fp.getString("interviewerNameRequired"));
        newStudy
            .getStudyParameterConfig()
            .setInterviewerNameDefault(fp.getString("interviewerNameDefault"));
        newStudy
            .getStudyParameterConfig()
            .setInterviewDateRequired(fp.getString("interviewDateRequired"));
        newStudy
            .getStudyParameterConfig()
            .setInterviewDateDefault(fp.getString("interviewDateDefault"));
        // YW >>

        // BWP 3169 1-12-2008 <<
        newStudy
            .getStudyParameterConfig()
            .setInterviewerNameEditable(
                currentStudy.getStudyParameterConfig().getInterviewerNameEditable());
        newStudy
            .getStudyParameterConfig()
            .setInterviewDateEditable(
                currentStudy.getStudyParameterConfig().getInterviewDateEditable());
        // >>

        try {
          local_df.parse(fp.getString(INPUT_START_DATE));
          fp.addPresetValue(INPUT_START_DATE, local_df.format(fp.getDate(INPUT_START_DATE)));
        } catch (ParseException pe) {
          fp.addPresetValue(INPUT_START_DATE, fp.getString(INPUT_START_DATE));
        }
        try {
          local_df.parse(fp.getString(INPUT_END_DATE));
          fp.addPresetValue(INPUT_END_DATE, local_df.format(fp.getDate(INPUT_END_DATE)));
        } catch (ParseException pe) {
          fp.addPresetValue(INPUT_END_DATE, fp.getString(INPUT_END_DATE));
        }
        // tbh 3946 07/2009
        try {
          local_df.parse(fp.getString(INPUT_VER_DATE));
          fp.addPresetValue(INPUT_VER_DATE, local_df.format(fp.getDate(INPUT_VER_DATE)));
        } catch (ParseException pe) {
          fp.addPresetValue(INPUT_VER_DATE, fp.getString(INPUT_VER_DATE));
        }
        // >> tbh
        setPresetValues(fp.getPresetValues());

        session.setAttribute("newStudy", newStudy);
        session.setAttribute("definitions", this.initDefinitions(newStudy));
        request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
        request.setAttribute("statuses", Status.toActiveArrayList());

        forwardPage(Page.CREATE_SUB_STUDY);
      }

    } else {
      if ("confirm".equalsIgnoreCase(action)) {
        confirmStudy();

      } else if ("back".equalsIgnoreCase(action)) {
        StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
        try {
          fp.addPresetValue(INPUT_START_DATE, local_df.format(newStudy.getDatePlannedEnd()));
        } catch (Exception pe) {
          fp.addPresetValue(INPUT_START_DATE, fp.getString(INPUT_START_DATE));
        }
        try {
          fp.addPresetValue(INPUT_END_DATE, local_df.format(newStudy.getDatePlannedStart()));
        } catch (Exception pe) {
          fp.addPresetValue(INPUT_END_DATE, fp.getString(INPUT_END_DATE));
        }
        try {
          fp.addPresetValue(
              INPUT_VER_DATE, local_df.format(newStudy.getProtocolDateVerification()));
        } catch (Exception pe) {
          fp.addPresetValue(INPUT_VER_DATE, fp.getString(INPUT_VER_DATE));
        }
        setPresetValues(fp.getPresetValues());
        request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
        request.setAttribute("statuses", Status.toActiveArrayList());

        forwardPage(Page.CREATE_SUB_STUDY);
      } else if ("submit".equalsIgnoreCase(action)) {
        submitStudy();
      }
    }
  }