Search in sources :

Example 1 with StudyEventDefBean

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

the class OdmExtractDAO method getODMMetadata.

/**
     * metadata for ODM extraction only
     */
public void getODMMetadata(int parentStudyId, int studyId, MetaDataVersionBean metadata, String odmVersion) {
    String cvIds = "";
    HashMap<Integer, Integer> cvIdPoses = new HashMap<Integer, Integer>();
    this.setStudyEventAndFormMetaTypesExpected();
    logger.debug("Begin to execute GetStudyEventAndFormMetaSql");
    logger.debug("getStudyEventAndFormMetaSQl= " + this.getStudyEventAndFormMetaSql(parentStudyId, studyId, false));
    ArrayList rows = this.select(this.getStudyEventAndFormMetaSql(parentStudyId, studyId, false));
    Iterator it = rows.iterator();
    String sedprev = "";
    MetaDataVersionProtocolBean protocol = metadata.getProtocol();
    HashMap<Integer, String> nullMap = new HashMap<Integer, String>();
    HashMap<String, String> nullValueCVs = new HashMap<String, String>();
    while (it.hasNext()) {
        HashMap row = (HashMap) it.next();
        Integer sedOrder = (Integer) row.get("definition_order");
        Integer cvId = (Integer) row.get("crf_version_id");
        String sedOID = (String) row.get("definition_oid");
        String sedName = (String) row.get("definition_name");
        Boolean sedRepeat = (Boolean) row.get("definition_repeating");
        String sedType = (String) row.get("definition_type");
        String cvOID = (String) row.get("cv_oid");
        String cvName = (String) row.get("cv_name");
        Boolean cvRequired = (Boolean) row.get("cv_required");
        String nullValue = (String) row.get("null_values");
        String crfName = (String) row.get("crf_name");
        String crfOid = (String) row.get("crf_oid");
        StudyEventDefBean sedef = new StudyEventDefBean();
        if (sedprev.equals(sedOID)) {
            int p = metadata.getStudyEventDefs().size() - 1;
            sedef = metadata.getStudyEventDefs().get(p);
        } else {
            sedprev = sedOID;
            ElementRefBean sedref = new ElementRefBean();
            sedref.setElementDefOID(sedOID);
            sedref.setMandatory("Yes");
            sedref.setOrderNumber(sedOrder);
            protocol.getStudyEventRefs().add(sedref);
            sedef.setOid(sedOID);
            sedef.setName(sedName);
            sedef.setRepeating(sedRepeat ? "Yes" : "No");
            String type = sedType.toLowerCase();
            type = type.substring(0, 1).toUpperCase() + type.substring(1);
            sedef.setType(type);
            metadata.getStudyEventDefs().add(sedef);
        }
        ElementRefBean formref = new ElementRefBean();
        formref.setElementDefOID(crfOid);
        formref.setMandatory(cvRequired ? "Yes" : "No");
        sedef.getFormRefs().add(formref);
        if (!cvIdPoses.containsKey(cvId)) {
            FormDefBean formdef = new FormDefBean();
            formdef.setOid(crfOid);
            formdef.setName(crfName);
            formdef.setRepeating("No");
            metadata.getFormDefs().add(formdef);
            cvIdPoses.put(cvId, metadata.getFormDefs().size() - 1);
            cvIds += cvId + ",";
            if (nullValue != null && nullValue.length() > 0) {
                nullMap.put(cvId, nullValue);
                nullValueCVs.put(sedOID + "-" + cvOID, nullValue);
            }
        }
    }
    cvIds = cvIds.substring(0, cvIds.length() - 1);
    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"));
    }
    this.setItemGroupAndItemMetaWithUnitTypesExpected();
    rows.clear();
    logger.debug("Begin to execute GetItemGroupAndItemMetaWithUnitSql");
    logger.debug("getItemGroupandItemMetaWithUnitsql= " + this.getItemGroupAndItemMetaWithUnitSql(cvIds));
    rows = select(this.getItemGroupAndItemMetaWithUnitSql(cvIds));
    it = rows.iterator();
    ArrayList<ItemGroupDefBean> itemGroupDefs = (ArrayList<ItemGroupDefBean>) metadata.getItemGroupDefs();
    ArrayList<ItemDefBean> itemDefs = (ArrayList<ItemDefBean>) metadata.getItemDefs();
    ArrayList<CodeListBean> codeLists = (ArrayList<CodeListBean>) metadata.getCodeLists();
    ArrayList<MultiSelectListBean> multiSelectLists = (ArrayList<MultiSelectListBean>) metadata.getMultiSelectLists();
    ArrayList<ElementRefBean> itemGroupRefs = new ArrayList<ElementRefBean>();
    Set<String> igset = new HashSet<String>();
    HashMap<String, Integer> igdPos = new HashMap<String, Integer>();
    Set<String> itset = new HashSet<String>();
    Set<Integer> itdset = new HashSet<Integer>();
    Set<Integer> clset = new HashSet<Integer>();
    Set<Integer> mslset = new HashSet<Integer>();
    ItemGroupDefBean igdef = new ItemGroupDefBean();
    HashMap<String, String> igMandatories = new HashMap<String, String>();
    boolean isLatest = false;
    int cvprev = -1;
    String igrprev = "";
    String igdprev = "";
    String itMandatory = "No";
    int itOrder = 0;
    Integer igId = -1;
    String sectionIds = ",";
    while (it.hasNext()) {
        HashMap row = (HashMap) it.next();
        Integer cId = (Integer) row.get("crf_id");
        Integer cvId = (Integer) row.get("crf_version_id");
        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");
        String igName = (String) row.get("item_group_name");
        String itName = (String) row.get("item_name");
        Integer dataTypeId = (Integer) row.get("item_data_type_id");
        Integer secId = (Integer) row.get("section_id");
        String header = (String) row.get("item_header");
        String left = (String) row.get("left_item_text");
        String right = (String) row.get("right_item_text");
        Boolean itRequired = (Boolean) row.get("item_required");
        String regexp = (String) row.get("regexp");
        String regexpErr = (String) row.get("regexp_error_msg");
        String widthDecimal = (String) row.get("width_decimal");
        Integer rsTypeId = (Integer) row.get("response_type_id");
        String rsText = (String) row.get("options_text");
        String rsValue = (String) row.get("options_values");
        String rsLabel = (String) row.get("response_label");
        String igHeader = (String) row.get("item_group_header");
        Boolean isRepeating = (Boolean) row.get("repeating_group");
        String itDesc = (String) row.get("item_description");
        String itQuesNum = (String) row.get("question_number_label");
        String muOid = (String) row.get("mu_oid");
        if (cvprev != cvId) {
            // at this point, itemGroupRefs is for old cvId
            if (itemGroupRefs != null && itemGroupRefs.size() > 0) {
                String temp = igMandatories.containsKey(igdprev) ? igMandatories.get(igdprev) : itMandatory;
                itemGroupRefs.get(itemGroupRefs.size() - 1).setMandatory(temp);
            }
            itMandatory = "No";
            // now update to new cvId
            cvprev = cvId;
            FormDefBean formDef = new FormDefBean();
            if (cvIdPoses.containsKey(cvId)) {
                int p = cvIdPoses.get(cvId);
                formDef = metadata.getFormDefs().get(p);
            } else {
                logger.debug("crf_version_id=" + cvId + " couldn't find from studyEventAndFormMetaSql");
            }
            itemGroupRefs = (ArrayList<ElementRefBean>) formDef.getItemGroupRefs();
        }
        // mandatory is based on the last crf-version
        String igDefKey = igId + "";
        if (!igdprev.equals(igDefKey)) {
            if (igdPos.containsKey(igDefKey)) {
                igdef = itemGroupDefs.get(igdPos.get(igDefKey));
                isLatest = false;
                itOrder = igdef.getItemRefs().size();
            } else {
                igdef = new ItemGroupDefBean();
                itOrder = 0;
                igMandatories.put(igdprev, itMandatory);
                isLatest = true;
                igdef.setOid(igOID);
                igdef.setName("ungrouped".equalsIgnoreCase(igName) ? igOID : igName);
                // igdef.setName(igName);
                igdef.setRepeating(isRepeating ? "Yes" : "No");
                igdef.setComment(igHeader);
                igdef.setPreSASDatasetName(igName.toUpperCase());
                itemGroupDefs.add(igdef);
                igdPos.put(igDefKey, itemGroupDefs.size() - 1);
            }
            igdprev = igDefKey;
        }
        String igRefKey = igId + "-" + cvId;
        if (igrprev.equals(igRefKey)) {
            itMandatory = isLatest && itRequired && "No".equals(itMandatory) ? "Yes" : itMandatory;
        } else {
            if (!igset.contains(igRefKey)) {
                igset.add(igRefKey);
                ElementRefBean igref = new ElementRefBean();
                igref.setElementDefOID(igOID);
                int size = itemGroupRefs.size();
                if (size > 0) {
                    String prev = igrprev.split("-")[0].trim();
                    String temp = igMandatories.containsKey(prev) ? igMandatories.get(prev) : itMandatory;
                    itemGroupRefs.get(size - 1).setMandatory(temp);
                }
                itemGroupRefs.add(igref);
                itMandatory = "No";
            }
            igrprev = igRefKey;
        }
        String mandatory = itRequired ? "Yes" : "No";
        if (!itset.contains(igDefKey + "-" + itId)) {
            ++itOrder;
            itset.add(igDefKey + "-" + itId);
            ElementRefBean itemRef = new ElementRefBean();
            itemRef.setElementDefOID(itOID);
            if (itemRef.getMandatory() == null || itemRef.getMandatory().length() <= 0) {
                itemRef.setMandatory(mandatory);
            }
            itemRef.setOrderNumber(itOrder);
            igdef.getItemRefs().add(itemRef);
        }
        boolean hasCode = MetadataUnit.needCodeList(rsTypeId, dataTypeId);
        LinkedHashMap<String, String> codes = new LinkedHashMap<String, String>();
        if (hasCode) {
            /*
                 * //null value will not be added to codelist if (nullMap.containsKey(cvId)) { codes =
                 * MetadataUnit.parseCode(rsText, rsValue,
                 * nullMap.get(cvId)); } else { codes = MetadataUnit.parseCode(rsText, rsValue); }
                 */
            codes = MetadataUnit.parseCode(rsText, rsValue);
        // no action has been taken if rsvalue/rstext go wrong,
        // since they have been validated when uploading crf.
        }
        boolean hasMultiSelect = MetadataUnit.needMultiSelectList(rsTypeId);
        LinkedHashMap<String, String> multi = new LinkedHashMap<String, String>();
        if (hasMultiSelect) {
            multi = MetadataUnit.parseCode(rsText, rsValue);
        // no action has been taken if rsvalue/rstext go wrong,
        // since they have been validated when uploading crf.
        }
        String datatype = MetadataUnit.getOdmItemDataType(rsTypeId, dataTypeId, odmVersion);
        if (sectionIds.contains("," + secId + ",")) {
        } else {
            sectionIds += secId + ",";
        }
        if (!itdset.contains(itId)) {
            itdset.add(itId);
            ItemDefBean idef = new ItemDefBean();
            idef.setOid(itOID);
            idef.setName(itName);
            idef.setComment(itDesc);
            if (muOid != null && muOid.length() > 0) {
                ElementRefBean measurementUnitRef = new ElementRefBean();
                measurementUnitRef.setElementDefOID(muOid);
                idef.setMeasurementUnitRef(measurementUnitRef);
            }
            idef.setPreSASFieldName(itName);
            idef.setCodeListOID(hasCode ? "CL_" + rsId : "");
            if (hasMultiSelect) {
                ElementRefBean multiSelectListRef = new ElementRefBean();
                multiSelectListRef.setElementDefOID("MSL_" + rsId);
                idef.setMultiSelectListRef(multiSelectListRef);
            }
            // if(nullMap.containsKey(cvId)) {
            // }
            idef.getQuestion().setQuestionNumber(itQuesNum);
            idef.getQuestion().getQuestion().setText(MetadataUnit.getItemQuestionText(header, left, right));
            if (regexp != null && regexp.startsWith("func:")) {
                idef.setRangeCheck(MetadataUnit.getItemRangeCheck(regexp.substring(5).trim(), metadata.getSoftHard(), regexpErr, muOid));
            }
            idef.setDataType(datatype);
            int len = 0;
            int sig = 0;
            if (widthDecimal != null && widthDecimal.length() > 0) {
                // now there is no validation for width_decimal here.
                len = parseWidth(widthDecimal);
                sig = parseDecimal(widthDecimal);
            }
            if (rsTypeId == 3 || rsTypeId == 7) {
                // 3:checkbox;
                // //7:multi-select
                // len = maxLengths.containsKey(itId) ? maxLengths.get(itId) : 0;
                // len = Math.max(len, Math.max(rsText.length(), rsValue.length()));
                Iterator<String> iter = multi.keySet().iterator();
                String temp = "";
                while (iter.hasNext()) {
                    temp += iter.next();
                    temp += ",";
                }
                idef.setLength(temp.length());
            } else if ("text".equalsIgnoreCase(datatype)) {
                if (len > 0) {
                    idef.setLength(len);
                } else {
                    idef.setLength(hasCode ? MetadataUnit.getDataTypeLength(codes.keySet()) : maxLengths.containsKey(itId) ? maxLengths.get(itId) : MetaDataCollector.getTextLength());
                }
            } else if ("integer".equalsIgnoreCase(datatype)) {
                if (len > 0) {
                    idef.setLength(len);
                } else {
                    idef.setLength(hasCode ? MetadataUnit.getDataTypeLength(codes.keySet()) : 10);
                }
            } else if ("float".equalsIgnoreCase(datatype)) {
                if (len > 0) {
                    idef.setLength(len);
                } else {
                    // idef.setLength(hasCode ?
                    // MetadataUnit.getDataTypeLength(codes.keySet()) : 32);
                    idef.setLength(hasCode ? MetadataUnit.getDataTypeLength(codes.keySet()) : 25);
                }
            } else {
                idef.setLength(0);
            }
            idef.setSignificantDigits(sig > 0 ? sig : MetadataUnit.getSignificantDigits(datatype, codes.keySet(), hasCode));
            itemDefs.add(idef);
        }
        if (hasCode && !clset.contains(rsId)) {
            clset.add(rsId);
            CodeListBean cl = new CodeListBean();
            cl.setOid("CL_" + rsId);
            cl.setName(rsLabel);
            cl.setPreSASFormatName(rsLabel);
            cl.setDataType(datatype);
            Iterator<String> iter = codes.keySet().iterator();
            while (iter.hasNext()) {
                String de = iter.next();
                CodeListItemBean cli = new CodeListItemBean();
                cli.setCodedValue(de);
                TranslatedTextBean tt = cli.getDecode();
                // cli.getDecode().setText(codes.get(de));
                tt.setText(codes.get(de));
                tt.setXmlLang(CoreResources.getField("translated_text_language"));
                cli.setDecode(tt);
                cl.getCodeListItems().add(cli);
            }
            codeLists.add(cl);
        }
        if (odmVersion.startsWith("oc") && hasMultiSelect && !mslset.contains(rsId)) {
            mslset.add(rsId);
            MultiSelectListBean msl = new MultiSelectListBean();
            msl.setOid("MSL_" + rsId);
            msl.setName(rsLabel);
            msl.setDataType(datatype);
            msl.setActualDataType(datatype);
            Iterator<String> iter = multi.keySet().iterator();
            while (iter.hasNext()) {
                String de = iter.next();
                MultiSelectListItemBean msli = new MultiSelectListItemBean();
                msli.setCodedOptionValue(de);
                TranslatedTextBean tt = new TranslatedTextBean();
                String t = multi.get(de);
                tt.setText(t);
                tt.setXmlLang(CoreResources.getField("translated_text_language"));
                msli.setDecode(tt);
                msl.getMultiSelectListItems().add(msli);
            }
            multiSelectLists.add(msl);
        }
    }
    if (itemGroupRefs != null && itemGroupRefs.size() > 0) {
        String last = igMandatories.containsKey(igId + "") ? igMandatories.get(igId + "") : itMandatory;
        itemGroupRefs.get(itemGroupRefs.size() - 1).setMandatory(last);
    }
    sectionIds = sectionIds.length() > 0 ? sectionIds.substring(1, sectionIds.length() - 1) : "";
    metadata.setSectionIds(sectionIds);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) CodeListBean(org.akaza.openclinica.bean.odmbeans.CodeListBean) ArrayList(java.util.ArrayList) TranslatedTextBean(org.akaza.openclinica.bean.odmbeans.TranslatedTextBean) LinkedHashMap(java.util.LinkedHashMap) StudyEventDefBean(org.akaza.openclinica.bean.odmbeans.StudyEventDefBean) MultiSelectListItemBean(org.akaza.openclinica.bean.odmbeans.MultiSelectListItemBean) Iterator(java.util.Iterator) HashSet(java.util.HashSet) MultiSelectListBean(org.akaza.openclinica.bean.odmbeans.MultiSelectListBean) ItemGroupDefBean(org.akaza.openclinica.bean.odmbeans.ItemGroupDefBean) ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) FormDefBean(org.akaza.openclinica.bean.odmbeans.FormDefBean) MetaDataVersionProtocolBean(org.akaza.openclinica.bean.odmbeans.MetaDataVersionProtocolBean) ItemDefBean(org.akaza.openclinica.bean.odmbeans.ItemDefBean) CodeListItemBean(org.akaza.openclinica.bean.odmbeans.CodeListItemBean)

