Search in sources :

Example 6 with ElementRefBean

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

the class OdmExtractDAO method fetchFormDetails.

public FormDefBean fetchFormDetails(CRFBean crfBean, FormDefBean formDef) {
    formDef.setOid(crfBean.getOid());
    formDef.setName(crfBean.getName());
    List<ElementRefBean> formLayoutRefs = getFormLayoutRefs(formDef);
    formDef.setFormLayoutRefs(formLayoutRefs);
    formDef.setRepeating("No");
    FormDetailsBean formDetails = new FormDetailsBean();
    formDetails.setName(crfBean.getName());
    formDetails.setOid(crfBean.getOid());
    formDetails.setParentFormOid(crfBean.getOid());
    formDetails.setDescription(crfBean.getDescription());
    setSectionBean(formDetails, new Integer(crfBean.getId()));
    formDef.setFormDetails(formDetails);
    return formDef;
}
Also used : ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) FormDetailsBean(org.akaza.openclinica.bean.odmbeans.FormDetailsBean)

Example 7 with ElementRefBean

use of org.akaza.openclinica.bean.odmbeans.ElementRefBean 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 8 with ElementRefBean

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

the class OdmExtractDAO method getClinicalData.

public void getClinicalData(StudyBean study, DatasetBean dataset, OdmClinicalDataBean data, String odmVersion, String studySubjectIds, String odmType) {
    String dbName = CoreResources.getDBName();
    String subprev = "";
    HashMap<String, Integer> sepos = new HashMap<String, Integer>();
    String seprev = "";
    String formprev = "";
    HashMap<String, Integer> igpos = new HashMap<String, Integer>();
    String igprev = "";
    String oidPos = "";
    HashMap<Integer, String> oidPoses = new HashMap<Integer, String>();
    HashMap<Integer, String> idataOidPoses = new HashMap<Integer, String>();
    // String studyIds = "";
    // if (study.getParentStudyId() > 0) {
    // studyIds += study.getId();
    // } else {
    // ArrayList<Integer> ids = (ArrayList<Integer>) (new
    // StudyDAO(this.ds)).findAllSiteIdsByStudy(study);
    // for (int i = 0; i < ids.size() - 1; ++i) {
    // studyIds += ids.get(i) + ",";
    // }
    // studyIds += ids.get(ids.size() - 1);
    // }
    String studyIds = study.getId() + "";
    int datasetItemStatusId = dataset.getDatasetItemStatus().getId();
    String sql = dataset.getSQLStatement().split("order by")[0].trim();
    sql = sql.split("study_event_definition_id in")[1];
    String[] ss = sql.split("and item_id in");
    String sedIds = ss[0];
    String[] sss = ss[1].split("and");
    String itemIds = sss[0];
    String dateConstraint = "";
    if ("postgres".equalsIgnoreCase(dbName)) {
        dateConstraint = "and " + sss[1] + " and " + sss[2];
        dateConstraint = dateConstraint.replace("date_created", "ss.enrollment_date");
    } else if ("oracle".equalsIgnoreCase(dbName)) {
        String[] os = (sss[1] + sss[2]).split("'");
        dateConstraint = "and trunc(ss.enrollment_date) >= to_date('" + os[1] + "') and trunc(ss.enrollment_date) <= to_date('" + os[3] + "')";
    }
    logger.debug("Begin to GetSubjectEventFormSql");
    if (odmVersion.startsWith("oc")) {
        logger.debug("getOCSubjectEventFormSql=" + getOCSubjectEventFormSqlSS(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
        this.setSubjectEventFormDataTypesExpected(odmVersion);
        ArrayList viewRows = select(getOCSubjectEventFormSqlSS(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
        Iterator iter = viewRows.iterator();
        this.setDataWithOCAttributes(study, dataset, data, odmVersion, iter, oidPoses, odmType);
    } else {
        logger.debug("getSubjectEventFormSql=" + getSubjectEventFormSqlSS(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
        this.setSubjectEventFormDataTypesExpected();
        ArrayList viewRows = select(getSubjectEventFormSqlSS(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
        Iterator iter = viewRows.iterator();
        // updated as well because this method came from here.
        while (iter.hasNext()) {
            JobTerminationMonitor.check();
            HashMap row = (HashMap) iter.next();
            String studySubjectLabel = (String) row.get("study_subject_oid");
            String sedOID = (String) row.get("definition_oid");
            Boolean studyEventRepeating = (Boolean) row.get("definition_repeating");
            Integer sampleOrdinal = (Integer) row.get("sample_ordinal");
            String cvOID = (String) row.get("crf_version_oid");
            // ecId
            Integer ecId = (Integer) row.get("event_crf_id");
            CRFVersionBean cvBean = cvdao.findByOid(cvOID);
            CRFBean cBean = (CRFBean) crfdao.findByPK(cvBean.getCrfId());
            // should
            // be unique;
            String key = studySubjectLabel;
            ExportSubjectDataBean sub = new ExportSubjectDataBean();
            if (subprev.equals(studySubjectLabel)) {
                int p = data.getExportSubjectData().size() - 1;
                sub = data.getExportSubjectData().get(p);
            } else {
                subprev = studySubjectLabel;
                sub.setSubjectOID(studySubjectLabel);
                data.getExportSubjectData().add(sub);
                seprev = "";
                formprev = "";
                igprev = "";
            }
            oidPos = data.getExportSubjectData().size() - 1 + "";
            ExportStudyEventDataBean se = new ExportStudyEventDataBean();
            // key += sedOID + sampleOrdinal;
            key += sedOID;
            if (!seprev.equals(key) || !sepos.containsKey(key + sampleOrdinal)) {
                sepos.put(key + sampleOrdinal, sub.getExportStudyEventData().size());
                seprev = key;
                se.setStudyEventOID(sedOID);
                se.setStudyEventRepeatKey(studyEventRepeating ? sampleOrdinal + "" : "-1");
                sub.getExportStudyEventData().add(se);
                formprev = "";
                igprev = "";
            } else {
                se = sub.getExportStudyEventData().get(sepos.get(key + sampleOrdinal));
            }
            oidPos += "---" + (sub.getExportStudyEventData().size() - 1);
            ExportFormDataBean form = new ExportFormDataBean();
            key += cvOID;
            if (formprev.equals(key)) {
                form = se.getExportFormData().get(se.getExportFormData().size() - 1);
            } else {
                formprev = key;
                form.setFormOID(cBean.getOid());
                se.getExportFormData().add(form);
                igprev = "";
            }
            oidPos += "---" + (se.getExportFormData().size() - 1);
            // ecId should be distinct
            oidPoses.put(ecId, oidPos);
            oidPos = "";
        }
    }
    this.setEventGroupItemDataWithUnitTypesExpected();
    logger.debug("Begin to GetEventGroupItemWithUnitSql");
    ArrayList viewRows = select(getEventGroupItemWithUnitSql(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
    logger.debug("getEventGroupItemWithUnitSql : " + getEventGroupItemWithUnitSql(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
    String idataIds = "";
    if (viewRows.size() > 0) {
        Iterator iter = viewRows.iterator();
        ExportSubjectDataBean sub = new ExportSubjectDataBean();
        ExportStudyEventDataBean se = new ExportStudyEventDataBean();
        ExportFormDataBean form = new ExportFormDataBean();
        int ecprev = -1;
        igprev = "";
        boolean goon = true;
        String itprev = "";
        // HashMap<String, String> nullValueMap =
        // ClinicalDataUnit.getNullValueMap();
        HashMap<String, String> nullValueCVs = this.getNullValueCVs(study);
        HashSet<Integer> itemDataIds = new HashSet<Integer>();
        String yearMonthFormat = StringUtil.parseDateFormat(ResourceBundleProvider.getFormatBundle(locale).getString("date_format_year_month"));
        String yearFormat = StringUtil.parseDateFormat(ResourceBundleProvider.getFormatBundle(locale).getString("date_format_year"));
        while (iter.hasNext()) {
            JobTerminationMonitor.check();
            HashMap row = (HashMap) iter.next();
            Integer ecId = (Integer) row.get("event_crf_id");
            Integer igId = (Integer) row.get("item_group_id");
            String igOID = (String) row.get("item_group_oid");
            String igName = (String) row.get("item_group_name");
            Integer itId = (Integer) row.get("item_id");
            String itOID = (String) row.get("item_oid");
            Integer itDataOrdinal = (Integer) row.get("item_data_ordinal");
            String itValue = (String) row.get("value");
            Integer datatypeid = (Integer) row.get("item_data_type_id");
            Integer idataId = (Integer) row.get("item_data_id");
            String muOid = (String) row.get("mu_oid");
            String key = "";
            if (ecId != ecprev) {
                logger.debug("Found ecId=" + ecId + " in subjectEventFormSql is:" + oidPoses.containsKey(ecId));
                if (oidPoses.containsKey(ecId)) {
                    goon = true;
                    String[] poses = oidPoses.get(ecId).split("---");
                    sub = data.getExportSubjectData().get(Integer.valueOf(poses[0]));
                    se = sub.getExportStudyEventData().get(Integer.valueOf(poses[1]));
                    form = se.getExportFormData().get(Integer.valueOf(poses[2]));
                } else {
                    goon = false;
                }
                ecprev = ecId;
            }
            if (goon) {
                ImportItemGroupDataBean ig = new ImportItemGroupDataBean();
                // key = ecId + igOID;
                key = ecId + "-" + igId;
                if (!igprev.equals(key) || !igpos.containsKey(key + itDataOrdinal)) {
                    igpos.put(key + itDataOrdinal, form.getItemGroupData().size());
                    igprev = key;
                    ig.setItemGroupOID(igOID + "");
                    ig.setItemGroupRepeatKey("ungrouped".equalsIgnoreCase(igName) ? "-1" : itDataOrdinal + "");
                    form.getItemGroupData().add(ig);
                } else {
                    ig = form.getItemGroupData().get(igpos.get(key + itDataOrdinal));
                }
                String newpos = oidPoses.get(ecId) + "---" + igpos.get(key + itDataOrdinal);
                // item should be distinct; but duplicated item data have
                // been reported because "save" have been clicked twice.
                // those duplicated item data have been arranged together by
                // "distinct" because of their same
                // ecId+igOID+itOID+itDataOrdinal (08-2008)
                key = itId + "_" + itDataOrdinal + key;
                if (!itprev.equals(key)) {
                    itprev = key;
                    ImportItemDataBean it = new ImportItemDataBean();
                    it.setItemOID(itOID);
                    it.setTransactionType("Insert");
                    String nullKey = study.getId() + "-" + se.getStudyEventOID() + "-" + form.getFormOID();
                    if (ClinicalDataUtil.isNull(itValue, nullKey, nullValueCVs)) {
                        // if
                        // (nullValueMap.containsKey(itValue.trim().toUpperCase()))
                        // {
                        // itValue =
                        // nullValueMap.get(itValue.trim().toUpperCase());
                        it.setIsNull("Yes");
                        String nullvalues = ClinicalDataUtil.presetNullValueStr(nullValueCVs.get(nullKey));
                        boolean hasValueWithNull = ClinicalDataUtil.isValueWithNull(itValue, nullvalues);
                        it.setHasValueWithNull(hasValueWithNull);
                        if (hasValueWithNull) {
                            it.setValue(itValue);
                            it.setReasonForNull(ClinicalDataUtil.getNullsInValue(itValue, nullvalues));
                        } else {
                            it.setReasonForNull(itValue.trim());
                        }
                    } else {
                        if (datatypeid == 9) {
                            try {
                                itValue = new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat(oc_df_string).parse(itValue));
                            } catch (Exception fe) {
                                logger.debug("Item -" + itOID + " value " + itValue + " might not be ODM date format yyyy-MM-dd.");
                            }
                        }
                        /*
                             * not be supported in openclinica-3.0.40.1
                             * else if (datatypeid == 10 && odmVersion.contains("1.3")) {
                             * if (StringUtil.isFormatDate(itValue, oc_df_string)) {
                             * try {
                             * itValue = new SimpleDateFormat("yyyy-MM-dd").format(new
                             * SimpleDateFormat(oc_df_string).parse(itValue));
                             * } catch (Exception e) {
                             * logger.info("Item -" + itOID + " value " + itValue +
                             * " might not be ODM partialDate format yyyy[-MM[-dd]].");
                             * }
                             * } else {
                             * if (StringUtil.isPartialYearMonth(itValue, yearMonthFormat)) {
                             * try {
                             * itValue = new SimpleDateFormat("yyyy-MM").format(new
                             * SimpleDateFormat(yearMonthFormat).parse(itValue));
                             * } catch (Exception e) {
                             * logger.info("Item -" + itOID + " value " + itValue +
                             * " might not be ODM partialDate format yyyy[-MM[-dd]].");
                             * }
                             * } else {
                             * try {
                             * itValue = new SimpleDateFormat("yyyy").format(new
                             * SimpleDateFormat(yearFormat).parse(itValue));
                             * } catch (Exception e) {
                             * logger.info("Item -" + itOID + " value " + itValue +
                             * " might not be ODM partialDate format yyyy[-MM[-dd]].");
                             * }
                             * }
                             * }
                             * }
                             */
                        it.setValue(itValue);
                    }
                    if (muOid != null && muOid.length() > 0) {
                        ElementRefBean measurementUnitRef = new ElementRefBean();
                        measurementUnitRef.setElementDefOID(muOid);
                        it.setMeasurementUnitRef(measurementUnitRef);
                    }
                    ig.getItemData().add(it);
                    newpos += "---" + (ig.getItemData().size() - 1);
                    idataOidPoses.put(idataId, newpos);
                }
                idataIds += "'" + idataId + "', ";
            }
        }
    }
    idataIds = idataIds.length() > 0 ? idataIds.substring(0, idataIds.length() - 2) : idataIds;
    if (idataIds.length() > 0 && itemIds.length() > 0) {
        this.setErasedScoreItemDataValues(data, itemIds, idataIds, idataOidPoses, odmVersion);
    } else {
        logger.info("OdmExtractDAO.setScoreItemDataNullValues was not called because of empty item_data_ids or/and item_ids");
    }
    if (odmType != null && odmType.equalsIgnoreCase("clinical_data")) {
        logger.debug("Do not create discrepancy notes");
    } else if (odmVersion.startsWith("oc")) {
        if (idataIds.length() > 0) {
            setOCItemDataAuditLogs(study, data, idataIds, idataOidPoses);
            setOCItemDataDNs(data, idataIds, idataOidPoses);
        } else {
            logger.info("OdmExtractDAO.setOCItemDataAuditLogs & setOCItemDataDNs weren't called because of empty idataIds");
        }
    }
}
Also used : ExportFormDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportFormDataBean) ImportItemGroupDataBean(org.akaza.openclinica.bean.submit.crfdata.ImportItemGroupDataBean) ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) ImportItemDataBean(org.akaza.openclinica.bean.submit.crfdata.ImportItemDataBean) ExportStudyEventDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportStudyEventDataBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) Iterator(java.util.Iterator) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) ExportSubjectDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean) SimpleDateFormat(java.text.SimpleDateFormat) HashSet(java.util.HashSet)

Example 9 with ElementRefBean

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

the class OdmExtractDAO method setOCFormDataDNs.

protected void setOCFormDataDNs(OdmClinicalDataBean data, String ecIds, HashMap<Integer, String> formOidPoses) {
    this.setOCFormDataDNsTypesExpected();
    HashMap<String, ArrayList<ChildNoteBean>> pDNs = new HashMap<String, ArrayList<ChildNoteBean>>();
    // HashMap<String, ArrayList<DiscrepancyNoteBean>> sDNs = new HashMap<String, ArrayList<DiscrepancyNoteBean>>();
    logger.debug("Begin to execute GetOCEventDataDNsSql");
    logger.debug("getOCFormDataDNsSql= " + this.getOCFormDataDNsSql(ecIds));
    ArrayList rows = select(this.getOCFormDataDNsSql(ecIds));
    Iterator iter = rows.iterator();
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        Integer ecId = (Integer) row.get("event_crf_id");
        Integer pdnId = (Integer) row.get("parent_dn_id");
        Integer dnId = (Integer) row.get("dn_id");
        String description = (String) row.get("description");
        String detailedNote = (String) row.get("detailed_notes");
        Integer ownerId = (Integer) row.get("owner_id");
        Date dateCreated = (Date) row.get("date_created");
        String status = (String) row.get("status");
        String noteType = (String) row.get("name");
        if (pdnId != null && pdnId > 0) {
            String key = ecId + "-" + pdnId;
            ChildNoteBean cn = new ChildNoteBean();
            cn.setDateCreated(dateCreated);
            cn.setDescription(description);
            cn.setDetailedNote(detailedNote);
            cn.setStatus(status);
            cn.setOid("CDN_" + dnId);
            ElementRefBean userRef = new ElementRefBean();
            userRef.setElementDefOID("USR_" + ownerId);
            cn.setUserRef(userRef);
            ArrayList<ChildNoteBean> cns = pDNs.containsKey(key) ? pDNs.get(key) : new ArrayList<ChildNoteBean>();
            cns.add(cn);
            pDNs.put(key, cns);
        } else {
            DiscrepancyNoteBean dn = new DiscrepancyNoteBean();
            String k = ecId + "-" + dnId;
            if (pDNs != null && pDNs.containsKey(k)) {
                dn.setChildNotes(pDNs.get(k));
                dn.setNumberOfChildNotes(dn.getChildNotes().size());
            }
            dn.setDateUpdated(dateCreated);
            dn.setNoteType(noteType);
            dn.setStatus(status);
            dn.setOid("DN_" + dnId);
            ElementRefBean userRef = new ElementRefBean();
            userRef.setElementDefOID("USR_" + ownerId);
            if (formOidPoses.containsKey(ecId)) {
                String[] poses = formOidPoses.get(ecId).split("---");
                int p0 = Integer.parseInt(poses[0]);
                int p1 = Integer.parseInt(poses[1]);
                int p2 = Integer.parseInt(poses[2]);
                String entityID = data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getExportFormData().get(p2).getFormOID();
                data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getExportFormData().get(p2).getDiscrepancyNotes().setEntityID(entityID);
                data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getExportFormData().get(p2).getDiscrepancyNotes().getDiscrepancyNotes().add(dn);
            }
        }
    }
}
Also used : ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Date(java.util.Date) ChildNoteBean(org.akaza.openclinica.bean.odmbeans.ChildNoteBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.odmbeans.DiscrepancyNoteBean) Iterator(java.util.Iterator)

Example 10 with ElementRefBean

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

the class MetadataUnit method getItemRangeCheck.

public static List<RangeCheckBean> getItemRangeCheck(String func, String constraint, String errorMessage, String muOid) {
    // at this time only supports one measurement unit for a RangeCheck,
    // and it is the same as its item unit
    ArrayList<ElementRefBean> unitRefs = new ArrayList<ElementRefBean>();
    ElementRefBean unit = new ElementRefBean();
    unit.setElementDefOID(muOid);
    unitRefs.add(unit);
    List<RangeCheckBean> rcs = new ArrayList<RangeCheckBean>();
    // final String[] odmComparator = { "LT", "LE", "GT", "GE", "EQ", "NE",
    // "IN", "NOTIN" };
    String[] s = func.split("\\(");
    RangeCheckBean rc = new RangeCheckBean();
    if (s[0].equalsIgnoreCase("range")) {
        String[] values = s[1].split("\\,");
        String smaller = values[0];
        String larger = values[1].trim();
        larger = larger.substring(0, larger.length() - 1);
        rc.setComparator("GE");
        rc.setSoftHard(constraint);
        rc.getErrorMessage().setText(errorMessage);
        rc.setCheckValue(smaller);
        rc.setMeasurementUnitRefs(unitRefs);
        rcs.add(rc);
        rc = new RangeCheckBean();
        rc.setComparator("LE");
        rc.setSoftHard(constraint);
        rc.getErrorMessage().setText(errorMessage);
        rc.setCheckValue(larger);
        rc.setMeasurementUnitRefs(unitRefs);
        rcs.add(rc);
    } else {
        rc = new RangeCheckBean();
        String value = s[1].trim();
        value = value.substring(0, value.length() - 1);
        if (s[0].equalsIgnoreCase("gt")) {
            rc.setComparator("GT");
        } else if (s[0].equalsIgnoreCase("lt")) {
            rc.setComparator("LT");
        } else if (s[0].equalsIgnoreCase("gte")) {
            rc.setComparator("GE");
        } else if (s[0].equalsIgnoreCase("lte")) {
            rc.setComparator("LE");
        } else if (s[0].equalsIgnoreCase("ne")) {
            rc.setComparator("NE");
        } else if (s[0].equalsIgnoreCase("eq")) {
            rc.setComparator("EQ");
        }
        rc.setSoftHard(constraint);
        rc.getErrorMessage().setText(errorMessage);
        rc.setCheckValue(value);
        rc.setMeasurementUnitRefs(unitRefs);
        rcs.add(rc);
    }
    return rcs;
}
Also used : ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) RangeCheckBean(org.akaza.openclinica.bean.odmbeans.RangeCheckBean) ArrayList(java.util.ArrayList)

Aggregations

ElementRefBean (org.akaza.openclinica.bean.odmbeans.ElementRefBean)19 ArrayList (java.util.ArrayList)15 HashMap (java.util.HashMap)9 Iterator (java.util.Iterator)9 LinkedHashMap (java.util.LinkedHashMap)9 ChildNoteBean (org.akaza.openclinica.bean.odmbeans.ChildNoteBean)5 DiscrepancyNoteBean (org.akaza.openclinica.bean.odmbeans.DiscrepancyNoteBean)5 FormDefBean (org.akaza.openclinica.bean.odmbeans.FormDefBean)5 StudyEventDefBean (org.akaza.openclinica.bean.odmbeans.StudyEventDefBean)5 Date (java.util.Date)4 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)4 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)4 HashSet (java.util.HashSet)3 ItemGroupDefBean (org.akaza.openclinica.bean.odmbeans.ItemGroupDefBean)3 CodeListBean (org.akaza.openclinica.bean.odmbeans.CodeListBean)2 CodeListItemBean (org.akaza.openclinica.bean.odmbeans.CodeListItemBean)2 ConfigurationParameters (org.akaza.openclinica.bean.odmbeans.ConfigurationParameters)2 FormDetailsBean (org.akaza.openclinica.bean.odmbeans.FormDetailsBean)2 ItemDefBean (org.akaza.openclinica.bean.odmbeans.ItemDefBean)2 MetaDataVersionProtocolBean (org.akaza.openclinica.bean.odmbeans.MetaDataVersionProtocolBean)2