Search in sources :

Example 46 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class CreateDiscrepancyNoteServlet method getCrf.

private CRFBean getCrf(int eventCRFId) {
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    CRFVersionBean cv = (CRFVersionBean) cvdao.findByPK(getEventCrf(eventCRFId).getCRFVersionId());
    CRFBean c = (CRFBean) cdao.findByPK(cv.getCrfId());
    return c;
}
Also used : EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 47 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class ListDiscNotesForCRFTableFactory method setDataAndLimitVariables.

@SuppressWarnings("unchecked")
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
    Limit limit = tableFacade.getLimit();
    ListDiscNotesForCRFFilter listDiscNotesForCRF = getListEventsForSubjectFilter(limit);
    listDiscNotesForCRF.addFilter("dn.discrepancy_note_type_id", this.discNoteType);
    StringBuffer constraints = new StringBuffer();
    if (this.discNoteType > 0 && this.discNoteType < 10) {
        constraints.append(" and dn.discrepancy_note_type_id=" + this.discNoteType);
    }
    if (this.resolutionStatusIds != null && this.resolutionStatusIds.size() > 0) {
        String s = " and (";
        for (Integer resolutionStatusId : this.resolutionStatusIds) {
            s += "dn.resolution_status_id = " + resolutionStatusId + " or ";
        }
        s = s.substring(0, s.length() - 3) + " )";
        listDiscNotesForCRF.addFilter("dn.resolution_status_id", s);
        constraints.append(s);
    }
    if (!limit.isComplete()) {
        int totalRows = getStudySubjectDAO().getCountWithFilter(listDiscNotesForCRF, getStudyBean());
        tableFacade.setTotalRows(totalRows);
    }
    ListDiscNotesForCRFSort eventsForSubjectSort = getListEventsForSubjectSort(limit);
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = limit.getRowSelect().getRowEnd();
    Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(), listDiscNotesForCRF, eventsForSubjectSort, rowStart, rowEnd);
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
    boolean hasDN = false;
    for (StudySubjectBean studySubjectBean : items) {
        HashMap<Object, Object> theItem = new HashMap<Object, Object>();
        theItem.put("studySubject", studySubjectBean);
        theItem.put("studySubject.label", studySubjectBean.getLabel());
        theItem.put("studySubject.status", studySubjectBean.getStatus());
        SubjectBean subjectBean = (SubjectBean) getSubjectDAO().findByPK(studySubjectBean.getSubjectId());
        theItem.put("subject", subjectBean);
        theItem.put("subject.charGender", subjectBean.getGender());
        // Get EventCrfs for study Subject
        List<EventCRFBean> eventCrfs = getEventCRFDAO().findAllByStudySubject(studySubjectBean.getId());
        HashMap<String, EventCRFBean> crfAsKeyEventCrfAsValue = new HashMap<String, EventCRFBean>();
        for (EventCRFBean eventCRFBean : eventCrfs) {
            CRFBean crf = getCrfDAO().findByVersionId(eventCRFBean.getCRFVersionId());
            crfAsKeyEventCrfAsValue.put(crf.getId() + "_" + eventCRFBean.getStudyEventId(), eventCRFBean);
        }
        // Get the event Status
        List<StudyEventBean> eventsForStudySubjectAndEventDefinitions = getStudyEventDAO().findAllByDefinitionAndSubject(selectedStudyEventDefinition, studySubjectBean);
        List<DisplayBean> events = new ArrayList<DisplayBean>();
        // study event size < 1
        if (eventsForStudySubjectAndEventDefinitions.size() < 1) {
            DisplayBean d = new DisplayBean();
            d.getProps().put("event", null);
            d.getProps().put("event.status", SubjectEventStatus.NOT_SCHEDULED);
            d.getProps().put("event.startDate", null);
            for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
                CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
                HashMap<ResolutionStatus, Integer> discCounts = new HashMap<ResolutionStatus, Integer>();
                d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
                d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
                d.getProps().put("crf_" + crf.getId() + "_crf", crf);
                d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
                d.getProps().put("crf_" + crf.getId() + "_discCounts", discCounts);
                theItem.put("crf_" + crf.getId(), "");
            }
            events.add(d);
        }
        // study event size >0
        for (StudyEventBean studyEventBean : eventsForStudySubjectAndEventDefinitions) {
            DisplayBean d = new DisplayBean();
            d.getProps().put("event", studyEventBean);
            d.getProps().put("event.status", studyEventBean.getSubjectEventStatus());
            d.getProps().put("event.startDate", studyEventBean.getCreatedDate());
            for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
                CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
                EventCRFBean eventCRFBean = crfAsKeyEventCrfAsValue.get(crf.getId() + "_" + studyEventBean.getId());
                HashMap<ResolutionStatus, Integer> discCounts = new HashMap<ResolutionStatus, Integer>();
                if (eventCRFBean != null) {
                    d.getProps().put("crf_" + crf.getId(), eventCRFBean.getStage());
                    d.getProps().put("crf_" + crf.getId() + "_eventCrf", eventCRFBean);
                    // List<DiscrepancyNoteBean> discs =
                    // getDiscrepancyNoteDAO().findAllByStudyEvent(studyEventBean);
                    List<DiscrepancyNoteBean> discs = getDiscrepancyNoteDAO().findAllParentItemNotesByEventCRFWithConstraints(eventCRFBean.getId(), constraints);
                    hasDN = hasDN == false ? discs != null && discs.size() > 0 : hasDN;
                    for (DiscrepancyNoteBean discrepancyNoteBean : discs) {
                        Integer value = discCounts.get(discrepancyNoteBean.getResStatus());
                        if (value != null) {
                            discCounts.put(discrepancyNoteBean.getResStatus(), ++value);
                        } else {
                            discCounts.put(discrepancyNoteBean.getResStatus(), 1);
                        }
                    }
                    d.getProps().put("crf_" + crf.getId() + "_discCounts", discCounts);
                } else {
                    d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
                    d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
                    d.getProps().put("crf_" + crf.getId() + "_discCounts", discCounts);
                }
                d.getProps().put("crf_" + crf.getId() + "_crf", crf);
                d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
                theItem.put("crf_" + crf.getId(), "");
            }
            events.add(d);
        }
        theItem.put("events", events);
        theItem.put("event.status", "");
        theItem.put("event.startDate", "");
        theItems.add(theItem);
    }
    // Do not forget to set the items back on the tableFacade.
    tableFacade.setItems(theItems);
    this.setStudyHasDiscNotes(hasDN);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ResolutionStatus(org.akaza.openclinica.bean.core.ResolutionStatus) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ListDiscNotesForCRFSort(org.akaza.openclinica.dao.managestudy.ListDiscNotesForCRFSort) ListDiscNotesForCRFFilter(org.akaza.openclinica.dao.managestudy.ListDiscNotesForCRFFilter) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) Limit(org.jmesa.limit.Limit)

