Search in sources :

Example 81 with StudyEventBean

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

the class ExtractBean method getSEDCRFVersionName.

private String getSEDCRFVersionName(int h, int sedInd, int crfInd) {
    // syncCRFIndex(sedInd, crfInd);
    StudyEventBean seb = getEvent(h, sedInd, crfInd);
    EventCRFBean eventCRF = null;
    if (seb.getEventCRFs().size() > 0) {
        eventCRF = (EventCRFBean) seb.getEventCRFs().get(0);
    }
    String returnMe = "";
    // EventCRFBean eventCRF = null;
    if (seb.getEventCRFs().size() > 0) {
        logger.info("found getEventCRFs.size " + seb.getEventCRFs().size());
        for (int t = 0; t < seb.getEventCRFs().size(); t++) {
            eventCRF = (EventCRFBean) seb.getEventCRFs().get(t);
            returnMe = eventCRF.getCrfVersion().getName();
        // logger.info("found versions.size "+versions.size());
        // for (int s = 0; s < versions.size(); s++) {
        // CRFVersionBean version = (CRFVersionBean)versions.get(s);
        // if (version.getId()==eventCRF.getCRFVersionId()) {
        // returnMe = version.getName();
        // break;
        // }
        // }
        }
    }
    logger.info("returning the following for crf version name: " + returnMe);
    return returnMe;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean)

Example 82 with StudyEventBean

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

the class ExtractBean method getCRFInterviewerDate.

protected String getCRFInterviewerDate(int h, int i, int j) {
    StudyEventBean seb = getEvent(h, i, j);
    EventCRFBean eventCRF = null;
    if (seb.getEventCRFs().size() > 0) {
        eventCRF = (EventCRFBean) seb.getEventCRFs().get(0);
    }
    // c.setTime(eventCRF.getDateInterviewed());
    return eventCRF != null && eventCRF.getDateInterviewed() != null ? sdf.format(eventCRF.getDateInterviewed()) : "";
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean)

Example 83 with StudyEventBean

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

the class ExtractBean method getAgeAtEvent.

private String getAgeAtEvent(int h, int i, int j) {
    // syncSubjectIndex(h);
    StudyEventBean seb = getEvent(h, i, j);
    Date startDate = seb.getDateStarted();
    // to try and avoid NPEs, tbh 092007
    startDate = seb.getDateStarted() != null ? seb.getDateStarted() : new Date();
    Date age = currentSubject.getDateOfBirth();
    String answer = "";
    if (age.before(startDate)) {
        Calendar dateOfBirth = Calendar.getInstance();
        // new GregorianCalendar(age);
        dateOfBirth.setTime(age);
        // new
        Calendar theStartDate = Calendar.getInstance();
        // GregorianCalendar(startDate);
        theStartDate.setTime(startDate);
        int theAge = theStartDate.get(Calendar.YEAR) - dateOfBirth.get(Calendar.YEAR);
        Calendar today = Calendar.getInstance();
        // add the age to the year to see if it's happened yet
        dateOfBirth.add(Calendar.YEAR, theAge);
        // subtract one from the age if the birthday hasn't happened yet
        if (today.before(dateOfBirth)) {
            theAge--;
        }
        answer = "" + theAge;
    } else {
        // ideally should not get here, but we have an 'error' code if it
        // does, tbh
        answer = "-1";
    // logger.info("reached error state for age at event");
    }
    return answer;
}
Also used : Calendar(java.util.Calendar) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) Date(java.util.Date)

Example 84 with StudyEventBean

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

the class ExtractBean method getCRFVersionName.

protected String getCRFVersionName(int h, int i, int j) {
    // syncCRFIndex(ind, crfv);
    // how to cross ref this with what's being entered???
    // return currentCRF.getVersions()
    StudyEventBean seb = getEvent(h, i, j);
    EventCRFBean eventCRF = null;
    if (seb.getEventCRFs().size() == 1) {
        eventCRF = (EventCRFBean) seb.getEventCRFs().get(0);
    } else {
        eventCRF = (EventCRFBean) seb.getEventCRFs().get(j - 1);
    }
    return eventCRF != null ? eventCRF.getCrfVersion().getName() : "";
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean)

Example 85 with StudyEventBean

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

