Search in sources :

Example 76 with ItemFormMetadataBean

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

the class OpenRosaXmlGenerator method getItemFormMetadata.

@SuppressWarnings("rawtypes")
private ItemFormMetadataBean getItemFormMetadata(ItemBean item, CRFVersionBean crfVersion) throws Exception {
    ItemFormMetadataBean itemFormMetadataBean = null;
    ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(dataSource);
    itemFormMetadataBean = ifmdao.findByItemIdAndCRFVersionId(item.getId(), crfVersion.getId());
    return itemFormMetadataBean;
}
Also used : ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO)

Example 77 with ItemFormMetadataBean

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

the class OpenRosaXmlGenerator method getItemFormMetadataBeanById.

@SuppressWarnings({ "unused", "rawtypes" })
private ItemFormMetadataBean getItemFormMetadataBeanById(Integer id) throws OpenClinicaException {
    itemFormMetadataDAO = new ItemFormMetadataDAO(dataSource);
    ItemFormMetadataBean itemFormMetadataBean = (ItemFormMetadataBean) itemFormMetadataDAO.findByPK(id);
    return itemFormMetadataBean;
}
Also used : ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 78 with ItemFormMetadataBean

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

the class OpenRosaXmlGenerator method mapBeansToDTO.

/**
 * @param html
 * @param crf
 * @param crfVersion
 * @param crfSections
 * @return
 * @throws Exception
 */
private Integer mapBeansToDTO(Html html, CRFBean crf, CRFVersionBean crfVersion, ArrayList<SectionBean> crfSections) throws Exception {
    boolean expressionEvaluate = true;
    int sectionCount = 0;
    ItemFormMetadataBean itemFormMetadataBean = null;
    Body body = html.getBody();
    ArrayList<Group> allSections = new ArrayList<Group>();
    ArrayList<Bind> bindList = new ArrayList<Bind>();
    WidgetFactory factory = new WidgetFactory(crfVersion);
    html.getHead().setTitle(crf.getName());
    for (SectionBean section : crfSections) {
        ArrayList<Group> groups = new ArrayList<Group>();
        Group singleSection = new Group();
        singleSection.setUsercontrol(new ArrayList<UserControl>());
        String ref = "/" + crfVersion.getOid() + "/" + "SECTION_" + section.getLabel().replaceAll("\\W", "_");
        singleSection.setRef(ref);
        String sectionExpression = null;
        igdao = new ItemGroupDAO(dataSource);
        ArrayList<ItemGroupBean> groupBeans = (ArrayList<ItemGroupBean>) igdao.findGroupBySectionId(section.getId());
        int count = 0;
        if (groupBeans.size() > 0) {
            for (ItemGroupBean groupBean : groupBeans) {
                ExpressionExpressionEvaluate eev = getSkipPattern(null, groupBean);
                String expr = eev.getExpression();
                expressionEvaluate = eev.isExpressionEvaluate();
                if (expr != null) {
                    if (sectionExpression != null) {
                        sectionExpression = sectionExpression + " and " + expr;
                        count++;
                    } else {
                        sectionExpression = expr;
                        count++;
                    }
                }
            }
            if (sectionExpression != null && groupBeans.size() == count) {
                sectionExpression = getFullExpressionToParse(sectionExpression, crfVersion, expressionEvaluate);
            } else {
                sectionExpression = null;
            }
            setSectionWidget(section, crfVersion, sectionExpression, bindList, factory, singleSection);
            HashMap<String, Object> groupMap = null;
            boolean isGroupRepeating = false;
            Group group = null;
            Repeat repeat = null;
            idao = new ItemDAO(dataSource);
            ArrayList<ItemBean> items = (ArrayList<ItemBean>) idao.findAllBySectionIdOrderedByItemFormMetadataOrdinal(section.getId());
            Integer itemGroupId = 0;
            for (ItemBean item : items) {
                ItemGroupBean itemGroupBean = getItemGroupBeanByItemId(item.getId());
                if (itemGroupId != itemGroupBean.getId()) {
                    groupMap = getGroupInfo(itemGroupBean, crfVersion, section, factory, bindList);
                    isGroupRepeating = (Boolean) groupMap.get("isGroupRepeating");
                    group = (Group) groupMap.get("group");
                    repeat = (Repeat) groupMap.get("repeat");
                }
                itemFormMetadataBean = getItemFormMetadata(item, crfVersion);
                int responseTypeId = itemFormMetadataBean.getResponseSet().getResponseTypeId();
                boolean isItemRequired = itemFormMetadataBean.isRequired();
                String responseLayout = itemFormMetadataBean.getResponseLayout();
                String itemExpression = null;
                ExpressionExpressionEvaluate eev = getSkipPattern(item, itemGroupBean);
                itemExpression = eev.getExpression();
                expressionEvaluate = eev.isExpressionEvaluate();
                if (itemExpression != null)
                    itemExpression = getFullExpressionToParse(itemExpression, crfVersion, expressionEvaluate);
                // Add the Item Header
                setHeaderWidget(item, itemFormMetadataBean, itemGroupBean, bindList, factory, isGroupRepeating, repeat, group, itemExpression);
                // Add the Item SubHeader
                setSubHeaderWidget(item, itemFormMetadataBean, itemGroupBean, bindList, factory, isGroupRepeating, repeat, group, itemExpression);
                // Add the Item itself
                setItemWidget(item, responseTypeId, itemFormMetadataBean, itemGroupBean, bindList, factory, isGroupRepeating, repeat, group, isItemRequired, responseLayout, itemExpression);
                if (itemGroupId != itemGroupBean.getId()) {
                    groups.add(group);
                    itemGroupId = itemGroupBean.getId();
                }
            }
            // end of item loop
            singleSection.setGroup(groups);
            allSections.add(singleSection);
        }
        // end of groups per section if exist
        sectionCount = allSections.size();
    }
    // end of section loop
    body.setGroup(allSections);
    html.getHead().getModel().setBind(bindList);
    return sectionCount;
}
Also used : Group(org.akaza.openclinica.web.pform.dto.Group) Bind(org.akaza.openclinica.web.pform.dto.Bind) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) ArrayList(java.util.ArrayList) ItemGroupDAO(org.akaza.openclinica.dao.submit.ItemGroupDAO) Repeat(org.akaza.openclinica.web.pform.dto.Repeat) UserControl(org.akaza.openclinica.web.pform.dto.UserControl) Body(org.akaza.openclinica.web.pform.dto.Body) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) WidgetFactory(org.akaza.openclinica.web.pform.widget.WidgetFactory) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 79 with ItemFormMetadataBean

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

