Search in sources :

Example 1 with SeRandomizationDTO

use of org.akaza.openclinica.service.pmanage.SeRandomizationDTO in project OpenClinica by OpenClinica.

the class RandomizeActionProcessor method mayProceed.

private boolean mayProceed(String studyOid) throws Exception {
    boolean accessPermission = false;
    StudyBean siteStudy = getStudy(studyOid);
    StudyBean study = getParentStudy(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(ds);
    StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(study.getId(), "randomization");
    randomizationRegistrar = new RandomizationRegistrar();
    SeRandomizationDTO seRandomizationDTO = randomizationRegistrar.getCachedRandomizationDTOObject(study.getOid().toString(), false);
    String randomizationStatusFromOCUI = seRandomizationDTO.getStatus();
    // enabled , disabled
    String randomizationStatusFromOC = pStatus.getValue().toString();
    // available , pending , frozen , locked
    String studyStatus = study.getStatus().getName().toString();
    // available , pending , frozen , locked
    String siteStatus = siteStudy.getStatus().getName().toString();
    System.out.println("randomizationStatusFromOCUI: " + randomizationStatusFromOCUI + "  randomizationStatusFromOC: " + randomizationStatusFromOC + "   studyStatus: " + studyStatus + "   siteStatus: " + siteStatus);
    logger.info("randomizationStatusFromOCUI: " + randomizationStatusFromOCUI + "  randomizationStatusFromOC: " + randomizationStatusFromOC + "   studyStatus: " + studyStatus + "   siteStatus: " + siteStatus);
    if (randomizationStatusFromOC.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && siteStatus.equalsIgnoreCase("available") && randomizationStatusFromOCUI.equalsIgnoreCase("ACTIVE")) {
        accessPermission = true;
    }
    return accessPermission;
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) RandomizationRegistrar(org.akaza.openclinica.service.pmanage.RandomizationRegistrar) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO)

Example 2 with SeRandomizationDTO

use of org.akaza.openclinica.service.pmanage.SeRandomizationDTO in project OpenClinica by OpenClinica.

the class ViewStudyServlet method processRequest.

