Search in sources :

Example 1 with StudyGroupBean

use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.

the class CreateSubjectGroupClassServlet method confirmGroup.

/**
 * Validates the first section of study inputs and save it into study bean
 *
 * @param request
 * @param response
 * @throws Exception
 */
private void confirmGroup() throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);
    v.addValidation("name", Validator.NO_BLANKS);
    v.addValidation("subjectAssignment", Validator.NO_BLANKS);
    v.addValidation("name", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 30);
    v.addValidation("subjectAssignment", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 30);
    ArrayList studyGroups = new ArrayList();
    for (int i = 0; i < 10; i++) {
        String name = fp.getString("studyGroup" + i);
        String description = fp.getString("studyGroupDescription" + i);
        if (!StringUtil.isBlank(name)) {
            StudyGroupBean group = new StudyGroupBean();
            group.setName(name);
            group.setDescription(description);
            studyGroups.add(group);
            if (name.length() > 255) {
                request.setAttribute("studyGroupError", respage.getString("group_name_cannot_be_more_255"));
                break;
            }
            if (description.length() > 1000) {
                request.setAttribute("studyGroupError", respage.getString("group_description_cannot_be_more_100"));
                break;
            }
        }
    }
    errors = v.validate();
    if (fp.getInt("groupClassTypeId") == 0) {
        Validator.addError(errors, "groupClassTypeId", resexception.getString("group_class_type_is_required"));
    }
    StudyGroupClassBean group = new StudyGroupClassBean();
    group.setName(fp.getString("name"));
    group.setGroupClassTypeId(fp.getInt("groupClassTypeId"));
    group.setSubjectAssignment(fp.getString("subjectAssignment"));
    session.setAttribute("group", group);
    session.setAttribute("studyGroups", studyGroups);
    if (errors.isEmpty()) {
        logger.info("no errors in the first section");
        group.setGroupClassTypeName(GroupClassType.get(group.getGroupClassTypeId()).getName());
        forwardPage(Page.CREATE_SUBJECT_GROUP_CLASS_CONFIRM);
    } else {
        logger.info("has validation errors in the first section");
        request.setAttribute("formMessages", errors);
        request.setAttribute("groupTypes", GroupClassType.toArrayList());
        forwardPage(Page.CREATE_SUBJECT_GROUP_CLASS);
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) Validator(org.akaza.openclinica.control.form.Validator) StudyGroupBean(org.akaza.openclinica.bean.managestudy.StudyGroupBean)

Example 2 with StudyGroupBean

use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.

the class CreateSubjectGroupClassServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String action = request.getParameter("action");
    if (StringUtil.isBlank(action)) {
        ArrayList studyGroups = new ArrayList();
        for (int i = 0; i < 10; i++) {
            studyGroups.add(new StudyGroupBean());
        }
        StudyGroupClassBean group = new StudyGroupClassBean();
        request.setAttribute("groupTypes", GroupClassType.toArrayList());
        session.setAttribute("group", group);
        session.setAttribute("studyGroups", studyGroups);
        forwardPage(Page.CREATE_SUBJECT_GROUP_CLASS);
    } else {
        if ("confirm".equalsIgnoreCase(action)) {
            confirmGroup();
        } else if ("submit".equalsIgnoreCase(action)) {
            submitGroup();
        }
    }
}
Also used : ArrayList(java.util.ArrayList) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) StudyGroupBean(org.akaza.openclinica.bean.managestudy.StudyGroupBean)

Example 3 with StudyGroupBean

use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.

the class ViewSubjectGroupClassServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String action = request.getParameter("action");
    FormProcessor fp = new FormProcessor(request);
    int classId = fp.getInt("id");
    if (classId == 0) {
        addPageMessage(respage.getString("please_choose_a_subject_group_class_to_view"));
        forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
    } else {
        StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
        StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
        SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
        StudyDAO studyDao = new StudyDAO(sm.getDataSource());
        StudyGroupClassBean sgcb = (StudyGroupClassBean) sgcdao.findByPK(classId);
        StudyBean study = (StudyBean) studyDao.findByPK(sgcb.getStudyId());
        checkRoleByUserAndStudy(ub, sgcb.getStudyId(), study.getParentStudyId());
        // YW 09-19-2007 <<
        sgcb.setGroupClassTypeName(GroupClassType.get(sgcb.getGroupClassTypeId()).getName());
        // YW >>
        ArrayList groups = sgdao.findAllByGroupClass(sgcb);
        ArrayList studyGroups = new ArrayList();
        for (int i = 0; i < groups.size(); i++) {
            StudyGroupBean sg = (StudyGroupBean) groups.get(i);
            ArrayList subjectMaps = sgmdao.findAllByStudyGroupClassAndGroup(sgcb.getId(), sg.getId());
            sg.setSubjectMaps(subjectMaps);
            // YW<<
            studyGroups.add(sg);
        // YW>>
        }
        request.setAttribute("group", sgcb);
        // request.setAttribute("studyGroups", groups);
        request.setAttribute("studyGroups", studyGroups);
        forwardPage(Page.VIEW_SUBJECT_GROUP_CLASS);
    }
}
Also used : SubjectGroupMapDAO(org.akaza.openclinica.dao.submit.SubjectGroupMapDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) ArrayList(java.util.ArrayList) StudyGroupDAO(org.akaza.openclinica.dao.managestudy.StudyGroupDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) StudyGroupBean(org.akaza.openclinica.bean.managestudy.StudyGroupBean)

Example 4 with StudyGroupBean

use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.

the class SubjectIdSDVFactory method getRow.

