Search in sources :

Example 6 with StudyParamsConfig

use of org.akaza.openclinica.bean.service.StudyParamsConfig in project OpenClinica by OpenClinica.

the class CreateSubStudyServlet method submitStudy.

/**
     * Inserts the new study into database
     * 
     */
private void submitStudy() throws IOException {
    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 >>
    this.submitSiteEventDefinitions(study);
    // 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"));
    ArrayList pageMessages = (ArrayList) request.getAttribute(PAGE_MESSAGE);
    session.setAttribute("pageMessages", pageMessages);
    response.sendRedirect(request.getContextPath() + Page.MANAGE_STUDY_MODULE.getFileName());
}
Also used : StudyParamsConfig(org.akaza.openclinica.bean.service.StudyParamsConfig) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Date(java.util.Date)

Example 7 with StudyParamsConfig

use of org.akaza.openclinica.bean.service.StudyParamsConfig in project OpenClinica by OpenClinica.

the class UpdateSubStudyServlet method createStudyBean.

/**
     * Constructs study bean from reques * *
     *
     * @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"));
    if (!StringUtil.isBlank(fp.getString("startDate")))
        study.setDatePlannedStart(fp.getDate("startDate"));
    else
        study.setDatePlannedStart(null);
    if (!StringUtil.isBlank(fp.getString("endDate")))
        study.setDatePlannedEnd(fp.getDate("endDate"));
    else
        study.setDatePlannedEnd(null);
    if (!StringUtil.isBlank(fp.getString(INPUT_VER_DATE)))
        study.setProtocolDateVerification(fp.getDate(INPUT_VER_DATE));
    else
        study.setProtocolDateVerification(null);
    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.setStatusId(fp.getInt("statusId"));
    study.setStatus(Status.get(fp.getInt("statusId")));
    // 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 >>
    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().setStudyId(study.getId());
        scg.getValue().setParameter(scg.getParameter().getHandle());
        scg.getValue().setValue(value);
    }
    return study;
}
Also used : StudyParamsConfig(org.akaza.openclinica.bean.service.StudyParamsConfig) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)7 StudyParamsConfig (org.akaza.openclinica.bean.service.StudyParamsConfig)7 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)6 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)5 StudyParameterValueBean (org.akaza.openclinica.bean.service.StudyParameterValueBean)4 Date (java.util.Date)3 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)3 StudyParameterValueDAO (org.akaza.openclinica.dao.service.StudyParameterValueDAO)3 ParseException (java.text.ParseException)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 StudyParameter (org.akaza.openclinica.bean.service.StudyParameter)1 InsufficientPermissionException (org.akaza.openclinica.web.InsufficientPermissionException)1