use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.
the class SignStudySubjectServlet method getDisplayEventCRFs.
/**
* Each of the event CRFs with its corresponding CRFBean. Then generates a
* list of DisplayEventCRFBeans, one for each event CRF.
*
* @param eventCRFs
* The list of event CRFs for this study event.
* @return The list of DisplayEventCRFBeans for this study event.
*/
public static ArrayList getDisplayEventCRFs(StudyBean study, DataSource ds, ArrayList eventCRFs, UserAccountBean ub, StudyUserRoleBean currentRole, SubjectEventStatus status) {
ArrayList answer = new ArrayList();
// HashMap definitionsById = new HashMap();
int i;
/*
* for (i = 0; i < eventDefinitionCRFs.size(); i++) {
* EventDefinitionCRFBean edc = (EventDefinitionCRFBean)
* eventDefinitionCRFs.get(i); definitionsById.put(new
* Integer(edc.getStudyEventDefinitionId()), edc); }
*/
StudyEventDAO sedao = new StudyEventDAO(ds);
CRFDAO cdao = new CRFDAO(ds);
CRFVersionDAO cvdao = new CRFVersionDAO(ds);
ItemDataDAO iddao = new ItemDataDAO(ds);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
// populate the event CRF with its crf bean
int crfVersionId = ecb.getCRFVersionId();
CRFBean cb = cdao.findByVersionId(crfVersionId);
ecb.setCrf(cb);
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(crfVersionId);
ecb.setCrfVersion(cvb);
// then get the definition so we can call
// DisplayEventCRFBean.setFlags
int studyEventId = ecb.getStudyEventId();
int studyEventDefinitionId = sedao.getDefinitionIdFromStudyEventId(studyEventId);
// EventDefinitionCRFBean edc = (EventDefinitionCRFBean)
// definitionsById.get(new Integer(
// studyEventDefinitionId));
// fix problem of the above code(commented out), find the correct
// edc, note that on definitionId can be related to multiple
// eventdefinitioncrfBeans
EventDefinitionCRFBean edc = edcdao.findByStudyEventDefinitionIdAndCRFId(study, studyEventDefinitionId, cb.getId());
// rules updated 112007 tbh
if (status.equals(SubjectEventStatus.LOCKED) || status.equals(SubjectEventStatus.SKIPPED) || status.equals(SubjectEventStatus.STOPPED)) {
ecb.setStage(DataEntryStage.LOCKED);
// we need to set a SED-wide flag here, because other edcs
// in this event can be filled in and change the status, tbh
} else if (status.equals(SubjectEventStatus.INVALID)) {
ecb.setStage(DataEntryStage.LOCKED);
} else if (!cb.getStatus().equals(Status.AVAILABLE)) {
ecb.setStage(DataEntryStage.LOCKED);
} else if (!cvb.getStatus().equals(Status.AVAILABLE)) {
ecb.setStage(DataEntryStage.LOCKED);
}
// TODO need to refactor since this is similar to other code, tbh
if (edc != null) {
// System.out.println("edc is not null, need to set flags");
DisplayEventCRFBean dec = new DisplayEventCRFBean();
// System.out.println("edc.isDoubleEntry()" +
// edc.isDoubleEntry() + ecb.getId());
dec.setFlags(ecb, ub, currentRole, edc.isDoubleEntry());
// if (dec.isLocked()) {
// System.out.println("*** found a locked DEC: " + edc.getCrfName());
// }
ArrayList idata = iddao.findAllByEventCRFId(ecb.getId());
if (!idata.isEmpty()) {
// consider an event crf started only if item data get
// created
answer.add(dec);
}
}
}
return answer;
}
use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.
the class TableOfContentsServlet method getDisplayBean.
public static DisplayTableOfContentsBean getDisplayBean(EventCRFBean ecb, DataSource ds, StudyBean currentStudy) {
DisplayTableOfContentsBean answer = new DisplayTableOfContentsBean();
answer.setEventCRF(ecb);
// get data
StudySubjectDAO ssdao = new StudySubjectDAO(ds);
StudySubjectBean ssb = (StudySubjectBean) ssdao.findByPK(ecb.getStudySubjectId());
answer.setStudySubject(ssb);
StudyEventDAO sedao = new StudyEventDAO(ds);
StudyEventBean seb = (StudyEventBean) sedao.findByPK(ecb.getStudyEventId());
answer.setStudyEvent(seb);
SectionDAO sdao = new SectionDAO(ds);
ArrayList sections = getSections(ecb, ds);
answer.setSections(sections);
// get metadata
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(ds);
StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(seb.getStudyEventDefinitionId());
answer.setStudyEventDefinition(sedb);
CRFVersionDAO cvdao = new CRFVersionDAO(ds);
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(ecb.getCRFVersionId());
answer.setCrfVersion(cvb);
CRFDAO cdao = new CRFDAO(ds);
CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
answer.setCrf(cb);
StudyBean studyForStudySubject = new StudyDAO(ds).findByStudySubjectId(ssb.getId());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
EventDefinitionCRFBean edcb = edcdao.findByStudyEventDefinitionIdAndCRFId(studyForStudySubject, sedb.getId(), cb.getId());
answer.setEventDefinitionCRF(edcb);
answer.setAction(getActionForStage(ecb.getStage()));
return answer;
}
use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.
the class CrfBusinessLogicHelper method noneAreRequired.
protected boolean noneAreRequired(StudyEventBean seBean, StudyBean study) {
boolean noneAreRequired = true;
EventDefinitionCRFDAO edcDao = new EventDefinitionCRFDAO(ds);
ArrayList allEDCs = (ArrayList) edcDao.findAllActiveByEventDefinitionId(study, seBean.getStudyEventDefinitionId());
logger.info("found all EDCs: " + allEDCs.size());
for (int i = 0; i < allEDCs.size(); i++) {
EventDefinitionCRFBean ec = (EventDefinitionCRFBean) allEDCs.get(i);
logger.info("found crf name: " + ec.getCrfName());
if (ec.isRequiredCRF()) {
noneAreRequired = false;
break;
}
}
logger.info("returning for none are required: " + noneAreRequired);
return noneAreRequired;
}
use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.
the class CrfBusinessLogicHelper method areAllRequiredCompleted.
protected boolean areAllRequiredCompleted(StudyEventBean seBean, StudyBean study) {
EventDefinitionCRFDAO edcDao = new EventDefinitionCRFDAO(ds);
EventCRFDAO eventCrfDao = new EventCRFDAO(ds);
ArrayList allCRFs = eventCrfDao.findAllByStudyEvent(seBean);
ArrayList allEDCs = (ArrayList) edcDao.findAllActiveByEventDefinitionId(study, seBean.getStudyEventDefinitionId());
boolean eventRequiredCompleted = true;
// while allEDCs return all event defs in an event
for (int i = 0; i < allCRFs.size(); i++) {
EventCRFBean ec = (EventCRFBean) allCRFs.get(i);
EventDefinitionCRFBean edcBean = edcDao.findByStudyEventIdAndCRFVersionId(study, seBean.getId(), ec.getCRFVersionId());
if (!ec.getStatus().equals(Status.UNAVAILABLE) && edcBean.isRequiredCRF()) {
// if it's not done but required, return FALSE
eventRequiredCompleted = false;
break;
}
}
if (allCRFs.size() < allEDCs.size()) {
// since we found one that we didn't catch before
for (int i = 0; i < allEDCs.size(); i++) {
EventDefinitionCRFBean ec = (EventDefinitionCRFBean) allEDCs.get(i);
if (ec.isRequiredCRF()) {
eventRequiredCompleted = false;
break;
}
}
}
logger.info("returning for event required completed: " + eventRequiredCompleted);
return eventRequiredCompleted;
}
Aggregations