Search in sources :

Example 16 with DynamicsItemFormMetadataBean

use of org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean in project OpenClinica by OpenClinica.

the class DynamicsMetadataService method hide.

public boolean hide(Object metadataBean, EventCRFBean eventCrfBean) {
    // TODO -- interesting problem, where is the SpringServletAccess object going to live now? tbh 03/2010
    ItemFormMetadataBean itemFormMetadataBean = (ItemFormMetadataBean) metadataBean;
    itemFormMetadataBean.setShowItem(false);
    // DynamicsItemFormMetadataDao dynamicsMetadataDao = (DynamicsItemFormMetadataDao) metadataDao;
    // DynamicsItemFormMetadataDao metadataDao = (DynamicsItemFormMetadataDao) SpringServletAccess.getApplicationContext(context).getBean("dynamicsItemFormMetadataDao");
    DynamicsItemFormMetadataBean dynamicsMetadataBean = new DynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBean);
    dynamicsMetadataBean.setShowItem(false);
    getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
    return true;
}
Also used : DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 17 with DynamicsItemFormMetadataBean

use of org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean in project OpenClinica by OpenClinica.

the class DataEntryServlet method isEachRequiredFieldFillout.

protected boolean isEachRequiredFieldFillout(HttpServletRequest request) {
    HttpSession session = request.getSession();
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(getDataSource());
    // need to update this method to accomodate dynamics, tbh
    ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
    ItemDAO idao = new ItemDAO(getDataSource());
    ItemFormMetadataDAO itemFormMetadataDao = new ItemFormMetadataDAO(getDataSource());
    // Below code will iterate all shown and hidden required fields/items in a crf version and verify if the data field is filled up with value or if not , then it is a hidden field with no show rule triggered for the item.        
    ArrayList<ItemFormMetadataBean> shownRequiredAllItemsInCrfVersion = itemFormMetadataDao.findAllItemsRequiredAndShownByCrfVersionId(ecb.getCRFVersionId());
    ArrayList<ItemFormMetadataBean> hiddenRequiredAllItemsInCrfVersion = itemFormMetadataDao.findAllItemsRequiredAndHiddenByCrfVersionId(ecb.getCRFVersionId());
    ItemGroupMetadataDAO<String, ArrayList> igdao = new ItemGroupMetadataDAO<String, ArrayList>(dataSource);
    ArrayList<ItemDataBean> itemdatas = null;
    for (ItemFormMetadataBean shownItemMeta : shownRequiredAllItemsInCrfVersion) {
        ItemGroupMetadataBean igBean = (ItemGroupMetadataBean) igdao.findByItemAndCrfVersion(shownItemMeta.getItemId(), ecb.getCRFVersionId());
        // verifies if the group that the item belongs to is not hidden.
        if (igBean != null && igBean.isShowGroup()) {
            itemdatas = iddao.findAllByEventCRFIdAndItemId(ecb.getId(), shownItemMeta.getItemId());
            if (itemdatas == null || itemdatas.size() == 0)
                return false;
            for (ItemDataBean itemdata : itemdatas) {
                System.out.println(itemdata.getItemId() + "  :  " + itemdata.getValue());
                if ((itemdata.getValue() == null || itemdata.getValue().equals("") || itemdata.getValue().trim().length() == 0) && dndao.findNumExistingNotesForItem(itemdata.getId()) < 1) {
                    return false;
                }
            }
        }
        ArrayList<DynamicsItemFormMetadataBean> dynamicsItemFormMetadataBeans = null;
        for (ItemFormMetadataBean hiddenItemMeta : hiddenRequiredAllItemsInCrfVersion) {
            itemdatas = iddao.findAllByEventCRFIdAndItemId(ecb.getId(), hiddenItemMeta.getItemId());
            dynamicsItemFormMetadataBeans = getItemMetadataService().getDynamicsItemFormMetadataDao().findByItemAndEventCrfShown(ecb, hiddenItemMeta.getItemId());
            if (itemdatas.size() == 0 && dynamicsItemFormMetadataBeans.size() > 0) {
                return false;
            }
            for (ItemDataBean itemdata : itemdatas) {
                if ((itemdata.getValue() == null || itemdata.getValue().equals("") || itemdata.getValue().trim().length() == 0) && dndao.findNumExistingNotesForItem(itemdata.getId()) < 1 && dynamicsItemFormMetadataBeans.size() > 0) {
                    return false;
                }
            }
        }
    }
    // had to change the query below to allow for hidden items here, tbh 04/2010
    ArrayList allFilled = iddao.findAllBlankRequiredByEventCRFId(ecb.getId(), ecb.getCRFVersionId());
    int numNotes = 0;
    if (!allFilled.isEmpty()) {
        LOGGER.trace("allFilled is not empty");
        FormDiscrepancyNotes fdn = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
        HashMap idNotes = fdn.getIdNotes();
        for (int i = 0; i < allFilled.size(); i++) {
            ItemDataBean idb = (ItemDataBean) allFilled.get(i);
            int exsitingNotes = dndao.findNumExistingNotesForItem(idb.getId());
            if (exsitingNotes > 0) {
                LOGGER.trace("has existing note");
                numNotes++;
            } else if (idNotes.containsKey(idb.getId())) {
                LOGGER.trace("has note in session");
                numNotes++;
            }
        }
        LOGGER.trace("numNotes allFilled.size:" + numNotes + " " + allFilled.size());
        if (numNotes >= allFilled.size()) {
            LOGGER.trace("all required are filled out");
            return true;
        } else {
            LOGGER.debug("numNotes < allFilled.size() " + numNotes + ": " + allFilled.size());
            return false;
        }
    }
    return true;
}
Also used : DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) FormDiscrepancyNotes(org.akaza.openclinica.control.form.FormDiscrepancyNotes) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) ArrayList(java.util.ArrayList) ItemGroupMetadataBean(org.akaza.openclinica.bean.submit.ItemGroupMetadataBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) ItemGroupMetadataDAO(org.akaza.openclinica.dao.submit.ItemGroupMetadataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Aggregations

DynamicsItemFormMetadataBean (org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean)17 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)14 ArrayList (java.util.ArrayList)7 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)6 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)5 ItemGroupMetadataBean (org.akaza.openclinica.bean.submit.ItemGroupMetadataBean)4 PropertyBean (org.akaza.openclinica.domain.rule.action.PropertyBean)4 DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)3 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)3 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)3 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)3 DynamicsItemGroupMetadataBean (org.akaza.openclinica.domain.crfdata.DynamicsItemGroupMetadataBean)3 Query (org.hibernate.Query)3 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)2 HashMap (java.util.HashMap)1 HttpSession (javax.servlet.http.HttpSession)1 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)1 FormDiscrepancyNotes (org.akaza.openclinica.control.form.FormDiscrepancyNotes)1 DiscrepancyNoteDAO (org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO)1 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)1