Search in sources :

Example 26 with EventCRFDAO

use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.

the class ViewStudyEventsServlet method genEventsForPrint.

/**
     * Generates an arraylist of study events for printing
     *
     * @param fp
     * @param definitions
     * @param startDate
     * @param endDate
     * @param sedId
     * @param definitionId
     * @param statusId
     * @return
     */
private ArrayList genEventsForPrint(FormProcessor fp, ArrayList definitions, Date startDate, Date endDate, int sedId, int definitionId, int statusId) {
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    ArrayList allEvents = new ArrayList();
    definitions = findDefinitionById(definitions, definitionId);
    // YW <<
    StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
    ArrayList studySubjects = ssdao.findAllByStudyId(currentStudy.getId());
    // YW >>
    for (int i = 0; i < definitions.size(); i++) {
        ViewEventDefinitionBean ved = new ViewEventDefinitionBean();
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) definitions.get(i);
        ved.setDefinition(sed);
        // YW <<
        ArrayList events = new ArrayList();
        for (int s = 0; s < studySubjects.size(); ++s) {
            StudySubjectBean ssb = (StudySubjectBean) studySubjects.get(s);
            ArrayList evts = sedao.findAllWithSubjectLabelByStudySubjectAndDefinition(ssb, sed.getId());
            for (int v = 0; v < evts.size(); ++v) {
                events.add(evts.get(v));
            }
        }
        // YW >>
        int subjectScheduled = 0;
        int subjectCompleted = 0;
        int subjectDiscontinued = 0;
        events = findEventByStatusAndDate(events, statusId, startDate, endDate);
        Date firstStartDateForScheduled = null;
        Date lastCompletionDate = null;
        // find the first firstStartDateForScheduled
        for (int k = 0; k < events.size(); k++) {
            StudyEventBean se = (StudyEventBean) events.get(k);
            if (se.getSubjectEventStatus().equals(SubjectEventStatus.SCHEDULED)) {
                firstStartDateForScheduled = se.getDateStarted();
                break;
            }
        }
        // find the first lastCompletionDate
        for (int k = 0; k < events.size(); k++) {
            StudyEventBean se = (StudyEventBean) events.get(k);
            if (se.getSubjectEventStatus().equals(SubjectEventStatus.COMPLETED)) {
                lastCompletionDate = se.getDateEnded();
                break;
            }
        }
        for (int j = 0; j < events.size(); j++) {
            StudyEventBean se = (StudyEventBean) events.get(j);
            if (se.getSubjectEventStatus().equals(SubjectEventStatus.SCHEDULED)) {
                subjectScheduled++;
                if (se.getDateStarted().before(new Date())) {
                    ArrayList eventCRFs = ecdao.findAllByStudyEvent(se);
                    if (eventCRFs.isEmpty()) {
                        se.setScheduledDatePast(true);
                    }
                }
                if (firstStartDateForScheduled == null) {
                    firstStartDateForScheduled = se.getDateStarted();
                } else if (se.getDateStarted().before(firstStartDateForScheduled)) {
                    firstStartDateForScheduled = se.getDateStarted();
                }
            } else if (se.getSubjectEventStatus().equals(SubjectEventStatus.COMPLETED)) {
                subjectCompleted++;
                if (lastCompletionDate == null) {
                    lastCompletionDate = se.getDateEnded();
                } else if (se.getDateEnded().after(lastCompletionDate)) {
                    lastCompletionDate = se.getDateEnded();
                }
            } else if (se.getSubjectEventStatus().getId() > 4) {
                // dropped out/stopped/skipped/relapse
                subjectDiscontinued++;
            }
        }
        ved.setSubjectCompleted(subjectCompleted);
        ved.setSubjectScheduled(subjectScheduled);
        ved.setSubjectDiscontinued(subjectDiscontinued);
        ved.setFirstScheduledStartDate(firstStartDateForScheduled);
        ved.setLastCompletionDate(lastCompletionDate);
        ved.setStudyEvents(events);
        if (!events.isEmpty()) {
            allEvents.add(ved);
        }
    }
    return allEvents;
}
Also used : StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) 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) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) Date(java.util.Date)

