Search in sources :

Example 1 with DisplayEventDefinitionCRFBean

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

the class StudySubjectServiceImpl method getUncompletedCRFs.

private ArrayList<DisplayEventDefinitionCRFBean> getUncompletedCRFs(List eventDefinitionCRFs, List eventCRFs, SubjectEventStatus status, Set<Integer> nonEmptyEventCrf, Map<Integer, FormLayoutBean> formLayoutById, Map<Integer, CRFBean> crfById) {
    int i;
    HashMap<Integer, Boolean> completed = new HashMap<Integer, Boolean>();
    HashMap<Integer, EventCRFBean> startedButIncompleted = new HashMap<Integer, EventCRFBean>();
    ArrayList<DisplayEventDefinitionCRFBean> answer = new ArrayList<DisplayEventDefinitionCRFBean>();
    for (i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
        startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
    }
    for (i = 0; i < eventCRFs.size(); i++) {
        EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
        int crfId = formLayoutById.get(ecrf.getFormLayoutId()).getCrfId();
        if (nonEmptyEventCrf.contains(ecrf.getId())) {
            // this crf has data
            // already
            completed.put(new Integer(crfId), Boolean.TRUE);
        } else {
            // event crf got created, but no data entered
            startedButIncompleted.put(new Integer(crfId), ecrf);
        }
    }
    // TODO possible relation to 1689 here, tbh
    for (i = 0; i < eventDefinitionCRFs.size(); i++) {
        DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
        EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        // available (i.e., not removed)
        if (edcrf.getStatus().equals(Status.AVAILABLE)) {
            dedc.setEdc(edcrf);
            // below added tbh, 112007 to fix bug 1943
            if (status.equals(SubjectEventStatus.LOCKED)) {
                dedc.setStatus(Status.LOCKED);
            }
            Boolean b = completed.get(new Integer(edcrf.getCrfId()));
            EventCRFBean ev = startedButIncompleted.get(new Integer(edcrf.getCrfId()));
            if (b == null || !b.booleanValue()) {
                dedc.setEventCRF(ev);
                answer.add(dedc);
            }
        }
    }
    return answer;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Example 2 with DisplayEventDefinitionCRFBean

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

the class StudySubjectServiceImpl method populateUncompletedCRFsWithCRFAndVersions.

@SuppressWarnings({ "rawtypes", "unchecked" })
public void populateUncompletedCRFsWithCRFAndVersions(ArrayList<DisplayEventDefinitionCRFBean> uncompletedEventDefinitionCRFs, Map<Integer, FormLayoutBean> formLayoutById, Map<Integer, CRFBean> crfById) {
    FormLayoutDAO formLayoutDAo = new FormLayoutDAO(dataSource);
    int size = uncompletedEventDefinitionCRFs.size();
    for (int i = 0; i < size; i++) {
        DisplayEventDefinitionCRFBean dedcrf = uncompletedEventDefinitionCRFs.get(i);
        CRFBean cb = crfById.get(dedcrf.getEdc().getCrfId());
        dedcrf.getEdc().setCrf(cb);
        ArrayList<FormLayoutBean> theVersions = (ArrayList<FormLayoutBean>) formLayoutDAo.findAllActiveByCRF(dedcrf.getEdc().getCrfId());
        ArrayList<FormLayoutBean> versions = new ArrayList<FormLayoutBean>();
        HashMap<String, FormLayoutBean> formLayoutIds = new HashMap<String, FormLayoutBean>();
        for (int j = 0; j < theVersions.size(); j++) {
            FormLayoutBean formLayout = theVersions.get(j);
            formLayoutIds.put(String.valueOf(formLayout.getId()), formLayout);
        }
        if (!dedcrf.getEdc().getSelectedVersionIds().equals("")) {
            String[] kk = dedcrf.getEdc().getSelectedVersionIds().split(",");
            for (String string : kk) {
                if (formLayoutIds.get(string) != null) {
                    versions.add(formLayoutIds.get(string));
                }
            }
        } else {
            versions = theVersions;
        }
        dedcrf.getEdc().setVersions(versions);
        uncompletedEventDefinitionCRFs.set(i, dedcrf);
    }
}
Also used : HashMap(java.util.HashMap) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) 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 3 with DisplayEventDefinitionCRFBean

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

the class EnterDataForStudyEventServlet method getUncompletedCRFs.

/**
 * Finds all the event definitions for which no event CRF exists - which is
 * the list of event definitions with uncompleted event CRFs.
 *
 * @param eventDefinitionCRFs
 *            All of the event definition CRFs for this study event.
 * @param eventCRFs
 *            All of the event CRFs for this study event.
 * @return The list of event definitions for which no event CRF exists.
 */