Example 48 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class ListDiscNotesForCRFTableFactory method getCrfs.

@SuppressWarnings("unchecked")
private ArrayList<CRFBean> getCrfs(StudyEventDefinitionBean eventDefinition) {
    if (this.crfBeans == null) {
        crfBeans = new ArrayList<CRFBean>();
        eventDefinitionCrfs = new ArrayList<EventDefinitionCRFBean>();
        ArrayList<Integer> ids = new ArrayList<Integer>();
        List<EventDefinitionCRFBean> edcs = new ArrayList<EventDefinitionCRFBean>();
        if (this.getStudyBean().getParentStudyId() > 0) {
            edcs = (List<EventDefinitionCRFBean>) getEventDefintionCRFDAO().findAllActiveNonHiddenByEventDefinitionIdAndStudy(eventDefinition.getId(), this.getStudyBean());
        } else {
            edcs = getEventDefintionCRFDAO().findAllActiveByEventDefinitionId(eventDefinition.getId());
        }
        if (edcs.size() > 0) {
            for (EventDefinitionCRFBean eventDefinitionCrf : edcs) {
                CRFBean crf = (CRFBean) getCrfDAO().findByPK(eventDefinitionCrf.getCrfId());
                if (!ids.contains(crf.getId())) {
                    crfBeans.add(crf);
                    ids.add(crf.getId());
                    eventDefinitionCrfs.add(eventDefinitionCrf);
                }
            }
        }
        return crfBeans;
    }
    return crfBeans;
}
Also used : ArrayList(java.util.ArrayList) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 49 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class EnterDataForStudyEventServlet method populateUncompletedCRFsWithCRFAndVersions.

