Search in sources :

Example 81 with StudyEventDefinitionBean

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

the class EventService method scheduleEvent.

public HashMap<String, String> scheduleEvent(UserAccountBean user, Date startDateTime, Date endDateTime, String location, String studyUniqueId, String siteUniqueId, String eventDefinitionOID, String studySubjectId) throws OpenClinicaSystemException {
    // Business Validation
    StudyBean study = getStudyDao().findByUniqueIdentifier(studyUniqueId);
    int parentStudyId = study.getId();
    if (siteUniqueId != null) {
        study = getStudyDao().findSiteByUniqueIdentifier(studyUniqueId, siteUniqueId);
    }
    StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionDao().findByOidAndStudy(eventDefinitionOID, study.getId(), parentStudyId);
    StudySubjectBean studySubject = getStudySubjectDao().findByLabelAndStudy(studySubjectId, study);
    Integer studyEventOrdinal = null;
    if (canSubjectScheduleAnEvent(studyEventDefinition, studySubject)) {
        StudyEventBean studyEvent = new StudyEventBean();
        studyEvent.setStudyEventDefinitionId(studyEventDefinition.getId());
        studyEvent.setStudySubjectId(studySubject.getId());
        studyEvent.setLocation(location);
        studyEvent.setDateStarted(startDateTime);
        studyEvent.setDateEnded(endDateTime);
        studyEvent.setOwner(user);
        studyEvent.setStatus(Status.AVAILABLE);
        studyEvent.setSubjectEventStatus(SubjectEventStatus.SCHEDULED);
        studyEvent.setSampleOrdinal(getStudyEventDao().getMaxSampleOrdinal(studyEventDefinition, studySubject) + 1);
        studyEvent = (StudyEventBean) getStudyEventDao().create(studyEvent, true);
        studyEventOrdinal = studyEvent.getSampleOrdinal();
    } else {
        throw new OpenClinicaSystemException("Cannot schedule an event for this Subject");
    }
    HashMap<String, String> h = new HashMap<String, String>();
    h.put("eventDefinitionOID", eventDefinitionOID);
    h.put("studyEventOrdinal", studyEventOrdinal.toString());
    h.put("studySubjectOID", studySubject.getOid());
    return h;
}
Also used : StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) HashMap(java.util.HashMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException)

Example 82 with StudyEventDefinitionBean

use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean 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);
    FormLayoutDAO formLayoutDAO = new FormLayoutDAO(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, FormLayoutBean> formLayoutById = formLayoutDAO.buildFormLayoutById(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, formLayoutById, crfById, event.getStudyEventDefinitionId(), eventDefinitionCRFs));
        ArrayList<DisplayEventDefinitionCRFBean> al = getUncompletedCRFs(eventDefinitionCRFs, eventCRFs, event.getSubjectEventStatus(), nonEmptyEventCrf, formLayoutById, crfById);
        populateUncompletedCRFsWithCRFAndVersions(al, formLayoutById, 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) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) 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) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Example 83 with StudyEventDefinitionBean

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

the class OdmExtractDAO method getEventDefCRF.

private EventDefinitionCRFBean getEventDefCRF(StudyEventDefBean studyEventDefBean, ElementRefBean formRef, int studyId) {
    StudyBean studyBean = (StudyBean) sdao.findByPK(studyId);
    StudyEventDefinitionBean sedBean = seddao.findByOid(studyEventDefBean.getOid());
    CRFBean crfBean = crfdao.findByOid(formRef.getElementDefOID());
    return edcdao.findByStudyEventDefinitionIdAndCRFId(studyBean, sedBean.getId(), crfBean.getId());
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 84 with StudyEventDefinitionBean

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

the class RandomizeActionValidator method validateOidInPropertyBean.

public void validateOidInPropertyBean(PropertyBean propertyBean, Errors e, String p) {
    if (getExpressionService().isExpressionPartial(getRuleSetBean().getTarget().getValue())) {
        if (getExpressionService().getExpressionSize(propertyBean.getOid()).intValue() > 3) {
            e.rejectValue(p + "oid", "oid.invalid", "OID: " + propertyBean.getOid() + " is Invalid.");
        }
        try {
            getExpressionService().isExpressionValid(propertyBean.getOid());
        } catch (OpenClinicaSystemException ose) {
            e.rejectValue(p + "oid", "oid.invalid", "OID: " + propertyBean.getOid() + " is Invalid.");
        }
        // Use OID in destinationProperty to get CRF
        CRFBean destinationPropertyOidCrf = getExpressionService().getCRFFromExpression(propertyBean.getOid());
        if (destinationPropertyOidCrf == null) {
            ItemBean item = getExpressionService().getItemBeanFromExpression(propertyBean.getOid());
            destinationPropertyOidCrf = getCrfDAO().findByItemOid(item.getOid());
        }
        // Use Target get CRF
        CRFBean targetCrf = getExpressionService().getCRFFromExpression(getRuleSetBean().getTarget().getValue());
        if (targetCrf == null) {
            ItemBean item = getExpressionService().getItemBeanFromExpression(getRuleSetBean().getTarget().getValue());
            targetCrf = getCrfDAO().findByItemOid(item.getOid());
        }
        // Get All event definitions the selected CRF belongs to
        List<StudyEventDefinitionBean> destinationPropertyStudyEventDefinitions = getStudyEventDefinitionDAO().findAllByCrf(destinationPropertyOidCrf);
        List<StudyEventDefinitionBean> targetStudyEventDefinitions = getStudyEventDefinitionDAO().findAllByCrf(targetCrf);
        Collection intersection = CollectionUtils.intersection(destinationPropertyStudyEventDefinitions, targetStudyEventDefinitions);
        if (intersection.size() == 0) {
            e.rejectValue(p + "oid", "oid.invalid", "OID: " + propertyBean.getOid() + " is Invalid.");
        }
    } else {
        String expression = getExpressionService().constructFullExpressionIfPartialProvided(propertyBean.getOid(), getRuleSetBean().getTarget().getValue());
        ItemBean item = getExpressionService().getItemBeanFromExpression(expression);
        if (!getExpressionService().isRandomizeActionExpressionValid(propertyBean.getOid(), getRuleSetBean(), 3) || item == null) {
            e.rejectValue(p + "oid", "oid.invalid", "OID: " + propertyBean.getOid() + " is Invalid.");
        }
    }
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) Collection(java.util.Collection) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 85 with StudyEventDefinitionBean

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

the class StudyEventDefinitionDAO method findByName.

/*
     * added tbh, 02/2008 (non-Javadoc)
     *
     * @see org.akaza.openclinica.dao.core.DAOInterface#findByPK(int)
     */
public EntityBean findByName(String name) {
    StudyEventDefinitionBean eb = new StudyEventDefinitionBean();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(new Integer(1), name);
    String sql = digester.getQuery("findByName");
    ArrayList alist = this.select(sql, variables);
    Iterator it = alist.iterator();
    if (it.hasNext()) {
        eb = (StudyEventDefinitionBean) this.getEntityFromHashMap((HashMap) it.next());
    }
    return eb;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)

Aggregations

StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)155 ArrayList (java.util.ArrayList)109 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)85 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)65 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)61 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)61 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)56 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)55 HashMap (java.util.HashMap)51 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)51 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)50 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)49 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)49 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 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)39 Date (java.util.Date)37 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)37