private ArrayList getUncompletedCRFs(ArrayList eventDefinitionCRFs, ArrayList eventCRFs) {
    int i;
    HashMap completed = new HashMap();
    HashMap startedButIncompleted = new HashMap();
    ArrayList answer = new ArrayList();
    for (i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
        startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
    }
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
    for (i = 0; i < eventCRFs.size(); i++) {
        EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
        int crfId = cvdao.getCRFIdFromCRFVersionId(ecrf.getCRFVersionId());
        ArrayList idata = iddao.findAllByEventCRFId(ecrf.getId());
        if (!idata.isEmpty()) {
            // this crf has data already
            completed.put(new Integer(crfId), Boolean.TRUE);
        } else {
            // event crf got created, but no data entered
            startedButIncompleted.put(new Integer(crfId), ecrf);
        }
    }
    for (i = 0; i < eventDefinitionCRFs.size(); i++) {
        DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
        EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        dedc.setEdc(edcrf);
        Boolean b = (Boolean) completed.get(new Integer(edcrf.getCrfId()));
        EventCRFBean ev = (EventCRFBean) startedButIncompleted.get(new Integer(edcrf.getCrfId()));
        if (b == null || !b.booleanValue()) {
            dedc.setEventCRF(ev);
            answer.add(dedc);
        }
    }
    return answer;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Example 4 with DisplayEventDefinitionCRFBean

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

the class ViewStudySubjectServlet method getUncompletedCRFs.

/**
 * Finds all the event definitions for which no event CRF exists - which is
 * the list of event definitions with uncompleted event CRFs.
 *
 * @param eventDefinitionCRFs
 *            All of the event definition CRFs for this study event.
 * @param eventCRFs
 *            All of the event CRFs for this study event.
 * @return The list of event definitions for which no event CRF exists.
 */
public static ArrayList getUncompletedCRFs(DataSource ds, ArrayList eventDefinitionCRFs, ArrayList eventCRFs, SubjectEventStatus status) {
    int i;
    HashMap completed = new HashMap();
    HashMap startedButIncompleted = new HashMap();
    ArrayList answer = new ArrayList();
    for (i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
        startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
    }
    CRFVersionDAO cvdao = new CRFVersionDAO(ds);
    ItemDataDAO iddao = new ItemDataDAO(ds);
    for (i = 0; i < eventCRFs.size(); i++) {
        EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
        // System.out.println("########event crf id:" + ecrf.getId());
        int crfId = cvdao.getCRFIdFromCRFVersionId(ecrf.getCRFVersionId());
        ArrayList idata = iddao.findAllByEventCRFId(ecrf.getId());
        if (!idata.isEmpty()) {
            // this crf has data already
            completed.put(new Integer(crfId), Boolean.TRUE);
        } else {
            // event crf got created, but no data entered
            // System.out.println("added one into startedButIncompleted" + ecrf.getId());
            startedButIncompleted.put(new Integer(crfId), ecrf);
        }
    }
    // TODO possible relation to 1689 here, tbh
    for (i = 0; i < eventDefinitionCRFs.size(); i++) {
        DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
        EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        // System.out.println("created dedc with edcrf
        // "+edcrf.getCrfName()+" default version "+
        // edcrf.getDefaultVersionName()+", id
        // "+edcrf.getDefaultVersionId());
        dedc.setEdc(edcrf);
        // below added tbh, 112007 to fix bug 1943
        if (status.equals(SubjectEventStatus.LOCKED)) {
            dedc.setStatus(Status.LOCKED);
        }
        Boolean b = (Boolean) completed.get(new Integer(edcrf.getCrfId()));
        EventCRFBean ev = (EventCRFBean) startedButIncompleted.get(new Integer(edcrf.getCrfId()));
        if (b == null || !b.booleanValue()) {
            // System.out.println("entered boolean loop with ev
            // "+ev.getId()+" crf version id "+
            // ev.getCRFVersionId());
            dedc.setEventCRF(ev);
            answer.add(dedc);
        // System.out.println("just added dedc to answer");
        // removed, tbh, since this is proving nothing, 11-2007
        /*
                 * if (dedc.getEdc().getDefaultVersionId() !=
                 * dedc.getEventCRF().getId()) { System.out.println("ID
                 * MISMATCH: edc name "+dedc.getEdc().getName()+ ", default
                 * version id "+dedc.getEdc().getDefaultVersionId()+ " event crf
                 * id "+dedc.getEventCRF().getId()); }
                 */
        }
    }
    // System.out.println("size of answer" + answer.size());
    return answer;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Example 5 with DisplayEventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean 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)

Aggregations

DisplayEventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)18 ArrayList (java.util.ArrayList)17 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)15 DisplayEventCRFBean (org.akaza.openclinica.bean.submit.DisplayEventCRFBean)15 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)14 HashMap (java.util.HashMap)10 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)10 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)7 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)5 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)5 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)5 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)5 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)4 DisplayStudyEventBean (org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean)3 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)3 Iterator (java.util.Iterator)2 List (java.util.List)1 SortedSet (java.util.SortedSet)1 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1