private SubjectAggregateContainer getRow(StudySubjectBean studySubjectBean) {
    SubjectAggregateContainer row = new SubjectAggregateContainer();
    EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
    StudyDAO studyDAO = new StudyDAO(dataSource);
    StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
    StudyGroupDAO studyGroupDAO = new StudyGroupDAO(dataSource);
    row.setStudySubjectId(studySubjectBean.getLabel());
    row.setPersonId(studySubjectBean.getUniqueIdentifier());
    row.setStudySubjectStatus(studySubjectBean.getStatus().getName());
    int numberEventCRFs = eventCRFDAO.countEventCRFsByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
    row.setTotalEventCRF(numberEventCRFs + "");
    StudyBean studyBean = (StudyBean) studyDAO.findByPK(studySubjectBean.getStudyId());
    row.setSiteId(studyBean.getIdentifier());
    List<EventCRFBean> eventCRFBeans = eventCRFDAO.getEventCRFsByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
    HashMap<String, Integer> stats = getEventCRFStats(eventCRFBeans, studySubjectBean);
    // int numberCRFComplete = getNumberCompletedEventCRFs(eventCRFBeans);
    // row.setNumberCRFComplete(numberCRFComplete + "");
    row.setNumberCRFComplete(stats.get("numberOfCompletedEventCRFs") + "");
    row.setNumberOfCRFsSDV(stats.get("numberOfSDVdEventCRFs") + "");
    // row.setNumberOfCRFsSDV(getNumberSDVdEventCRFs(eventCRFBeans) + "");
    // boolean studySubjectSDVd =
    // eventCRFDAO.countEventCRFsByByStudySubjectCompleteOrLockedAndNotSDVd(studySubjectBean.getId()) == 0 &&
    // numberCRFComplete > 0;
    boolean studySubjectSDVd = stats.get("areEventCRFsSDVd") == -1 || stats.get("areEventCRFsSDVd") == 1 ? false : true;
    StringBuilder sdvStatus = new StringBuilder("");
    if (stats.get("shouldDisplaySDVButton") == 0) {
        sdvStatus.append("");
    } else if (studySubjectSDVd) {
        sdvStatus.append("<center><a href='javascript:void(0)' onclick='prompt(document.sdvForm,");
        sdvStatus.append(studySubjectBean.getId());
        sdvStatus.append(")'>");
        sdvStatus.append(getIconForCrfStatusPrefix()).append("DoubleCheck").append(ICON_FORCRFSTATUS_SUFFIX).append("</a></center>");
    } else {
        sdvStatus.append("<center><input style='margin-right: 5px' type='checkbox' ").append("class='sdvCheck'").append(" name='").append("sdvCheck_").append(studySubjectBean.getId()).append("' /></center>");
    }
    row.setSdvStatus(sdvStatus.toString());
    List<StudyGroupBean> studyGroupBeans = studyGroupDAO.getGroupByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
    if (studyGroupBeans != null && !studyGroupBeans.isEmpty()) {
        row.setGroup(studyGroupBeans.get(0).getName());
    }
    StringBuilder actions = new StringBuilder("<table><tr><td>");
    StringBuilder urlPrefix = new StringBuilder("<a href=\"");
    StringBuilder path = new StringBuilder(contextPath).append("/pages/viewAllSubjectSDVtmp?studyId=").append(studyId).append("&sdv_f_studySubjectId=");
    path.append(studySubjectBean.getLabel());
    urlPrefix.append(path).append("\">");
    actions.append(urlPrefix).append(SDVUtil.VIEW_ICON_HTML).append("</a></td>");
    if (!studySubjectSDVd && stats.get("shouldDisplaySDVButton") == 1) {
        StringBuilder jsCodeString = new StringBuilder("this.form.method='GET'; this.form.action='").append(contextPath).append("/pages/sdvStudySubject").append("';").append("this.form.theStudySubjectId.value='").append(studySubjectBean.getId()).append("';").append("this.form.submit();");
        if (!studyBean.getStatus().isLocked()) {
            actions.append("<td><input type=\"submit\" class=\"button\" value=\"SDV\" name=\"sdvSubmit\" ").append("onclick=\"").append(jsCodeString.toString()).append("\" /></td>");
        }
    } else if (!studySubjectSDVd) {
        actions.append("<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SDV N/A</td>");
    }
    actions.append("</tr></table>");
    row.setActions(actions.toString());
    return row;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyGroupDAO(org.akaza.openclinica.dao.managestudy.StudyGroupDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) StudyGroupBean(org.akaza.openclinica.bean.managestudy.StudyGroupBean) SubjectAggregateContainer(org.akaza.openclinica.controller.helper.table.SubjectAggregateContainer) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 5 with StudyGroupBean

use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.

the class StudyGroupDAO method create.

/**
 * Creates a new StudyGroup
 */
public EntityBean create(EntityBean eb) {
    StudyGroupBean sb = (StudyGroupBean) eb;
    HashMap variables = new HashMap();
    variables.put(new Integer(1), sb.getName());
    variables.put(new Integer(2), sb.getDescription());
    variables.put(new Integer(3), new Integer(sb.getStudyGroupClassId()));
    this.execute(digester.getQuery("create"), variables);
    return sb;
}
Also used : HashMap(java.util.HashMap) StudyGroupBean(org.akaza.openclinica.bean.managestudy.StudyGroupBean)

Aggregations

StudyGroupBean (org.akaza.openclinica.bean.managestudy.StudyGroupBean)26 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)12 Iterator (java.util.Iterator)10 StudyGroupClassBean (org.akaza.openclinica.bean.managestudy.StudyGroupClassBean)10 StudyGroupDAO (org.akaza.openclinica.dao.managestudy.StudyGroupDAO)9 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)6 StudyGroupClassDAO (org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO)6 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)5 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)5 SubjectGroupMapDAO (org.akaza.openclinica.dao.submit.SubjectGroupMapDAO)5 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)4 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)4 SubjectGroupMapBean (org.akaza.openclinica.bean.submit.SubjectGroupMapBean)4 Date (java.util.Date)3 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)3 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)3 DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)2 StudyUserRoleBean (org.akaza.openclinica.bean.login.StudyUserRoleBean)2 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)2