Search in sources :

Example 36 with StudyGroupClassBean

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

the class CreateSubjectGroupClassServlet method submitGroup.

/**
     * Saves study group information into database
     *
     * @throws OpenClinicaException
     */
private void submitGroup() throws OpenClinicaException, IOException {
    StudyGroupClassBean group = (StudyGroupClassBean) session.getAttribute("group");
    ArrayList studyGroups = (ArrayList) session.getAttribute("studyGroups");
    StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
    group.setStudyId(currentStudy.getId());
    group.setOwner(ub);
    group.setStatus(Status.AVAILABLE);
    group = (StudyGroupClassBean) sgcdao.create(group);
    if (!group.isActive()) {
        addPageMessage(respage.getString("the_subject_group_class_not_created_database"));
    } else {
        StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
        for (int i = 0; i < studyGroups.size(); i++) {
            StudyGroupBean sg = (StudyGroupBean) studyGroups.get(i);
            sg.setStudyGroupClassId(group.getId());
            sg.setOwner(ub);
            sg.setStatus(Status.AVAILABLE);
            sgdao.create(sg);
        }
        addPageMessage(respage.getString("the_subject_group_class_created_succesfully"));
    }
    ArrayList pageMessages = (ArrayList) request.getAttribute(PAGE_MESSAGE);
    session.setAttribute("pageMessages", pageMessages);
    response.sendRedirect(request.getContextPath() + Page.MANAGE_STUDY_MODULE.getFileName());
}
Also used : StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) ArrayList(java.util.ArrayList) StudyGroupDAO(org.akaza.openclinica.dao.managestudy.StudyGroupDAO) StudyGroupBean(org.akaza.openclinica.bean.managestudy.StudyGroupBean)

Example 37 with StudyGroupClassBean

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

the class ListEventsForSubjectTableFactory method getColumnNamesMap.

private void getColumnNamesMap() {
    ArrayList<String> columnNamesList = new ArrayList<String>();
    columnNamesList.add("studySubject.label");
    columnNamesList.add("studySubject.status");
    columnNamesList.add("enrolledAt");
    columnNamesList.add("subject.charGender");
    for (StudyGroupClassBean studyGroupClass : getStudyGroupClasses()) {
        columnNamesList.add("sgc_" + studyGroupClass.getId());
    }
    columnNamesList.add("event.status");
    columnNamesList.add("studySubject.createdDate");
    for (CRFBean crfBean : getCrfs(selectedStudyEventDefinition)) {
        columnNamesList.add("crf_" + crfBean.getId());
    }
    columnNamesList.add("actions");
    columnNames = columnNamesList.toArray(columnNames);
}
Also used : ArrayList(java.util.ArrayList) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 38 with StudyGroupClassBean

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

the class ListEventsForSubjectTableFactory method setDataAndLimitVariables.