Example 2 with StudyEventDefBean

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

the class OdmExtractDAO method getUpdatedSiteMetadata.

public void getUpdatedSiteMetadata(int parentStudyId, int studyId, MetaDataVersionBean metadata, String odmVersion) {
    HashMap<Integer, Integer> cvIdPoses = new HashMap<Integer, Integer>();
    this.setStudyEventAndFormMetaTypesExpected();
    ArrayList rows = this.select(this.getStudyEventAndFormMetaSql(parentStudyId, studyId, true));
    Iterator it = rows.iterator();
    String sedprev = "";
    MetaDataVersionProtocolBean protocol = metadata.getProtocol();
    while (it.hasNext()) {
        HashMap row = (HashMap) it.next();
        Integer sedOrder = (Integer) row.get("definition_order");
        Integer cvId = (Integer) row.get("crf_version_id");
        String sedOID = (String) row.get("definition_oid");
        String sedName = (String) row.get("definition_name");
        Boolean sedRepeat = (Boolean) row.get("definition_repeating");
        String sedType = (String) row.get("definition_type");
        String cvOID = (String) row.get("cv_oid");
        String cvName = (String) row.get("cv_name");
        Boolean cvRequired = (Boolean) row.get("cv_required");
        String nullValue = (String) row.get("null_values");
        String crfName = (String) row.get("crf_name");
        String crfOid = (String) row.get("crf_oid");
        StudyEventDefBean sedef = new StudyEventDefBean();
        if (sedprev.equals(sedOID)) {
            int p = metadata.getStudyEventDefs().size() - 1;
            sedef = metadata.getStudyEventDefs().get(p);
        } else {
            sedprev = sedOID;
            ElementRefBean sedref = new ElementRefBean();
            sedref.setElementDefOID(sedOID);
            sedref.setMandatory("Yes");
            sedref.setOrderNumber(sedOrder);
            protocol.getStudyEventRefs().add(sedref);
            sedef.setOid(sedOID);
            sedef.setName(sedName);
            sedef.setRepeating(sedRepeat ? "Yes" : "No");
            String type = sedType.toLowerCase();
            type = type.substring(0, 1).toUpperCase() + type.substring(1);
            sedef.setType(type);
            metadata.getStudyEventDefs().add(sedef);
        }
        ElementRefBean formref = new ElementRefBean();
        formref.setElementDefOID(crfOid);
        formref.setMandatory(cvRequired ? "Yes" : "No");
        sedef.getFormRefs().add(formref);
        if (!cvIdPoses.containsKey(cvId)) {
            FormDefBean formdef = new FormDefBean();
            formdef.setOid(crfOid);
            formdef.setName(crfName);
            formdef.setRepeating("No");
            metadata.getFormDefs().add(formdef);
            cvIdPoses.put(cvId, metadata.getFormDefs().size() - 1);
            if (nullValue != null && nullValue.length() > 0) {
            }
        }
    }
}
Also used : StudyEventDefBean(org.akaza.openclinica.bean.odmbeans.StudyEventDefBean) ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) FormDefBean(org.akaza.openclinica.bean.odmbeans.FormDefBean) MetaDataVersionProtocolBean(org.akaza.openclinica.bean.odmbeans.MetaDataVersionProtocolBean)

