Search in sources :

Example 21 with ItemDataBean

use of org.akaza.openclinica.bean.submit.ItemDataBean 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)

Example 22 with ItemDataBean

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

the class RuleSetService method filterRuleSetsByGroupOrdinal.

/*
     * (non-Javadoc)
     * @see org.akaza.openclinica.service.rule.RuleSetServiceInterface#filterRuleSetsByGroupOrdinal(java.util.List)
     */
public List<RuleSetBean> filterRuleSetsByGroupOrdinal(List<RuleSetBean> ruleSets) {
    for (RuleSetBean ruleSetBean : ruleSets) {
        List<ExpressionBean> expressionsWithCorrectGroupOrdinal = new ArrayList<ExpressionBean>();
        for (ExpressionBean expression : ruleSetBean.getExpressions()) {
            String studyEventId = getExpressionService().getStudyEventDefinitionOrdninalCurated(expression.getValue());
            String itemOid = getExpressionService().getItemOid(expression.getValue());
            String itemGroupOid = getExpressionService().getItemGroupOid(expression.getValue());
            String groupOrdinal = getExpressionService().getGroupOrdninalCurated(expression.getValue());
            List<ItemDataBean> itemDatas = getItemDataDao().findByStudyEventAndOids(Integer.valueOf(studyEventId), itemOid, itemGroupOid);
            logger.debug("studyEventId {} , itemOid {} , itemGroupOid {} , groupOrdinal {} , itemDatas {}", new Object[] { studyEventId, itemOid, itemGroupOid, groupOrdinal, itemDatas.size() });
            // case 1 : group ordinal = ""
            if (groupOrdinal.equals("") && itemDatas.size() > 0) {
                for (int k = 0; k < itemDatas.size(); k++) {
                    ExpressionBean expBean = new ExpressionBean();
                    expBean.setValue(getExpressionService().replaceGroupOidOrdinalInExpression(expression.getValue(), k + 1));
                    expBean.setContext(expression.getContext());
                    expressionsWithCorrectGroupOrdinal.add(expBean);
                }
            }
            // case 2 : group ordinal = x and itemDatas should be size >= x
            if (!groupOrdinal.equals("") && itemDatas.size() >= Integer.valueOf(groupOrdinal)) {
                ExpressionBean expBean = new ExpressionBean();
                expBean.setValue(getExpressionService().replaceGroupOidOrdinalInExpression(expression.getValue(), null));
                expBean.setContext(expression.getContext());
                expressionsWithCorrectGroupOrdinal.add(expBean);
            }
        }
        ruleSetBean.setExpressions(expressionsWithCorrectGroupOrdinal);
    }
    logExpressions(ruleSets);
    return ruleSets;
}
Also used : ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) ArrayList(java.util.ArrayList) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) ExpressionBean(org.akaza.openclinica.domain.rule.expression.ExpressionBean)

Example 23 with ItemDataBean

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

the class ExpressionService method getItemDataBeanFromDb.

public ItemDataBean getItemDataBeanFromDb(String expression) throws OpenClinicaSystemException {
    if (isExpressionPartial(expression)) {
        throw new OpenClinicaSystemException("getItemDataBeanFromDb:We cannot get the ItemData of a PARTIAL expression : " + expression);
    }
    String studyEventId = getStudyEventDefinitionOidOrdinalFromExpression(expression);
    Integer index = getItemGroupOidOrdinalFromExpression(expression).equals("") ? 0 : Integer.valueOf(getItemGroupOidOrdinalFromExpression(expression)) - 1;
    List<ItemDataBean> itemData = getItemDataDao().findByStudyEventAndOids(Integer.valueOf(studyEventId), getItemOidFromExpression(expression), getItemGroupOidFromExpression(expression));
    ItemDataBean itemDataBean = itemData.size() > index ? itemData.get(index) : null;
    return itemDataBean;
// << tbh 04/28/2010
}
Also used : ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException)

Example 24 with ItemDataBean

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

the class ExpressionService method getValueFromDbb.