@SuppressWarnings("unchecked")
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
    Limit limit = tableFacade.getLimit();
    ListEventsForSubjectFilter eventsForSubjectFilter = getListEventsForSubjectFilter(limit);
    if (!limit.isComplete()) {
        int totalRows = getStudySubjectDAO().getCountWithFilter(eventsForSubjectFilter, getStudyBean());
        tableFacade.setTotalRows(totalRows);
    }
    ListEventsForSubjectSort eventsForSubjectSort = getListEventsForSubjectSort(limit);
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = limit.getRowSelect().getRowEnd();
    Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(), eventsForSubjectFilter, eventsForSubjectSort, rowStart, rowEnd);
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
    for (StudySubjectBean studySubjectBean : items) {
        HashMap<Object, Object> theItem = new HashMap<Object, Object>();
        theItem.put("studySubject", studySubjectBean);
        theItem.put("studySubject.label", studySubjectBean.getLabel());
        theItem.put("studySubject.status", studySubjectBean.getStatus());
        theItem.put("enrolledAt", ((StudyBean) getStudyDAO().findByPK(studySubjectBean.getStudyId())).getIdentifier());
        SubjectBean subjectBean = (SubjectBean) getSubjectDAO().findByPK(studySubjectBean.getSubjectId());
        theItem.put("subject", subjectBean);
        theItem.put("subject.charGender", subjectBean.getGender());
        // study group classes
        SubjectGroupMapBean subjectGroupMapBean = new SubjectGroupMapBean();
        for (StudyGroupClassBean studyGroupClass : getStudyGroupClasses()) {
            subjectGroupMapBean = getSubjectGroupMapDAO().findAllByStudySubjectAndStudyGroupClass(studySubjectBean.getId(), studyGroupClass.getId());
            if (null != subjectGroupMapBean) {
                theItem.put("sgc_" + studyGroupClass.getId(), subjectGroupMapBean.getStudyGroupId());
                theItem.put("grpName_sgc_" + studyGroupClass.getId(), subjectGroupMapBean.getStudyGroupName());
            }
        }
        subjectGroupMapBean = null;
        // Get EventCrfs for study Subject
        List<EventCRFBean> eventCrfs = getEventCRFDAO().findAllByStudySubject(studySubjectBean.getId());
        HashMap<String, EventCRFBean> crfAsKeyEventCrfAsValue = new HashMap<String, EventCRFBean>();
        for (EventCRFBean eventCRFBean : eventCrfs) {
            CRFBean crf = getCrfDAO().findByVersionId(eventCRFBean.getCRFVersionId());
            crfAsKeyEventCrfAsValue.put(crf.getId() + "_" + eventCRFBean.getStudyEventId(), eventCRFBean);
        }
        // Get the event Status
        List<StudyEventBean> eventsForStudySubjectAndEventDefinitions = getStudyEventDAO().findAllByDefinitionAndSubject(selectedStudyEventDefinition, studySubjectBean);
        List<DisplayBean> events = new ArrayList<DisplayBean>();
        // study event size < 1
        if (eventsForStudySubjectAndEventDefinitions.size() < 1) {
            DisplayBean d = new DisplayBean();
            d.getProps().put("event", null);
            d.getProps().put("event.status", SubjectEventStatus.NOT_SCHEDULED);
            d.getProps().put("studySubject.createdDate", null);
            for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
                CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
                d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
                d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
                d.getProps().put("crf_" + crf.getId() + "_crf", crf);
                // d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
                d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", getEventDefinitionCRFBean(selectedStudyEventDefinition.getId(), crf, studySubjectBean));
                theItem.put("crf_" + crf.getId(), "");
            }
            events.add(d);
        }
        // study event size >0
        for (StudyEventBean studyEventBean : eventsForStudySubjectAndEventDefinitions) {
            DisplayBean d = new DisplayBean();
            d.getProps().put("event", studyEventBean);
            d.getProps().put("event.status", studyEventBean.getSubjectEventStatus());
            d.getProps().put("studySubject.createdDate", studyEventBean.getDateStarted());
            for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
                CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
                EventCRFBean eventCRFBean = crfAsKeyEventCrfAsValue.get(crf.getId() + "_" + studyEventBean.getId());
                if (eventCRFBean != null) {
                    d.getProps().put("crf_" + crf.getId(), eventCRFBean.getStage());
                    d.getProps().put("crf_" + crf.getId() + "_eventCrf", eventCRFBean);
                } else {
                    d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
                    d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
                }
                d.getProps().put("crf_" + crf.getId() + "_crf", crf);
                // d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
                d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", getEventDefinitionCRFBean(selectedStudyEventDefinition.getId(), crf, studySubjectBean));
                theItem.put("crf_" + crf.getId(), "");
            }
            events.add(d);
        }
        theItem.put("events", events);
        theItem.put("event.status", "");
        theItem.put("studySubject.createdDate", "");
        theItem.put("webappContext", tableFacade.getWebContext().getContextPath());
        theItems.add(theItem);
    }
    // Do not forget to set the items back on the tableFacade.
    tableFacade.setItems(theItems);
}
Also used : SubjectGroupMapBean(org.akaza.openclinica.bean.submit.SubjectGroupMapBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ListEventsForSubjectSort(org.akaza.openclinica.dao.managestudy.ListEventsForSubjectSort) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) ListEventsForSubjectFilter(org.akaza.openclinica.dao.managestudy.ListEventsForSubjectFilter) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) Limit(org.jmesa.limit.Limit)

Example 39 with StudyGroupClassBean

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

the class CoreSecureController method getStudyGroupClassesByCurrentStudy.