Example 3 with StudyEventDefBean

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

the class MetaDataReportBean method addStudyEventDef.

public void addStudyEventDef(boolean isStudy, String currentIndent) {
    StringBuffer xml = this.getXmlOutput();
    String indent = this.getIndent();
    ArrayList<StudyEventDefBean> seds = (ArrayList<StudyEventDefBean>) odmstudy.getMetaDataVersion().getStudyEventDefs();
    for (StudyEventDefBean sed : seds) {
        xml.append(currentIndent + "<StudyEventDef OID=\"" + StringEscapeUtils.escapeXml(sed.getOid()) + "\"  Name=\"" + StringEscapeUtils.escapeXml(sed.getName()) + "\" Repeating=\"" + sed.getRepeating() + "\" Type=\"" + sed.getType() + "\">");
        xml.append(nls);
        ArrayList<ElementRefBean> formRefs = (ArrayList<ElementRefBean>) sed.getFormRefs();
        for (ElementRefBean formRef : formRefs) {
            xml.append(currentIndent + indent + "<FormRef FormOID=\"" + StringEscapeUtils.escapeXml(formRef.getElementDefOID()) + "\" Mandatory=\"" + formRef.getMandatory() + "\">");
            xml.append(nls);
            ConfigurationParameters conf = formRef.getConfigurationParameters();
            if (conf != null) {
                xml.append(currentIndent + indent + indent + "<OpenClinica:ConfigurationParameters HideCRF=\"" + (conf.isHiddenCrf() ? "Yes" : "No") + "\" ParticipantForm=\"" + (conf.isParticipantForm() ? "Yes" : "No") + "\" AllowAnonymousSubmission=\"" + (conf.isAllowAnynymousSubmission() ? "Yes" : "No") + "\" SubmissionUrl=\"" + conf.getSubmissionUrl() + "\" Offline=\"" + (conf.isOffline() ? "Yes" : "No") + "\"/>");
                xml.append(nls);
                ArrayList<ElementRefBean> formLayoutRefs = (ArrayList<ElementRefBean>) formRef.getFormLayoutRefs();
                for (ElementRefBean formLayoutRef : formLayoutRefs) {
                    xml.append(currentIndent + indent + indent + "<OpenClinica:FormLayoutRef OID=\"" + StringEscapeUtils.escapeXml(formLayoutRef.getName()) + "\" IsDefaultVersion=\"" + (formLayoutRef.isDefaultVersion() ? "Yes" : "No") + "\"/>");
                    xml.append(nls);
                }
            }
            xml.append(currentIndent + indent + "</FormRef>");
            xml.append(nls);
        }
        // MR=416
        if ("oc1.3".equals(this.getODMVersion())) {
            this.addEventDefinitionDetails(sed.getEventDefinitionDetais(), currentIndent + indent);
        }
        xml.append(currentIndent + "</StudyEventDef>");
        xml.append(nls);
    }
}
Also used : StudyEventDefBean(org.akaza.openclinica.bean.odmbeans.StudyEventDefBean) ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) ArrayList(java.util.ArrayList) ConfigurationParameters(org.akaza.openclinica.bean.odmbeans.ConfigurationParameters)