the class StudySubjectServiceImpl method getDisplayStudyEventsForStudySubject.

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<DisplayStudyEventBean> getDisplayStudyEventsForStudySubject(StudySubjectBean studySubject, UserAccountBean userAccount, StudyUserRoleBean currentRole) {
    StudyEventDAO studyEventDao = new StudyEventDAO(dataSource);
    StudyEventDefinitionDAO studyEventDefinitionDao = new StudyEventDefinitionDAO(dataSource);
    StudyDAO studyDao = new StudyDAO(dataSource);
    EventDefinitionCRFDAO eventDefinitionCrfDao = new EventDefinitionCRFDAO(dataSource);
    EventCRFDAO eventCrfDao = new EventCRFDAO(dataSource);
    CRFDAO crfDao = new CRFDAO(dataSource);
    CRFVersionDAO crfVersionDao = new CRFVersionDAO(dataSource);
    ArrayList events = studyEventDao.findAllByStudySubject(studySubject);
    Map<Integer, StudyEventDefinitionBean> eventDefinitionByEvent = studyEventDefinitionDao.findByStudySubject(studySubject.getId());
    StudyBean study = (StudyBean) studyDao.findByPK(studySubject.getStudyId());
    Map<Integer, SortedSet<EventDefinitionCRFBean>> eventDefinitionCrfByStudyEventDefinition;
    if (study.getParentStudyId() < 1) {
        // Is a study
        eventDefinitionCrfByStudyEventDefinition = eventDefinitionCrfDao.buildEventDefinitionCRFListByStudyEventDefinitionForStudy(studySubject.getId());
    } else {
        // Is a site
        eventDefinitionCrfByStudyEventDefinition = eventDefinitionCrfDao.buildEventDefinitionCRFListByStudyEventDefinition(studySubject.getId(), study.getId(), study.getParentStudyId());
    }
    Map<Integer, SortedSet<EventCRFBean>> eventCrfListByStudyEvent = eventCrfDao.buildEventCrfListByStudyEvent(studySubject.getId());
    Map<Integer, Integer> maxOrdinalByStudyEvent = studyEventDefinitionDao.buildMaxOrdinalByStudyEvent(studySubject.getId());
    Set<Integer> nonEmptyEventCrf = eventCrfDao.buildNonEmptyEventCrfIds(studySubject.getId());
    Map<Integer, CRFVersionBean> crfVersionById = crfVersionDao.buildCrfVersionById(studySubject.getId());
    Map<Integer, CRFBean> crfById = crfDao.buildCrfById(studySubject.getId());
    ArrayList<DisplayStudyEventBean> displayEvents = new ArrayList<DisplayStudyEventBean>();
    for (int i = 0; i < events.size(); i++) {
        StudyEventBean event = (StudyEventBean) events.get(i);
        StudyEventDefinitionBean sed = eventDefinitionByEvent.get(event.getStudyEventDefinitionId());
        event.setStudyEventDefinition(sed);
        List eventDefinitionCRFs = new ArrayList((eventDefinitionCrfByStudyEventDefinition.containsKey(sed.getId()) ? eventDefinitionCrfByStudyEventDefinition.get(sed.getId()) : Collections.EMPTY_LIST));
        List eventCRFs = new ArrayList((eventCrfListByStudyEvent.containsKey(event.getId())) ? eventCrfListByStudyEvent.get(event.getId()) : Collections.EMPTY_LIST);
        // construct info needed on view study event page
        DisplayStudyEventBean de = new DisplayStudyEventBean();
        de.setStudyEvent(event);
        de.setDisplayEventCRFs((ArrayList<DisplayEventCRFBean>) getDisplayEventCRFs(eventCRFs, userAccount, currentRole, event.getSubjectEventStatus(), study, nonEmptyEventCrf, crfVersionById, crfById, event.getStudyEventDefinitionId(), eventDefinitionCRFs));
        ArrayList<DisplayEventDefinitionCRFBean> al = getUncompletedCRFs(eventDefinitionCRFs, eventCRFs, event.getSubjectEventStatus(), nonEmptyEventCrf, crfVersionById, crfById);
        populateUncompletedCRFsWithCRFAndVersions(al, crfVersionById, crfById);
        de.setUncompletedCRFs(al);
        // de.setMaximumSampleOrdinal(studyEventDao.getMaxSampleOrdinal(sed,
        // studySubject));
        de.setMaximumSampleOrdinal(maxOrdinalByStudyEvent.get(event.getStudyEventDefinitionId()));
        displayEvents.add(de);
    // event.setEventCRFs(createAllEventCRFs(eventCRFs,
    // eventDefinitionCRFs));
    }
    return displayEvents;
}
Also used : ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) SortedSet(java.util.SortedSet) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) ArrayList(java.util.ArrayList) List(java.util.List) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Aggregations

StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)162 ArrayList (java.util.ArrayList)103 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)91 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)90 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)74 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)71 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)62 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)62 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)60 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)58 Date (java.util.Date)52 HashMap (java.util.HashMap)50 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)47 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)43 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)37 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)37 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)36 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)34 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)34 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)31