Search in sources :

Example 61 with ItemDataDAO

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

the class DataEntryServlet method prepareSectionItemdata.

protected HashMap<Integer, String> prepareSectionItemdata(int sectionId, HttpServletRequest request) {
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
    HashMap<Integer, String> itemdata = new HashMap<Integer, String>();
    ArrayList<ItemDataBean> idbs = iddao.findAllActiveBySectionIdAndEventCRFId(sectionId, ecb.getId());
    for (ItemDataBean idb : idbs) {
        itemdata.put(idb.getId(), idb.getValue());
    }
    return itemdata;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) HashMap(java.util.HashMap) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO)

Example 62 with ItemDataDAO

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

the class DataEntryServlet method buildMatrixForRepeatingGroups.

// @pgawade 30-May-2012 Fix for issue 13963 - added an extra parameter 'isSubmitted' to method buildMatrixForRepeatingGroups
protected DisplayItemWithGroupBean buildMatrixForRepeatingGroups(DisplayItemWithGroupBean diwgb, DisplayItemGroupBean itemGroup, EventCRFBean ecb, SectionBean sb, List<ItemBean> itBeans, Map<String, ItemDataBean> dataMap, List<String> nullValuesList, boolean isSubmitted) {
    int tempOrdinal = 1;
    ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
    int maxOrdinal = iddao.getMaxOrdinalForGroup(ecb, sb, itemGroup.getItemGroupBean());
    // Incase of no data
    if (maxOrdinal == 0)
        maxOrdinal = 1;
    ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO<String, ArrayList>(getDataSource());
    List<DisplayItemGroupBean> itemGroups = new ArrayList<DisplayItemGroupBean>();
    boolean groupHasData = false;
    for (int i = 1; i <= maxOrdinal; i++) {
        List<DisplayItemBean> displayItemBeans = new ArrayList<DisplayItemBean>();
        DisplayItemGroupBean dig = new DisplayItemGroupBean();
        for (ItemBean itBean : itBeans) {
            DisplayItemBean displayItemBean = new DisplayItemBean();
            ItemFormMetadataBean ifm = ifmdao.findByItemIdAndCRFVersionId(itBean.getId(), ecb.getCRFVersionId());
            // itBean.setItemMeta(ifm);//TODO:remove this or the one down displayItemBean.setMetadata(ifm);
            displayItemBean.setMetadata(ifm);
            displayItemBean.setItem(itBean);
            ItemDataBean itemData = dataMap.get(itBean.getId() + "," + i);
            if (itemData != null) {
                // to indicate any item in the group has data;
                groupHasData = true;
                displayItemBean.setIsNewItem(false);
            }
            if (itemData == null) {
                itemData = displayItemBean.getData();
                itemData.setValue("");
                itemData.setOrdinal(i);
            }
            addNullValues(displayItemBean, nullValuesList);
            displayItemBean.setData(itemData);
            // displayItemBean.loadDBValue();
            if (ecb.getStage() == DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE || ecb.getStage() == DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) {
                if (shouldLoadDBValues(displayItemBean) && !isSubmitted) {
                    displayItemBean.loadDBValue();
                }
            } else {
                if (shouldLoadDBValues(displayItemBean)) {
                    LOGGER.trace("should load db values is true, set value");
                    displayItemBean.loadDBValue();
                    LOGGER.trace("just got data loaded: " + displayItemBean.getData().getValue());
                }
            }
            displayItemBeans.add(displayItemBean);
        }
        Collections.sort(displayItemBeans);
        dig.setItems(displayItemBeans);
        dig.setHasData(groupHasData);
        itemGroups.add(dig);
    }
    diwgb.setItemGroups(itemGroups);
    diwgb.setDbItemGroups(itemGroups);
    return diwgb;
}
Also used : DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) ArrayList(java.util.ArrayList) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 63 with ItemDataDAO

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

the class CrfBusinessLogicHelper method isEachRequiredFieldFillout.

protected boolean isEachRequiredFieldFillout(EventCRFBean ecb) {
    ItemDataDAO iddao = new ItemDataDAO(ds);
    ItemDAO idao = new ItemDAO(ds);
    int allRequiredNum = idao.findAllRequiredByCRFVersionId(ecb.getCRFVersionId());
    int allRequiredFilledOut = iddao.findAllRequiredByEventCRFId(ecb);
    if (allRequiredNum > allRequiredFilledOut) {
        return false;
    }
    ArrayList allFilled = iddao.findAllBlankRequiredByEventCRFId(ecb.getId(), ecb.getCRFVersionId());
    if (!allFilled.isEmpty()) {
        return false;
    }
    return true;
}
Also used : ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) ArrayList(java.util.ArrayList) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO)

Example 64 with ItemDataDAO

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

the class UpdateStudyEventServlet method getUncompletedCRFs.