Example 4 with StudyEventDefBean

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

the class OdmExtractDAO method applyStudyEventDef.

private void applyStudyEventDef(MetaDataVersionBean metadata, String formOID) {
    StudyEventDefBean studyEventDef = new StudyEventDefBean();
    studyEventDef.setOid(MetadataUnit.FAKE_STUDY_EVENT_OID);
    studyEventDef.setName(MetadataUnit.FAKE_SE_NAME);
    studyEventDef.setRepeating(MetadataUnit.FAKE_SE_REPEATING);
    ElementRefBean formRefBean = new ElementRefBean();
    formRefBean.setElementDefOID(formOID);
    studyEventDef.getFormRefs().add(formRefBean);
    metadata.getStudyEventDefs().add(studyEventDef);
}
Also used : StudyEventDefBean(org.akaza.openclinica.bean.odmbeans.StudyEventDefBean) ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean)

Example 5 with StudyEventDefBean

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

the class OdmExtractDAO method getStudyEventAndFormMetaOC1_3.

public void getStudyEventAndFormMetaOC1_3(int parentStudyId, int studyId, MetaDataVersionBean metadata, String odmVersion, boolean isIncludedSite) {
    ArrayList<StudyEventDefBean> seds = (ArrayList<StudyEventDefBean>) metadata.getStudyEventDefs();
    ArrayList<FormDefBean> forms = (ArrayList<FormDefBean>) metadata.getFormDefs();
    for (StudyEventDefBean sed : seds) {
        List<ElementRefBean> formRefs = sed.getFormRefs();
        for (ElementRefBean formRef : formRefs) {
            ConfigurationParameters conf = new ConfigurationParameters();
            EventDefinitionCRFBean edc = getEventDefCRF(sed, formRef, studyId);
            CRFBean cBean = (CRFBean) crfdao.findByPK(edc.getCrfId());
            String crfPath = sed.getOid() + "." + cBean.getOid();
            conf = populateConfigurationParameters(edc, conf, crfPath);
            formRef.setConfigurationParameters(conf);
            int defaultVersionId = edc.getDefaultVersionId();
            formRef.setFormLayoutRefs(getFormLayoutRefs(formRef, defaultVersionId));
        }
    }
    HashMap<String, EventDefinitionDetailsBean> sedDetails = new HashMap<String, EventDefinitionDetailsBean>();
    HashMap<String, FormDetailsBean> formDetails = new HashMap<String, FormDetailsBean>();
    this.setStudyEventAndFormMetaOC1_3TypesExpected();
    logger.debug("Begin to execute GetStudyEventAndFormMetaOC1_3Sql");
    logger.debug("getStudyEventAndFormMetaOC1_3SQl= " + this.getStudyEventAndFormMetaOC1_3Sql(parentStudyId, studyId, isIncludedSite));
    ArrayList rows = this.select(this.getStudyEventAndFormMetaOC1_3Sql(parentStudyId, studyId, isIncludedSite));
    Iterator iter = rows.iterator();
    String sedOIDs = "";
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        Integer cvId = (Integer) row.get("crf_version_id");
        String sedOID = (String) row.get("definition_oid");
        String cvOID = (String) row.get("cv_oid");
        String sedDesc = (String) row.get("description");
        String category = (String) row.get("category");
        String cvDesc = (String) row.get("version_description");
        String notes = (String) row.get("revision_notes");
        String cOID = (String) row.get("crf_oid");
        String crfDescription = (String) row.get("crf_description");
        String nullValue = (String) row.get("null_values");
        Integer dvId = (Integer) row.get("default_version_id");
        Boolean pwdRequired = (Boolean) row.get("electronic_signature");
        Boolean doubleEntry = (Boolean) row.get("double_entry");
        Boolean hideCrf = (Boolean) row.get("hide_crf");
        Boolean participantForm = (Boolean) row.get("participant_form");
        Boolean allowAnonymousSubmission = (Boolean) row.get("allow_anonymous_submission");
        String submissionUrl = (String) row.get("submission_url");
        Integer sdvId = (Integer) row.get("source_data_verification_code");
        Boolean offline = (Boolean) row.get("active");
        if (sedDetails.containsKey(sedOID)) {
        } else {
            EventDefinitionDetailsBean sedDetail = new EventDefinitionDetailsBean();
            sedDetail.setOid(sedOID);
            sedDetail.setCategory(category);
            sedDetail.setDescription(sedDesc);
            sedDetails.put(sedOID, sedDetail);
        }
        if (formDetails.containsKey(cOID)) {
            FormDetailsBean formDetail = formDetails.get(cOID);
            PresentInEventDefinitionBean p = new PresentInEventDefinitionBean();
            p.setStudyEventOid(sedOID);
            p.setDoubleDataEntry(doubleEntry == false ? "No" : "Yes");
            p.setHideCrf(hideCrf == false ? "No" : "Yes");
            p.setParticipantForm(participantForm == false ? "No" : "Yes");
            p.setIsDefaultVersion(cvId.equals(dvId) ? "Yes" : "No");
            p.setNullValues(nullValue);
            p.setPasswordRequired(pwdRequired == false ? "No" : "Yes");
            p.setAllowAnonymousSubmission(allowAnonymousSubmission == false ? "No" : "Yes");
            p.setOffline((offline == false) ? "No" : "Yes");
            p.setSubmissionUrl(submissionUrl);
            p.setSourceDataVerification(SourceDataVerification.getByCode(sdvId > 0 ? sdvId : 3).getDescription());
            formDetail.getPresentInEventDefinitions().add(p);
        } else {
            FormDetailsBean formDetail = new FormDetailsBean();
            formDetail.setOid(cOID);
            formDetail.setRevisionNotes(notes);
            formDetail.setParentFormOid(cOID);
            formDetail.setVersionDescription(cvDesc);
            formDetail.setDescription(crfDescription);
            // ArrayList sectionBeansRows = this.select(this.getSectionDetails(cvOID),cvId);
            formDetail = setSectionBean(formDetail, cvId);
            PresentInEventDefinitionBean p = new PresentInEventDefinitionBean();
            p.setStudyEventOid(sedOID);
            p.setDoubleDataEntry(doubleEntry == false ? "No" : "Yes");
            p.setHideCrf(hideCrf == false ? "No" : "Yes");
            p.setParticipantForm(participantForm == false ? "No" : "Yes");
            p.setIsDefaultVersion(cvId.equals(dvId) ? "Yes" : "No");
            p.setNullValues(nullValue);
            p.setPasswordRequired(pwdRequired == false ? "No" : "Yes");
            p.setAllowAnonymousSubmission(allowAnonymousSubmission == false ? "No" : "Yes");
            p.setOffline((offline == false) ? "No" : "Yes");
            p.setSubmissionUrl(submissionUrl);
            p.setSourceDataVerification(SourceDataVerification.getByCode(sdvId > 0 ? sdvId : 3).getDescription());
            formDetail.getPresentInEventDefinitions().add(p);
            formDetails.put(cOID, formDetail);
        }
    }
    for (StudyEventDefBean sedef : seds) {
        sedef.setEventDefinitionDetais(sedDetails.get(sedef.getOid()));
    }
    for (FormDefBean formdef : forms) {
        List<ElementRefBean> formLayoutRefs = getFormLayoutRefs(formdef);
        formdef.setFormLayoutRefs(formLayoutRefs);
        formdef.setFormDetails(formDetails.get(formdef.getOid()));
    }
}
Also used : EventDefinitionDetailsBean(org.akaza.openclinica.bean.odmbeans.EventDefinitionDetailsBean) ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) FormDefBean(org.akaza.openclinica.bean.odmbeans.FormDefBean) ConfigurationParameters(org.akaza.openclinica.bean.odmbeans.ConfigurationParameters) PresentInEventDefinitionBean(org.akaza.openclinica.bean.odmbeans.PresentInEventDefinitionBean) FormDetailsBean(org.akaza.openclinica.bean.odmbeans.FormDetailsBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) StudyEventDefBean(org.akaza.openclinica.bean.odmbeans.StudyEventDefBean) Iterator(java.util.Iterator) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Aggregations

