Search in sources :

Example 1 with DisplayEventCRFBean

use of org.akaza.openclinica.bean.submit.DisplayEventCRFBean in project OpenClinica by OpenClinica.

the class StudyInfoPanel method generateTreeFromBeansWithoutLink.

/**
 * Generates a tree view in sdie info panel for submitting data page
 *
 * @param rows
 * @param displayData
 * @param studySubject
 * @param ecb
 * @return
 */
public ArrayList generateTreeFromBeansWithoutLink(ArrayList rows, ArrayList displayData, StudySubjectBean studySubject, EventCRFBean ecb) {
    Iterator itRows = rows.iterator();
    displayData.add(new StudyInfoPanelLine("Study Events", "(" + rows.size() + ")", true, false, false));
    while (itRows.hasNext()) {
        DisplayStudyEventBean dseBean = (DisplayStudyEventBean) itRows.next();
        StudyEventBean seBean = dseBean.getStudyEvent();
        // checks whether the event is the current one
        if (ecb != null && ecb.getStudyEventId() == seBean.getId()) {
            displayData.add(new StudyInfoPanelLine("Study Event", seBean.getStudyEventDefinition().getName(), true, false, true));
        } else {
            displayData.add(new StudyInfoPanelLine("Study Event", seBean.getStudyEventDefinition().getName(), true, false, false));
        }
        displayData.add(new StudyInfoPanelLine("<b>Status: </b>", seBean.getSubjectEventStatus().getName(), false, false, false));
        ArrayList displayCRFs = dseBean.getDisplayEventCRFs();
        int count = 0;
        Iterator displayIt = displayCRFs.iterator();
        while (displayIt.hasNext()) {
            DisplayEventCRFBean dec = (DisplayEventCRFBean) displayIt.next();
            if (count == displayCRFs.size() - 1 && dseBean.getUncompletedCRFs().size() == 0) {
                // it's the current crf
                if (ecb != null && ecb.getId() == dec.getEventCRF().getId()) {
                    displayData.add(new StudyInfoPanelLine("" + getStageImageText(dec.getStage()), "<span class='alert'>" + dec.getEventCRF().getCrf().getName() + " " + dec.getEventCRF().getCrfVersion().getName() + "</span>", false, true, true));
                } else {
                    displayData.add(new StudyInfoPanelLine("" + getStageImageText(dec.getStage()), dec.getEventCRF().getCrf().getName() + " " + dec.getEventCRF().getCrfVersion().getName(), false, true, false));
                }
            } else {
                if (ecb != null && ecb.getId() == dec.getEventCRF().getId()) {
                    displayData.add(new StudyInfoPanelLine("" + getStageImageText(dec.getStage()), "<span class='alert'>" + dec.getEventCRF().getCrf().getName() + " " + dec.getEventCRF().getCrfVersion().getName() + "</span>", false, false, true));
                } else {
                    displayData.add(new StudyInfoPanelLine("" + getStageImageText(dec.getStage()), dec.getEventCRF().getCrf().getName() + " " + dec.getEventCRF().getCrfVersion().getName(), false, false, false));
                }
            }
            count++;
        }
        count = 0;
        ArrayList uncompleted = dseBean.getUncompletedCRFs();
        Iterator uncompIt = uncompleted.iterator();
        while (uncompIt.hasNext()) {
            DisplayEventDefinitionCRFBean dedc = (DisplayEventDefinitionCRFBean) uncompIt.next();
            if (count == uncompleted.size() - 1) {
                if (ecb != null && ecb.getId() == dedc.getEventCRF().getId() && ecb.getCrf().getId() == dedc.getEventCRF().getCrf().getId()) {
                    // logger.info("ecb id*******" + ecb.getId() +
                    // dedc.getEventCRF().getId());
                    displayData.add(new StudyInfoPanelLine("<img src='images/icon_NotStarted.gif' alt='Not Started'/>", "<span class='alert'>" + dedc.getEdc().getCrf().getName() + "</span>", false, true, true));
                } else {
                    displayData.add(new StudyInfoPanelLine("<img src='images/icon_NotStarted.gif' alt='Not Started'/>", dedc.getEdc().getCrf().getName(), false, true, false));
                }
            } else {
                if (ecb != null && ecb.getId() == dedc.getEventCRF().getId()) {
                    // logger.info("ecb id*******" + ecb.getId() +
                    // dedc.getEventCRF().getId());
                    displayData.add(new StudyInfoPanelLine("<img src='images/icon_NotStarted.gif' alt='Not Started'/>", "<span class='alert'>" + dedc.getEdc().getCrf().getName() + "</span>", false, false, true));
                } else {
                    displayData.add(new StudyInfoPanelLine("<img src='images/icon_NotStarted.gif' alt='Not Started'/>", dedc.getEdc().getCrf().getName(), false, false, false));
                }
            }
            count++;
        }
    }
    return displayData;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Example 2 with DisplayEventCRFBean

use of org.akaza.openclinica.bean.submit.DisplayEventCRFBean in project OpenClinica by OpenClinica.

the class DeleteEventCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    int studySubId = fp.getInt(STUDY_SUB_ID, true);
    int eventCRFId = fp.getInt(EVENT_CRF_ID);
    String action = request.getParameter("action");
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    if (eventCRFId == 0) {
        addPageMessage(respage.getString("please_choose_an_event_CRF_to_delete"));
        request.setAttribute("id", new Integer(studySubId).toString());
        forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
    } else {
        EventCRFBean eventCRF = (EventCRFBean) ecdao.findByPK(eventCRFId);
        StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
        request.setAttribute("studySub", studySub);
        // construct info needed on view event crf page
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
        int crfVersionId = eventCRF.getCRFVersionId();
        CRFBean cb = cdao.findByVersionId(crfVersionId);
        eventCRF.setCrf(cb);
        CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(crfVersionId);
        eventCRF.setCrfVersion(cvb);
        // then get the definition so we can call
        // DisplayEventCRFBean.setFlags
        int studyEventId = eventCRF.getStudyEventId();
        StudyEventBean event = (StudyEventBean) sedao.findByPK(studyEventId);
        int studyEventDefinitionId = sedao.getDefinitionIdFromStudyEventId(studyEventId);
        StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(studyEventDefinitionId);
        event.setStudyEventDefinition(sed);
        request.setAttribute("event", event);
        EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
        StudyBean study = (StudyBean) sdao.findByPK(studySub.getStudyId());
        EventDefinitionCRFBean edc = edcdao.findByStudyEventDefinitionIdAndCRFId(study, studyEventDefinitionId, cb.getId());
        DisplayEventCRFBean dec = new DisplayEventCRFBean();
        dec.setEventCRF(eventCRF);
        dec.setFlags(eventCRF, ub, currentRole, edc.isDoubleEntry());
        // find all item data
        ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
        dnDao = new DiscrepancyNoteDAO(sm.getDataSource());
        ArrayList<ItemDataBean> itemData = iddao.findAllByEventCRFId(eventCRF.getId());
        request.setAttribute("items", itemData);
        if ("confirm".equalsIgnoreCase(action)) {
            request.setAttribute("displayEventCRF", dec);
            forwardPage(Page.DELETE_EVENT_CRF);
        } else {
            logger.info("submit to delete the event CRF from event");
            // OC-6303  Deleting Event CRF resets Show / Hide logic
            // delete records from DynamicItemForm and DynamicItemGroup
            getDynamicsItemFormMetadataDao().delete(eventCRFId);
            getDynamicsItemGroupMetadataDao().delete(eventCRFId);
            eventCRF.setOldStatus(eventCRF.getStatus());
            eventCRF.setStatus(Status.RESET);
            eventCRF.setUpdater(ub);
            // OC-12177 added to fix displaying DDE workflow status
            eventCRF.setValidatorId(0);
            ecdao.update(eventCRF);
            for (ItemDataBean itemdata : itemData) {
                // OC-6343 Rule behaviour must be reset if an Event CRF is deleted
                // delete the records from ruleActionRunLogDao
                getRuleActionRunLogDao().delete(itemdata.getId());
                // OC-6344 Notes & Discrepancies must be set to "closed" when event CRF is deleted
                // parentDiscrepancyNoteList is the list of the parent DNs records only
                ArrayList<DiscrepancyNoteBean> parentDiscrepancyNoteList = getDnDao().findParentNotesOnlyByItemData(itemdata.getId());
                for (DiscrepancyNoteBean parentDiscrepancyNote : parentDiscrepancyNoteList) {
                    if (parentDiscrepancyNote.getResolutionStatusId() != 4) {
                        // if the DN's resolution status is not set to Closed
                        String description = resword.getString("dn_auto-closed_description");
                        String detailedNotes = resword.getString("dn_auto_closed_detailed_notes");
                        // create new DN record , new DN Map record , also update the parent record
                        createDiscrepancyNoteBean(description, detailedNotes, itemdata.getId(), study, ub, parentDiscrepancyNote);
                    }
                }
                iddao = new ItemDataDAO(sm.getDataSource());
                ifmdao = new ItemFormMetadataDAO(sm.getDataSource());
                ItemDataBean idBean = (ItemDataBean) iddao.findByPK(itemdata.getId());
                ItemFormMetadataBean ifmBean = ifmdao.findByItemIdAndCRFVersionId(idBean.getItemId(), crfVersionId);
                // Updating Dn_item_data_map actovated column into false for the existing DNs
                ArrayList<DiscrepancyNoteBean> dnBeans = getDnDao().findExistingNotesForItemData(itemdata.getId());
                if (dnBeans.size() != 0) {
                    DiscrepancyNoteBean dnBean = new DiscrepancyNoteBean();
                    dnBean.setEntityId(itemdata.getId());
                    dnBean.setActivated(false);
                    getDnDao().updateDnMapActivation(dnBean);
                }
                // Default Values are not addressed
                itemdata.setValue("");
                itemdata.setOldStatus(itemdata.getStatus());
                itemdata.setOwner(ub);
                itemdata.setStatus(Status.AVAILABLE);
                itemdata.setUpdater(ub);
                iddao.updateUser(itemdata);
                iddao.update(itemdata);
            }
            // OC-6291 event_crf status change
            eventCRF.setOldStatus(eventCRF.getStatus());
            eventCRF.setStatus(Status.AVAILABLE);
            eventCRF.setUpdater(ub);
            ecdao.update(eventCRF);
            if (event.getSubjectEventStatus().isCompleted() || event.getSubjectEventStatus().isSigned()) {
                event.setSubjectEventStatus(SubjectEventStatus.DATA_ENTRY_STARTED);
                event.setUpdater(ub);
                sedao = new StudyEventDAO(sm.getDataSource());
                sedao.update(event);
            }
            String emailBody = respage.getString("the_event_CRF") + cb.getName() + respage.getString("has_been_deleted_from_the_event") + event.getStudyEventDefinition().getName() + ". " + respage.getString("has_been_deleted_from_the_event_cont");
            addPageMessage(emailBody);
            // sendEmail(emailBody);
            request.setAttribute("id", new Integer(studySubId).toString());
            forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
        }
    }
}
Also used : StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) 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) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 3 with DisplayEventCRFBean