private void populateUncompletedCRFsWithCRFAndVersions(ArrayList uncompletedEventDefinitionCRFs) {
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    int size = uncompletedEventDefinitionCRFs.size();
    for (int i = 0; i < size; i++) {
        DisplayEventDefinitionCRFBean dedcrf = (DisplayEventDefinitionCRFBean) uncompletedEventDefinitionCRFs.get(i);
        CRFBean cb = (CRFBean) cdao.findByPK(dedcrf.getEdc().getCrfId());
        // check it here, tbh 102007
        if (cb.getStatus().equals(Status.AVAILABLE)) {
            // the above does not allow us to show the CRF as a thing with
            // status of 'invalid' so we have to
            // go to the JSP for this one, I think
            dedcrf.getEdc().setCrf(cb);
            ArrayList theVersions = (ArrayList) cvdao.findAllActiveByCRF(dedcrf.getEdc().getCrfId());
            ArrayList versions = new ArrayList();
            HashMap<String, CRFVersionBean> crfVersionIds = new HashMap<String, CRFVersionBean>();
            for (int j = 0; j < theVersions.size(); j++) {
                CRFVersionBean crfVersion = (CRFVersionBean) theVersions.get(j);
                crfVersionIds.put(String.valueOf(crfVersion.getId()), crfVersion);
            }
            if (!dedcrf.getEdc().getSelectedVersionIds().equals("")) {
                String[] kk = dedcrf.getEdc().getSelectedVersionIds().split(",");
                for (String string : kk) {
                    if (crfVersionIds.get(string) != null) {
                        versions.add(crfVersionIds.get(string));
                    }
                }
            } else {
                versions = theVersions;
            }
            dedcrf.getEdc().setVersions(versions);
            // added tbh 092007, fix for 1461
            if (versions != null && versions.size() != 0) {
                boolean isLocked = false;
                for (int ii = 0; ii < versions.size(); ii++) {
                    CRFVersionBean crfvb = (CRFVersionBean) versions.get(ii);
                    logger.debug("...checking versions..." + crfvb.getName());
                    if (!crfvb.getStatus().equals(Status.AVAILABLE)) {
                        logger.debug("found a non active crf version");
                        isLocked = true;
                    }
                }
                logger.debug("re-set event def, line 240: " + isLocked);
                if (isLocked) {
                    dedcrf.setStatus(Status.LOCKED);
                    dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
                }
                uncompletedEventDefinitionCRFs.set(i, dedcrf);
            } else {
                // above added 092007, tbh
                dedcrf.setStatus(Status.LOCKED);
                dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
                uncompletedEventDefinitionCRFs.set(i, dedcrf);
            }
        // added 102007, tbh
        } else {
            dedcrf.getEdc().setCrf(cb);
            logger.debug("_found a non active crf _");
            dedcrf.setStatus(Status.LOCKED);
            dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
            dedcrf.getEdc().getCrf().setStatus(Status.LOCKED);
            uncompletedEventDefinitionCRFs.set(i, dedcrf);
        }
    // enclosing if statement added 102007, tbh
    }
}
Also used : 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) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) 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)

Example 50 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class OdmController method getFormDataPerCrf.

private ODMcomplexTypeDefinitionFormData getFormDataPerCrf(CRFVersionBean crfVersion, StudyEventBean nextEvent, List<EventCRFBean> eventCrfs, CRFDAO crfDAO, String formUrl, boolean itemDataExists) {
    EventCRFBean selectedEventCRFBean = null;
    CRFBean crfBean = (CRFBean) crfDAO.findByVersionId(crfVersion.getId());
    for (EventCRFBean eventCRFBean : eventCrfs) {
        if (eventCRFBean.getCRFVersionId() == crfVersion.getId()) {
            selectedEventCRFBean = eventCRFBean;
            break;
        }
    }
    return generateFormData(crfVersion, nextEvent, selectedEventCRFBean, crfBean, formUrl, itemDataExists);
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Aggregations

CRFBean (org.akaza.openclinica.bean.admin.CRFBean)138 ArrayList (java.util.ArrayList)95 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)78 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)78 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)70 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)67 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)63 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)56 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)44 HashMap (java.util.HashMap)43 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)43 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)40 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)37 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)29 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)27 Iterator (java.util.Iterator)26 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)26 DisplayEventCRFBean (org.akaza.openclinica.bean.submit.DisplayEventCRFBean)22 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)21 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)20