Example 27 with EventCRFDAO

use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.

the class ViewStudyEventsServlet method genTables.

/**
     *
     * @param fp
     * @param definitions
     * @param startDate
     * @param endDate
     * @param sedId
     * @param definitionId
     * @param statusId
     * @return
     */
private ArrayList genTables(FormProcessor fp, ArrayList definitions, Date startDate, Date endDate, int sedId, int definitionId, int statusId) {
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    ArrayList allEvents = new ArrayList();
    definitions = findDefinitionById(definitions, definitionId);
    // YW <<
    StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
    ArrayList studySubjects = ssdao.findAllByStudyId(currentStudy.getId());
    // YW >>
    for (int i = 0; i < definitions.size(); i++) {
        ViewEventDefinitionBean ved = new ViewEventDefinitionBean();
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) definitions.get(i);
        ved.setDefinition(sed);
        // YW <<
        ArrayList events = new ArrayList();
        for (int s = 0; s < studySubjects.size(); ++s) {
            StudySubjectBean ssb = (StudySubjectBean) studySubjects.get(s);
            ArrayList evts = sedao.findAllWithSubjectLabelByStudySubjectAndDefinition(ssb, sed.getId());
            for (int v = 0; v < evts.size(); ++v) {
                StudyEventBean seb = (StudyEventBean) evts.get(v);
                if (!(currentRole.isDirector() || currentRole.isCoordinator()) && seb.getSubjectEventStatus().isLocked()) {
                    seb.setEditable(false);
                }
                events.add(seb);
            }
        }
        int subjectScheduled = 0;
        int subjectCompleted = 0;
        int subjectDiscontinued = 0;
        events = findEventByStatusAndDate(events, statusId, startDate, endDate);
        Date firstStartDateForScheduled = null;
        Date lastCompletionDate = null;
        // find the first firstStartDateForScheduled
        for (int k = 0; k < events.size(); k++) {
            StudyEventBean se = (StudyEventBean) events.get(k);
            if (se.getSubjectEventStatus().equals(SubjectEventStatus.SCHEDULED)) {
                firstStartDateForScheduled = se.getDateStarted();
                break;
            }
        }
        // find the first lastCompletionDate
        for (int k = 0; k < events.size(); k++) {
            StudyEventBean se = (StudyEventBean) events.get(k);
            if (se.getSubjectEventStatus().equals(SubjectEventStatus.COMPLETED) && se.getDateEnded() != null) {
                lastCompletionDate = se.getDateEnded();
                break;
            }
        }
        for (int j = 0; j < events.size(); j++) {
            StudyEventBean se = (StudyEventBean) events.get(j);
            if (se.getSubjectEventStatus().equals(SubjectEventStatus.SCHEDULED)) {
                subjectScheduled++;
                if (se.getDateStarted().before(new Date())) {
                    ArrayList eventCRFs = ecdao.findAllByStudyEvent(se);
                    if (eventCRFs.isEmpty()) {
                        se.setScheduledDatePast(true);
                    }
                }
                if (firstStartDateForScheduled == null) {
                    firstStartDateForScheduled = se.getDateStarted();
                } else if (se.getDateStarted().before(firstStartDateForScheduled)) {
                    firstStartDateForScheduled = se.getDateStarted();
                }
            } else if (se.getSubjectEventStatus().equals(SubjectEventStatus.COMPLETED)) {
                subjectCompleted++;
                if (lastCompletionDate == null) {
                    lastCompletionDate = se.getDateEnded();
                } else if (se.getDateEnded() != null && se.getDateEnded().after(lastCompletionDate)) {
                    lastCompletionDate = se.getDateEnded();
                }
            } else if (se.getSubjectEventStatus().getId() > 4) {
                // dropped out/stopped/skipped/relapse
                subjectDiscontinued++;
            }
        }
        ved.setSubjectCompleted(subjectCompleted);
        ved.setSubjectScheduled(subjectScheduled);
        ved.setSubjectDiscontinued(subjectDiscontinued);
        ved.setFirstScheduledStartDate(firstStartDateForScheduled);
        ved.setLastCompletionDate(lastCompletionDate);
        EntityBeanTable table;
        if (sedId == sed.getId()) {
            // apply finding function or ordering
            // function
            // to a specific table
            table = fp.getEntityBeanTable();
        } else {
            table = new EntityBeanTable();
        }
        // sort by event
        table.setSortingIfNotExplicitlySet(1, false);
        // start date,
        // desc
        ArrayList allEventRows = StudyEventRow.generateRowsFromBeans(events);
        String[] columns = { resword.getString("study_subject_ID"), resword.getString("event_date_started"), resword.getString("subject_event_status"), resword.getString("actions") };
        table.setColumns(new ArrayList(Arrays.asList(columns)));
        table.hideColumnLink(3);
        HashMap args = new HashMap();
        args.put("sedId", new Integer(sed.getId()).toString());
        args.put("definitionId", new Integer(definitionId).toString());
        args.put("statusId", new Integer(statusId).toString());
        args.put("startDate", local_df.format(startDate));
        args.put("endDate", local_df.format(endDate));
        table.setQuery("ViewStudyEvents", args);
        table.setRows(allEventRows);
        table.computeDisplay();
        ved.setStudyEventTable(table);
        if (!events.isEmpty()) {
            allEvents.add(ved);
        }
    }
    //A. Hamid.
    return allEvents;
}
Also used : HashMap(java.util.HashMap) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) 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) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 28 with EventCRFDAO

