Search in sources :

Example 1 with ItemPresentInFormBean

use of org.akaza.openclinica.bean.odmbeans.ItemPresentInFormBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method getMetadataOC1_3.

public void getMetadataOC1_3(int parentStudyId, int studyId, MetaDataVersionBean metadata, String odmVersion) {
    this.getOCMetadata(parentStudyId, studyId, metadata, odmVersion);
    // StudyBean study = metadata.getStudy();
    // if(study.getId()>0) {
    // } else {
    // StudyDAO sdao = new StudyDAO(this.ds);
    // study = (StudyBean)sdao.findByPK(studyId);
    // }
    // StudyConfigService studyConfig = new StudyConfigService(this.ds);
    // study = studyConfig.setParametersForStudy(study);
    this.getStudyEventAndFormMetaOC1_3(parentStudyId, studyId, metadata, odmVersion, false);
    String cvIds = metadata.getCvIds();
    ArrayList<ItemGroupDefBean> igs = (ArrayList<ItemGroupDefBean>) metadata.getItemGroupDefs();
    HashMap<String, Integer> igPoses = getItemGroupOIDPos(metadata);
    ArrayList<ItemDefBean> its = (ArrayList<ItemDefBean>) metadata.getItemDefs();
    HashMap<String, Integer> itPoses = getItemOIDPos(metadata);
    HashMap<String, Integer> inPoses = new HashMap<String, Integer>();
    ItemGroupDefBean ig = new ItemGroupDefBean();
    ItemDefBean it = new ItemDefBean();
    String prevCvIg = "";
    HashMap<Integer, String> sectionLabels = this.getSectionLabels(metadata.getSectionIds());
    HashMap<Integer, String> parentItemOIDs = this.getParentItemOIDs(cvIds);
    this.setItemGroupAndItemMetaOC1_3TypesExpected();
    logger.debug("Begin to execute GetItemGroupAndItemMetaWithUnitSql");
    logger.debug("getItemGroupandItemMetaWithUnitsql= " + this.getItemGroupAndItemMetaOC1_3Sql(cvIds));
    ArrayList rows = select(this.getItemGroupAndItemMetaOC1_3Sql(cvIds));
    Iterator iter = rows.iterator();
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        // Integer cId = (Integer) row.get("crf_id");
        Integer cvId = (Integer) row.get("crf_version_id");
        Integer igId = (Integer) row.get("item_group_id");
        // Integer itId = (Integer) row.get("item_id");
        // Integer rsId = (Integer) row.get("response_set_id");
        String cvOID = (String) row.get("crf_version_oid");
        String igOID = (String) row.get("item_group_oid");
        String itOID = (String) row.get("item_oid");
        Integer igRepeatNum = (Integer) row.get("repeat_number");
        Integer igRepeatMax = (Integer) row.get("repeat_max");
        Boolean showGroup = (Boolean) row.get("show_group");
        String itemGroupHeader = (String) row.get("item_group_header");
        String itHeader = (String) row.get("item_header");
        String left = (String) row.get("left_item_text");
        String right = (String) row.get("right_item_text");
        String itSubheader = (String) row.get("subheader");
        Integer itSecId = (Integer) row.get("section_id");
        Integer itPId = (Integer) row.get("parent_id");
        Integer itColNum = (Integer) row.get("column_number");
        String itpgNum = (String) row.get("page_number_label");
        String layout = (String) row.get("response_layout");
        Integer rsTypeId = (Integer) row.get("response_type_id");
        String dfValue = (String) row.get("default_value");
        Boolean phi = (Boolean) row.get("phi_status");
        Boolean showItem = (Boolean) row.get("show_item");
        Integer orderInForm = (Integer) row.get("item_order");
        if ((cvId + "-" + igId).equals(prevCvIg)) {
        } else {
            prevCvIg = cvId + "-" + igId;
            ig = igs.get(igPoses.get(igOID));
            ItemGroupDetailsBean igDetail = ig.getItemGroupDetails();
            igDetail.setOid(igOID);
            PresentInFormBean inForm = new PresentInFormBean();
            inForm.setFormOid(cvOID);
            ItemGroupRepeatBean igr = new ItemGroupRepeatBean();
            igr.setRepeatMax(igRepeatMax);
            igr.setRepeatNumber(igRepeatNum);
            inForm.setItemGroupRepeatBean(igr);
            inForm.setShowGroup(showGroup == true ? "Yes" : "No");
            inForm.setItemGroupHeader(itemGroupHeader);
            igDetail.getPresentInForms().add(inForm);
        }
        it = its.get(itPoses.get(itOID));
        ItemDetailsBean itDetail = it.getItemDetails();
        itDetail.setOid(itOID);
        ItemPresentInFormBean itInForm = new ItemPresentInFormBean();
        itInForm.setFormOid(cvOID);
        itInForm.setColumnNumber(itColNum);
        itInForm.setDefaultValue(dfValue);
        itInForm.setItemHeader(itHeader);
        itInForm.setLeftItemText(left);
        itInForm.setRightItemText(right);
        itInForm.setItemSubHeader(itSubheader);
        itInForm.setPageNumber(itpgNum);
        itInForm.setParentItemOid(parentItemOIDs.get(itPId));
        itInForm.setSectionLabel(sectionLabels.get(itSecId));
        itInForm.setPhi(phi == false ? "No" : "Yes");
        itInForm.setOrderInForm(orderInForm);
        itInForm.setShowItem(showItem == true ? "Yes" : "No");
        ItemResponseBean itemResponse = new ItemResponseBean();
        itemResponse.setResponseLayout(layout);
        itemResponse.setResponseType(ResponseType.get(rsTypeId).getName());
        itInForm.setItemResponse(itemResponse);
        itDetail.getItemPresentInForm().add(itInForm);
        inPoses.put(itOID + "-" + cvOID, itDetail.getItemPresentInForm().size() - 1);
    }
    this.getSCDs(cvIds, its, itPoses, inPoses);
}
Also used : ItemGroupDefBean(org.akaza.openclinica.bean.odmbeans.ItemGroupDefBean) ItemGroupDetailsBean(org.akaza.openclinica.bean.odmbeans.ItemGroupDetailsBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) ItemGroupRepeatBean(org.akaza.openclinica.bean.odmbeans.ItemGroupRepeatBean) ItemPresentInFormBean(org.akaza.openclinica.bean.odmbeans.ItemPresentInFormBean) Iterator(java.util.Iterator) ItemDefBean(org.akaza.openclinica.bean.odmbeans.ItemDefBean) ItemResponseBean(org.akaza.openclinica.bean.odmbeans.ItemResponseBean) ItemPresentInFormBean(org.akaza.openclinica.bean.odmbeans.ItemPresentInFormBean) PresentInFormBean(org.akaza.openclinica.bean.odmbeans.PresentInFormBean) ItemDetailsBean(org.akaza.openclinica.bean.odmbeans.ItemDetailsBean)

