Search in sources :

Example 1 with StudyParameter

use of org.akaza.openclinica.bean.service.StudyParameter 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 2 with StudyParameter

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

the class StudyParameterValueDAO method findAllParameters.

public ArrayList findAllParameters() {
    this.setTypesExpectedForParameter();
    ArrayList alist = this.select(digester.getQuery("findAllParameters"));
    ArrayList al = new ArrayList();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        StudyParameter eb = (StudyParameter) this.getParameterEntityFromHashMap((HashMap) it.next());
        al.add(eb);
    }
    return al;
}
Also used : StudyParameter(org.akaza.openclinica.bean.service.StudyParameter) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 3 with StudyParameter

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

the class StudyParameterValueDAO method findParameterByHandle.

public StudyParameter findParameterByHandle(String handle) {
    StudyParameter sp = new StudyParameter();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(new Integer(1), handle);
    String sql = digester.getQuery("findParameterByHandle");
    ArrayList alist = this.select(sql, variables);
    Iterator it = alist.iterator();
    if (it.hasNext()) {
        sp = (StudyParameter) this.getEntityFromHashMap((HashMap) it.next());
    }
    return sp;
}
Also used : StudyParameter(org.akaza.openclinica.bean.service.StudyParameter) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 4 with StudyParameter

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

the class StudyConfigService method setParametersForStudy.

/**
     * This method construct an object which has all the study parameter values
     *
     * @param study
     * @return
     */
public StudyBean setParametersForStudy(StudyBean study) {
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(ds);
    ArrayList parameters = spvdao.findAllParameters();
    StudyParameterConfig spc = new StudyParameterConfig();
    for (int i = 0; i < parameters.size(); i++) {
        StudyParameter sp = (StudyParameter) parameters.get(i);
        String handle = sp.getHandle();
        // logger.info("handle:" + handle);
        StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), handle);
        // TO DO: will change to use java reflection later
        if (spv.getId() > 0) {
            if (handle.equalsIgnoreCase("collectDob")) {
                spc.setCollectDob(spv.getValue());
            } else if (handle.equalsIgnoreCase("genderRequired")) {
                spc.setGenderRequired(spv.getValue());
            } else if (handle.equalsIgnoreCase("discrepancyManagement")) {
                spc.setDiscrepancyManagement(spv.getValue());
            } else if (handle.equalsIgnoreCase("subjectPersonIdRequired")) {
                spc.setSubjectPersonIdRequired(spv.getValue());
            // logger.info("subjectPersonIdRequired" +
            // spc.getSubjectPersonIdRequired());
            } else if (handle.equalsIgnoreCase("interviewerNameRequired")) {
                spc.setInterviewerNameRequired(spv.getValue());
            } else if (handle.equalsIgnoreCase("interviewerNameDefault")) {
                spc.setInterviewerNameDefault(spv.getValue());
            } else if (handle.equalsIgnoreCase("interviewerNameEditable")) {
                spc.setInterviewerNameEditable(spv.getValue());
            } else if (handle.equalsIgnoreCase("interviewDateRequired")) {
                spc.setInterviewDateRequired(spv.getValue());
            } else if (handle.equalsIgnoreCase("interviewDateDefault")) {
                spc.setInterviewDateDefault(spv.getValue());
            } else if (handle.equalsIgnoreCase("interviewDateEditable")) {
                spc.setInterviewDateEditable(spv.getValue());
            } else if (handle.equalsIgnoreCase("subjectIdGeneration")) {
                spc.setSubjectIdGeneration(spv.getValue());
                logger.debug("subjectIdGeneration" + spc.getSubjectIdGeneration());
            } else if (handle.equalsIgnoreCase("subjectIdPrefixSuffix")) {
                spc.setSubjectIdPrefixSuffix(spv.getValue());
            } else if (handle.equalsIgnoreCase("personIdShownOnCRF")) {
                spc.setPersonIdShownOnCRF(spv.getValue());
            } else if (handle.equalsIgnoreCase("secondaryLabelViewable")) {
                spc.setSecondaryLabelViewable(spv.getValue());
            } else if (handle.equalsIgnoreCase("adminForcedReasonForChange")) {
                spc.setAdminForcedReasonForChange(spv.getValue());
            } else if (handle.equalsIgnoreCase("eventLocationRequired")) {
                spc.setEventLocationRequired(spv.getValue());
            } else if (handle.equalsIgnoreCase("participantPortal")) {
                spc.setParticipantPortal(spv.getValue());
            } else if (handle.equalsIgnoreCase("randomization")) {
                spc.setRandomization(spv.getValue());
            }
        }
    }
    study.setStudyParameterConfig(spc);
    return study;
}
Also used : StudyParameterConfig(org.akaza.openclinica.bean.service.StudyParameterConfig) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyParameter(org.akaza.openclinica.bean.service.StudyParameter) ArrayList(java.util.ArrayList)

Example 5 with StudyParameter

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

the class StudyConfigService method hasDefinedParameterValue.

/**
     *  true if the study has a value defined for this parameter o if studyId
     * is a parent study, then this is true iff there is a row for this
     * study/parameter pair in the study_parameter_value table o if studyId is a
     * site, then this is true if: ? * the parameter is inheritable and the
     * studys parent has a defined parameter value; OR ? * the parameter is not
     * inheritable and there is a row for this studyId/parameter pair in the
     * study_parameter_value table
     *
     * @param studyId
     * @param parameterHandle
     * @return
     */
public String hasDefinedParameterValue(int studyId, String parameterHandle) {
    StudyDAO sdao = new StudyDAO(ds);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(ds);
    if (studyId <= 0 || StringUtil.isBlank(parameterHandle)) {
        return null;
    }
    StudyParameterValueBean spv = spvdao.findByHandleAndStudy(studyId, parameterHandle);
    StudyParameter sp = spvdao.findParameterByHandle(parameterHandle);
    StudyBean study = (StudyBean) sdao.findByPK(studyId);
    if (spv.getId() > 0) {
        // top study or not
        return spv.getValue();
    }
    int parentId = study.getParentStudyId();
    if (parentId > 0) {
        StudyParameterValueBean spvParent = spvdao.findByHandleAndStudy(parentId, parameterHandle);
        if (spvParent.getId() > 0 && sp.isInheritable()) {
            return spvParent.getValue();
        }
    }
    return null;
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyParameter(org.akaza.openclinica.bean.service.StudyParameter) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Aggregations

StudyParameter (org.akaza.openclinica.bean.service.StudyParameter)6 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3 StudyParameterValueBean (org.akaza.openclinica.bean.service.StudyParameterValueBean)3 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 StudyParameterConfig (org.akaza.openclinica.bean.service.StudyParameterConfig)1 StudyParamsConfig (org.akaza.openclinica.bean.service.StudyParamsConfig)1 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)1