Search in sources :

Example 56 with EventCRFBean

use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.

the class DataEntryServlet method isEachSectionReviewedOnce.

/**
     * Checks if all the sections in an event crf are reviewed once
     * tbh updated to prevent duplicates, 03/2011
     * @param request TODO
     *
     * @return
     */
protected boolean isEachSectionReviewedOnce(HttpServletRequest request) {
    SectionDAO sdao = new SectionDAO(getDataSource());
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    DataEntryStage stage = ecb.getStage();
    EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
    // below block changed tbh 04/2011, to remove repeating items generated by mistake
    ArrayList<SectionBean> sections = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
    /*  for (SectionBean section : sections) {
                boolean toContinue = isSectionReviewedOnce(section, request);
                if (!toContinue) {
                        return false;
                }
        }*/
    HashMap numItemsHM = sdao.getNumItemsBySectionId();
    HashMap numItemsPendingHM = sdao.getNumItemsPendingBySectionId(ecb);
    HashMap numItemsCompletedHM = sdao.getNumItemsCompletedBySectionId(ecb);
    for (int i = 0; i < sections.size(); i++) {
        SectionBean sb = sections.get(i);
        Integer key = new Integer(sb.getId());
        int numItems = TableOfContentsServlet.getIntById(numItemsHM, key);
        int numItemsPending = TableOfContentsServlet.getIntById(numItemsPendingHM, key);
        int numItemsCompleted = TableOfContentsServlet.getIntById(numItemsCompletedHM, key);
        if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY) && edcb.isDoubleEntry()) {
            if (numItemsPending == 0 && numItems > 0) {
                return false;
            }
        } else {
            if (numItemsCompleted == 0 && numItems > 0) {
                return false;
            } else if (numItemsCompleted < numItems) {
                return false;
            }
        }
    }
    return true;
// if we get this far, all sections are checked and we return a true
// return true;
}
Also used : SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) 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 57 with EventCRFBean

use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.

the class DataEntryServlet method prepareScoreItemdata.

protected HashMap<String, String> prepareScoreItemdata(HttpServletRequest request) {
    HashMap<String, String> scoreItemdata = new HashMap<String, String>();
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    SectionDAO sdao = new SectionDAO(getDataSource());
    ArrayList<SectionBean> sbs = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
    for (SectionBean section : sbs) {
        HashMap<String, String> data = prepareSectionItemDataBeans(section.getId(), request);
        if (data != null && data.size() > 0) {
            scoreItemdata.putAll(data);
        }
    }
    return scoreItemdata;
}
Also used : SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) HashMap(java.util.HashMap) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 58 with EventCRFBean

use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.

the class DataEntryServlet method getChildrenDisplayItems.

/**
     * Get the DisplayItemBean objects corresponding to the items which are children of the specified parent.
     *
     * @param parent
     *            The item whose children are to be retrieved.
     * @param request TODO
     * @return An array of DisplayItemBean objects corresponding to the items which are children of parent, and are sorted by column number (ascending), then
     *         ordinal (ascending).
     */
private ArrayList getChildrenDisplayItems(DisplayItemBean parent, EventDefinitionCRFBean edcb, HttpServletRequest request) {
    ArrayList answer = new ArrayList();
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    int parentId = parent.getItem().getId();
    ItemDAO idao = new ItemDAO(getDataSource());
    ArrayList childItemBeans = idao.findAllByParentIdAndCRFVersionId(parentId, ecb.getCRFVersionId());
    ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
    ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(getDataSource());
    for (int i = 0; i < childItemBeans.size(); i++) {
        ItemBean child = (ItemBean) childItemBeans.get(i);
        ItemDataBean data = iddao.findByItemIdAndEventCRFId(child.getId(), ecb.getId());
        ItemFormMetadataBean metadata = ifmdao.findByItemIdAndCRFVersionId(child.getId(), ecb.getCRFVersionId());
        DisplayItemBean dib = new DisplayItemBean();
        dib.setEventDefinitionCRF(edcb);
        dib.setItem(child);
        // tbh
        if (!getServletPage(request).equals(Page.DOUBLE_DATA_ENTRY_SERVLET)) {
            dib.setData(data);
        }
        // <<tbh 07/2009, bug #3883
        // ItemDataBean dbData = iddao.findByItemIdAndEventCRFIdAndOrdinal(itemId, eventCRFId, ordinal)
        dib.setDbData(data);
        boolean showItem = getItemMetadataService().isShown(metadata.getItemId(), ecb, data);
        if (getServletPage(request).equals(Page.DOUBLE_DATA_ENTRY_SERVLET)) {
            showItem = getItemMetadataService().hasPassedDDE(metadata, ecb, data);
        }
        // boolean passedDDE = getItemMetadataService().hasPassedDDE(data);
        if (showItem) {
            LOGGER.debug("set show item: " + metadata.getItemId() + " data " + data.getId());
            // metadata.setShowItem(showItem);
            metadata.setShowItem(true);
        }
        // logger.debug("did not catch NPE");
        dib.setMetadata(metadata);
        if (shouldLoadDBValues(dib)) {
            LOGGER.trace("should load db values is true, set value");
            dib.loadDBValue();
            LOGGER.trace("just loaded the child value: " + dib.getData().getValue());
        }
        answer.add(dib);
    }
    // this is a pretty slow and memory intensive way to sort... see if we
    // can
    // have the db do this instead
    Collections.sort(answer);
    return answer;
}
Also used : DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) 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 59 with EventCRFBean

use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.

the class ViewSectionDataEntryPreview method setEventCRFAnnotations.

/*
     * (non-Javadoc)
     *
     * @see org.akaza.openclinica.control.submit.DataEntryServlet#setEventCRFAnnotations(java.lang.String)
     */
@Override
protected void setEventCRFAnnotations(String annotations, HttpServletRequest request) {
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    ecb.setAnnotations(annotations);
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean)

Example 60 with EventCRFBean

use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.

the class CreateDiscrepancyNoteServlet method updateStudySubjectStatus.

/**
     * Pulls the note related information from database according to note type
     *
     * @param note
     */
private void updateStudySubjectStatus(String entityType, int entityId) {
    if ("itemData".equalsIgnoreCase(entityType)) {
        int itemDataId = entityId;
        ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
        ItemDataBean itemData = (ItemDataBean) iddao.findByPK(itemDataId);
        EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
        StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
        StudySubjectDAO studySubjectDAO = new StudySubjectDAO(sm.getDataSource());
        EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
        StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
        StudySubjectBean studySubject = (StudySubjectBean) studySubjectDAO.findByPK(event.getStudySubjectId());
        if (studySubject.getStatus() != null && studySubject.getStatus().equals(Status.SIGNED)) {
            studySubject.setStatus(Status.AVAILABLE);
            studySubject.setUpdater(ub);
            studySubject.setUpdatedDate(new Date());
            studySubjectDAO.update(studySubject);
        }
        if (ec.isSdvStatus()) {
            studySubject.setStatus(Status.AVAILABLE);
            studySubject.setUpdater(ub);
            studySubject.setUpdatedDate(new Date());
            studySubjectDAO.update(studySubject);
            ec.setSdvStatus(false);
            ec.setSdvUpdateId(ub.getId());
            ecdao.update(ec);
        }
    }
}
Also used : 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) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) Date(java.util.Date)

Aggregations

EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)198 ArrayList (java.util.ArrayList)118 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)89 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)85 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)68 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)64 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)63 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)62 HashMap (java.util.HashMap)54 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)52 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)52 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)48 Date (java.util.Date)47 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)47 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)44 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)43 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)42 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)41 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)41 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)41