Search in sources :

Example 1 with StudyParamsConfig

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

the class UpdateSubStudyServlet method submitStudy.

/**
     * Inserts the new study into databa *
     * 
     * @throws MalformedURLException
     *             *
     */
private void submitStudy() throws MalformedURLException {
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    StudyBean study = (StudyBean) session.getAttribute("newStudy");
    ArrayList parameters = study.getStudyParameters();
    /*
         * logger.info("study bean to be updated:\n");
         * logger.info(study.getName()+ "\n" + study.getCreatedDate() + "\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.setCreatedDate(new Date());
    study.setUpdatedDate(new Date());
    study.setUpdater(ub);
    sdao.update(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();
        StudyParameterValueBean spv1 = spvdao.findByHandleAndStudy(spv.getStudyId(), spv.getParameter());
        if (spv1.getId() > 0) {
            spv = (StudyParameterValueBean) spvdao.update(spv);
        } else {
            spv = (StudyParameterValueBean) spvdao.create(spv);
        }
    // spv = (StudyParameterValueBean)spvdao.update(config.getValue());
    }
    submitSiteEventDefinitions(study);
    // session.removeAttribute("newStudy");
    // session.removeAttribute("parentName");
    // session.removeAttribute("definitions");
    // session.removeAttribute("sdvOptions");
    addPageMessage(respage.getString("the_site_has_been_updated_succesfully"));
    String fromListSite = (String) session.getAttribute("fromListSite");
    if (fromListSite != null && fromListSite.equals("yes")) {
        // session.removeAttribute("fromListSite");
        forwardPage(Page.SITE_LIST_SERVLET);
    } else {
        // session.removeAttribute("fromListSite");
        forwardPage(Page.STUDY_LIST_SERVLET);
    }
}
Also used : StudyParamsConfig(org.akaza.openclinica.bean.service.StudyParamsConfig) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) 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 2 with StudyParamsConfig

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

the class StudyParameterValueDAO method findParamConfigByStudy.

public ArrayList findParamConfigByStudy(StudyBean study) {
    this.unsetTypeExpected();
    this.setTypeExpected(1, TypeNames.INT);
    this.setTypeExpected(2, TypeNames.INT);
    this.setTypeExpected(3, TypeNames.STRING);
    this.setTypeExpected(4, TypeNames.STRING);
    this.setTypeExpected(5, TypeNames.INT);
    this.setTypeExpected(6, TypeNames.STRING);
    this.setTypeExpected(7, TypeNames.STRING);
    this.setTypeExpected(8, TypeNames.STRING);
    this.setTypeExpected(9, TypeNames.STRING);
    this.setTypeExpected(10, TypeNames.BOOL);
    this.setTypeExpected(11, TypeNames.BOOL);
    HashMap variables = new HashMap();
    variables.put(new Integer(1), new Integer(study.getId()));
    ArrayList alist = this.select(digester.getQuery("findParamConfigByStudy"), variables);
    ArrayList al = new ArrayList();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        HashMap hm = (HashMap) it.next();
        StudyParameterValueBean spvb = new StudyParameterValueBean();
        spvb.setValue((String) hm.get("value"));
        spvb.setStudyId(((Integer) hm.get("study_id")).intValue());
        spvb.setId(((Integer) hm.get("study_parameter_value_id")).intValue());
        StudyParameter sp = new StudyParameter();
        sp.setId(((Integer) hm.get("study_parameter_id")).intValue());
        sp.setHandle((String) hm.get("handle"));
        sp.setName((String) hm.get("name"));
        sp.setDescription((String) hm.get("description"));
        sp.setDefaultValue((String) hm.get("default_value"));
        sp.setInheritable(((Boolean) hm.get("inheritable")).booleanValue());
        sp.setOverridable(((Boolean) hm.get("overridable")).booleanValue());
        StudyParamsConfig config = new StudyParamsConfig();
        config.setParameter(sp);
        config.setValue(spvb);
        al.add(config);
    }
    return al;
}
Also used : StudyParamsConfig(org.akaza.openclinica.bean.service.StudyParamsConfig) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) HashMap(java.util.HashMap) StudyParameter(org.akaza.openclinica.bean.service.StudyParameter) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 3 with StudyParamsConfig

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

the class CreateSubStudyServlet method processRequest.

@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) {
                // 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());
                        // 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().setInterviewerNameDefault(currentStudy.getStudyParameterConfig().getInterviewerNameDefault());
            newStudy.getStudyParameterConfig().setInterviewDateEditable(currentStudy.getStudyParameterConfig().getInterviewDateEditable());
            newStudy.getStudyParameterConfig().setInterviewDateDefault(currentStudy.getStudyParameterConfig().getInterviewDateDefault());
            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();
        }
    }
}
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) ParseException(java.text.ParseException) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException) ParseException(java.text.ParseException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 4 with StudyParamsConfig

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

the class CreateSubStudyServlet method createStudyBean.

/**
     * Constructs study bean from 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;
    java.util.Date protocolDate = 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);
    // >> tbh 3946 07/2009
    try {
        local_df.setLenient(false);
        protocolDate = local_df.parse(fp.getString(INPUT_VER_DATE));
    } catch (ParseException fe) {
        protocolDate = study.getProtocolDateVerification();
    }
    study.setProtocolDateVerification(protocolDate);
    // << tbh
    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"));
    return study;
}
Also used : StudyParamsConfig(org.akaza.openclinica.bean.service.StudyParamsConfig) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) Date(java.util.Date) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException)

Example 5 with StudyParamsConfig

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

the class InitUpdateSubStudyServlet method processRequest.

@Override
public void processRequest() throws Exception {
    // baseUrl();
    String userName = request.getRemoteUser();
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    String idString = request.getParameter("id");
    logger.info("study id:" + idString);
    if (StringUtil.isBlank(idString)) {
        addPageMessage(respage.getString("please_choose_a_study_to_edit"));
        forwardPage(Page.STUDY_LIST_SERVLET);
    } else {
        int studyId = Integer.valueOf(idString.trim()).intValue();
        StudyBean study = (StudyBean) sdao.findByPK(studyId);
        checkRoleByUserAndStudy(ub, study.getParentStudyId(), study.getId());
        String parentStudyName = "";
        StudyBean parent = new StudyBean();
        if (study.getParentStudyId() > 0) {
            parent = (StudyBean) sdao.findByPK(study.getParentStudyId());
            parentStudyName = parent.getName();
            // at this time, this feature is only available for site
            createEventDefinitions(parent);
        }
        if (currentStudy.getId() != study.getId()) {
            ArrayList parentConfigs = currentStudy.getStudyParameters();
            // logger.info("parentConfigs size:" + parentConfigs.size());
            ArrayList configs = new ArrayList();
            StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
            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());
                        StudyParameterValueBean spvb = spvdao.findByHandleAndStudy(study.getId(), scg.getParameter().getHandle());
                        if (spvb.getValue().equals("enabled"))
                            baseUrl();
                        if (spvb.getId() > 0) {
                            // the sub study itself has the parameter
                            scg.setValue(spvb);
                        }
                        configs.add(scg);
                    }
                }
            }
            study.setStudyParameters(configs);
        }
        request.setAttribute("parentStudy", parent);
        session.setAttribute("parentName", parentStudyName);
        session.setAttribute("newStudy", study);
        request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
        request.setAttribute("statuses", Status.toStudyUpdateMembersList());
        FormProcessor fp = new FormProcessor(request);
        logger.info("start date:" + study.getDatePlannedEnd());
        if (study.getDatePlannedEnd() != null) {
            fp.addPresetValue(UpdateSubStudyServlet.INPUT_END_DATE, local_df.format(study.getDatePlannedEnd()));
        }
        if (study.getDatePlannedStart() != null) {
            fp.addPresetValue(UpdateSubStudyServlet.INPUT_START_DATE, local_df.format(study.getDatePlannedStart()));
        }
        if (study.getProtocolDateVerification() != null) {
            fp.addPresetValue(UpdateSubStudyServlet.INPUT_VER_DATE, local_df.format(study.getProtocolDateVerification()));
        }
        setPresetValues(fp.getPresetValues());
        forwardPage(Page.UPDATE_SUB_STUDY);
    }
}
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)

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