Search in sources :

Example 6 with SectionDAO

use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.

the class ViewEventCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    int eventCRFId = fp.getInt("id", true);
    int studySubId = fp.getInt("studySubId", true);
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
    ItemDAO idao = new ItemDAO(sm.getDataSource());
    ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    SectionDAO secdao = new SectionDAO(sm.getDataSource());
    if (eventCRFId == 0) {
        addPageMessage(respage.getString("please_choose_an_event_CRF_to_view"));
        forwardPage(Page.LIST_STUDY_SUBJECTS);
    } else {
        StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
        request.setAttribute("studySub", studySub);
        EventCRFBean eventCRF = (EventCRFBean) ecdao.findByPK(eventCRFId);
        CRFBean crf = cdao.findByVersionId(eventCRF.getCRFVersionId());
        request.setAttribute("crf", crf);
        ArrayList sections = secdao.findAllByCRFVersionId(eventCRF.getCRFVersionId());
        for (int j = 0; j < sections.size(); j++) {
            SectionBean section = (SectionBean) sections.get(j);
            ArrayList itemData = iddao.findAllByEventCRFId(eventCRFId);
            ArrayList displayItemData = new ArrayList();
            for (int i = 0; i < itemData.size(); i++) {
                ItemDataBean id = (ItemDataBean) itemData.get(i);
                DisplayItemBean dib = new DisplayItemBean();
                ItemBean item = (ItemBean) idao.findByPK(id.getItemId());
                ItemFormMetadataBean ifm = ifmdao.findByItemIdAndCRFVersionId(item.getId(), eventCRF.getCRFVersionId());
                item.setItemMeta(ifm);
                dib.setItem(item);
                dib.setData(id);
                dib.setMetadata(ifm);
                displayItemData.add(dib);
            }
            section.setItems(displayItemData);
        }
        request.setAttribute("sections", sections);
        request.setAttribute("studySubId", new Integer(studySubId).toString());
        forwardPage(Page.VIEW_EVENT_CRF);
    }
}
Also used : EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 7 with SectionDAO

use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.

the class DataEntryServlet method isCreateItemReqd.

protected boolean isCreateItemReqd(SectionBean sb, HttpServletRequest request) {
    SectionDAO sdao = new SectionDAO(getDataSource());
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
    DataEntryStage stage = ecb.getStage();
    HashMap numItemsHM = sdao.getNumItemsBySectionId();
    HashMap numItemsPendingHM = sdao.getNumItemsPendingBySectionId(ecb);
    HashMap numItemsCompletedHM = sdao.getNumItemsCompletedBySection(ecb);
    HashMap numItemsBlankHM = sdao.getNumItemsBlankBySectionId(ecb);
    Integer key = new Integer(sb.getId());
    int numItems = TableOfContentsServlet.getIntById(numItemsHM, key);
    int numItemsPending = TableOfContentsServlet.getIntById(numItemsPendingHM, key);
    int numItemsCompleted = TableOfContentsServlet.getIntById(numItemsCompletedHM, key);
    int numItemsBlank = TableOfContentsServlet.getIntById(numItemsBlankHM, key);
    LOGGER.debug(" for " + key + " num items " + numItems + " num items blank " + numItemsBlank + " num items pending " + numItemsPending + " completed " + numItemsCompleted);
    if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY) && edcb.isDoubleEntry()) {
        if (numItemsPending == 0 && numItems > 0) {
            // System.out.println("returns false on ide loop " + key);
            return false;
        }
    } else {
        if (numItemsCompleted < numItems) {
            return false;
        }
    }
    return true;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) HashMap(java.util.HashMap) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO) DataEntryStage(org.akaza.openclinica.bean.core.DataEntryStage)

Example 8 with SectionDAO

use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.

the class DataEntryServlet method isSectionReviewedOnce.

/**
     * Checks if a section is reviewed at least once by user
     * updated tbh 03/2011, to fix duplicates issues
     * @param sb
     * @param request TODO
     * @return
     */
protected boolean isSectionReviewedOnce(SectionBean sb, HttpServletRequest request) {
    SectionDAO sdao = new SectionDAO(getDataSource());
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
    DataEntryStage stage = ecb.getStage();
    HashMap numItemsHM = sdao.getNumItemsBySectionId();
    HashMap numItemsPendingHM = sdao.getNumItemsPendingBySectionId(ecb);
    HashMap numItemsCompletedHM = sdao.getNumItemsCompletedBySectionId(ecb);
    HashMap numItemsBlankHM = sdao.getNumItemsBlankBySectionId(ecb);
    Integer key = new Integer(sb.getId());
    int numItems = TableOfContentsServlet.getIntById(numItemsHM, key);
    int numItemsPending = TableOfContentsServlet.getIntById(numItemsPendingHM, key);
    int numItemsCompleted = TableOfContentsServlet.getIntById(numItemsCompletedHM, key);
    int numItemsBlank = TableOfContentsServlet.getIntById(numItemsBlankHM, key);
    LOGGER.debug(" for " + key + " num items " + numItems + " num items blank " + numItemsBlank + " num items pending " + numItemsPending + " completed " + numItemsCompleted);
    if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY) && edcb.isDoubleEntry()) {
        if (numItemsPending == 0 && numItems > 0) {
            LOGGER.debug("returns false on ide loop " + key);
            return false;
        }
    } else {
        if (numItemsCompleted == 0 && numItems > 0) {
            LOGGER.debug("returns false on other loop " + key);
            return false;
        }
    }
    return true;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) HashMap(java.util.HashMap) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO) DataEntryStage(org.akaza.openclinica.bean.core.DataEntryStage)