use of org.akaza.openclinica.bean.submit.DisplayEventCRFBean in project OpenClinica by OpenClinica.

the class HideCRFManager method studyEventHasAHideCRFProperty.

public boolean studyEventHasAHideCRFProperty(DisplayStudyEventBean displayStudyEventBean) {
    EventDefinitionCRFBean tempEventCRFBean = new EventDefinitionCRFBean();
    boolean hasAHideCRFProperty = false;
    for (DisplayEventCRFBean deCRFBean : displayStudyEventBean.getAllEventCRFs()) {
        tempEventCRFBean = deCRFBean.getEventDefinitionCRF();
        if (tempEventCRFBean.isHideCrf()) {
            hasAHideCRFProperty = true;
        }
    }
    for (DisplayEventCRFBean deCRFBean : displayStudyEventBean.getDisplayEventCRFs()) {
        tempEventCRFBean = deCRFBean.getEventDefinitionCRF();
        if (tempEventCRFBean.isHideCrf()) {
            hasAHideCRFProperty = true;
        }
    }
    return hasAHideCRFProperty;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 4 with DisplayEventCRFBean

use of org.akaza.openclinica.bean.submit.DisplayEventCRFBean in project OpenClinica by OpenClinica.

the class HideCRFManager method suppressHiddenEventCRFBeans.

private ArrayList<DisplayEventCRFBean> suppressHiddenEventCRFBeans(List<DisplayEventCRFBean> eventCRFBeans) {
    // Must make this an ArrayList because of the
    // displayStudyEventBean.setAllEventCRFs()
    // method definition
    ArrayList<DisplayEventCRFBean> newEventCRFBeans = new ArrayList<DisplayEventCRFBean>();
    EventDefinitionCRFBean definitionCRFBean = new EventDefinitionCRFBean();
    for (DisplayEventCRFBean deCRFBean : eventCRFBeans) {
        definitionCRFBean = deCRFBean.getEventDefinitionCRF();
        if (!definitionCRFBean.isHideCrf()) {
            newEventCRFBeans.add(deCRFBean);
        }
    }
    return newEventCRFBeans;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) ArrayList(java.util.ArrayList) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 5 with DisplayEventCRFBean

use of org.akaza.openclinica.bean.submit.DisplayEventCRFBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteUtil method getEventCRFIdsFromDisplayEvents.

private SortedSet<Integer> getEventCRFIdsFromDisplayEvents(List<DisplayStudyEventBean> displayEvents) {
    SortedSet<Integer> treeSet = new TreeSet<Integer>();
    if (displayEvents == null || displayEvents.isEmpty()) {
        return treeSet;
    }
    StudyEventBean studyEventBean = null;
    List<DisplayEventCRFBean> displayEventCRFBeans = null;
    List<EventCRFBean> eventCRFBeans = null;
    for (DisplayStudyEventBean displayStudyEventBean : displayEvents) {
        displayEventCRFBeans = displayStudyEventBean.getDisplayEventCRFs();
        if (displayEventCRFBeans.isEmpty()) {
            eventCRFBeans = displayStudyEventBean.getStudyEvent().getEventCRFs();
            for (EventCRFBean evBean : eventCRFBeans) {
                treeSet.add(evBean.getId());
            }
            // move on to the next DisplayStudyEventBean
            continue;
        }
        for (DisplayEventCRFBean disBean : displayEventCRFBeans) {
            treeSet.add(disBean.getEventCRF().getId());
        }
    }
    return treeSet;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) TreeSet(java.util.TreeSet) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean)

Aggregations

DisplayEventCRFBean (org.akaza.openclinica.bean.submit.DisplayEventCRFBean)20 ArrayList (java.util.ArrayList)17 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)15 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)14 DisplayEventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)13 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)12 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)11 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)10 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)10 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)9 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)9 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)8 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)7 HashMap (java.util.HashMap)6 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)6 DisplayStudyEventBean (org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean)5 Iterator (java.util.Iterator)4 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)4 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)4 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)4