the class OpenRosaXmlGenerator method getFullExpressionToParse.

/**
 * This method is for Skip pattern to build multiple expressions (not complete yet)
 *
 * @param expression
 * @param version
 * @return
 */
private String getFullExpressionToParse(String expression, CRFVersionBean version, boolean expressionEvaluates) throws Exception {
    String result = "";
    expression = " " + expression;
    expression = expression.replaceAll("\\(", "\\( ");
    expression = expression.replaceAll("_CURRENT_DATE", "today()");
    /*
         * today() function returns date and time and will not work with 'eq' operator. But it will work with 'gt' or
         * 'lt' operators
         */
    expression = expression.replaceAll(" I_", " ../I_");
    expression = expression.replaceAll("\\S*/I_", " ../I_");
    expression = expression.replaceAll(" eq ", " = ");
    // convert contains
    expression = expression.replaceAll(" ct ", " = ");
    expression = expression.replaceAll(" ne ", " != ");
    expression = expression.replaceAll(" gt ", " > ");
    expression = expression.replaceAll(" gte ", " >= ");
    expression = expression.replaceAll(" lt ", " < ");
    expression = expression.replaceAll(" lte ", " <= ");
    if (expressionEvaluates == false) {
        expression = "not(" + expression + ")";
    }
    /*
         * This statement will remove all (SE_ , F_, IG_) entities and will leave only Item_Oid entities. And will
         * neglect the whole path
         */
    String[] exprs = expression.split(" ");
    boolean byPass = false;
    String tempExpr = "";
    for (String expr : exprs) {
        if (expr.contains("../I_")) {
            String itemOid = expr.substring(3);
            logger.info("itemOid:  " + itemOid);
            ItemBean itemBean = getItemBean(itemOid);
            ItemGroupBean itemGroupBean = getItemGroupBeanByItemId(itemBean.getId());
            itemFormMetadataDAO = new ItemFormMetadataDAO(dataSource);
            ItemFormMetadataBean ifmBean = (ItemFormMetadataBean) itemFormMetadataDAO.findByItemIdAndCRFVersionId(itemBean.getId(), version.getId());
            if (ifmBean.getResponseSet().getResponseTypeId() == 3 || ifmBean.getResponseSet().getResponseTypeId() == 7) {
                byPass = true;
                tempExpr = expr;
            }
            expr = "/" + version.getOid() + "/" + itemGroupBean.getOid() + "/" + itemOid;
        }
        if (byPass && tempExpr.contains("../I_")) {
            tempExpr = expr;
        } else if (byPass && expr.equals("=")) {
            tempExpr = "selected (" + tempExpr + " , ";
        } else if (byPass && expr.equals("!=")) {
            tempExpr = " not selected (" + tempExpr + " , ";
        } else if (byPass && (expr.equals(">") || expr.equals(">=") || expr.equals("<") || expr.equals("<="))) {
            tempExpr = tempExpr + " " + expr;
            result = result + " " + tempExpr;
            byPass = false;
        } else if (byPass && !expr.contains("../I_") && !expr.equals("!=") && !expr.equals("=") && !expr.equals(">") && !expr.equals(">=") && !expr.equals("<") && !expr.equals("<=")) {
            tempExpr = tempExpr + " " + expr + " ) ";
            result = result + " " + tempExpr;
            byPass = false;
        } else {
            result = result + " " + expr;
        }
    }
    logger.info("Full Expression is:  " + result);
    return result;
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 80 with ItemFormMetadataBean

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

the class ResolveDiscrepancyServlet method prepareRequestForResolution.

public boolean prepareRequestForResolution(HttpServletRequest request, DataSource ds, StudyBean currentStudy, DiscrepancyNoteBean note, boolean isCompleted) {
    String entityType = note.getEntityType().toLowerCase();
    int id = note.getEntityId();
    if ("subject".equalsIgnoreCase(entityType)) {
        StudySubjectDAO ssdao = new StudySubjectDAO(ds);
        StudySubjectBean ssb = ssdao.findBySubjectIdAndStudy(id, currentStudy);
        request.setAttribute("action", "show");
        request.setAttribute("id", String.valueOf(note.getEntityId()));
        request.setAttribute("studySubId", String.valueOf(ssb.getId()));
    } else if ("studysub".equalsIgnoreCase(entityType)) {
        request.setAttribute("action", "show");
        request.setAttribute("id", String.valueOf(note.getEntityId()));
    } else if ("eventcrf".equalsIgnoreCase(entityType)) {
        request.setAttribute("editInterview", "1");
        EventCRFDAO ecdao = new EventCRFDAO(ds);
        EventCRFBean ecb = (EventCRFBean) ecdao.findByPK(id);
        request.setAttribute(TableOfContentsServlet.INPUT_EVENT_CRF_BEAN, ecb);
        // If the request is passed along to ViewSectionDataEntryServlet,
        // that code needs
        // an event crf id; the (ecb.getId()+"") is necessary because
        // FormProcessor throws
        // a ClassCastException without the casting to a String
        request.setAttribute(ViewSectionDataEntryServlet.EVENT_CRF_ID, ecb.getId() + "");
    } else if ("studyevent".equalsIgnoreCase(entityType)) {
        StudyEventDAO sedao = new StudyEventDAO(ds);
        StudyEventBean seb = (StudyEventBean) sedao.findByPK(id);
        request.setAttribute(EnterDataForStudyEventServlet.INPUT_EVENT_ID, String.valueOf(id));
        request.setAttribute(UpdateStudyEventServlet.EVENT_ID, String.valueOf(id));
        request.setAttribute(UpdateStudyEventServlet.STUDY_SUBJECT_ID, String.valueOf(seb.getStudySubjectId()));
    } else // this is for item data
    if ("itemdata".equalsIgnoreCase(entityType)) {
        ItemDataDAO iddao = new ItemDataDAO(ds);
        ItemDataBean idb = (ItemDataBean) iddao.findByPK(id);
        EventCRFDAO ecdao = new EventCRFDAO(ds);
        EventCRFBean ecb = (EventCRFBean) ecdao.findByPK(idb.getEventCRFId());
        StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
        StudySubjectBean ssb = (StudySubjectBean) ssdao.findByPK(ecb.getStudySubjectId());
        ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(ds);
        ItemFormMetadataBean ifmb = ifmdao.findByItemIdAndCRFVersionId(idb.getItemId(), ecb.getCRFVersionId());
        if (currentRole.getRole().equals(Role.MONITOR) || !isCompleted) {
            StudyEventDAO sedao = new StudyEventDAO(ds);
            StudyEventBean seb = (StudyEventBean) sedao.findByPK(id);
            request.setAttribute(EVENT_CRF_ID, String.valueOf(idb.getEventCRFId()));
            request.setAttribute(STUDY_SUB_ID, String.valueOf(seb.getStudySubjectId()));
        } else {
            request.setAttribute(DataEntryServlet.INPUT_EVENT_CRF_ID, String.valueOf(idb.getEventCRFId()));
            request.setAttribute(DataEntryServlet.INPUT_SECTION_ID, String.valueOf(ifmb.getSectionId()));
        }
        DataEntryStage stage = ecb.getStage();
    // if (!stage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE)) {
    // return false;
    // }
    }
    return true;
}
Also used : StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) DataEntryStage(org.akaza.openclinica.bean.core.DataEntryStage) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Aggregations

ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)93 ArrayList (java.util.ArrayList)58 HashMap (java.util.HashMap)36 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)36 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)28 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)26 ItemFormMetadataDAO (org.akaza.openclinica.dao.submit.ItemFormMetadataDAO)25 DynamicsItemFormMetadataBean (org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean)25 Iterator (java.util.Iterator)21 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)18 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)16 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)16 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)14 ItemGroupMetadataBean (org.akaza.openclinica.bean.submit.ItemGroupMetadataBean)13 DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)12 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)12 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)9 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)9 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)8 ResponseSetBean (org.akaza.openclinica.bean.submit.ResponseSetBean)8