Search in sources :

Example 26 with StudyParameterValueBean

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

the class SubjectService method createStudySubject.

private StudySubjectBean createStudySubject(SubjectBean subject, StudyBean studyBean, Date enrollmentDate, String secondaryId) {
    StudySubjectBean studySubject = new StudySubjectBean();
    studySubject.setSecondaryLabel(secondaryId);
    studySubject.setOwner(getUserAccount());
    studySubject.setEnrollmentDate(enrollmentDate);
    studySubject.setSubjectId(subject.getId());
    studySubject.setStudyId(studyBean.getId());
    studySubject.setStatus(Status.AVAILABLE);
    int handleStudyId = studyBean.getParentStudyId() > 0 ? studyBean.getParentStudyId() : studyBean.getId();
    StudyParameterValueBean subjectIdGenerationParameter = getStudyParameterValueDAO().findByHandleAndStudy(handleStudyId, "subjectIdGeneration");
    String idSetting = subjectIdGenerationParameter.getValue();
    if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
        // Warning: Here we have a race condition. 
        // At least, a uniqueness constraint should be set on the database! Better provide an atomic method which stores a new label in the database and returns it.  
        int nextLabel = getStudySubjectDao().findTheGreatestLabel() + 1;
        studySubject.setLabel(Integer.toString(nextLabel));
    } else {
        studySubject.setLabel(subject.getLabel());
        subject.setLabel(null);
    }
    return studySubject;
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean)

Example 27 with StudyParameterValueBean

use of org.akaza.openclinica.bean.service.StudyParameterValueBean 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)

Example 28 with StudyParameterValueBean

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

the class StudyModuleController method registerParticipate.

@RequestMapping(value = "/{study}/register", method = RequestMethod.POST)
public String registerParticipate(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
    studyDao = new StudyDAO(dataSource);
    StudyBean study = studyDao.findByOid(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
    ParticipantPortalRegistrar registrar = new ParticipantPortalRegistrar();
    Locale locale = LocaleResolver.getLocale(request);
    ResourceBundleProvider.updateLocale(locale);
    respage = ResourceBundleProvider.getPageMessagesBundle(locale);
    // Check if desired hostName is available. If so, send OCUI registration request
    String hostName = request.getParameter("hostName");
    if (hostName == null || hostName.equals("")) {
        addRegMessage(request, respage.getString("participate_hostname_invalid"));
        return "redirect:/pages/studymodule";
    }
    String status = "";
    String nameAvailability = registrar.getHostNameAvailability(hostName);
    if (nameAvailability.equals(ParticipantPortalRegistrar.UNAVAILABLE)) {
        addRegMessage(request, respage.getString("participate_hostname_not_available"));
        return "redirect:/pages/studymodule";
    } else if (nameAvailability.equals(ParticipantPortalRegistrar.UNKNOWN)) {
        addRegMessage(request, respage.getString("participate_not_available"));
        return "redirect:/pages/studymodule";
    } else if (nameAvailability.equals(ParticipantPortalRegistrar.INVALID)) {
        addRegMessage(request, respage.getString("participate_hostname_invalid"));
        return "redirect:/pages/studymodule";
    } else {
        // Returned status was 'available'. Proceed with registration.
        status = registrar.registerStudy(study.getOid(), hostName, study.getIdentifier());
    }
    // parameter.
    if (status.equals("")) {
        addRegMessage(request, respage.getString("participate_not_available"));
    } else {
        // Update OC Study configuration
        spv.setStudyId(study.getId());
        spv.setParameter("participantPortal");
        spv.setValue("enabled");
        if (spv.getId() > 0)
            spvdao.update(spv);
        else
            spvdao.create(spv);
        StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
        currentStudy.getStudyParameterConfig().setParticipantPortal("enabled");
    }
    return "redirect:/pages/studymodule";
}
Also used : Locale(java.util.Locale) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 29 with StudyParameterValueBean

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

the class StudyModuleController method deactivateRandomization.

@RequestMapping(value = "/{study}/deactivaterandomization", method = RequestMethod.GET)
public String deactivateRandomization(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
    studyDao = new StudyDAO(dataSource);
    StudyBean study = studyDao.findByOid(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "randomization");
    spv.setStudyId(study.getId());
    spv.setParameter("randomization");
    spv.setValue("disabled");
    if (spv.getId() > 0)
        spvdao.update(spv);
    else
        spvdao.create(spv);
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    currentStudy.getStudyParameterConfig().setRandomization("disabled");
    return "redirect:/pages/studymodule";
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 30 with StudyParameterValueBean

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

the class StudyModuleController method reactivateRandomization.

@RequestMapping(value = "/{study}/reactivaterandomization", method = RequestMethod.GET)
public String reactivateRandomization(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
    studyDao = new StudyDAO(dataSource);
    StudyBean study = studyDao.findByOid(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "randomization");
    spv.setStudyId(study.getId());
    spv.setParameter("randomization");
    spv.setValue("enabled");
    if (spv.getId() > 0)
        spvdao.update(spv);
    else
        spvdao.create(spv);
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    currentStudy.getStudyParameterConfig().setRandomization("enabled");
    return "redirect:/pages/studymodule";
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

StudyParameterValueBean (org.akaza.openclinica.bean.service.StudyParameterValueBean)46 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)31 StudyParameterValueDAO (org.akaza.openclinica.dao.service.StudyParameterValueDAO)27 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)18 ArrayList (java.util.ArrayList)16 Date (java.util.Date)9 HashMap (java.util.HashMap)9 ParticipantPortalRegistrar (org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar)9 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)6 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 Iterator (java.util.Iterator)5 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)4 StudyParamsConfig (org.akaza.openclinica.bean.service.StudyParamsConfig)4 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)3 StudyParameter (org.akaza.openclinica.bean.service.StudyParameter)3 RandomizationRegistrar (org.akaza.openclinica.service.pmanage.RandomizationRegistrar)3 IOException (java.io.IOException)2