Example 9 with SectionDAO

use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.

the class DataEntryServlet method checkGroups.

/**
     * Tries to check if a seciton has item groups
     * @param fp TODO
     * @param ecb TODO
     *
     * @return
     */
protected boolean checkGroups(FormProcessor fp, EventCRFBean ecb) {
    int sectionId = fp.getInt(INPUT_SECTION_ID, true);
    SectionDAO sdao = new SectionDAO(getDataSource());
    if (sectionId <= 0) {
        ArrayList sections = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
        for (int i = 0; i < sections.size(); i++) {
            SectionBean sb = (SectionBean) sections.get(i);
            // find the first section of this CRF
            sectionId = sb.getId();
            break;
        }
    }
    // we will look into db to see if any repeating items for this CRF
    // section
    ItemGroupDAO igdao = new ItemGroupDAO(getDataSource());
    // find any item group which doesn't equal to 'Ungrouped'
    ItemGroupBean itemGroup = igdao.findTopOneGroupBySectionId(sectionId);
    if (itemGroup != null && itemGroup.getId() > 0) {
        LOGGER.trace("This section has group");
        return true;
    }
    return false;
}
Also used : SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) ArrayList(java.util.ArrayList) ItemGroupDAO(org.akaza.openclinica.dao.submit.ItemGroupDAO) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 10 with SectionDAO

use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.

the class DataEntryServlet method saveItemsToMarkComplete.

/**
     * 06/13/2007- jxu Since we don't require users to review each section before mark a CRF as complete, we need to create item data in the database because
     * items will not be created unless the section which contains the items is reviewed by users
     * @param request TODO
     */
private boolean saveItemsToMarkComplete(Status completeStatus, HttpServletRequest request) throws Exception {
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    SectionDAO sdao = new SectionDAO(getDataSource());
    ArrayList sections = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
    UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
    ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
    ItemDAO idao = new ItemDAO(getDataSource());
    for (int i = 0; i < sections.size(); i++) {
        SectionBean sb = (SectionBean) sections.get(i);
        if (!isCreateItemReqd(sb, request)) {
            // ArrayList requiredItems =
            // idao.findAllRequiredBySectionId(sb.getId());
            // if (!requiredItems.isEmpty()) {
            // return false;
            // }
            ArrayList items = idao.findAllBySectionId(sb.getId());
            for (int j = 0; j < items.size(); j++) {
                ItemBean item = (ItemBean) items.get(j);
                ArrayList<ItemDataBean> itemBean = iddao.findAllByEventCRFIdAndItemIdNoStatus(ecb.getId(), item.getId());
                ItemDataBean idb = new ItemDataBean();
                idb.setItemId(item.getId());
                idb.setEventCRFId(ecb.getId());
                idb.setCreatedDate(new Date());
                idb.setOrdinal(1);
                idb.setOwner(ub);
                if (completeStatus != null) {
                    // to avoid null exception
                    idb.setStatus(completeStatus);
                } else {
                    idb.setStatus(Status.UNAVAILABLE);
                }
                idb.setValue("");
                boolean save = true;
                if (itemBean.size() > 0)
                    save = false;
                /* while(itemBean.iterator().hasNext())
                    {

                        ItemDataBean temp = itemBean.iterator().next();
                       if(idb.getEventCRFId()==(temp.getEventCRFId()))
                       {
                           if(idb.getItemId()==(temp.getItemId())){
                              save = false;
                           }
                       }


                    }*/
                if (save) {
                    iddao.create(idb);
                }
            }
        }
    }
    return true;
}
Also used : DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) ArrayList(java.util.ArrayList) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) Date(java.util.Date) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Aggregations

SectionDAO (org.akaza.openclinica.dao.submit.SectionDAO)40 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)35 ArrayList (java.util.ArrayList)31 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)28 DisplaySectionBean (org.akaza.openclinica.bean.submit.DisplaySectionBean)19 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)18 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)18 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)17 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)17 HashMap (java.util.HashMap)16 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)14 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)14 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)14 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)13 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)12 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)12 DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)11 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)11 ItemGroupDAO (org.akaza.openclinica.dao.submit.ItemGroupDAO)11 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)10