Search in sources :

Example 6 with DynamicsItemFormMetadataBean

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

the class DynamicsMetadataService method hideNew.

public void hideNew(Integer itemDataId, List<PropertyBean> properties, UserAccountBean ub, RuleSetBean ruleSet) {
    ItemDataBean itemDataBeanA = (ItemDataBean) getItemDataDAO().findByPK(itemDataId);
    EventCRFBean eventCrfBeanA = (EventCRFBean) getEventCRFDAO().findByPK(itemDataBeanA.getEventCRFId());
    ItemGroupMetadataBean itemGroupMetadataBeanA = (ItemGroupMetadataBean) getItemGroupMetadataDAO().findByItemAndCrfVersion(itemDataBeanA.getItemId(), eventCrfBeanA.getCRFVersionId());
    Boolean isGroupARepeating = isGroupRepeating(itemGroupMetadataBeanA);
    String itemGroupAOrdinal = getExpressionService().getGroupOrdninalCurated(ruleSet.getTarget().getValue());
    for (PropertyBean propertyBean : properties) {
        String oid = propertyBean.getOid();
        ItemOrItemGroupHolder itemOrItemGroup = getItemOrItemGroup(oid);
        // OID is an item
        if (itemOrItemGroup.getItemBean() != null) {
            String expression = getExpressionService().constructFullExpressionIfPartialProvided(propertyBean.getOid(), ruleSet.getTarget().getValue());
            ItemBean itemBeanB = getExpressionService().getItemBeanFromExpression(expression);
            ItemGroupBean itemGroupBeanB = getExpressionService().getItemGroupExpression(expression);
            EventCRFBean eventCrfBeanB = eventCrfBeanA;
            ItemGroupMetadataBean itemGroupMetadataBeanB = (ItemGroupMetadataBean) getItemGroupMetadataDAO().findByItemAndCrfVersion(itemBeanB.getId(), eventCrfBeanB.getCRFVersionId());
            Boolean isGroupBRepeating = isGroupRepeating(itemGroupMetadataBeanB);
            String itemGroupBOrdinal = getExpressionService().getGroupOrdninalCurated(expression);
            List<ItemDataBean> itemDataBeans = new ArrayList<ItemDataBean>();
            // If A and B are both non repeating groups
            if (!isGroupARepeating && !isGroupBRepeating) {
                ItemDataBean oidBasedItemData = oneToOne(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, 1);
                itemDataBeans.add(oidBasedItemData);
            }
            // If A is not repeating group & B is a repeating group with no index selected
            if (!isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("")) {
                List<ItemDataBean> oidBasedItemDatas = oneToMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub);
                itemDataBeans.addAll(oidBasedItemDatas);
            }
            // If A is not repeating group & B is a repeating group with index selected
            if (!isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("")) {
                ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupBOrdinal));
                itemDataBeans.add(oidBasedItemData);
            }
            // If A is repeating group with index & B is a repeating group with index selected
            if (isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("")) {
                ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupBOrdinal));
                itemDataBeans.add(oidBasedItemData);
            }
            // If A is repeating group with index & B is a repeating group with no index selected
            if (isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("")) {
                ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupAOrdinal));
                itemDataBeans.add(oidBasedItemData);
            }
            for (ItemDataBean oidBasedItemData : itemDataBeans) {
                ItemFormMetadataBean itemFormMetadataBean = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemOrItemGroup.getItemBean().getId(), eventCrfBeanA.getCRFVersionId());
                DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBeanA, oidBasedItemData);
                if (dynamicsMetadataBean == null && oidBasedItemData.getValue().equals("")) {
                    hideNewItem(itemFormMetadataBean, eventCrfBeanA, oidBasedItemData);
                } else if (dynamicsMetadataBean != null && dynamicsMetadataBean.isShowItem() && oidBasedItemData.getValue().equals("")) {
                    // tbh #5287: add an additional check here to see if it should be hidden
                    dynamicsMetadataBean.setShowItem(false);
                    getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
                }
            }
        } else // OID is a group
        {
            // ItemGroupBean itemGroupBean = itemOrItemGroup.getItemGroupBean();
            // below taken from showNew and reversed, tbh 07/2010
            logger.debug("found item group id 1 " + oid);
            ItemGroupBean itemGroupBean = itemOrItemGroup.getItemGroupBean();
            ArrayList sectionBeans = getSectionDAO().findAllByCRFVersionId(eventCrfBeanA.getCRFVersionId());
            for (int i = 0; i < sectionBeans.size(); i++) {
                SectionBean sectionBean = (SectionBean) sectionBeans.get(i);
                // System.out.println("found section " + sectionBean.getId());
                List<ItemGroupMetadataBean> itemGroupMetadataBeans = getItemGroupMetadataDAO().findMetaByGroupAndSection(itemGroupBean.getId(), eventCrfBeanA.getCRFVersionId(), sectionBean.getId());
                for (ItemGroupMetadataBean itemGroupMetadataBean : itemGroupMetadataBeans) {
                    if (itemGroupMetadataBean.getItemGroupId() == itemGroupBean.getId()) {
                        // System.out.println("found item group id 2 " + oid);
                        DynamicsItemGroupMetadataBean dynamicsGroupBean = getDynamicsItemGroupMetadataBean(itemGroupMetadataBean, eventCrfBeanA);
                        if (dynamicsGroupBean == null) {
                            hideGroup(itemGroupMetadataBean, eventCrfBeanA);
                        } else if (dynamicsGroupBean != null && !dynamicsGroupBean.isShowGroup()) {
                            dynamicsGroupBean.setShowGroup(false);
                            getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
                        // TODO is below required in hide?
                        } else if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
                            //setVersion(1); // version 1 = passed DDE
                            dynamicsGroupBean.setPassedDde(1);
                            getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
                        }
                    }
                }
            }
        }
    }