ElementRefBean (org.akaza.openclinica.bean.odmbeans.ElementRefBean)5 StudyEventDefBean (org.akaza.openclinica.bean.odmbeans.StudyEventDefBean)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3 LinkedHashMap (java.util.LinkedHashMap)3 FormDefBean (org.akaza.openclinica.bean.odmbeans.FormDefBean)3 ConfigurationParameters (org.akaza.openclinica.bean.odmbeans.ConfigurationParameters)2 MetaDataVersionProtocolBean (org.akaza.openclinica.bean.odmbeans.MetaDataVersionProtocolBean)2 HashSet (java.util.HashSet)1 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)1 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)1 CodeListBean (org.akaza.openclinica.bean.odmbeans.CodeListBean)1 CodeListItemBean (org.akaza.openclinica.bean.odmbeans.CodeListItemBean)1 EventDefinitionDetailsBean (org.akaza.openclinica.bean.odmbeans.EventDefinitionDetailsBean)1 FormDetailsBean (org.akaza.openclinica.bean.odmbeans.FormDetailsBean)1 ItemDefBean (org.akaza.openclinica.bean.odmbeans.ItemDefBean)1 ItemGroupDefBean (org.akaza.openclinica.bean.odmbeans.ItemGroupDefBean)1 MultiSelectListBean (org.akaza.openclinica.bean.odmbeans.MultiSelectListBean)1 MultiSelectListItemBean (org.akaza.openclinica.bean.odmbeans.MultiSelectListItemBean)1