@Override
public void processRequest() throws Exception {
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    int studyId = fp.getInt("id");
    if (studyId == 0) {
        addPageMessage(respage.getString("please_choose_a_study_to_view"));
        forwardPage(Page.STUDY_LIST_SERVLET);
    } else {
        if (currentStudy.getId() != studyId && currentStudy.getParentStudyId() != studyId) {
            checkRoleByUserAndStudy(ub, studyId, 0);
        }
        String viewFullRecords = fp.getString("viewFull");
        StudyBean study = (StudyBean) sdao.findByPK(studyId);
        StudyConfigService scs = new StudyConfigService(sm.getDataSource());
        study = scs.setParametersForStudy(study);
        StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
        String randomizationStatusInOC = spvdao.findByHandleAndStudy(study.getId(), "randomization").getValue();
        String participantStatusInOC = spvdao.findByHandleAndStudy(study.getId(), "participantPortal").getValue();
        if (participantStatusInOC == "")
            participantStatusInOC = "disabled";
        if (randomizationStatusInOC == "")
            randomizationStatusInOC = "disabled";
        RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
        SeRandomizationDTO seRandomizationDTO = randomizationRegistrar.getCachedRandomizationDTOObject(study.getOid(), false);
        if (seRandomizationDTO != null && seRandomizationDTO.getStatus().equalsIgnoreCase("ACTIVE") && randomizationStatusInOC.equalsIgnoreCase("enabled")) {
            study.getStudyParameterConfig().setRandomization("enabled");
        } else {
            study.getStudyParameterConfig().setRandomization("disabled");
        }
        ;
        ParticipantPortalRegistrar participantPortalRegistrar = new ParticipantPortalRegistrar();
        String pStatus = participantPortalRegistrar.getCachedRegistrationStatus(study.getOid(), session);
        if (participantPortalRegistrar != null && pStatus.equalsIgnoreCase("ACTIVE") && participantStatusInOC.equalsIgnoreCase("enabled")) {
            study.getStudyParameterConfig().setParticipantPortal("enabled");
        } else {
            study.getStudyParameterConfig().setParticipantPortal("disabled");
        }
        ;
        request.setAttribute("studyToView", study);
        if ("yes".equalsIgnoreCase(viewFullRecords)) {
            UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
            StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
            ArrayList sites = new ArrayList();
            ArrayList userRoles = new ArrayList();
            ArrayList subjects = new ArrayList();
            if (this.currentStudy.getParentStudyId() > 0 && this.currentRole.getRole().getId() > 3) {
                sites.add(this.currentStudy);
                userRoles = udao.findAllUsersByStudy(currentStudy.getId());
                subjects = ssdao.findAllByStudy(currentStudy);
            } else {
                sites = (ArrayList) sdao.findAllByParent(studyId);
                userRoles = udao.findAllUsersByStudy(studyId);
                subjects = ssdao.findAllByStudy(study);
            }
            // find all subjects in the study, include ones in sites
            StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
            EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
            // StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
            //                ArrayList displayStudySubs = new ArrayList();
            //                for (int i = 0; i < subjects.size(); i++) {
            //                    StudySubjectBean studySub = (StudySubjectBean) subjects.get(i);
            //                    // find all events
            //                    ArrayList events = sedao.findAllByStudySubject(studySub);
            //
            //                    // find all eventcrfs for each event
            //                    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
            //
            //                    DisplayStudySubjectBean dssb = new DisplayStudySubjectBean();
            //                    dssb.setStudyEvents(events);
            //                    dssb.setStudySubject(studySub);
            //                    displayStudySubs.add(dssb);
            //                }
            // find all events in the study, include ones in sites
            ArrayList definitions = seddao.findAllByStudy(study);
            for (int i = 0; i < definitions.size(); i++) {
                StudyEventDefinitionBean def = (StudyEventDefinitionBean) definitions.get(i);
                ArrayList crfs = (ArrayList) edcdao.findAllActiveParentsByEventDefinitionId(def.getId());
                def.setCrfNum(crfs.size());
            }
            String moduleManager = CoreResources.getField("moduleManager");
            request.setAttribute("moduleManager", moduleManager);
            String portalURL = CoreResources.getField("portalURL");
            request.setAttribute("portalURL", portalURL);
            request.setAttribute("config", study);
            request.setAttribute("sitesToView", sites);
            request.setAttribute("siteNum", sites.size() + "");
            request.setAttribute("userRolesToView", userRoles);
            request.setAttribute("userNum", userRoles.size() + "");
            // request.setAttribute("subjectsToView", displayStudySubs);
            // request.setAttribute("subjectNum", subjects.size() + "");
            request.setAttribute("definitionsToView", definitions);
            request.setAttribute("defNum", definitions.size() + "");
            forwardPage(Page.VIEW_FULL_STUDY);
        } else {
            forwardPage(Page.VIEW_STUDY);
        }
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) RandomizationRegistrar(org.akaza.openclinica.service.pmanage.RandomizationRegistrar) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 3 with SeRandomizationDTO

use of org.akaza.openclinica.service.pmanage.SeRandomizationDTO in project OpenClinica by OpenClinica.

the class RandomizeService method getRandomizationCode.

// Rest Call to OCUI to get Randomization
public String getRandomizationCode(EventCRFBean eventCrfBean, List<StratificationFactorBean> stratificationFactorBeans, RuleSetBean ruleSet) throws JSONException {
    StudySubjectDAO ssdao = new StudySubjectDAO<>(ds);
    StudySubjectBean ssBean = (StudySubjectBean) ssdao.findByPK(eventCrfBean.getStudySubjectId());
    // study subject oid
    String identifier = ssBean.getOid();
    StudyDAO sdao = new StudyDAO<>(ds);
    StudyBean sBean = (StudyBean) sdao.findByPK(ssBean.getStudyId());
    // site or study oid
    String siteIdentifier = sBean.getOid();
    // site or study name
    String name = sBean.getName();
    UserAccountDAO udao = new UserAccountDAO(ds);
    int userId = 0;
    if (eventCrfBean.getUpdaterId() == 0) {
        userId = eventCrfBean.getOwnerId();
    } else {
        userId = eventCrfBean.getUpdaterId();
    }
    UserAccountBean uBean = (UserAccountBean) udao.findByPK(userId);
    String user = uBean.getName();
    // sBean should be parent study
    // put randomization object in cache
    StudyBean study = getParentStudy(sBean.getOid());
    SeRandomizationDTO randomization = null;
    try {
        randomization = getCachedRandomizationDTOObject(study.getOid(), false);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String randomiseUrl = randomization.getUrl();
    String username = randomization.getUsername();
    String password = randomization.getPassword();
    String timezone = "America/New_York";
    // String randomiseUrl = "https://evaluation.sealedenvelope.com/redpill/seti2";
    // String username = "oc";
    // String password = "secret";
    HttpHeaders headers = createHeaders(username, password);
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    // retrieve json object if Randomization exist ,otherwise return a null object
    JSONObject jsonRandObject = retrieveARandomisation(randomiseUrl, ssBean, headers);
    if (jsonRandObject != null) {
        return (String) jsonRandObject.get("code");
    } else {
        // if Site identifier exists ,then update otherwise create new Site identifier
        addOrUpdateASite(randomiseUrl, sBean, headers, timezone);
        // send for Randomization
        JSONObject jsonRandomisedObject = randomiseSubject(randomiseUrl, ssBean, sBean, headers, user, stratificationFactorBeans, eventCrfBean, ruleSet);
        if (jsonRandomisedObject != null)
            return (String) jsonRandomisedObject.get("code");
        else
            return "";
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) JSONObject(org.json.JSONObject) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) JSONException(org.json.JSONException)

Example 4 with SeRandomizationDTO

use of org.akaza.openclinica.service.pmanage.SeRandomizationDTO in project OpenClinica by OpenClinica.

the class StudyModuleController method handleMainPage.

@RequestMapping(method = RequestMethod.GET)
public ModelMap handleMainPage(HttpServletRequest request, HttpServletResponse response) {
    ModelMap map = new ModelMap();
    // Todo need something to reset panel from all the Spring Controllers
    StudyInfoPanel panel = new StudyInfoPanel();
    UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
    if (!mayProceed(request)) {
        try {
            response.sendRedirect(request.getContextPath() + "/MainMenu?message=authentication_failed");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    panel.reset();
    request.getSession().setAttribute("panel", panel);
    // setUpSidebar(request);
    ResourceBundleProvider.updateLocale(LocaleResolver.getLocale(request));
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    eventDefinitionCRFDao = new EventDefinitionCRFDAO(dataSource);
    studyEventDefinitionDao = new StudyEventDefinitionDAO(dataSource);
    crfDao = new CRFDAO(dataSource);
    studyGroupClassDao = new StudyGroupClassDAO(dataSource);
    studyDao = new StudyDAO(dataSource);
    userDao = new UserAccountDAO(dataSource);
    ruleDao = new RuleDAO(dataSource);
    StudyModuleStatus sms = studyModuleStatusDao.findByStudyId(currentStudy.getId());
    if (sms == null) {
        sms = new StudyModuleStatus();
        sms.setStudyId(currentStudy.getId());
    }
    int crfCount = crfDao.findAllByStudy(currentStudy.getId()).size();
    int crfWithEventDefinition = crfDao.findAllActiveByDefinitions(currentStudy.getId()).size();
    int totalCrf = crfCount + crfWithEventDefinition;
    // int eventDefinitionCount = eventDefinitionCRFDao.findAllActiveByStudy(currentStudy).size();
    int eventDefinitionCount = studyEventDefinitionDao.findAllActiveByStudy(currentStudy).size();
    int subjectGroupCount = studyGroupClassDao.findAllActiveByStudy(currentStudy).size();
    // List<RuleSetBean> ruleSets = ruleSetService.getRuleSetsByStudy(currentStudy);
    // ruleSets = ruleSetService.filterByStatusEqualsAvailableOnlyRuleSetRules(ruleSets);
    int ruleCount = ruleSetService.getCountByStudy(currentStudy);
    int siteCount = studyDao.findOlnySiteIdsByStudy(currentStudy).size();
    int userCount = userDao.findAllUsersByStudy(currentStudy.getId()).size();
    Collection childStudies = studyDao.findAllByParent(currentStudy.getId());
    Map childStudyUserCount = new HashMap();
    for (Object sb : childStudies) {
        StudyBean childStudy = (StudyBean) sb;
        childStudyUserCount.put(childStudy.getName(), userDao.findAllUsersByStudy(childStudy.getId()).size());
    }
    if (sms.getCrf() == 0) {
        sms.setCrf(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getCrf() != 3 && totalCrf > 0) {
        sms.setCrf(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getEventDefinition() == 0) {
        sms.setEventDefinition(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getEventDefinition() != 3 && eventDefinitionCount > 0) {
        sms.setEventDefinition(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getSubjectGroup() == 0) {
        sms.setSubjectGroup(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getSubjectGroup() != 3 && subjectGroupCount > 0) {
        sms.setSubjectGroup(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getRule() == 0) {
        sms.setRule(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getRule() != 3 && ruleCount > 0) {
        sms.setRule(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getSite() == 0) {
        sms.setSite(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getSite() != 3 && siteCount > 0) {
        sms.setSite(StudyModuleStatus.IN_PROGRESS);
    }
    if (sms.getUsers() == 0) {
        sms.setUsers(StudyModuleStatus.NOT_STARTED);
    }
    if (sms.getUsers() != 3 && userCount > 0) {
        sms.setUsers(StudyModuleStatus.IN_PROGRESS);
    }
    map.addAttribute(sms);
    map.addAttribute("crfCount", totalCrf);
    map.addAttribute("eventDefinitionCount", eventDefinitionCount);
    map.addAttribute("subjectGroupCount", subjectGroupCount);
    map.addAttribute("ruleCount", ruleCount);
    map.addAttribute("siteCount", siteCount);
    map.addAttribute("userCount", userCount);
    map.addAttribute("childStudyUserCount", childStudyUserCount);
    map.addAttribute("studyId", currentStudy.getId());
    map.addAttribute("currentStudy", currentStudy);
    // Load Participate registration information
    String portalURL = CoreResources.getField("portalURL");
    map.addAttribute("portalURL", portalURL);
    if (portalURL != null && !portalURL.equals("")) {
        String participateOCStatus = currentStudy.getStudyParameterConfig().getParticipantPortal();
        ParticipantPortalRegistrar registrar = new ParticipantPortalRegistrar();
        Authorization pManageAuthorization = registrar.getAuthorization(currentStudy.getOid());
        String participateStatus = "";
        String url = "";
        try {
            URL pManageUrl = new URL(portalURL);
            if (pManageAuthorization != null && pManageAuthorization.getAuthorizationStatus() != null && pManageAuthorization.getAuthorizationStatus().getStatus() != null)
                participateStatus = pManageAuthorization.getAuthorizationStatus().getStatus();
            map.addAttribute("participateURL", pManageUrl);
            map.addAttribute("participateOCStatus", participateOCStatus);
            map.addAttribute("participateStatus", participateStatus);
            if (pManageAuthorization != null && pManageAuthorization.getStudy() != null && pManageAuthorization.getStudy().getHost() != null && !pManageAuthorization.getStudy().getHost().equals("")) {
                url = pManageUrl.getProtocol() + "://" + pManageAuthorization.getStudy().getHost() + "." + pManageUrl.getHost() + ((pManageUrl.getPort() > 0) ? ":" + String.valueOf(pManageUrl.getPort()) : "");
            }
        } catch (MalformedURLException e) {
            logger.error(e.getMessage());
            logger.error(ExceptionUtils.getStackTrace(e));
        }
        map.addAttribute("participateURLDisplay", url);
        map.addAttribute("participateURLFull", url + "/#/login");
    }
    // Load Randomization  information
    String moduleManager = CoreResources.getField("moduleManager");
    map.addAttribute("moduleManager", moduleManager);
    if (moduleManager != null && !moduleManager.equals("")) {
        String randomizationOCStatus = currentStudy.getStudyParameterConfig().getRandomization();
        RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
        SeRandomizationDTO randomization = null;
        try {
            randomization = randomizationRegistrar.getCachedRandomizationDTOObject(currentStudy.getOid(), true);
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        String randomizationStatus = "";
        URL randomizeUrl = null;
        if (randomization != null && randomization.getStatus() != null) {
            randomizationStatus = randomization.getStatus();
            if (randomization.getUrl() != null) {
                try {
                    randomizeUrl = new URL(randomization.getUrl());
                } catch (MalformedURLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
        map.addAttribute("randomizeURL", randomizeUrl);
        map.addAttribute("randomizationOCStatus", randomizationOCStatus);
        map.addAttribute("randomizationStatus", randomizationStatus);
    }
    // @pgawade 13-April-2011- #8877: Added the rule designer URL
    if (null != coreResources) {
        map.addAttribute("ruleDesignerURL", coreResources.getField("designer.url"));
        map.addAttribute("contextPath", getContextPath(request));
        logMe("before checking getHostPath url = " + request.getRequestURL());
        // JN: for the eclinicalhosting the https is not showing up in the request path, going for a fix of taking
        // the hostpath from sysurl
        // map.addAttribute("hostPath", getHostPath(request));
        map.addAttribute("hostPath", getHostPathFromSysUrl(coreResources.getField("sysURL.base"), request.getContextPath()));
        map.addAttribute("path", "pages/studymodule");
    }
    // UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
    request.setAttribute("userBean", userBean);
    ArrayList statusMap = Status.toStudyUpdateMembersList();
    // statusMap.add(Status.PENDING);
    request.setAttribute("statusMap", statusMap);
    if (currentStudy.getParentStudyId() > 0) {
        StudyBean parentStudy = (StudyBean) studyDao.findByPK(currentStudy.getParentStudyId());
        request.setAttribute("parentStudy", parentStudy);
    }
    ArrayList pageMessages = new ArrayList();
    if (request.getSession().getAttribute("pageMessages") != null) {
        pageMessages.addAll((ArrayList) request.getSession().getAttribute("pageMessages"));
        request.setAttribute("pageMessages", pageMessages);
        request.getSession().removeAttribute("pageMessages");
    }
    ArrayList regMessages = new ArrayList();
    if (request.getSession().getAttribute(REG_MESSAGE) != null) {
        regMessages.addAll((ArrayList) request.getSession().getAttribute(REG_MESSAGE));
        request.setAttribute(REG_MESSAGE, regMessages);
        request.getSession().removeAttribute(REG_MESSAGE);
    }
    return map;
}
Also used : MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) ArrayList(java.util.ArrayList) StudyInfoPanel(org.akaza.openclinica.view.StudyInfoPanel) URL(java.net.URL) RuleDAO(org.akaza.openclinica.dao.rule.RuleDAO) Authorization(org.akaza.openclinica.service.pmanage.Authorization) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) StudyModuleStatus(org.akaza.openclinica.domain.managestudy.StudyModuleStatus) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) ModelMap(org.springframework.ui.ModelMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) HttpSessionRequiredException(org.springframework.web.HttpSessionRequiredException) MalformedURLException(java.net.MalformedURLException) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) Collection(java.util.Collection) RandomizationRegistrar(org.akaza.openclinica.service.pmanage.RandomizationRegistrar) ModelMap(org.springframework.ui.ModelMap) Map(java.util.Map) HashMap(java.util.HashMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with SeRandomizationDTO

use of org.akaza.openclinica.service.pmanage.SeRandomizationDTO in project OpenClinica by OpenClinica.

the class SystemController method getRandomizeModule.

public HashMap<String, Object> getRandomizeModule(StudyBean studyBean) {
    StudyParameterValueBean spvBean = getParticipateMod(studyBean, "randomization");
    String ocRandomizeStatus = "";
    if (spvBean.isActive()) {
        // enabled , disabled
        ocRandomizeStatus = spvBean.getValue().toString();
    }
    SeRandomizationDTO seRandomizationDTO = null;
    String ocuiRandomizeStatus = "";
    URL randomizeUrl = null;
    HashMap<String, String> mapMetadata = new HashMap<>();
    if (ocRandomizeStatus.equals("enabled")) {
        try {
            RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
            seRandomizationDTO = randomizationRegistrar.getRandomizationDTOObject(studyBean.getOid());
            if (seRandomizationDTO != null && seRandomizationDTO.getStatus() != null) {
                ocuiRandomizeStatus = seRandomizationDTO.getStatus();
                if (seRandomizationDTO.getUrl() != null) {
                    randomizeUrl = new URL(seRandomizationDTO.getUrl());
                }
                mapMetadata.put("Randomize URL", randomizeUrl == null ? "" : randomizeUrl.toString());
            }
        } catch (MalformedURLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    HashMap<String, Object> mapRandomize = new HashMap<>();
    mapRandomize.put("enabled", ocRandomizeStatus.equals("enabled") ? "True" : "False");
    mapRandomize.put("status", ocuiRandomizeStatus.equals("") ? "INACTIVE" : ocuiRandomizeStatus);
    mapRandomize.put("metadata", mapMetadata);
    HashMap<String, Object> mapModule = new HashMap<>();
    mapModule.put("Randomize", mapRandomize);
    return mapModule;
}
Also used : MalformedURLException(java.net.MalformedURLException) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) HashMap(java.util.HashMap) RandomizationRegistrar(org.akaza.openclinica.service.pmanage.RandomizationRegistrar) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO) URL(java.net.URL) MessagingException(javax.mail.MessagingException) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) MailException(org.springframework.mail.MailException) SQLException(java.sql.SQLException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

SeRandomizationDTO (org.akaza.openclinica.service.pmanage.SeRandomizationDTO)5 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)4 RandomizationRegistrar (org.akaza.openclinica.service.pmanage.RandomizationRegistrar)4 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)3 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)3 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)2 StudyParameterValueBean (org.akaza.openclinica.bean.service.StudyParameterValueBean)2 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)2 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)2 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)2 StudyParameterValueDAO (org.akaza.openclinica.dao.service.StudyParameterValueDAO)2 ParticipantPortalRegistrar (org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar)2 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 Collection (java.util.Collection)1 Map (java.util.Map)1