Search in sources :

Example 61 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class DynamicsMetadataService method insert.

private void insert(Integer itemDataId, List<PropertyBean> properties, UserAccountBean ub, RuleSetBean ruleSet, Status itemDataStatus, List<StratificationFactorBean> stratificationFactorBeans) {
    ItemDataBean itemDataBeanA = (ItemDataBean) getItemDataDAO().findByPK(itemDataId);
    EventCRFBean eventCrfBeanA = (EventCRFBean) getEventCRFDAO().findByPK(itemDataBeanA.getEventCRFId());
    StudyEventBean studyEventBeanA = (StudyEventBean) getStudyEventDAO().findByPK(eventCrfBeanA.getStudyEventId());
    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 expression = getExpressionService().constructFullExpressionIfPartialProvided(propertyBean.getOid(), ruleSet.getTarget().getValue());
        ItemBean itemBeanB = getExpressionService().getItemBeanFromExpression(expression);
        ItemGroupBean itemGroupBeanB = getExpressionService().getItemGroupExpression(expression);
        ItemGroupMetadataBean itemGroupMetadataBeanB = null;
        Boolean isGroupBRepeating = null;
        String itemGroupBOrdinal = null;
        EventCRFBean eventCrfBeanB = null;
        Boolean isItemInSameForm = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemBeanB.getId(), eventCrfBeanA.getCRFVersionId()).getId() != 0 ? true : false;
        // Item Does not below to same form
        if (!isItemInSameForm) {
            List<EventCRFBean> eventCrfs = getEventCRFDAO().findAllByStudyEventAndCrfOrCrfVersionOid(studyEventBeanA, getExpressionService().getCrfOid(expression));
            if (eventCrfs.size() == 0) {
                CRFVersionBean crfVersion = getExpressionService().getCRFVersionFromExpression(expression);
                CRFBean crf = getExpressionService().getCRFFromExpression(expression);
                int crfVersionId = 0;
                EventDefinitionCRFBean eventDefinitionCRFBean = getEventDefinitionCRfDAO().findByStudyEventDefinitionIdAndCRFId(studyEventBeanA.getStudyEventDefinitionId(), crf.getId());
                if (eventDefinitionCRFBean.getId() != 0) {
                    crfVersionId = crfVersion != null ? crfVersion.getId() : eventDefinitionCRFBean.getDefaultVersionId();
                }
                // Create new event crf
                eventCrfBeanB = eventCrfBeanA.copy();
                eventCrfBeanB.setStatus(Status.AVAILABLE);
                eventCrfBeanB.setId(0);
                eventCrfBeanB.setCRFVersionId(crfVersionId);
                eventCrfBeanB = (EventCRFBean) getEventCRFDAO().create(eventCrfBeanB);
            } else {
                eventCrfBeanB = eventCrfs.get(0);
            }
        }
        if (isItemInSameForm) {
            eventCrfBeanB = eventCrfBeanA;
        }
        itemGroupMetadataBeanB = (ItemGroupMetadataBean) getItemGroupMetadataDAO().findByItemAndCrfVersion(itemBeanB.getId(), eventCrfBeanB.getCRFVersionId());
        isGroupBRepeating = isGroupRepeating(itemGroupMetadataBeanB);
        itemGroupBOrdinal = getExpressionService().getGroupOrdninalCurated(expression);
        // If A and B are both non repeating groups
        if (!isGroupARepeating && !isGroupBRepeating) {
            ItemDataBean oidBasedItemData = oneToOne(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, 1);
            oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
            if (itemDataStatus != null)
                oidBasedItemData.setStatus(itemDataStatus);
            getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
        }
        // 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);
            for (ItemDataBean oidBasedItemData : oidBasedItemDatas) {
                oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
                if (itemDataStatus != null)
                    oidBasedItemData.setStatus(itemDataStatus);
                getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
            }
        }
        // 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));
            oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
            if (itemDataStatus != null)
                oidBasedItemData.setStatus(itemDataStatus);
            getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
        }
        // If A is repeating/ non repeating group & B is a repeating group with index selected as END
        if (isGroupBRepeating && itemGroupBOrdinal.equals("END")) {
            ItemDataBean oidBasedItemData = oneToEndMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub);
            oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
            if (itemDataStatus != null)
                oidBasedItemData.setStatus(itemDataStatus);
            getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
        }
        // If A is repeating group with index & B is a repeating group with index selected
        if (isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("") && !itemGroupBOrdinal.equals("END")) {
            ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupBOrdinal));
            oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
            if (itemDataStatus != null)
                oidBasedItemData.setStatus(itemDataStatus);
            getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
        }
        // 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));
            oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
            if (itemDataStatus != null)
                oidBasedItemData.setStatus(itemDataStatus);
            getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
        }
    // // If A is repeating group with index & B is none-repeating group
    // if (isGroupARepeating && !isGroupBRepeating ) {
    // ItemDataBean oidBasedItemData =
    // oneToOne(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, 1);
    // 
    // oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA));
    // getItemDataDAO().updateValue(oidBasedItemData, "yyyy-MM-dd");
    // }
    }
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ItemGroupMetadataBean(org.akaza.openclinica.bean.submit.ItemGroupMetadataBean) DynamicsItemGroupMetadataBean(org.akaza.openclinica.domain.crfdata.DynamicsItemGroupMetadataBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) PropertyBean(org.akaza.openclinica.domain.rule.action.PropertyBean)