public HashMap<String, String> getValueFromDbb(String expression) throws OpenClinicaSystemException {
    HashMap<String, String> map = new HashMap<>();
    if (isExpressionPartial(expression)) {
        throw new OpenClinicaSystemException("getValueFromDb:We cannot get the Value of a PARTIAL expression : " + expression);
    }
    try {
        // Get the studyEventId from RuleSet Target so we can know which
        // StudySubject we are dealing with.
        String ruleSetExpression = expressionWrapper.getRuleSet().getTarget().getValue();
        String ruleSetExpressionStudyEventId = getStudyEventDefinitionOidOrdinalFromExpression(ruleSetExpression);
        StudyEventBean studyEvent = (StudyEventBean) getStudyEventDao().findByPK(Integer.valueOf(ruleSetExpressionStudyEventId));
        // Prepare Method arguments
        String studyEventDefinitionOid = getStudyEventDefinitionOidFromExpression(expression);
        String crfOrCrfVersionOid = getCrfOidFromExpression(expression);
        String studyEventDefinitionOrdinal = getStudyEventDefinitionOidOrdinalFromExpression(expression);
        studyEventDefinitionOrdinal = studyEventDefinitionOrdinal.equals("") ? "1" : studyEventDefinitionOrdinal;
        String studySubjectId = String.valueOf(studyEvent.getStudySubjectId());
        System.out.println("studySubjectId:  " + studySubjectId);
        logger.debug("ruleSet studyEventId  {} , studyEventDefinitionOid {} , crfOrCrfVersionOid {} , studyEventDefinitionOrdinal {} ,studySubjectId {}", new Object[] { studyEvent.getId(), studyEventDefinitionOid, crfOrCrfVersionOid, studyEventDefinitionOrdinal, studySubjectId });
        StudyEventBean studyEventofThisExpression = getStudyEventDao().findAllByStudyEventDefinitionAndCrfOidsAndOrdinal(studyEventDefinitionOid, crfOrCrfVersionOid, studyEventDefinitionOrdinal, studySubjectId);
        if (studyEvent.getId() == studyEventofThisExpression.getId())
            map.put("match", "true");
        logger.debug("studyEvent : {} , itemOid {} , itemGroupOid {}", new Object[] { studyEventofThisExpression.getId(), getItemOidFromExpression(expression), getItemGroupOidFromExpression(expression) });
        List<ItemDataBean> itemData = getItemDataDao().findByStudyEventAndOids(Integer.valueOf(studyEventofThisExpression.getId()), getItemOidFromExpression(expression), getItemGroupOidFromExpression(expression));
        expression = fixGroupOrdinal(expression, ruleSetExpression, itemData, expressionWrapper.getEventCrf());
        Integer index = getItemGroupOidOrdinalFromExpression(expression).equals("") ? 0 : Integer.valueOf(getItemGroupOidOrdinalFromExpression(expression)) - 1;
        ItemDataBean itemDataBean = itemData.get(index);
        ItemBean itemBean = (ItemBean) getItemDao().findByPK(itemDataBean.getItemId());
        String value = itemData.get(index).getValue();
        value = ifValueIsDate(itemBean, value);
        map.put("value", value);
        return map;
    } catch (Exception e) {
        return map;
    }
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) HashMap(java.util.HashMap) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException)

Example 25 with ItemDataBean

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

the class ExpressionService method getValueFromDb.

public String getValueFromDb(String expression, List<ItemDataBean> itemData) throws OpenClinicaSystemException {
    if (isExpressionPartial(expression)) {
        throw new OpenClinicaSystemException("getValueFromDb:We cannot get the Value of a PARTIAL expression : " + expression);
    }
    try {
        Integer index = getItemGroupOidOrdinalFromExpression(expression).equals("") ? 0 : Integer.valueOf(getItemGroupOidOrdinalFromExpression(expression)) - 1;
        ItemDataBean itemDataBean = itemData.get(index);
        ItemBean itemBean = (ItemBean) getItemDao().findByPK(itemDataBean.getItemId());
        String value = itemData.get(index).getValue();
        value = ifValueIsDate(itemBean, value);
        return value;
    } catch (NullPointerException npe) {
        logger.error("NullPointerException was thrown ");
        return null;
    } catch (IndexOutOfBoundsException ioobe) {
        logger.error("IndexOutOfBoundsException was thrown ");
        return null;
    }
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException)

Aggregations

ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)133 ArrayList (java.util.ArrayList)74 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)64 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)61 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)42 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)41 HashMap (java.util.HashMap)39 Date (java.util.Date)37 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)37 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)33 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)33 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)26 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)26 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)26 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)26 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)21 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)21 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)20 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)20 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)18