Search in sources :

Example 1 with StudyEventDefinitionBean

use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.

the class OdmDataCollector method createFakeStudyObj.

private void createFakeStudyObj() {
    dataset = new DatasetBean();
    odmbean = new ODMBean();
    StudyBean studyBean = new StudyBean();
    studyBean.setName(MetadataUnit.FAKE_STUDY_NAME);
    studyBean.setOid(MetadataUnit.FAKE_STUDY_OID);
    studyBean.setParentStudyId(0);
    StudyEventDefinitionBean sedFake = new StudyEventDefinitionBean();
    sedFake.setName(MetadataUnit.FAKE_SE_NAME);
    sedFake.setOid(MetadataUnit.FAKE_STUDY_EVENT_OID);
    List<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
    seds.add(sedFake);
    LinkedHashMap<String, OdmStudyBase> Bases = new LinkedHashMap<String, OdmStudyBase>();
    Bases.put(studyBean.getOid(), new OdmStudyBase(ds, studyBean, seds));
    // this.studyBaseMap = new LinkedHashMap<String, OdmStudyBase>();
    this.studyBaseMap = Bases;
}
Also used : DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) ODMBean(org.akaza.openclinica.bean.odmbeans.ODMBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with StudyEventDefinitionBean

use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.

the class ImportDataRuleRunnerContainer method initRuleSetsAndTargets.

/**
 * Populate importDataTrueRuleSets and variableAndValue.
 * Precondition: import data file passed validation which means all OIDs are not empty.
 * @param ds
 * @param studyBean
 * @param subjectDataBean
 * @param ruleSetService
 */
@Transactional
public void initRuleSetsAndTargets(DataSource ds, StudyBean studyBean, SubjectDataBean subjectDataBean, RuleSetServiceInterface ruleSetService) {
    this.shouldRunRules = this.shouldRunRules == null ? Boolean.FALSE : this.shouldRunRules;
    this.importDataTrueRuleSets = this.importDataTrueRuleSets == null ? new ArrayList<RuleSetBean>() : this.importDataTrueRuleSets;
    this.variableAndValue = this.variableAndValue == null ? new HashMap<String, String>() : this.variableAndValue;
    studyOid = studyBean.getOid();
    studySubjectOid = subjectDataBean.getSubjectOID();
    StudySubjectBean studySubject = new StudySubjectDAO<String, ArrayList>(ds).findByOid(studySubjectOid);
    HashMap<String, StudyEventDefinitionBean> seds = new HashMap<String, StudyEventDefinitionBean>();
    HashMap<String, CRFVersionBean> cvs = new HashMap<String, CRFVersionBean>();
    ArrayList<StudyEventDataBean> studyEventDataBeans = subjectDataBean.getStudyEventData();
    for (StudyEventDataBean studyEventDataBean : studyEventDataBeans) {
        String sedOid = studyEventDataBean.getStudyEventOID();
        StudyEventDefinitionBean sed;
        if (seds.containsKey(sedOid))
            sed = seds.get(sedOid);
        else {
            sed = new StudyEventDefinitionDAO<String, ArrayList>(ds).findByOid(sedOid);
            seds.put(sedOid, sed);
        }
        ArrayList<FormDataBean> formDataBeans = studyEventDataBean.getFormData();
        for (FormDataBean formDataBean : formDataBeans) {
            String cvOid = formDataBean.getFormOID();
            CRFVersionBean crfVersion;
            if (cvs.containsKey(cvOid))
                crfVersion = cvs.get(cvOid);
            else {
                crfVersion = new CRFVersionDAO<String, ArrayList>(ds).findByOid(cvOid);
                cvs.put(cvOid, crfVersion);
            }
            String sedOrd = studyEventDataBean.getStudyEventRepeatKey();
            Integer sedOrdinal = sedOrd != null && !sedOrd.isEmpty() ? Integer.valueOf(sedOrd) : 1;
            StudyEventBean studyEvent = (StudyEventBean) new StudyEventDAO(ds).findByStudySubjectIdAndDefinitionIdAndOrdinal(studySubject.getId(), sed.getId(), sedOrdinal);
            List<RuleSetBean> ruleSets = ruleSetService.getRuleSetsByCrfStudyAndStudyEventDefinition(studyBean, sed, crfVersion);
            // Set<String> targetItemOids = new HashSet<String>();
            if (ruleSets != null && !ruleSets.isEmpty()) {
                ruleSets = filterByImportDataEntryTrue(ruleSets);
                if (ruleSets != null && !ruleSets.isEmpty()) {
                    ruleSets = ruleSetService.filterByStatusEqualsAvailable(ruleSets);
                    ruleSets = ruleSetService.filterRuleSetsByStudyEventOrdinal(ruleSets, studyEvent, crfVersion, sed);
                    // ruleSets = ruleSetService.filterRuleSetsByHiddenItems(ruleSets, eventCrfBean, crfVersion, new ArrayList<ItemBean>());
                    shouldRunRules = ruleSetService.shouldRunRulesForRuleSets(ruleSets, Phase.IMPORT);
                    if (shouldRunRules != null && shouldRunRules == Boolean.TRUE) {
                        // targetItemOids = collectTargetItemOids(ruleSets);
                        HashMap<String, Integer> grouped = new HashMap<String, Integer>();
                        ArrayList<ImportItemGroupDataBean> itemGroupDataBeans = formDataBean.getItemGroupData();
                        for (ImportItemGroupDataBean itemGroupDataBean : itemGroupDataBeans) {
                            ArrayList<ImportItemDataBean> itemDataBeans = itemGroupDataBean.getItemData();
                            for (ImportItemDataBean importItemDataBean : itemDataBeans) {
                                // if(targetItemOids.contains(importItemDataBean.getItemOID())) {
                                ItemBean item = new ItemDAO<String, ArrayList>(ds).findByOid(importItemDataBean.getItemOID()).get(0);
                                String igOid = itemGroupDataBean.getItemGroupOID();
                                String igOrd = itemGroupDataBean.getItemGroupRepeatKey();
                                Integer igOrdinal = igOrd != null && !igOrd.isEmpty() ? Integer.valueOf(igOrd) : 1;
                                // logic from DataEntryServlet method: populateRuleSpecificHashMaps()
                                if (isRepeatIGForSure(ds, crfVersion.getId(), igOid, igOrdinal, item.getId())) {
                                    String key1 = igOid + "[" + igOrdinal + "]." + importItemDataBean.getItemOID();
                                    String key = igOid + "." + importItemDataBean.getItemOID();
                                    variableAndValue.put(key1, importItemDataBean.getValue());
                                    if (grouped.containsKey(key)) {
                                        grouped.put(key, grouped.get(key) + 1);
                                    } else {
                                        grouped.put(key, 1);
                                    }
                                } else {
                                    variableAndValue.put(importItemDataBean.getItemOID(), importItemDataBean.getValue());
                                    grouped.put(importItemDataBean.getItemOID(), 1);
                                }
                            // 
                            // }
                            }
                        }
                        ruleSets = ruleSetService.solidifyGroupOrdinalsUsingFormProperties(ruleSets, grouped);
                        importDataTrueRuleSets.addAll(ruleSets);
                    }
                }
            }
        }
    }
}
Also used : ImportItemGroupDataBean(org.akaza.openclinica.bean.submit.crfdata.ImportItemGroupDataBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) HashMap(java.util.HashMap) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ImportItemDataBean(org.akaza.openclinica.bean.submit.crfdata.ImportItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudyEventDataBean(org.akaza.openclinica.bean.submit.crfdata.StudyEventDataBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) FormDataBean(org.akaza.openclinica.bean.submit.crfdata.FormDataBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with StudyEventDefinitionBean

use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.

the class MetadataUnit method collectMetaDataVersion.

private void collectMetaDataVersion() {
    ArrayList<StudyEventDefinitionBean> sedBeansInStudy = (ArrayList<StudyEventDefinitionBean>) studyBase.getSedBeansInStudy();
    if (sedBeansInStudy == null || sedBeansInStudy.size() < 1) {
        logger.info("null, because there is no study event definition in this study.");
        return;
    }
    StudyBean study = studyBase.getStudy();
    StudyConfigService studyConfig = new StudyConfigService(this.ds);
    study = studyConfig.setParametersForStudy(study);
    MetaDataVersionBean metadata = this.odmStudy.getMetaDataVersion();
    metadata.setStudy(study);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(this.ds);
    int parentId = study.getParentStudyId() > 0 ? study.getParentStudyId() : study.getId();
    StudyParameterValueBean spv = spvdao.findByHandleAndStudy(parentId, "discrepancyManagement");
    metadata.setSoftHard(spv.getValue().equalsIgnoreCase("true") ? "Hard" : "Soft");
    OdmExtractDAO oedao = new OdmExtractDAO(this.ds);
    int studyId = study.getId();
    int parentStudyId = study.getParentStudyId() > 0 ? study.getParentStudyId() : studyId;
    if (this.getCategory() == 1 && study.isSite(study.getParentStudyId())) {
        // populate MetaDataVersion attributes
        if (dataset != null) {
            metadata.setOid(dataset.getODMMetaDataVersionOid() + "-" + study.getOid());
            metadata.setName(dataset.getODMMetaDataVersionName() + "-" + study.getOid());
            this.setParentMetaDataVersionOid(dataset.getODMMetaDataVersionOid());
        }
        if (metadata.getOid() == null || metadata.getOid().length() <= 0) {
            metadata.setOid("v1.0.0" + "-" + study.getOid());
            this.setParentMetaDataVersionOid("v1.0.0");
        }
        if (metadata.getName() == null || metadata.getName().length() <= 0) {
            metadata.setName("MetaDataVersion_v1.0.0" + "-" + study.getOid());
        }
        // populate Include
        this.collectIncludeFromParentInSameFile();
        // populate protocol
        oedao.getUpdatedSiteMetadata(parentStudyId, studyId, metadata, this.odmBean.getODMVersion());
    } else {
        if (dataset != null) {
            metadata.setOid(dataset.getODMMetaDataVersionOid());
            metadata.setName(dataset.getODMMetaDataVersionName());
        }
        if (metadata.getOid() == null || metadata.getOid().length() <= 0) {
            metadata.setOid("v1.0.0");
        }
        if (metadata.getName() == null || metadata.getName().length() <= 0) {
            metadata.setName("MetaDataVersion_v1.0.0");
        }
        // populate Include
        String psOid = new String();
        String pmOid = new String();
        if (dataset != null) {
            psOid = dataset.getODMPriorStudyOid();
            pmOid = dataset.getODMPriorMetaDataVersionOid();
        }
        if (pmOid != null && pmOid.length() > 0) {
            MetaDataVersionIncludeBean ib = metadata.getInclude();
            ib.setMetaDataVersionOID(pmOid);
            if (psOid != null && psOid.length() > 0) {
                ib.setStudyOID(psOid);
            } else {
                ib.setStudyOID(study.getOid());
            }
        }
        // populate protocol
        // Set<Integer> nullCodeSet = oedao.getMetadata(parentStudyId,
        // studyId,
        // metadata, this.getODMBean().getODMVersion());
        // studyBase.setNullClSet(nullCodeSet);
        oedao.getMetadata(parentStudyId, studyId, metadata, this.odmBean.getODMVersion());
        metadata.setRuleSetRules(getRuleSetRuleDao().findByRuleSetStudyIdAndStatusAvail(parentStudyId));
    }
}
Also used : StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) MetaDataVersionIncludeBean(org.akaza.openclinica.bean.odmbeans.MetaDataVersionIncludeBean) MetaDataVersionBean(org.akaza.openclinica.bean.odmbeans.MetaDataVersionBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) OdmStudyBean(org.akaza.openclinica.bean.odmbeans.OdmStudyBean) ArrayList(java.util.ArrayList) OdmExtractDAO(org.akaza.openclinica.dao.extract.OdmExtractDAO) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO)

Example 4 with StudyEventDefinitionBean

use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.

the class ImportDataHelper method createEventCRF.

public EventCRFBean createEventCRF(HashMap<String, String> importedObject) {
    EventCRFBean eventCrfBean = null;
    int studyEventId = importedObject.get("study_event_id") == null ? -1 : Integer.parseInt(importedObject.get("study_event_id"));
    String crfVersionName = importedObject.get("crf_version_name") == null ? "" : importedObject.get("crf_version_name").toString();
    String crfName = importedObject.get("crf_name") == null ? "" : importedObject.get("crf_name").toString();
    String eventDefinitionCRFName = importedObject.get("event_definition_crf_name") == null ? "" : importedObject.get("event_definition_crf_name").toString();
    String subjectName = importedObject.get("subject_name") == null ? "" : importedObject.get("subject_name").toString();
    String studyName = importedObject.get("study_name") == null ? "" : importedObject.get("study_name").toString();
    logger.info("found the following: study event id " + studyEventId + ", crf version name " + crfVersionName + ", crf name " + crfName + ", event def crf name " + eventDefinitionCRFName + ", subject name " + subjectName + ", study name " + studyName);
    // << tbh
    int eventCRFId = 0;
    EventCRFDAO eventCrfDao = new EventCRFDAO(sm.getDataSource());
    StudyDAO studyDao = new StudyDAO(sm.getDataSource());
    StudySubjectDAO studySubjectDao = new StudySubjectDAO(sm.getDataSource());
    StudyEventDefinitionDAO studyEventDefinistionDao = new StudyEventDefinitionDAO(sm.getDataSource());
    CRFVersionDAO crfVersionDao = new CRFVersionDAO(sm.getDataSource());
    StudyEventDAO studyEventDao = new StudyEventDAO(sm.getDataSource());
    CRFDAO crfdao = new CRFDAO(sm.getDataSource());
    SubjectDAO subjectDao = new SubjectDAO(sm.getDataSource());
    StudyBean studyBean = (StudyBean) studyDao.findByName(studyName);
    // .findByPK(studyId);
    // generate the subject bean first, so that we can have the subject id
    // below...
    SubjectBean subjectBean = // .findByUniqueIdentifierAndStudy(subjectName,
    subjectDao.findByUniqueIdentifier(subjectName);
    StudySubjectBean studySubjectBean = studySubjectDao.findBySubjectIdAndStudy(subjectBean.getId(), studyBean);
    // .findByLabelAndStudy(subjectName, studyBean);
    logger.info("::: found study subject id here: " + studySubjectBean.getId() + " with the following: subject ID " + subjectBean.getId() + " study bean name " + studyBean.getName());
    StudyEventBean studyEventBean = (StudyEventBean) studyEventDao.findByPK(studyEventId);
    // TODO need to replace, can't really replace
    logger.info("found study event status: " + studyEventBean.getStatus().getName());
    // [study] event should be scheduled, event crf should be not started
    CRFVersionBean crfVersion = (CRFVersionBean) crfVersionDao.findByFullName(crfVersionName, crfName);
    // .findByPK(crfVersionId);
    // replaced by findByName(name, version)
    logger.info("found crf version name here: " + crfVersion.getName());
    EntityBean crf = crfdao.findByPK(crfVersion.getCrfId());
    logger.info("found crf name here: " + crf.getName());
    // trying it again up here since down there doesn't seem to work, tbh
    StudyEventDefinitionBean studyEventDefinitionBean = (StudyEventDefinitionBean) studyEventDefinistionDao.findByName(eventDefinitionCRFName);
    if (studySubjectBean.getId() <= 0 && studyEventBean.getId() <= 0 && crfVersion.getId() <= 0 && studyBean.getId() <= 0 && studyEventDefinitionBean.getId() <= 0) {
        logger.info("Throw an Exception, One of the provided ids is not valid");
    }
    // >> tbh repeating items:
    ArrayList eventCrfBeans = eventCrfDao.findByEventSubjectVersion(studyEventBean, studySubjectBean, crfVersion);
    // TODO repeating items here? not yet
    if (eventCrfBeans.size() > 1) {
        logger.info("found more than one");
    }
    if (!eventCrfBeans.isEmpty() && eventCrfBeans.size() == 1) {
        eventCrfBean = (EventCRFBean) eventCrfBeans.get(0);
        logger.info("This EventCrfBean was found");
    }
    if (!eventCrfBeans.isEmpty() && eventCrfBeans.size() > 1) {
        logger.info("Throw a System exception , result should either be 0 or 1");
    }
    if (eventCrfBean == null) {
        StudyBean studyWithSED = studyBean;
        if (studyBean.getParentStudyId() > 0) {
            studyWithSED = new StudyBean();
            studyWithSED.setId(studyBean.getParentStudyId());
        }
        AuditableEntityBean studyEvent = studyEventDao.findByPKAndStudy(studyEventId, studyWithSED);
        if (studyEvent.getId() <= 0) {
            logger.info("Hello Exception");
        }
        eventCrfBean = new EventCRFBean();
        // eventCrfBean.setCrfVersion(crfVersion);
        if (eventCRFId == 0) {
            // ???
            if (studyBean.getStudyParameterConfig().getInterviewerNameDefault().equals("blank")) {
                eventCrfBean.setInterviewerName("");
            } else {
                // default will be event's owner name
                eventCrfBean.setInterviewerName(studyEventBean.getOwner().getName());
            }
            if (!studyBean.getStudyParameterConfig().getInterviewDateDefault().equals("blank")) {
                if (studyEventBean.getDateStarted() != null) {
                    // default
                    eventCrfBean.setDateInterviewed(studyEventBean.getDateStarted());
                // date
                } else {
                    // logger.info("evnet start date is null, so date
                    // interviewed is null");
                    eventCrfBean.setDateInterviewed(null);
                }
            } else {
                eventCrfBean.setDateInterviewed(null);
            }
            eventCrfBean.setAnnotations("");
            eventCrfBean.setCreatedDate(new Date());
            eventCrfBean.setCRFVersionId(crfVersion.getId());
            // eventCrfBean.setCrfVersion((CRFVersionBean)crfVersion);
            eventCrfBean.setOwner(ub);
            // eventCrfBean.setCrf((CRFBean)crf);
            eventCrfBean.setStatus(Status.AVAILABLE);
            eventCrfBean.setCompletionStatusId(1);
            // problem with the line below
            eventCrfBean.setStudySubjectId(studySubjectBean.getId());
            eventCrfBean.setStudyEventId(studyEventId);
            eventCrfBean.setValidateString("");
            eventCrfBean.setValidatorAnnotations("");
            try {
                eventCrfBean = (EventCRFBean) eventCrfDao.create(eventCrfBean);
            // TODO review
            // eventCrfBean.setCrfVersion((CRFVersionBean)crfVersion);
            // eventCrfBean.setCrf((CRFBean)crf);
            } catch (Exception ee) {
                logger.info(ee.getMessage());
                logger.info("throws with crf version id " + crfVersion.getId() + " and study event id " + studyEventId + " study subject id " + studySubjectBean.getId());
            }
        // note that you need to catch an exception if the numbers are
        // bogus, ie you can throw an error here
        // however, putting the try catch allows you to pass which is
        // also bad
        // logger.info("CREATED EVENT CRF");
        } else {
            // there is an event CRF already, only need to update
            // is the status not started???
            logger.info("*** already-started event CRF with msg: " + eventCrfBean.getStatus().getName());
            if (eventCrfBean.getStatus().equals(Status.PENDING)) {
                logger.info("Not Started???");
            }
            eventCrfBean = (EventCRFBean) eventCrfDao.findByPK(eventCRFId);
            eventCrfBean.setCRFVersionId(crfVersion.getId());
            eventCrfBean.setUpdatedDate(new Date());
            eventCrfBean.setUpdater(ub);
            eventCrfBean = (EventCRFBean) eventCrfDao.update(eventCrfBean);
        // eventCrfBean.setCrfVersion((CRFVersionBean)crfVersion);
        // eventCrfBean.setCrf((CRFBean)crf);
        }
        if (eventCrfBean.getId() <= 0) {
            logger.info("error");
        } else {
            // TODO change status here, tbh
            // 2/08 this part seems to work, tbh
            studyEventBean.setSubjectEventStatus(SubjectEventStatus.DATA_ENTRY_STARTED);
            studyEventBean.setUpdater(ub);
            studyEventBean.setUpdatedDate(new Date());
            studyEventDao.update(studyEventBean);
        }
    }
    eventCrfBean.setCrfVersion(crfVersion);
    eventCrfBean.setCrf((CRFBean) crf);
    // repeating?
    return eventCrfBean;
}
Also used : EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) AuditableEntityBean(org.akaza.openclinica.bean.core.AuditableEntityBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) Date(java.util.Date) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EntityBean(org.akaza.openclinica.bean.core.EntityBean) AuditableEntityBean(org.akaza.openclinica.bean.core.AuditableEntityBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 5 with StudyEventDefinitionBean

use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.

the class BatchCRFMigrationServlet method processRequest.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    ArrayList<CRFVersionBean> crfVersionList = null;
    ArrayList<StudyEventDefinitionBean> eventList = null;
    ArrayList<StudyBean> siteList = null;
    // checks which module the requests are from, manage or admin
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    int crfId = fp.getInt(CRF_ID);
    if (crfId == 0) {
        addPageMessage(respage.getString("please_choose_a_CRF_to_view"));
        forwardPage(Page.CRF_LIST);
    } else {
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource());
        CRFBean crf = (CRFBean) cdao.findByPK(crfId);
        request.setAttribute("crfName", crf.getName());
        ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) vdao.findAllByCRF(crfId);
        crfVersionList = new ArrayList<CRFVersionBean>();
        for (CRFVersionBean version : versions) {
            if (version.getStatus().isAvailable())
                crfVersionList.add(version);
        }
        crf.setVersions(crfVersionList);
        ArrayList<StudyBean> listOfSites = (ArrayList<StudyBean>) sdao().findAllByParent(currentStudy.getId());
        siteList = new ArrayList<StudyBean>();
        StudyBean studyBean = new StudyBean();
        studyBean.setOid(currentStudy.getOid());
        studyBean.setName(resterm.getString("Study_Level_Subjects_Only"));
        siteList.add(studyBean);
        for (StudyBean s : listOfSites) {
            if (s.getStatus().isAvailable()) {
                siteList.add(s);
            }
        }
        ArrayList<StudyEventDefinitionBean> listOfDefn = seddao().findAllByStudy(currentStudy);
        eventList = new ArrayList<StudyEventDefinitionBean>();
        for (StudyEventDefinitionBean d : listOfDefn) {
            if (d.getStatus().isAvailable()) {
                eventList.add(d);
            }
        }
        // if coming from change crf version -> display message
        String crfVersionChangeMsg = fp.getString("isFromCRFVersionBatchChange");
        if (crfVersionChangeMsg != null && !crfVersionChangeMsg.equals("")) {
            addPageMessage(crfVersionChangeMsg);
        }
        request.setAttribute("study", currentStudy);
        request.setAttribute("siteList", siteList);
        request.setAttribute("eventList", eventList);
        request.setAttribute(CRF, crf);
        forwardPage(Page.BATCH_CRF_MIGRATION);
    }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean)

Aggregations

StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)156 ArrayList (java.util.ArrayList)107 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)86 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)65 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)63 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)62 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)56 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)56 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)52 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)52 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)50 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)50 HashMap (java.util.HashMap)49 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)49 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)48 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)48 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)45 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)45 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)42 Date (java.util.Date)37