Search in sources :

Example 31 with StudyParameterValueBean

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

the class SystemController method getParticipateModule.

public HashMap<String, Object> getParticipateModule(StudyBean studyBean) {
    String portalURL = CoreResources.getField("portalURL");
    StudyParameterValueBean spvBean = getParticipateMod(studyBean, "participantPortal");
    String ocParticipateStatus = "";
    if (spvBean.isActive()) {
        // enabled , disabled
        ocParticipateStatus = spvBean.getValue().toString();
    }
    String ocuiParticipateStatus = "";
    ParticipantPortalRegistrar participantPortalRegistrar = new ParticipantPortalRegistrar();
    if (ocParticipateStatus.equals("enabled")) {
        try {
            ocuiParticipateStatus = participantPortalRegistrar.getRegistrationStatus(studyBean.getOid());
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    HashMap<String, String> mapMetadata = new HashMap<>();
    String url = "";
    URL pManageUrl = null;
    try {
        pManageUrl = new URL(portalURL);
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    Authorization pManageAuthorization = participantPortalRegistrar.getAuthorization(studyBean.getOid());
    if (pManageAuthorization != null) {
        url = pManageUrl.getProtocol() + "://" + pManageAuthorization.getStudy().getHost() + "." + pManageUrl.getHost() + ((pManageUrl.getPort() > 0) ? ":" + String.valueOf(pManageUrl.getPort()) : "");
        mapMetadata.put("Participate Url", url);
    }
    HashMap<String, Object> mapParticipate = new HashMap<>();
    mapParticipate.put("enabled", ocParticipateStatus.equals("enabled") ? "True" : "False");
    mapParticipate.put("status", ocuiParticipateStatus.equals("") ? "INACTIVE" : ocuiParticipateStatus);
    mapParticipate.put("metadata", mapMetadata);
    HashMap<String, Object> mapModule = new HashMap<>();
    mapModule.put("Participate", mapParticipate);
    return mapModule;
}
Also used : Authorization(org.akaza.openclinica.service.pmanage.Authorization) MalformedURLException(java.net.MalformedURLException) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) HashMap(java.util.HashMap) 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) URL(java.net.URL)

Example 32 with StudyParameterValueBean

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

Example 33 with StudyParameterValueBean

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

the class ChangeStudyServlet method changeStudy.

private void changeStudy() throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);
    int studyId = fp.getInt("studyId");
    int prevStudyId = currentStudy.getId();
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    StudyBean current = (StudyBean) sdao.findByPK(studyId);
    // reset study parameters -jxu 02/09/2007
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    ArrayList studyParameters = spvdao.findParamConfigByStudy(current);
    current.setStudyParameters(studyParameters);
    int parentStudyId = currentStudy.getParentStudyId() > 0 ? currentStudy.getParentStudyId() : currentStudy.getId();
    StudyParameterValueBean parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectIdGeneration");
    current.getStudyParameterConfig().setSubjectIdGeneration(parentSPV.getValue());
    String idSetting = current.getStudyParameterConfig().getSubjectIdGeneration();
    if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
        int nextLabel = this.getStudySubjectDAO().findTheGreatestLabel() + 1;
        request.setAttribute("label", new Integer(nextLabel).toString());
    }
    StudyConfigService scs = new StudyConfigService(sm.getDataSource());
    if (current.getParentStudyId() <= 0) {
        // top study
        scs.setParametersForStudy(current);
    } else {
        // YW <<
        if (current.getParentStudyId() > 0) {
            current.setParentStudyName(((StudyBean) sdao.findByPK(current.getParentStudyId())).getName());
        }
        // YW 06-12-2007>>
        scs.setParametersForSite(current);
    }
    if (current.getStatus().equals(Status.DELETED) || current.getStatus().equals(Status.AUTO_DELETED)) {
        session.removeAttribute("studyWithRole");
        addPageMessage(restext.getString("study_choosed_removed_restore_first"));
    } else {
        session.setAttribute("study", current);
        currentStudy = current;
        // change user's active study id
        UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
        ub.setActiveStudyId(current.getId());
        ub.setUpdater(ub);
        ub.setUpdatedDate(new java.util.Date());
        udao.update(ub);
        if (current.getParentStudyId() > 0) {
            /*
                 * The Role decription will be set depending on whether the user
                 * logged in at study lever or site level. issue-2422
                 */
            List roles = Role.toArrayList();
            for (Iterator it = roles.iterator(); it.hasNext(); ) {
                Role role = (Role) it.next();
                switch(role.getId()) {
                    case 2:
                        role.setDescription("site_Study_Coordinator");
                        break;
                    case 3:
                        role.setDescription("site_Study_Director");
                        break;
                    case 4:
                        role.setDescription("site_investigator");
                        break;
                    case 5:
                        role.setDescription("site_Data_Entry_Person");
                        break;
                    case 6:
                        role.setDescription("site_monitor");
                        break;
                    case 7:
                        role.setDescription("site_Data_Entry_Person2");
                        break;
                    default:
                }
            }
        } else {
            /*
                 * If the current study is a site, we will change the role
                 * description. issue-2422
                 */
            List roles = Role.toArrayList();
            for (Iterator it = roles.iterator(); it.hasNext(); ) {
                Role role = (Role) it.next();
                switch(role.getId()) {
                    case 2:
                        role.setDescription("Study_Coordinator");
                        break;
                    case 3:
                        role.setDescription("Study_Director");
                        break;
                    case 4:
                        role.setDescription("investigator");
                        break;
                    case 5:
                        role.setDescription("Data_Entry_Person");
                        break;
                    case 6:
                        role.setDescription("monitor");
                        break;
                    default:
                }
            }
        }
        currentRole = (StudyUserRoleBean) session.getAttribute("studyWithRole");
        session.setAttribute("userRole", currentRole);
        session.removeAttribute("studyWithRole");
        addPageMessage(restext.getString("current_study_changed_succesfully"));
    }
    ub.incNumVisitsToMainMenu();
    // YW 2-18-2008, if study has been really changed <<
    if (prevStudyId != studyId) {
        session.removeAttribute("eventsForCreateDataset");
        session.setAttribute("tableFacadeRestore", "false");
    }
    request.setAttribute("studyJustChanged", "yes");
    // YW >>
    //Integer assignedDiscrepancies = getDiscrepancyNoteDAO().countAllItemDataByStudyAndUser(currentStudy, ub);
    Integer assignedDiscrepancies = getDiscrepancyNoteDAO().getViewNotesCountWithFilter(" AND dn.assigned_user_id =" + ub.getId() + " AND (dn.resolution_status_id=1 OR dn.resolution_status_id=2 OR dn.resolution_status_id=3)", currentStudy);
    request.setAttribute("assignedDiscrepancies", assignedDiscrepancies == null ? 0 : assignedDiscrepancies);
    if (currentRole.isInvestigator() || currentRole.isResearchAssistant() || currentRole.isResearchAssistant2()) {
        setupListStudySubjectTable();
    }
    if (currentRole.isMonitor()) {
        setupSubjectSDVTable();
    } else if (currentRole.isCoordinator() || currentRole.isDirector()) {
        if (currentStudy.getStatus().isPending()) {
            response.sendRedirect(request.getContextPath() + Page.MANAGE_STUDY_MODULE.getFileName());
            return;
        }
        setupStudySiteStatisticsTable();
        setupSubjectEventStatusStatisticsTable();
        setupStudySubjectStatusStatisticsTable();
        if (currentStudy.getParentStudyId() == 0) {
            setupStudyStatisticsTable();
        }
    }
    forwardPage(Page.MENU);
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Role(org.akaza.openclinica.bean.core.Role) StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Validator(org.akaza.openclinica.control.form.Validator)

Example 34 with StudyParameterValueBean

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

the class OdmStudySubjectController method mayProceed.

private boolean mayProceed(String studyOid, StudySubjectBean ssBean) throws Exception {
    boolean accessPermission = false;
    StudyBean study = getParentStudy(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
    participantPortalRegistrar = new ParticipantPortalRegistrar();
    // ACTIVE ,
    String pManageStatus = participantPortalRegistrar.getRegistrationStatus(studyOid).toString();
    // PENDING ,
    // INACTIVE
    // enabled , disabled
    String participateStatus = pStatus.getValue().toString();
    // available , pending , frozen , locked
    String studyStatus = study.getStatus().getName().toString();
    logger.info("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus + "  studySubjectStatus: " + ssBean.getStatus().getName());
    System.out.println("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus + "  studySubjectStatus: " + ssBean.getStatus().getName());
    if (participateStatus.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && pManageStatus.equalsIgnoreCase("ACTIVE") && ssBean.getStatus() == Status.AVAILABLE) {
        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 35 with StudyParameterValueBean

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

the class OdmController method mayProceed.

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

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