use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.

the class ViewEventCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    int eventCRFId = fp.getInt("id", true);
    int studySubId = fp.getInt("studySubId", true);
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
    ItemDAO idao = new ItemDAO(sm.getDataSource());
    ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    SectionDAO secdao = new SectionDAO(sm.getDataSource());
    if (eventCRFId == 0) {
        addPageMessage(respage.getString("please_choose_an_event_CRF_to_view"));
        forwardPage(Page.LIST_STUDY_SUBJECTS);
    } else {
        StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
        request.setAttribute("studySub", studySub);
        EventCRFBean eventCRF = (EventCRFBean) ecdao.findByPK(eventCRFId);
        CRFBean crf = cdao.findByVersionId(eventCRF.getCRFVersionId());
        request.setAttribute("crf", crf);
        ArrayList sections = secdao.findAllByCRFVersionId(eventCRF.getCRFVersionId());
        for (int j = 0; j < sections.size(); j++) {
            SectionBean section = (SectionBean) sections.get(j);
            ArrayList itemData = iddao.findAllByEventCRFId(eventCRFId);
            ArrayList displayItemData = new ArrayList();
            for (int i = 0; i < itemData.size(); i++) {
                ItemDataBean id = (ItemDataBean) itemData.get(i);
                DisplayItemBean dib = new DisplayItemBean();
                ItemBean item = (ItemBean) idao.findByPK(id.getItemId());
                ItemFormMetadataBean ifm = ifmdao.findByItemIdAndCRFVersionId(item.getId(), eventCRF.getCRFVersionId());
                item.setItemMeta(ifm);
                dib.setItem(item);
                dib.setData(id);
                dib.setMetadata(ifm);
                displayItemData.add(dib);
            }
            section.setItems(displayItemData);
        }
        request.setAttribute("sections", sections);
        request.setAttribute("studySubId", new Integer(studySubId).toString());
        forwardPage(Page.VIEW_EVENT_CRF);
    }
}
Also used : EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 29 with EventCRFDAO

use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.

the class DataEntryServlet method createEventCRF.

/**
     * Creates a new Event CRF or update the exsiting one, that is, an event CRF can be created but not item data yet, in this case, still consider it is not
     * started(called uncompleted before)
     * @param request TODO
     * @param fp TODO
     *
     * @return
     * @throws Exception
     */