Example 2 with ItemPresentInFormBean

use of org.akaza.openclinica.bean.odmbeans.ItemPresentInFormBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method getODMMetadataForForm.

/**
     * Metadata to be obtained based on formVersionOID. The studyOID and studyEventOID are irrelevant as these are the
     * global crfs, i.e crfs that do not belong to
     * any particular CRF. In order to comply with cdisc ODM, the studyOID, studyeventDefOID etc will be static values
     * which do not exist in the database.
     * 
     * @param metadata
     * @param formVersionOID
     */
// The method underneath tries to reuse the code based on getODMMetadata
public void getODMMetadataForForm(MetaDataVersionBean metadata, String formOID, String odmVersion) {
    FormDefBean formDef = new FormDefBean();
    String cvIds = new String("");
    CRFBean crfBean = crfdao.findByOid(formOID);
    List<CRFVersionBean> crfVersions = (List<CRFVersionBean>) cvdao.findAllActiveByCRF(crfBean.getId());
    CRFVersionBean crfVersionBean = crfVersions.get(0);
    cvIds = crfVersionBean.getId() + "";
    applyStudyEventDef(metadata, formOID);
    fetchItemGroupMetaData(metadata, cvIds, odmVersion);
    getOCMetadataForGlobals(crfVersionBean.getId(), metadata, odmVersion);
    ArrayList rows = new ArrayList();
    ArrayList<ItemGroupDefBean> igs = (ArrayList<ItemGroupDefBean>) metadata.getItemGroupDefs();
    HashMap<String, Integer> igPoses = getItemGroupOIDPos(metadata);
    ArrayList<ItemDefBean> its = (ArrayList<ItemDefBean>) metadata.getItemDefs();
    HashMap<String, Integer> itPoses = getItemOIDPos(metadata);
    HashMap<String, Integer> inPoses = new HashMap<String, Integer>();
    ItemGroupDefBean ig = new ItemGroupDefBean();
    Iterator it;
    metadata.setCvIds(cvIds);
    HashMap<Integer, Integer> maxLengths = new HashMap<Integer, Integer>();
    this.setItemDataMaxLengthTypesExpected();
    rows.clear();
    logger.debug("Begin to execute GetItemDataMaxLengths");
    rows = select(this.getItemDataMaxLengths(cvIds));
    it = rows.iterator();
    while (it.hasNext()) {
        HashMap row = (HashMap) it.next();
        maxLengths.put((Integer) row.get("item_id"), (Integer) row.get("max_length"));
    }
    ItemDefBean itDef = new ItemDefBean();
    formDef = fetchFormDetails(crfBean, formDef);
    this.setItemGroupAndItemMetaWithUnitTypesExpected();
    rows.clear();
    String prevCvIg = "";
    logger.debug("Begin to execute GetItemGroupAndItemMetaWithUnitSql");
    logger.debug("getItemGroupandItemMetaWithUnitsql= " + this.getItemGroupAndItemMetaWithUnitSql(cvIds));
    HashMap<Integer, String> sectionLabels = this.getSectionLabels(metadata.getSectionIds());
    HashMap<Integer, String> parentItemOIDs = this.getParentItemOIDs(cvIds);
    this.setItemGroupAndItemMetaOC1_3TypesExpected();
    logger.debug("Begin to execute GetItemGroupAndItemMetaWithUnitSql");
    logger.debug("getItemGroupandItemMetaWithUnitsql= " + this.getItemGroupAndItemMetaOC1_3Sql(cvIds));
    rows = select(this.getItemGroupAndItemMetaOC1_3Sql(cvIds));
    Iterator iter = rows.iterator();
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        Integer cvId = (Integer) row.get("crf_version_id");
        Integer igId = (Integer) row.get("item_group_id");
        String cvOID = (String) row.get("crf_version_oid");
        String igOID = (String) row.get("item_group_oid");
        String itOID = (String) row.get("item_oid");
        Integer igRepeatNum = (Integer) row.get("repeat_number");
        Integer igRepeatMax = (Integer) row.get("repeat_max");
        Boolean showGroup = (Boolean) row.get("show_group");
        String itemGroupHeader = (String) row.get("item_group_header");
        String itHeader = (String) row.get("item_header");
        String left = (String) row.get("left_item_text");
        String right = (String) row.get("right_item_text");
        String itSubheader = (String) row.get("subheader");
        Integer itSecId = (Integer) row.get("section_id");
        Integer itPId = (Integer) row.get("parent_id");
        Integer itColNum = (Integer) row.get("column_number");
        String itpgNum = (String) row.get("page_number_label");
        String layout = (String) row.get("response_layout");
        Integer rsTypeId = (Integer) row.get("response_type_id");
        String dfValue = (String) row.get("default_value");
        Boolean phi = (Boolean) row.get("phi_status");
        Boolean showItem = (Boolean) row.get("show_item");
        Integer orderInForm = (Integer) row.get("item_order");
        if ((cvId + "-" + igId).equals(prevCvIg)) {
        } else {
            prevCvIg = cvId + "-" + igId;
            ig = igs.get(igPoses.get(igOID));
            ItemGroupDetailsBean igDetail = ig.getItemGroupDetails();
            igDetail.setOid(igOID);
            PresentInFormBean inForm = new PresentInFormBean();
            inForm.setFormOid(cvOID);
            ItemGroupRepeatBean igr = new ItemGroupRepeatBean();
            igr.setRepeatMax(igRepeatMax);
            igr.setRepeatNumber(igRepeatNum);
            inForm.setItemGroupRepeatBean(igr);
            inForm.setShowGroup(showGroup == true ? "Yes" : "No");
            inForm.setItemGroupHeader(itemGroupHeader);
            igDetail.getPresentInForms().add(inForm);
            ig.setItemGroupDetails(igDetail);
        }
        itDef = its.get(itPoses.get(itOID));
        ItemDetailsBean itDetail = itDef.getItemDetails();
        itDetail.setOid(itOID);
        ItemPresentInFormBean itInForm = new ItemPresentInFormBean();
        itInForm.setFormOid(cvOID);
        itInForm.setColumnNumber(itColNum);
        itInForm.setDefaultValue(dfValue);
        itInForm.setItemHeader(itHeader);
        itInForm.setLeftItemText(left);
        itInForm.setRightItemText(right);
        itInForm.setItemSubHeader(itSubheader);
        itInForm.setPageNumber(itpgNum);
        itInForm.setParentItemOid(parentItemOIDs.get(itPId));
        itInForm.setSectionLabel(sectionLabels.get(itSecId));
        itInForm.setPhi(phi == false ? "No" : "Yes");
        itInForm.setOrderInForm(orderInForm);
        itInForm.setShowItem(showItem == true ? "Yes" : "No");
        ItemResponseBean itemResponse = new ItemResponseBean();
        itemResponse.setResponseLayout(layout);
        itemResponse.setResponseType(ResponseType.get(rsTypeId).getName());
        itInForm.setItemResponse(itemResponse);
        itDetail.getItemPresentInForm().add(itInForm);
        inPoses.put(itOID + "-" + cvOID, itDetail.getItemPresentInForm().size() - 1);
    }
    this.getSCDs(cvIds, its, itPoses, inPoses);
    metadata.getFormDefs().add(formDef);
}
Also used : ItemGroupDefBean(org.akaza.openclinica.bean.odmbeans.ItemGroupDefBean) ItemGroupDetailsBean(org.akaza.openclinica.bean.odmbeans.ItemGroupDetailsBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) FormDefBean(org.akaza.openclinica.bean.odmbeans.FormDefBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) ItemGroupRepeatBean(org.akaza.openclinica.bean.odmbeans.ItemGroupRepeatBean) ItemPresentInFormBean(org.akaza.openclinica.bean.odmbeans.ItemPresentInFormBean) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) ItemDefBean(org.akaza.openclinica.bean.odmbeans.ItemDefBean) ItemResponseBean(org.akaza.openclinica.bean.odmbeans.ItemResponseBean) ItemPresentInFormBean(org.akaza.openclinica.bean.odmbeans.ItemPresentInFormBean) PresentInFormBean(org.akaza.openclinica.bean.odmbeans.PresentInFormBean) ItemDetailsBean(org.akaza.openclinica.bean.odmbeans.ItemDetailsBean)