public ArrayList getStudyGroupClassesByCurrentStudy(HttpServletRequest request) {
    StudyDAO studyDAO = new StudyDAO(getDataSource());
    StudyGroupClassDAO studyGroupClassDAO = new StudyGroupClassDAO(getDataSource());
    StudyGroupDAO studyGroupDAO = new StudyGroupDAO(getDataSource());
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    int parentStudyId = currentStudy.getParentStudyId();
    ArrayList studyGroupClasses = new ArrayList();
    if (parentStudyId > 0) {
        StudyBean parentStudy = (StudyBean) studyDAO.findByPK(parentStudyId);
        studyGroupClasses = studyGroupClassDAO.findAllActiveByStudy(parentStudy);
    } else {
        parentStudyId = currentStudy.getId();
        studyGroupClasses = studyGroupClassDAO.findAllActiveByStudy(currentStudy);
    }
    for (int i = 0; i < studyGroupClasses.size(); i++) {
        StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(i);
        ArrayList groups = studyGroupDAO.findAllByGroupClass(sgc);
        sgc.setStudyGroups(groups);
    }
    return studyGroupClasses;
}
Also used : StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) StudyGroupDAO(org.akaza.openclinica.dao.managestudy.StudyGroupDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 40 with StudyGroupClassBean

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

the class EditSelectedServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    boolean selectAll = fp.getBoolean("all");
    boolean selectAllItemsGroupsAttrs = fp.getBoolean("allAttrsAndItems");
    // BWP 3095: Only show a "select all items" like on a side info panel if
    // it
    // is not part of the EditSelected-related JSP>>
    request.setAttribute("EditSelectedSubmitted", true);
    // <<
    ItemDAO idao = new ItemDAO(sm.getDataSource());
    // CRFDAO crfdao = new CRFDAO(sm.getDataSource());
    ItemFormMetadataDAO imfdao = new ItemFormMetadataDAO(sm.getDataSource());
    CRFDAO crfdao = new CRFDAO(sm.getDataSource());
    DatasetBean db = (DatasetBean) session.getAttribute("newDataset");
    if (db == null) {
        db = new DatasetBean();
        session.setAttribute("newDataset", db);
    }
    // << tbh
    // HashMap eventlist = (HashMap) request.getAttribute("eventlist");
    // if (eventlist == null) {
    // System.out.println("TTTTT found the second hashmap!");
    HashMap eventlist = (LinkedHashMap) session.getAttribute("eventsForCreateDataset");
    // }
    ArrayList<String> ids = CreateDatasetServlet.allSedItemIdsInStudy(eventlist, crfdao, idao);
    // >> tbh 11/09, need to fill in a session variable
    if (selectAll) {
        logger.info("select all..........");
        db = selectAll(db);
        MessageFormat msg = new MessageFormat("");
        msg.setLocale(locale);
        msg.applyPattern(respage.getString("choose_include_all_items_dataset"));
        Object[] arguments = { ids.size() };
        addPageMessage(msg.format(arguments));
    // addPageMessage("You choose to include all items in current study
    // for the dataset, " +db.getItemIds().size() + " items total.");
    }
    if (selectAllItemsGroupsAttrs) {
        logger.info("select everything....");
        db = selectAll(db);
        db.setShowCRFcompletionDate(true);
        db.setShowCRFinterviewerDate(true);
        db.setShowCRFinterviewerName(true);
        db.setShowCRFstatus(true);
        db.setShowCRFversion(true);
        db.setShowEventEnd(true);
        db.setShowEventEndTime(true);
        db.setShowEventLocation(true);
        db.setShowEventStart(true);
        db.setShowEventStartTime(true);
        db.setShowEventStatus(true);
        db.setShowSubjectAgeAtEvent(true);
        db.setShowSubjectDob(true);
        db.setShowSubjectGender(true);
        db.setShowSubjectGroupInformation(true);
        db.setShowSubjectStatus(true);
        db.setShowSubjectUniqueIdentifier(true);
        // select all groups
        ArrayList sgclasses = (ArrayList) session.getAttribute("allSelectedGroups");
        //
        ArrayList newsgclasses = new ArrayList();
        StudyDAO studydao = new StudyDAO(sm.getDataSource());
        StudyGroupClassDAO sgclassdao = new StudyGroupClassDAO(sm.getDataSource());
        StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
        sgclasses = sgclassdao.findAllActiveByStudy(theStudy);
        for (int i = 0; i < sgclasses.size(); i++) {
            StudyGroupClassBean sgclass = (StudyGroupClassBean) sgclasses.get(i);
            sgclass.setSelected(true);
            newsgclasses.add(sgclass);
        }
        session.setAttribute("allSelectedGroups", newsgclasses);
        request.setAttribute("allSelectedGroups", newsgclasses);
    }
    session.setAttribute("newDataset", db);
    HashMap events = (HashMap) session.getAttribute(CreateDatasetServlet.EVENTS_FOR_CREATE_DATASET);
    if (events == null) {
        events = new HashMap();
    }
    ArrayList allSelectItems = selectAll ? selectAll(events, crfdao, idao) : ViewSelectedServlet.getAllSelected(db, idao, imfdao);
    // >> tbh
    session.setAttribute("numberOfStudyItems", new Integer(ids.size()).toString());
    // << tbh 11/2009
    session.setAttribute("allSelectedItems", allSelectItems);
    setUpStudyGroups();
    forwardPage(Page.CREATE_DATASET_VIEW_SELECTED);
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) MessageFormat(java.text.MessageFormat) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO)

Aggregations

StudyGroupClassBean (org.akaza.openclinica.bean.managestudy.StudyGroupClassBean)44 ArrayList (java.util.ArrayList)35 StudyGroupClassDAO (org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO)21 HashMap (java.util.HashMap)17 StudyGroupDAO (org.akaza.openclinica.dao.managestudy.StudyGroupDAO)16 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)15 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)14 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)14 StudyGroupBean (org.akaza.openclinica.bean.managestudy.StudyGroupBean)10 SubjectGroupMapBean (org.akaza.openclinica.bean.submit.SubjectGroupMapBean)10 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)9 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)9 SubjectGroupMapDAO (org.akaza.openclinica.dao.submit.SubjectGroupMapDAO)9 Iterator (java.util.Iterator)8 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)7 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)6 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)6 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)6 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)5 DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)5