private ArrayList getUncompletedCRFs(ArrayList eventDefinitionCRFs, ArrayList eventCRFs) {
    int i;
    HashMap completed = new HashMap();
    HashMap startedButIncompleted = new HashMap();
    ArrayList answer = new ArrayList();
    for (i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
        startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
    }
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
    for (i = 0; i < eventCRFs.size(); i++) {
        EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
        int crfId = cvdao.getCRFIdFromCRFVersionId(ecrf.getCRFVersionId());
        ArrayList idata = iddao.findAllByEventCRFId(ecrf.getId());
        if (!idata.isEmpty()) {
            // this crf has data already
            completed.put(new Integer(crfId), Boolean.TRUE);
        } else {
            // event crf got created, but no data entered
            startedButIncompleted.put(new Integer(crfId), ecrf);
        }
    }
    for (i = 0; i < eventDefinitionCRFs.size(); i++) {
        DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
        EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        dedc.setEdc(edcrf);
        Boolean b = (Boolean) completed.get(new Integer(edcrf.getCrfId()));
        EventCRFBean ev = (EventCRFBean) startedButIncompleted.get(new Integer(edcrf.getCrfId()));
        if (b == null || !b.booleanValue()) {
            dedc.setEventCRF(ev);
            answer.add(dedc);
        }
    }
    return answer;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Example 65 with ItemDataDAO

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

the class ResolveDiscrepancyServlet method prepareRequestForResolution.

public boolean prepareRequestForResolution(HttpServletRequest request, DataSource ds, StudyBean currentStudy, DiscrepancyNoteBean note, boolean isCompleted) {
    String entityType = note.getEntityType().toLowerCase();
    int id = note.getEntityId();
    if ("subject".equalsIgnoreCase(entityType)) {
        StudySubjectDAO ssdao = new StudySubjectDAO(ds);
        StudySubjectBean ssb = ssdao.findBySubjectIdAndStudy(id, currentStudy);
        request.setAttribute("action", "show");
        request.setAttribute("id", String.valueOf(note.getEntityId()));
        request.setAttribute("studySubId", String.valueOf(ssb.getId()));
    } else if ("studysub".equalsIgnoreCase(entityType)) {
        request.setAttribute("action", "show");
        request.setAttribute("id", String.valueOf(note.getEntityId()));
    } else if ("eventcrf".equalsIgnoreCase(entityType)) {
        request.setAttribute("editInterview", "1");
        EventCRFDAO ecdao = new EventCRFDAO(ds);
        EventCRFBean ecb = (EventCRFBean) ecdao.findByPK(id);
        request.setAttribute(TableOfContentsServlet.INPUT_EVENT_CRF_BEAN, ecb);
        // If the request is passed along to ViewSectionDataEntryServlet,
        // that code needs
        // an event crf id; the (ecb.getId()+"") is necessary because
        // FormProcessor throws
        // a ClassCastException without the casting to a String
        request.setAttribute(ViewSectionDataEntryServlet.EVENT_CRF_ID, ecb.getId() + "");
    } else if ("studyevent".equalsIgnoreCase(entityType)) {
        StudyEventDAO sedao = new StudyEventDAO(ds);
        StudyEventBean seb = (StudyEventBean) sedao.findByPK(id);
        request.setAttribute(EnterDataForStudyEventServlet.INPUT_EVENT_ID, String.valueOf(id));
        request.setAttribute(UpdateStudyEventServlet.EVENT_ID, String.valueOf(id));
        request.setAttribute(UpdateStudyEventServlet.STUDY_SUBJECT_ID, String.valueOf(seb.getStudySubjectId()));
    } else // this is for item data
    if ("itemdata".equalsIgnoreCase(entityType)) {
        ItemDataDAO iddao = new ItemDataDAO(ds);
        ItemDataBean idb = (ItemDataBean) iddao.findByPK(id);
        EventCRFDAO ecdao = new EventCRFDAO(ds);
        EventCRFBean ecb = (EventCRFBean) ecdao.findByPK(idb.getEventCRFId());
        StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
        StudySubjectBean ssb = (StudySubjectBean) ssdao.findByPK(ecb.getStudySubjectId());
        ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(ds);
        ItemFormMetadataBean ifmb = ifmdao.findByItemIdAndCRFVersionId(idb.getItemId(), ecb.getCRFVersionId());
        if (currentRole.getRole().equals(Role.MONITOR) || !isCompleted) {
            StudyEventDAO sedao = new StudyEventDAO(ds);
            StudyEventBean seb = (StudyEventBean) sedao.findByPK(id);
            request.setAttribute(EVENT_CRF_ID, String.valueOf(idb.getEventCRFId()));
            request.setAttribute(STUDY_SUB_ID, String.valueOf(seb.getStudySubjectId()));
        } else {
            request.setAttribute(DataEntryServlet.INPUT_EVENT_CRF_ID, String.valueOf(idb.getEventCRFId()));
            request.setAttribute(DataEntryServlet.INPUT_SECTION_ID, String.valueOf(ifmb.getSectionId()));
        }
        DataEntryStage stage = ecb.getStage();
    // if (!stage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE)) {
    // return false;
    // }
    }
    return true;
}
Also used : StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) DataEntryStage(org.akaza.openclinica.bean.core.DataEntryStage) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Aggregations

ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)83 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)64 ArrayList (java.util.ArrayList)61 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)61 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)52 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)40 Date (java.util.Date)38 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)37 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)31 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)30 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)29 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)29 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)28 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)27 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)26 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)24 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)23 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)22 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)21 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)21