Example 62 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class HideCRFManager method studyEventHasAHideCRFProperty.

public boolean studyEventHasAHideCRFProperty(DisplayStudyEventBean displayStudyEventBean) {
    EventDefinitionCRFBean tempEventCRFBean = new EventDefinitionCRFBean();
    boolean hasAHideCRFProperty = false;
    for (DisplayEventCRFBean deCRFBean : displayStudyEventBean.getAllEventCRFs()) {
        tempEventCRFBean = deCRFBean.getEventDefinitionCRF();
        if (tempEventCRFBean.isHideCrf()) {
            hasAHideCRFProperty = true;
        }
    }
    for (DisplayEventCRFBean deCRFBean : displayStudyEventBean.getDisplayEventCRFs()) {
        tempEventCRFBean = deCRFBean.getEventDefinitionCRF();
        if (tempEventCRFBean.isHideCrf()) {
            hasAHideCRFProperty = true;
        }
    }
    return hasAHideCRFProperty;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 63 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class HideCRFManager method removeHiddenCRFBeans.

/**
 * Given a StudyEventDefinitionBean and a list of CRFBeans as parameters,
 * this method returns of new list of CRFBeans containing only unhidden CRFs
 * (their isHideCRF property is false).
 *
 * @param studyEventBean
 *            The StudyEventDefinitionBean
 * @param crfBeans
 *            An ArrayList of CRFBeans
 * @param dataSource
 *            A javax.sql.DataSource for the use of the
 *            EventDefinitionCRFDAO.
 * @return An ArrayList of CRFBeans containing only "unhidden" CRFs.
 */
public ArrayList<CRFBean> removeHiddenCRFBeans(StudyBean study, StudyEventDefinitionBean studyEventBean, ArrayList<CRFBean> crfBeans, DataSource dataSource) {
    ArrayList<CRFBean> newBeans = new ArrayList<CRFBean>();
    if (crfBeans == null || crfBeans.isEmpty()) {
        return newBeans;
    }
    EventDefinitionCRFDAO eventDefinitionCRFDAO = new EventDefinitionCRFDAO(dataSource);
    EventDefinitionCRFBean tempBean = new EventDefinitionCRFBean();
    for (CRFBean crfBean : crfBeans) {
        tempBean = eventDefinitionCRFDAO.findByStudyEventDefinitionIdAndCRFId(study, studyEventBean.getId(), crfBean.getId());
        if (tempBean != null && !tempBean.isHideCrf()) {
            newBeans.add(crfBean);
        }
    }
    return newBeans;
}
Also used : ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 64 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class HideCRFManager method suppressHiddenEventCRFBeans.

private ArrayList<DisplayEventCRFBean> suppressHiddenEventCRFBeans(List<DisplayEventCRFBean> eventCRFBeans) {
    // Must make this an ArrayList because of the
    // displayStudyEventBean.setAllEventCRFs()
    // method definition
    ArrayList<DisplayEventCRFBean> newEventCRFBeans = new ArrayList<DisplayEventCRFBean>();
    EventDefinitionCRFBean definitionCRFBean = new EventDefinitionCRFBean();
    for (DisplayEventCRFBean deCRFBean : eventCRFBeans) {
        definitionCRFBean = deCRFBean.getEventDefinitionCRF();
        if (!definitionCRFBean.isHideCrf()) {
            newEventCRFBeans.add(deCRFBean);
        }
    }
    return newEventCRFBeans;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) ArrayList(java.util.ArrayList) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 65 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class HideCRFManager method removeHiddenEventDefinitionCRFBeans.

public ArrayList<DisplayEventDefinitionCRFBean> removeHiddenEventDefinitionCRFBeans(List<DisplayEventDefinitionCRFBean> displayEventDefinitionCRFBeans) {
    ArrayList<DisplayEventDefinitionCRFBean> newDisplayEventDefinitionCRFBeans = new ArrayList<DisplayEventDefinitionCRFBean>();
    EventDefinitionCRFBean eventDefinitionCRFBean = new EventDefinitionCRFBean();
    for (DisplayEventDefinitionCRFBean displayEventDefinitionCRFBean : displayEventDefinitionCRFBeans) {
        eventDefinitionCRFBean = displayEventDefinitionCRFBean.getEdc();
        if (!eventDefinitionCRFBean.isHideCrf()) {
            newDisplayEventDefinitionCRFBeans.add(displayEventDefinitionCRFBean);
        }
    }
    return newDisplayEventDefinitionCRFBeans;
}
Also used : ArrayList(java.util.ArrayList) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Aggregations

EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)146 ArrayList (java.util.ArrayList)112 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)67 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)65 HashMap (java.util.HashMap)57 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)50 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)50 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)49 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)48 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)43 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)42 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)38 Iterator (java.util.Iterator)36 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)35 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)35 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)32 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)30 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)28 DisplayEventCRFBean (org.akaza.openclinica.bean.submit.DisplayEventCRFBean)26 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)26