use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class StudyInfoPanel method generateTreeFromBeans.
/**
* Generates a tree view in sdie info panel for submitting data page
*
* @param rows
* @param displayData
* @param studySubject
* @param ecb
* @return
*/
public ArrayList generateTreeFromBeans(ArrayList rows, ArrayList displayData, StudySubjectBean studySubject, EventCRFBean ecb) {
Iterator itRows = rows.iterator();
displayData.add(new StudyInfoPanelLine(resword.getString("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>", "<a href='EnterDataForStudyEvent?eventId=" + seBean.getId() + "'>" + seBean.getSubjectEventStatus().getName() + "</a>", 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()) {
// was
// getName(),
// tbh
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()), "<a href='" + getTOCLink(dec) + "'>" + dec.getEventCRF().getCrf().getName() + " " + dec.getEventCRF().getCrfVersion().getName() + "</a>", 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()), "<a href='" + getTOCLink(dec) + "'>" + dec.getEventCRF().getCrf().getName() + " " + dec.getEventCRF().getCrfVersion().getName() + "</a>", 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'/>", "<a href='InitialDataEntry?eventDefinitionCRFId=" + dedc.getEdc().getId() + "&studyEventId=" + seBean.getId() + "&subjectId=" + studySubject.getSubjectId() + "&eventCRFId=" + dedc.getEventCRF().getId() + "&crfVersionId=" + dedc.getEdc().getDefaultVersionId() + "'>" + dedc.getEdc().getCrf().getName() + "</a>", 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'/>", "<a href='InitialDataEntry?eventDefinitionCRFId=" + dedc.getEdc().getId() + "&studyEventId=" + seBean.getId() + "&subjectId=" + studySubject.getSubjectId() + "&eventCRFId=" + dedc.getEventCRF().getId() + "&crfVersionId=" + dedc.getEdc().getDefaultVersionId() + "'>" + dedc.getEdc().getCrf().getName() + "</a>", false, false, false));
}
}
count++;
}
}
return displayData;
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class EnterDataForStudyEventServlet method populateUncompletedCRFsWithAnOwner.
private void populateUncompletedCRFsWithAnOwner(List<DisplayEventDefinitionCRFBean> displayEventDefinitionCRFBeans) {
if (displayEventDefinitionCRFBeans == null || displayEventDefinitionCRFBeans.isEmpty()) {
return;
}
UserAccountDAO userAccountDAO = new UserAccountDAO(sm.getDataSource());
UserAccountBean userAccountBean;
EventCRFBean eventCRFBean;
EventDefinitionCRFBean eventDefinitionCRFBean;
for (DisplayEventDefinitionCRFBean dedcBean : displayEventDefinitionCRFBeans) {
eventCRFBean = dedcBean.getEventCRF();
if (eventCRFBean != null && eventCRFBean.getOwner() == null && eventCRFBean.getOwnerId() > 0) {
userAccountBean = (UserAccountBean) userAccountDAO.findByPK(eventCRFBean.getOwnerId());
eventCRFBean.setOwner(userAccountBean);
}
// EventDefinitionCRFBean
if (eventCRFBean != null && eventCRFBean.getOwner() == null) {
int ownerId = dedcBean.getEdc().getOwnerId();
if (ownerId > 0) {
userAccountBean = (UserAccountBean) userAccountDAO.findByPK(ownerId);
eventCRFBean.setOwner(userAccountBean);
}
}
}
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class UpdateStudyEventServlet 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 versions = (ArrayList) cvdao.findAllActiveByCRF(dedcrf.getEdc().getCrfId());
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
}
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class UpdateStudyEventServlet method getUncompletedCRFs.
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;
}
use of org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class SignStudySubjectServlet 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);
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);
}
}
// 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()); }
*/
}
}
return answer;
}
Aggregations