// tbh #5287: reset the check to make sure items that have been shown are not re-hidden
// resetItemCounter();
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ArrayList(java.util.ArrayList) ItemGroupMetadataBean(org.akaza.openclinica.bean.submit.ItemGroupMetadataBean) DynamicsItemGroupMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemGroupMetadataBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) DynamicsItemGroupMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemGroupMetadataBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) PropertyBean(org.akaza.openclinica.domain.rule.action.PropertyBean) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 7 with DynamicsItemFormMetadataBean

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

the class DynamicsMetadataService method isShown.

public boolean isShown(Integer itemId, EventCRFBean eventCrfBean, ItemDataBean itemDataBean) {
    // do we check against the database, or just against the object? against the db
    // ItemFormMetadataBean itemFormMetadataBean = (ItemFormMetadataBean) metadataBean;
    // return itemFormMetadataBean.isShowItem();
    ItemFormMetadataBean itemFormMetadataBean = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemId, eventCrfBean.getCRFVersionId());
    DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBean, itemDataBean);
    // DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataDao().findByMetadataBean(itemFormMetadataBean, eventCrfBean);
    if (dynamicsMetadataBean != null) {
        // System.out.println("DID find a row in the db for (with IDB) " + itemFormMetadataBean.getId() + " idb id " + itemDataBean.getId());
        return dynamicsMetadataBean.isShowItem();
    } else {
        // System.out.println("did not find a row in the db for (with IDB) " + itemFormMetadataBean.getId() + " idb id " + itemDataBean.getId());
        return false;
    }
// return false;
}
Also used : DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 8 with DynamicsItemFormMetadataBean

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

the class DynamicsMetadataService method isShown.

// deprecated?
public boolean isShown(Object metadataBean, EventCRFBean eventCrfBean) {
    ItemFormMetadataBean itemFormMetadataBean = (ItemFormMetadataBean) metadataBean;
    DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBean, null);
    if (dynamicsMetadataBean != null) {
        return dynamicsMetadataBean.isShowItem();
    } else {
        logger.debug("did not find a row in the db for " + itemFormMetadataBean.getId());
        return false;
    }
