Search in sources :

Example 16 with StudyParameterValueBean

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

the class EditFormController method mayProceed.

private boolean mayProceed(String studyOid) throws Exception {
    boolean accessPermission = false;
    StudyBean siteStudy = getStudy(studyOid);
    StudyBean study = getParentStudy(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
    participantPortalRegistrar = new ParticipantPortalRegistrar();
    // ACTIVE ,
    String pManageStatus = participantPortalRegistrar.getRegistrationStatus(study.getOid()).toString();
    // PENDING ,
    // INACTIVE
    // enabled , disabled
    String participateStatus = pStatus.getValue().toString();
    // available , pending , frozen , locked
    String studyStatus = study.getStatus().getName().toString();
    // available , pending , frozen , locked
    String siteStatus = siteStudy.getStatus().getName().toString();
    logger.info("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus + "   siteStatus: " + siteStatus);
    if (participateStatus.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && siteStatus.equalsIgnoreCase("available") && pManageStatus.equalsIgnoreCase("ACTIVE")) {
        accessPermission = true;
    }
    return accessPermission;
}
Also used : 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)

Example 17 with StudyParameterValueBean

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

the class StudyModuleController method registerRandimization.

@RequestMapping(value = "/{study}/randomize", method = RequestMethod.POST)
public String registerRandimization(@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");
    RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
    Locale locale = LocaleResolver.getLocale(request);
    ResourceBundleProvider.updateLocale(locale);
    respage = ResourceBundleProvider.getPageMessagesBundle(locale);
    String status = "";
    UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
    // Update OC Study configuration
    // send another email to sales@openclinica.com thru MandrillViaOcUi
    status = randomizationRegistrar.randomizeStudy(study.getOid(), study.getIdentifier(), userBean);
    if (status.equals("")) {
    //        addRegMessage(request, respage.getString("randomization_not_available"));
    } else {
        // Update OC Study configuration
        randomizationRegistrar.sendEmail(mailSender, userBean, respage.getString("randomization_email_subject_sent_to_user"), respage.getString("randomization_email_content_message_sent_to_user"));
        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 : Locale(java.util.Locale) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) RandomizationRegistrar(org.akaza.openclinica.service.pmanage.RandomizationRegistrar) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with StudyParameterValueBean

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

the class StudyModuleController method deactivateParticipate.

@RequestMapping(value = "/{study}/deactivate", method = RequestMethod.GET)
public String deactivateParticipate(@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");
    spv.setStudyId(study.getId());
    spv.setParameter("participantPortal");
    spv.setValue("disabled");
    if (spv.getId() > 0)
        spvdao.update(spv);
    else
        spvdao.create(spv);
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    currentStudy.getStudyParameterConfig().setParticipantPortal("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 19 with StudyParameterValueBean

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

the class SystemController method getParticipateMod.

public StudyParameterValueBean getParticipateMod(StudyBean studyBean, String value) {
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(studyBean.getId(), value);
    return pStatus;
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO)

Example 20 with StudyParameterValueBean

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

the class StudyEventTransferValidator method validate.

public void validate(Object obj, Errors e) {
    StudyEventTransferBean studyEventTransferBean = (StudyEventTransferBean) obj;
    // Non Business Validation
    if (studyEventTransferBean.getStudyUniqueId() == null || studyEventTransferBean.getStudyUniqueId().length() < 1) {
        e.reject("studyEventTransferValidator.invalid_study_identifier");
        return;
    }
    // Business Validation
    Status[] included_status = new Status[] { Status.AVAILABLE, Status.PENDING };
    StudyBean study = helper.verifyStudy(getStudyDAO(), studyEventTransferBean.getStudyUniqueId(), included_status, e);
    if (study == null) {
        return;
    }
    studyEventTransferBean.setStudy(study);
    StudyBean site = null;
    int site_id = -1;
    if (studyEventTransferBean.getSiteUniqueId() != null) {
        site = helper.verifySite(getStudyDAO(), studyEventTransferBean.getStudyUniqueId(), studyEventTransferBean.getSiteUniqueId(), included_status, e);
        if (site == null) {
            return;
        }
        site_id = site.getId();
        studyEventTransferBean.setStudy(site);
    }
    boolean isRoleVerified = helper.verifyRole(studyEventTransferBean.getUser(), study.getId(), site_id, Role.MONITOR, e);
    if (!isRoleVerified)
        return;
    // Non Business Validation
    if (studyEventTransferBean.getSubjectLabel() == null) {
        e.reject("studyEventTransferValidator.studySubjectId_required");
        return;
    }
    StudySubjectBean studySubject = getStudySubjectDAO().findByLabelAndStudy(studyEventTransferBean.getSubjectLabel(), studyEventTransferBean.getStudy());
    //it is not null but label null
    if (studySubject == null || studySubject.getOid() == null) {
        e.reject("studyEventTransferValidator.study_subject_does_not_exist", new Object[] { studyEventTransferBean.getSubjectLabel(), studyEventTransferBean.getStudy().getName() }, "StudySubject label you specified " + studyEventTransferBean.getSubjectLabel() + " does not correspond to a study " + studyEventTransferBean.getStudy().getName());
        return;
    }
    // Non Business Validation
    if (studyEventTransferBean.getEventDefinitionOID() == null || studyEventTransferBean.getEventDefinitionOID().length() < 1) {
        e.reject("studyEventTransferValidator.eventDefinitionOID_required");
        return;
    }
    if (studyEventTransferBean.getStartDateTime() == null) {
        e.reject("studyEventTransferValidator.startDateTime_required");
        return;
    }
    StudyParameterValueBean eventLocationRequiredSetting = getStudyParameterValueDAO().findByHandleAndStudy(studyEventTransferBean.getStudy().getId(), "eventLocationRequired");
    //        if ("true".equals(eventLocationRequiredSetting.getValue()) && (studyEventTransferBean.getLocation() == null || studyEventTransferBean.getLocation().length() < 1)) {
    if (REQUIRED.equals(eventLocationRequiredSetting.getValue()) && (studyEventTransferBean.getLocation() == null || studyEventTransferBean.getLocation().length() < 1)) {
        e.reject("studyEventTransferValidator.location_required");
        return;
    }
    if (studyEventTransferBean.getEndDateTime() != null && studyEventTransferBean.getStartDateTime() != null) {
        if (studyEventTransferBean.getEndDateTime().compareTo(studyEventTransferBean.getStartDateTime()) == -1) {
            e.reject("studyEventTransferValidator.start_date_after_end_date", new Object[] { studyEventTransferBean.getStartDateTime(), studyEventTransferBean.getEndDateTime() }, "Start date " + studyEventTransferBean.getStartDateTime() + "  after end date (" + studyEventTransferBean.getEndDateTime() + ").");
            return;
        }
    }
    int parentStudyId = study.getParentStudyId();
    StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionDAO().findByOidAndStudy(studyEventTransferBean.getEventDefinitionOID(), study.getId(), parentStudyId);
    if (studyEventDefinition == null) {
        e.reject("studyEventTransferValidator.invalid_eventDefinitionOID", new Object[] { studyEventTransferBean.getEventDefinitionOID() }, "EventDefinitionOID you specified " + studyEventTransferBean.getEventDefinitionOID() + " is not valid.");
        return;
    }
}
Also used : Status(org.akaza.openclinica.bean.core.Status) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyEventTransferBean(org.akaza.openclinica.ws.bean.StudyEventTransferBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)

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