Search in sources :

Example 76 with ItemBean

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

the class ItemDAO method findAllActiveByCRF.

public ArrayList findAllActiveByCRF(CRFBean crf) {
    HashMap variables = new HashMap();
    this.setTypesExpected();
    // crf_version_id
    this.setTypeExpected(14, TypeNames.INT);
    // version name
    this.setTypeExpected(15, TypeNames.STRING);
    variables.put(new Integer(1), new Integer(crf.getId()));
    String sql = digester.getQuery("findAllActiveByCRF");
    ArrayList alist = this.select(sql, variables);
    ArrayList al = new ArrayList();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        HashMap hm = (HashMap) it.next();
        ItemBean eb = (ItemBean) this.getEntityFromHashMap(hm);
        Integer versionId = (Integer) hm.get("crf_version_id");
        String versionName = (String) hm.get("cvname");
        ItemFormMetadataBean imf = new ItemFormMetadataBean();
        imf.setCrfVersionName(versionName);
        // logger.info("versionName" + imf.getCrfVersionName());
        imf.setCrfVersionId(versionId.intValue());
        eb.setItemMeta(imf);
        al.add(eb);
    }
    return al;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 77 with ItemBean

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

the class ItemDAO method findAllItemsByGroupId.

public List<ItemBean> findAllItemsByGroupId(int id, int crfVersionId) {
    this.setTypesExpected();
    HashMap<Integer, Integer> variables = new HashMap<Integer, Integer>();
    variables.put(1, id);
    variables.put(2, crfVersionId);
    String sql = digester.getQuery("findAllItemsByGroupId");
    List listofMaps = this.select(sql, variables);
    List<ItemBean> beanList = new ArrayList<ItemBean>();
    ItemBean bean;
    for (Object map : listofMaps) {
        bean = (ItemBean) this.getEntityFromHashMap((HashMap) map);
        beanList.add(bean);
    }
    return beanList;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 78 with ItemBean

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

the class ItemDAO method findAllItemsByGroupIdAndSectionIdOrdered.

public List<ItemBean> findAllItemsByGroupIdAndSectionIdOrdered(int id, int crfVersionId, int sectionId) {
    this.setTypesExpected();
    HashMap<Integer, Integer> variables = new HashMap<Integer, Integer>();
    variables.put(1, id);
    variables.put(2, sectionId);
    variables.put(3, crfVersionId);
    String sql = digester.getQuery("findAllItemsByGroupIdAndSectionIdOrdered");
    List listofMaps = this.select(sql, variables);
    List<ItemBean> beanList = new ArrayList<ItemBean>();
    ItemBean bean;
    for (Object map : listofMaps) {
        bean = (ItemBean) this.getEntityFromHashMap((HashMap) map);
        beanList.add(bean);
    }
    return beanList;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 79 with ItemBean

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

the class GenerateExtractFileService method createSPSSFile.

/**
     * createSPSSFile, added by tbh, 01/2009
     *
     * @param db
     * @param eb
     * @param currentstudyid
     * @param parentstudy
     * @return
     */
public HashMap<String, Integer> createSPSSFile(DatasetBean db, ExtractBean eb2, StudyBean currentStudy, StudyBean parentStudy, long sysTimeBegin, String generalFileDir, SPSSReportBean answer, String generalFileDirCopy, UserAccountBean userBean) {
    setUpResourceBundles();
    String SPSSFileName = db.getName() + "_data_spss.dat";
    String DDLFileName = db.getName() + "_ddl_spss.sps";
    String ZIPFileName = db.getName() + "_spss";
    SPSSVariableNameValidator svnv = new SPSSVariableNameValidator();
    answer.setDatFileName(SPSSFileName);
    // DatasetDAO dsdao = new DatasetDAO(ds);
    // create the extract bean here, tbh
    // ExtractBean eb = this.generateExtractBean(db, currentStudy,
    // parentStudy);
    // eb = dsdao.getDatasetData(eb, currentStudy.getId(),
    // parentStudy.getId());
    // eb.getMetadata();
    // eb.computeReport(answer);
    // set up items here to get
    answer.setItems(eb2.getItemNames());
    // itemMetadata
    // set up response sets for each item here
    ItemDAO itemdao = new ItemDAO(ds);
    ItemFormMetadataDAO imfdao = new ItemFormMetadataDAO(ds);
    ArrayList items = answer.getItems();
    for (int i = 0; i < items.size(); i++) {
        DisplayItemHeaderBean dih = (DisplayItemHeaderBean) items.get(i);
        ItemBean item = dih.getItem();
        ArrayList metas = imfdao.findAllByItemId(item.getId());
        // for (int h = 0; h < metas.size(); h++) {
        // ItemFormMetadataBean ifmb = (ItemFormMetadataBean)
        // metas.get(h);
        // logger.info("group name found:
        // "+ifmb.getGroupLabel());
        // }
        // logger.info("crf versionname" +
        // meta.getCrfVersionName());
        item.setItemMetas(metas);
    }
    HashMap eventDescs = new HashMap<String, String>();
    eventDescs = eb2.getEventDescriptions();
    eventDescs.put("SubjID", resword.getString("study_subject_ID"));
    eventDescs.put("ProtocolID", resword.getString("protocol_ID_site_ID"));
    eventDescs.put("DOB", resword.getString("date_of_birth"));
    eventDescs.put("YOB", resword.getString("year_of_birth"));
    eventDescs.put("Gender", resword.getString("gender"));
    answer.setDescriptions(eventDescs);
    ArrayList generatedReports = new ArrayList<String>();
    try {
        // YW <<
        generatedReports.add(answer.getMetadataFile(svnv, eb2).toString());
        generatedReports.add(answer.getDataFile().toString());
    // YW >>
    } catch (IndexOutOfBoundsException i) {
        generatedReports.add(answer.getMetadataFile(svnv, eb2).toString());
        logger.debug("throw the error here");
    }
    long sysTimeEnd = System.currentTimeMillis() - sysTimeBegin;
    ArrayList titles = new ArrayList();
    // YW <<
    titles.add(DDLFileName);
    titles.add(SPSSFileName);
    // YW >>
    // create new createFile method that accepts array lists to
    // put into zip files
    int fId = this.createFile(ZIPFileName, titles, generalFileDir, generatedReports, db, sysTimeEnd, ExportFormatBean.TXTFILE, true, userBean);
    if (!"".equals(generalFileDirCopy)) {
        int fId2 = this.createFile(ZIPFileName, titles, generalFileDirCopy, generatedReports, db, sysTimeEnd, ExportFormatBean.TXTFILE, false, userBean);
    }
    // return DDLFileName;
    HashMap answerMap = new HashMap<String, Integer>();
    answerMap.put(DDLFileName, new Integer(fId));
    return answerMap;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) HashMap(java.util.HashMap) SPSSVariableNameValidator(org.akaza.openclinica.bean.extract.SPSSVariableNameValidator) ArrayList(java.util.ArrayList) DisplayItemHeaderBean(org.akaza.openclinica.bean.extract.DisplayItemHeaderBean) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO)

Example 80 with ItemBean

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

the class DynamicsMetadataService method showNew.

public void showNew(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);
            }
            logger.debug("** found item data beans: " + itemDataBeans.toString());
            for (ItemDataBean oidBasedItemData : itemDataBeans) {
                ItemFormMetadataBean itemFormMetadataBean = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemBeanB.getId(), eventCrfBeanB.getCRFVersionId());
                DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBeanA, oidBasedItemData);
                if (dynamicsMetadataBean == null) {
                    showItem(itemFormMetadataBean, eventCrfBeanA, oidBasedItemData);
                // itemsAlreadyShown.add(new Integer(oidBasedItemData.getId()));
                } else if (dynamicsMetadataBean != null && !dynamicsMetadataBean.isShowItem()) {
                    dynamicsMetadataBean.setShowItem(true);
                    getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
                // itemsAlreadyShown.add(new Integer(oidBasedItemData.getId()));
                } else if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
                    logger.debug("hit DDE here: idb " + oidBasedItemData.getId());
                    // need a guard clause to guarantee DDE
                    // if we get there, it means that we've hit DDE and the bean exists
                    //setVersion(1);// version 1 = passed DDE
                    dynamicsMetadataBean.setPassedDde(1);
                    getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
                }
            }
        } else // OID is a group
        {
            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) {
                            showGroup(itemGroupMetadataBean, eventCrfBeanA);
                        } else if (dynamicsGroupBean != null && !dynamicsGroupBean.isShowGroup()) {
                            dynamicsGroupBean.setShowGroup(true);
                            getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
                        } else if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
                            //setVersion(1); // version 1 = passed DDE
                            dynamicsGroupBean.setPassedDde(1);
                            getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
                        }
                    }
                }
            }
        }
    }
}
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)

Aggregations

ItemBean (org.akaza.openclinica.bean.submit.ItemBean)132 ArrayList (java.util.ArrayList)77 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)56 HashMap (java.util.HashMap)50 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)43 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)42 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)36 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)26 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)25 Iterator (java.util.Iterator)23 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)22 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)22 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)21 ItemFormMetadataDAO (org.akaza.openclinica.dao.submit.ItemFormMetadataDAO)20 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)15 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)15 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)15 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)13 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)13 DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)13