private EventCRFBean createEventCRF(HttpServletRequest request, FormProcessor fp) throws InconsistentStateException {
    locale = LocaleResolver.getLocale(request);
    // < resmessage =
    // ResourceBundle.getBundle("org.akaza.openclinica.i18n.page_messages",
    // locale);
    // < restext =
    // ResourceBundle.getBundle("org.akaza.openclinica.i18n.notes",locale);
    // <
    // resexception=ResourceBundle.getBundle(
    // "org.akaza.openclinica.i18n.exceptions",locale);
    UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    EventCRFBean ecb;
    EventCRFDAO ecdao = new EventCRFDAO(getDataSource());
    int crfVersionId = fp.getInt(INPUT_CRF_VERSION_ID);
    LOGGER.trace("***FOUND*** crfversionid: " + crfVersionId);
    int studyEventId = fp.getInt(INPUT_STUDY_EVENT_ID);
    int eventDefinitionCRFId = fp.getInt(INPUT_EVENT_DEFINITION_CRF_ID);
    int subjectId = fp.getInt(INPUT_SUBJECT_ID);
    int eventCRFId = fp.getInt(INPUT_EVENT_CRF_ID);
    LOGGER.trace("look specifically wrt event crf id: " + eventCRFId);
    LOGGER.trace("Creating event CRF.  Study id: " + currentStudy.getId() + "; CRF Version id: " + crfVersionId + "; Study Event id: " + studyEventId + "; Event Definition CRF id: " + eventDefinitionCRFId + "; Subject: " + subjectId);
    StudySubjectDAO ssdao = new StudySubjectDAO(getDataSource());
    StudySubjectBean ssb = ssdao.findBySubjectIdAndStudy(subjectId, currentStudy);
    if (ssb.getId() <= 0) {
        LOGGER.trace("throwing ISE with study subject bean id of " + ssb.getId());
        // "begin_data_entry_without_event_but_subject"));
        throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("begin_data_entry_without_event_but_subject"));
    }
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(getDataSource());
    StudyEventDefinitionBean sedb = seddao.findByEventDefinitionCRFId(eventDefinitionCRFId);
    // logger.trace("study event definition:" + sedb.getId());
    if (sedb.getId() <= 0) {
        addPageMessage(resexception.getString("begin_data_entry_without_event_but_study"), request);
        throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("begin_data_entry_without_event_but_study"));
    }
    CRFVersionDAO cvdao = new CRFVersionDAO(getDataSource());
    EntityBean eb = cvdao.findByPK(crfVersionId);
    if (eb.getId() <= 0) {
        //addPageMessage(resexception.getString("begin_data_entry_without_event_but_CRF"));
        throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("begin_data_entry_without_event_but_CRF"));
    }
    StudyEventDAO sedao = new StudyEventDAO(getDataSource());
    StudyEventBean sEvent = (StudyEventBean) sedao.findByPK(studyEventId);
    StudyBean studyWithSED = currentStudy;
    if (currentStudy.getParentStudyId() > 0) {
        studyWithSED = new StudyBean();
        studyWithSED.setId(currentStudy.getParentStudyId());
    }
    AuditableEntityBean aeb = sedao.findByPKAndStudy(studyEventId, studyWithSED);
    if (aeb.getId() <= 0) {
        addPageMessage(resexception.getString("begin_data_entry_without_event_but_especified_event"), request);
        throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("begin_data_entry_without_event_but_especified_event"));
    }
    ecb = new EventCRFBean();
    if (eventCRFId == 0) {
        // no event CRF created yet
        ArrayList ecList = ecdao.findByEventSubjectVersion(sEvent, ssb, (CRFVersionBean) eb);
        if (ecList.size() > 0) {
            ecb = (EventCRFBean) ecList.get(0);
        } else {
            ecb.setAnnotations("");
            ecb.setCreatedDate(new Date());
            ecb.setCRFVersionId(crfVersionId);
            if (currentStudy.getStudyParameterConfig().getInterviewerNameDefault().equals("blank")) {
                ecb.setInterviewerName("");
            } else {
                // default will be event's owner name
                ecb.setInterviewerName(sEvent.getOwner().getName());
            }
            if (!currentStudy.getStudyParameterConfig().getInterviewDateDefault().equals("blank")) {
                if (sEvent.getDateStarted() != null) {
                    // default
                    ecb.setDateInterviewed(sEvent.getDateStarted());
                // date
                } else {
                    // logger.trace("evnet start date is null, so date
                    // interviewed is null");
                    ecb.setDateInterviewed(null);
                }
            } else {
                ecb.setDateInterviewed(null);
            // logger.trace("date interviewed is
            // null,getInterviewDateDefault() is blank");
            }
            // ecb.setOwnerId(ub.getId());
            // above depreciated, try without it, tbh
            ecb.setOwner(ub);
            ecb.setStatus(Status.AVAILABLE);
            ecb.setCompletionStatusId(1);
            ecb.setStudySubjectId(ssb.getId());
            ecb.setStudyEventId(studyEventId);
            ecb.setValidateString("");
            ecb.setValidatorAnnotations("");
            ecb = (EventCRFBean) ecdao.create(ecb);
            LOGGER.debug("*********CREATED EVENT CRF");
        }
    } else {
        // there is an event CRF already, only need to update
        ecb = (EventCRFBean) ecdao.findByPK(eventCRFId);
        ecb.setCRFVersionId(crfVersionId);
        ecb.setUpdatedDate(new Date());
        ecb.setUpdater(ub);
        ecb = updateECB(sEvent, request);
        ecb = (EventCRFBean) ecdao.update(ecb);
    }
    if (ecb.getId() <= 0) {
        addPageMessage(resexception.getString("new_event_CRF_not_created"), request);
        throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("new_event_CRF_not_created"));
    } else {
        if (sEvent.getSubjectEventStatus().equals(SubjectEventStatus.SIGNED)) {
            sEvent.setSubjectEventStatus(SubjectEventStatus.COMPLETED);
            sEvent.setUpdater(ub);
            sEvent.setUpdatedDate(new Date());
            sedao.update(sEvent);
        } else {
            sEvent.setSubjectEventStatus(SubjectEventStatus.DATA_ENTRY_STARTED);
            sEvent.setUpdater(ub);
            sEvent.setUpdatedDate(new Date());
            sedao.update(sEvent);
        }
    }
    return ecb;
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) AuditableEntityBean(org.akaza.openclinica.bean.core.AuditableEntityBean) 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) InconsistentStateException(org.akaza.openclinica.web.InconsistentStateException) Date(java.util.Date) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) EntityBean(org.akaza.openclinica.bean.core.EntityBean) AuditableEntityBean(org.akaza.openclinica.bean.core.AuditableEntityBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 30 with EventCRFDAO

use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.

the class CreateOneDiscrepancyNoteServlet method updateStudyEvent.

private void updateStudyEvent(String entityType, int entityId) {
    if ("itemData".equalsIgnoreCase(entityType)) {
        int itemDataId = entityId;
        ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
        ItemDataBean itemData = (ItemDataBean) iddao.findByPK(itemDataId);
        EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
        StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
        EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
        StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
        if (event.getSubjectEventStatus().equals(SubjectEventStatus.SIGNED)) {
            event.setSubjectEventStatus(SubjectEventStatus.COMPLETED);
            event.setUpdater(ub);
            event.setUpdatedDate(new Date());
            svdao.update(event);
        }
    } else if ("eventCrf".equalsIgnoreCase(entityType)) {
        int eventCRFId = entityId;
        EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
        StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
        EventCRFBean ec = (EventCRFBean) ecdao.findByPK(eventCRFId);
        StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
        if (event.getSubjectEventStatus().equals(SubjectEventStatus.SIGNED)) {
            event.setSubjectEventStatus(SubjectEventStatus.COMPLETED);
            event.setUpdater(ub);
            event.setUpdatedDate(new Date());
            svdao.update(event);
        }
    }
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) Date(java.util.Date)

Aggregations

EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)106 ArrayList (java.util.ArrayList)80 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)76 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)73 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)71 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)57 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)51 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)51 Date (java.util.Date)50 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)49 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)49 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)47 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)45 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)45 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)43 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)41 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)37 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)34 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)32 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)24