// return false;
}
Also used : DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 9 with DynamicsItemFormMetadataBean

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

the class DynamicsMetadataService method hide.

public void hide(Integer itemDataId, List<PropertyBean> properties) {
    ItemDataBean itemDataBean = (ItemDataBean) getItemDataDAO().findByPK(itemDataId);
    EventCRFBean eventCrfBean = (EventCRFBean) getEventCRFDAO().findByPK(itemDataBean.getEventCRFId());
    for (PropertyBean propertyBean : properties) {
        String oid = propertyBean.getOid();
        ItemOrItemGroupHolder itemOrItemGroup = getItemOrItemGroup(oid);
        // OID is an item
        if (itemOrItemGroup.getItemBean() != null) {
            ItemDataBean oidBasedItemData = getItemData(itemOrItemGroup.getItemBean(), eventCrfBean, itemDataBean.getOrdinal());
            ItemFormMetadataBean itemFormMetadataBean = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemOrItemGroup.getItemBean().getId(), eventCrfBean.getCRFVersionId());
            DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBean, oidBasedItemData);
            if (dynamicsMetadataBean == null && oidBasedItemData.getValue().equals("")) {
                showItem(itemFormMetadataBean, eventCrfBean, oidBasedItemData);
            } else if (dynamicsMetadataBean != null && dynamicsMetadataBean.isShowItem() && oidBasedItemData.getValue().equals("")) {
                dynamicsMetadataBean.setShowItem(false);
                getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
            }
        } else // OID is a group
        {
        // ItemGroupBean itemGroupBean = itemOrItemGroup.getItemGroupBean();
        }
    }
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) PropertyBean(org.akaza.openclinica.domain.rule.action.PropertyBean) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 10 with DynamicsItemFormMetadataBean

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

the class RuleSetService method filterRuleSetsByHiddenItems.

public List<RuleSetBean> filterRuleSetsByHiddenItems(List<RuleSetBean> ruleSets, EventCRFBean eventCrf, CRFVersionBean crfVersion, List<ItemBean> itemBeansWithSCDShown) {
    ArrayList<RuleSetBean> shownRuleSets = new ArrayList<RuleSetBean>();
    for (RuleSetBean ruleSetBean : ruleSets) {
        logMe("Entering the filterRuleSetsBy HiddenItems? Thread::" + Thread.currentThread() + "eventCrf?" + eventCrf + "crfVersion??" + crfVersion + "ruleSets?" + ruleSets);
        ItemBean target = ruleSetBean.getItem();
        ItemFormMetadataBean metadataBean = this.getItemFormMetadataDao().findByItemIdAndCRFVersionId(target.getId(), crfVersion.getId());
        ItemDataBean itemData = this.getItemDataDao().findByItemIdAndEventCRFId(target.getId(), eventCrf.getId());
        DynamicsItemFormMetadataBean dynamicsBean = this.getDynamicsItemFormMetadataDao().findByMetadataBean(metadataBean, eventCrf, itemData);
        if (itemBeansWithSCDShown == null)
            itemBeansWithSCDShown = new ArrayList<ItemBean>();
        if (dynamicsBean == null) {
            if (metadataBean.isShowItem() || itemBeansWithSCDShown.contains(target)) {
                logger.debug("just added rule set bean");
                shownRuleSets.add(ruleSetBean);
            }
        } else {
            if (metadataBean.isShowItem() || dynamicsBean.isShowItem()) {
                logger.debug("just added rule set bean 2, with dyn bean");
                shownRuleSets.add(ruleSetBean);
            }
        }
    }
    return shownRuleSets;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) DynamicsItemFormMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean) ArrayList(java.util.ArrayList) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) 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