Example 3 with ItemPresentInFormBean

use of org.akaza.openclinica.bean.odmbeans.ItemPresentInFormBean in project OpenClinica by OpenClinica.

the class MetaDataReportBean method addItemDetails.

public void addItemDetails(ItemDetailsBean detail, String currentIndent) {
    StringBuffer xml = this.getXmlOutput();
    String indent = this.getIndent();
    String temp = "";
    Integer itemp = -1;
    ArrayList<ItemPresentInFormBean> informs = (ArrayList<ItemPresentInFormBean>) detail.getItemPresentInForm();
    xml.append(currentIndent + "<OpenClinica:ItemDetails ItemOID=\"" + StringEscapeUtils.escapeXml(detail.getOid()) + "\">");
    xml.append(nls);
    for (ItemPresentInFormBean inform : informs) {
        xml.append(currentIndent + indent + "<OpenClinica:ItemPresentInForm FormOID=\"" + inform.getFormOid() + "\"");
        temp = inform.getParentItemOid();
        xml.append(temp != null && temp.length() > 0 ? " ParentItemOID=\"" + temp + "\"" : "");
        itemp = inform.getColumnNumber();
        xml.append(itemp != null && itemp > 0 ? " ColumnNumber=\"" + itemp + "\"" : "");
        temp = inform.getPageNumber();
        xml.append(temp != null && temp.length() > 0 ? " PageNumber=\"" + StringEscapeUtils.escapeXml(temp) + "\"" : "");
        temp = inform.getDefaultValue();
        xml.append(temp != null && temp.length() > 0 ? " DefaultValue=\"" + StringEscapeUtils.escapeXml(temp) + "\"" : "");
        xml.append(" PHI=\"" + inform.getPhi() + "\" ShowItem=\"" + inform.getShowItem() + "\" OrderInForm= \"" + inform.getOrderInForm() + "\">");
        xml.append(nls);
        temp = inform.getLeftItemText();
        xml.append(temp != null && temp.length() > 0 ? currentIndent + indent + indent + "<OpenClinica:LeftItemText>" + StringEscapeUtils.escapeXml(temp) + "</OpenClinica:LeftItemText>" + nls : "");
        temp = inform.getRightItemText();
        xml.append(temp != null && temp.length() > 0 ? currentIndent + indent + indent + "<OpenClinica:RightItemText>" + StringEscapeUtils.escapeXml(temp) + "</OpenClinica:RightItemText>" + nls : "");
        temp = inform.getItemHeader();
        xml.append(temp != null && temp.length() > 0 ? currentIndent + indent + indent + "<OpenClinica:ItemHeader>" + StringEscapeUtils.escapeXml(temp) + "</OpenClinica:ItemHeader>" + nls : "");
        temp = inform.getItemSubHeader();
        xml.append(temp != null && temp.length() > 0 ? currentIndent + indent + indent + "<OpenClinica:ItemSubHeader>" + StringEscapeUtils.escapeXml(temp) + "</OpenClinica:ItemSubHeader>" + nls : "");
        temp = inform.getSectionLabel();
        xml.append(temp != null && temp.length() > 0 ? currentIndent + indent + indent + "<OpenClinica:SectionLabel>" + StringEscapeUtils.escapeXml(temp) + "</OpenClinica:SectionLabel>" + nls : "");
        ItemResponseBean response = inform.getItemResponse();
        xml.append(currentIndent + indent + indent + "<OpenClinica:ItemResponse ResponseType=\"" + StringEscapeUtils.escapeXml(response.getResponseType()));
        temp = response.getResponseLayout();
        if (temp != null && temp.length() > 0) {
            xml.append("\" ResponseLayout=\"" + StringEscapeUtils.escapeXml(temp) + "\"/>");
        } else {
            xml.append("\"/>");
        }
        xml.append(nls);
        if ("no".equalsIgnoreCase(inform.getShowItem())) {
            addSimpleConditionalDisplay(inform, currentIndent + indent + indent);
        }
        xml.append(currentIndent + indent + "</OpenClinica:ItemPresentInForm>");
        xml.append(nls);
    }
    xml.append(currentIndent + "</OpenClinica:ItemDetails>");
    xml.append(nls);
}
Also used : ItemPresentInFormBean(org.akaza.openclinica.bean.odmbeans.ItemPresentInFormBean) ArrayList(java.util.ArrayList) ItemResponseBean(org.akaza.openclinica.bean.odmbeans.ItemResponseBean)

Aggregations

ArrayList (java.util.ArrayList)3 ItemPresentInFormBean (org.akaza.openclinica.bean.odmbeans.ItemPresentInFormBean)3 ItemResponseBean (org.akaza.openclinica.bean.odmbeans.ItemResponseBean)3 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2 ItemDefBean (org.akaza.openclinica.bean.odmbeans.ItemDefBean)2 ItemDetailsBean (org.akaza.openclinica.bean.odmbeans.ItemDetailsBean)2 ItemGroupDefBean (org.akaza.openclinica.bean.odmbeans.ItemGroupDefBean)2 ItemGroupDetailsBean (org.akaza.openclinica.bean.odmbeans.ItemGroupDetailsBean)2 ItemGroupRepeatBean (org.akaza.openclinica.bean.odmbeans.ItemGroupRepeatBean)2 PresentInFormBean (org.akaza.openclinica.bean.odmbeans.PresentInFormBean)2 List (java.util.List)1 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)1 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)1 FormDefBean (org.akaza.openclinica.bean.odmbeans.FormDefBean)1 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)1