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());
}
FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
int crfId = fldao.getCRFIdFromFormLayoutId(ecrf.getFormLayoutId());
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;
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean 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;
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean 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;
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class HideCRFManager method removeHiddenEventCRF.
public void removeHiddenEventCRF(DisplayStudyEventBean displayStudyEventBean) {
List<DisplayEventCRFBean> eventCRFBeans = displayStudyEventBean.getAllEventCRFs();
displayStudyEventBean.setAllEventCRFs(suppressHiddenEventCRFBeans(eventCRFBeans));
eventCRFBeans = displayStudyEventBean.getDisplayEventCRFs();
displayStudyEventBean.setDisplayEventCRFs(suppressHiddenEventCRFBeans(eventCRFBeans));
List<DisplayEventDefinitionCRFBean> displayEventDefinitionCRFBeans = displayStudyEventBean.getUncompletedCRFs();
ArrayList<DisplayEventDefinitionCRFBean> newDisplayEventDefinitionCRFBeans = new ArrayList<DisplayEventDefinitionCRFBean>();
for (DisplayEventDefinitionCRFBean displayEventDefinitionCRFBean : displayEventDefinitionCRFBeans) {
if (!displayEventDefinitionCRFBean.getEdc().isHideCrf()) {
newDisplayEventDefinitionCRFBeans.add(displayEventDefinitionCRFBean);
}
}
displayStudyEventBean.setUncompletedCRFs(newDisplayEventDefinitionCRFBeans);
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class ViewStudySubjectServlet method populateUncompletedCRFsWithCRFAndVersions.
public static void populateUncompletedCRFsWithCRFAndVersions(DataSource ds, ArrayList uncompletedEventDefinitionCRFs) {
CRFDAO cdao = new CRFDAO(ds);
CRFVersionDAO cvdao = new CRFVersionDAO(ds);
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());
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);
uncompletedEventDefinitionCRFs.set(i, dedcrf);
}
}
Aggregations