Search in sources :

Example 1 with SCDItemMetadataBean

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

the class SimpleConditionalDisplayService method conditionalDisplayToBeShown.

/**
 * Base on chosen option of a control item. scdItemId has to be initialized for SCDItemMetadataBean.
 * @param dib
 * @param showSCDItemIds.
 * @return
 */
public static Set<Integer> conditionalDisplayToBeShown(DisplayItemBean dib, Set<Integer> showSCDItemIds) {
    Set<Integer> showIds = showSCDItemIds;
    // a conditional display item will be always after its control item.
    ArrayList<SCDItemMetadataBean> cds = dib.getScdData().getScdSetsForControl();
    if (cds.size() > 0) {
        for (SCDItemMetadataBean cd : cds) {
            Integer scdItemId = cd.getScdItemId();
            if (scdItemId > 0) {
                if (conditionalDisplayToBeShown(dib.getData().getValue(), cd)) {
                    showIds.add(scdItemId);
                } else if (showIds.contains(scdItemId)) {
                    showIds.remove(scdItemId);
                }
            }
        }
    }
    return showIds;
}
Also used : SCDItemMetadataBean(org.akaza.openclinica.domain.crfdata.SCDItemMetadataBean)

Example 2 with SCDItemMetadataBean

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

the class SimpleConditionalDisplayService method getControlMetaIdAndSCDSetMap.

public HashMap<Integer, ArrayList<SCDItemMetadataBean>> getControlMetaIdAndSCDSetMap(int sectionId, ArrayList<SCDItemMetadataBean> scdSets) {
    HashMap<Integer, ArrayList<SCDItemMetadataBean>> cdPairMap = new HashMap<Integer, ArrayList<SCDItemMetadataBean>>();
    if (scdSets == null) {
        logger.info("SimpleConditionalDisplayService.getControlMetaIdAndSCDSetMap() ArrayList<SCDItemMetadataBean> parameter is null.");
    } else {
        for (SCDItemMetadataBean scd : scdSets) {
            Integer conId = scd.getControlItemFormMetadataId();
            ArrayList<SCDItemMetadataBean> conScds = cdPairMap.containsKey(conId) ? cdPairMap.get(conId) : new ArrayList<SCDItemMetadataBean>();
            conScds.add(scd);
            cdPairMap.put(conId, conScds);
        }
    }
    return cdPairMap;
}
Also used : SCDItemMetadataBean(org.akaza.openclinica.domain.crfdata.SCDItemMetadataBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 3 with SCDItemMetadataBean

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

the class SimpleConditionalDisplayService method initSCDItems.

public ArrayList<DisplayItemBean> initSCDItems(ArrayList<DisplayItemBean> displayItems, ArrayList<SCDItemMetadataBean> cds, Set<Integer> showSCDItemIds) {
    ArrayList<DisplayItemBean> dis = displayItems;
    HashMap<Integer, SCDItemMetadataBean> scds = (HashMap<Integer, SCDItemMetadataBean>) this.getSCDMetaIdAndSCDSetMap(cds);
    for (DisplayItemBean displayItem : dis) {
        ItemFormMetadataBean meta = displayItem.getMetadata();
        if (scds.containsKey(meta.getId())) {
            SCDItemMetadataBean scdItemMetadataBean = scds.get(meta.getId());
            scdItemMetadataBean.setScdItemId(meta.getItemId());
            displayItem.getScdData().setScdItemMetadataBean(scdItemMetadataBean);
        }
        if (meta.getParentId() < 1) {
            ArrayList<DisplayItemBean> cs = displayItem.getChildren();
            for (DisplayItemBean c : cs) {
                ItemFormMetadataBean cmeta = c.getMetadata();
                if (scds.containsKey(cmeta.getId())) {
                    SCDItemMetadataBean scdItemMetadataBean = scds.get(cmeta.getId());
                    scdItemMetadataBean.setScdItemId(cmeta.getItemId());
                    c.getScdData().setScdItemMetadataBean(scdItemMetadataBean);
                }
            }
        }
    }
    return dis;
}
Also used : SCDItemMetadataBean(org.akaza.openclinica.domain.crfdata.SCDItemMetadataBean) HashMap(java.util.HashMap) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Aggregations

SCDItemMetadataBean (org.akaza.openclinica.domain.crfdata.SCDItemMetadataBean)3 HashMap (java.util.HashMap)2 ArrayList (java.util.ArrayList)1 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)1 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)1