use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.
the class DisplaySectionBeanHandler method getDisplaySectionBeans.
/**
* This method creates a List of DisplaySectionBeans, returning them in the
* order that the sections appear in a CRF. This List is "lazily"
* initialized the first time it is requested.
*
* @return A List of DisplaySectionBeans.
* @see org.akaza.openclinica.control.managestudy.PrintCRFServlet
* @see org.akaza.openclinica.control.managestudy.PrintDataEntryServlet
*/
public List<DisplaySectionBean> getDisplaySectionBeans() {
FormBeanUtil formBeanUtil;
ViewPersistanceHandler persistanceHandler;
ArrayList<SectionBean> allCrfSections;
// DAO classes for getting item definitions
SectionDAO sectionDao;
CRFVersionDAO crfVersionDao;
if (displaySectionBeans == null) {
displaySectionBeans = new ArrayList<DisplaySectionBean>();
formBeanUtil = new FormBeanUtil();
if (hasStoredData)
persistanceHandler = new ViewPersistanceHandler();
// We need a CRF version id to populate the form display
if (this.crfVersionId == 0) {
return displaySectionBeans;
}
sectionDao = new SectionDAO(dataSource);
allCrfSections = (ArrayList) sectionDao.findByVersionId(this.crfVersionId);
// for the purposes of null values, try to obtain a valid
// eventCrfDefinition id
EventDefinitionCRFBean eventDefBean = null;
EventCRFBean eventCRFBean = new EventCRFBean();
if (eventCRFId > 0) {
EventCRFDAO ecdao = new EventCRFDAO(dataSource);
eventCRFBean = (EventCRFBean) ecdao.findByPK(eventCRFId);
StudyEventDAO sedao = new StudyEventDAO(dataSource);
StudyEventBean studyEvent = (StudyEventBean) sedao.findByPK(eventCRFBean.getStudyEventId());
EventDefinitionCRFDAO eventDefinitionCRFDAO = new EventDefinitionCRFDAO(dataSource);
StudyDAO sdao = new StudyDAO(dataSource);
StudyBean study = sdao.findByStudySubjectId(eventCRFBean.getStudySubjectId());
eventDefBean = eventDefinitionCRFDAO.findByStudyEventIdAndCRFVersionId(study, studyEvent.getId(), this.crfVersionId);
}
eventDefBean = eventDefBean == null ? new EventDefinitionCRFBean() : eventDefBean;
// Create an array or List of DisplaySectionBeans representing each
// section
// for printing
DisplaySectionBean displaySectionBean;
for (SectionBean sectionBean : allCrfSections) {
displaySectionBean = formBeanUtil.createDisplaySectionBWithFormGroupsForPrint(sectionBean.getId(), this.crfVersionId, dataSource, eventDefBean.getId(), eventCRFBean, context);
displaySectionBeans.add(displaySectionBean);
}
}
return displaySectionBeans;
}
use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.
the class SDVUtil method getAllEventCRFs.
public List<EventCRFBean> getAllEventCRFs(List<StudyEventBean> studyEventBeans) {
List<EventCRFBean> eventCRFBeans = new ArrayList<EventCRFBean>();
List<EventCRFBean> studyEventCRFBeans = new ArrayList<EventCRFBean>();
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
for (StudyEventBean studyEventBean : studyEventBeans) {
eventCRFBeans = eventCRFDAO.findAllByStudyEvent(studyEventBean);
if (eventCRFBeans != null && !eventCRFBeans.isEmpty()) {
studyEventCRFBeans.addAll(eventCRFBeans);
}
}
return studyEventCRFBeans;
}
use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.
the class SDVUtil method getFilteredItemsSubject.
@SuppressWarnings("unchecked")
private Collection<SubjectSDVContainer> getFilteredItemsSubject(FilterSet filterSet, SortSet sortSet, int rowStart, int rowEnd, int studyId, int studySubjectId, HttpServletRequest request) {
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
StudyEventDAO studyEventDAO = new StudyEventDAO(dataSource);
List<EventCRFBean> eventCRFBeans = new ArrayList<EventCRFBean>();
String label = "";
String eventName = "";
String eventDate = "";
String sdvStatus = "";
String crfStatus = "";
if (filterSet.getFilter("studySubjectId") != null) {
label = filterSet.getFilter("studySubjectId").getValue().trim();
eventCRFBeans = eventCRFDAO.getEventCRFsByStudySubjectLabelLimit(label, studyId, studyId, rowEnd - rowStart, rowStart);
} else if (filterSet.getFilter("eventName") != null) {
eventName = filterSet.getFilter("eventName").getValue().trim();
// eventCRFBeans = eventCRFDAO.getEventCRFsByEventNameLimit(eventName,
// rowEnd-rowStart,rowStart);
} else if (filterSet.getFilter("eventDate") != null) {
eventDate = filterSet.getFilter("eventDate").getValue().trim();
// eventCRFBeans = eventCRFDAO.getEventCRFsByEventDateLimit(studyId,eventDate,
// rowEnd-rowStart,rowStart);
} else if (filterSet.getFilter("crfStatus") != null) {
crfStatus = filterSet.getFilter("crfStatus").getValue().trim();
//Get the study event for the event crf
// eventCRFBeans = eventCRFDAO.getEventCRFsByCRFStatus(studyId,
// SubjectEventStatus.getSubjectEventStatusIdByName(crfStatus),
// rowEnd-rowStart,rowStart);
} else if (filterSet.getFilter("sdvStatusActions") != null) {
sdvStatus = filterSet.getFilter("sdvStatusActions").getValue().trim();
// eventCRFBeans = eventCRFDAO.getEventCRFsByStudySDV(studyId,
// ("complete".equalsIgnoreCase(sdvStatus)),
// rowEnd-rowStart,rowStart);
} else {
eventCRFBeans = eventCRFDAO.getEventCRFsByStudySubjectLimit(studySubjectId, studyId, studyId, rowEnd - rowStart, rowStart);
}
return getSubjectRows(eventCRFBeans, request);
}
use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.
the class SDVUtil method getTotalRowCountSubjects.
public int getTotalRowCountSubjects(FilterSet filterSet, int studyId, int studySubjectId) {
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
if (filterSet.getFilters().size() == 0) {
return eventCRFDAO.countEventCRFsByStudySubject(studySubjectId, studyId, studyId);
}
int count = 0;
//Filter for study subject label
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
StudySubjectBean studySubjectBean = new StudySubjectBean();
studySubjectBean = (StudySubjectBean) studySubjectDAO.findByPK(studySubjectId);
String label = studySubjectBean.getLabel();
String eventNameValue = "";
String eventDateValue = "";
String crfStatus = "";
String sdvStatus = "";
for (Filter filter : filterSet.getFilters()) {
if (filter.getProperty().equalsIgnoreCase("eventName")) {
eventNameValue = filter.getValue();
continue;
}
if (filter.getProperty().equalsIgnoreCase("eventDate")) {
eventDateValue = filter.getValue();
continue;
}
if (filter.getProperty().equalsIgnoreCase("crfStatus")) {
crfStatus = filter.getValue();
continue;
}
if (filter.getProperty().equalsIgnoreCase("sdvStatusActions")) {
sdvStatus = filter.getValue();
}
}
if (eventNameValue.length() > 0) {
return eventCRFDAO.countEventCRFsByEventNameSubjectLabel(eventNameValue, label);
}
if (eventDateValue.length() > 0) {
//return eventCRFDAO.countEventCRFsByEventDate(studyId,eventDateValue);
}
if (crfStatus.length() > 0) {
//return eventCRFDAO.countEventCRFsByCRFStatus(studyId,
// SubjectEventStatus.getSubjectEventStatusIdByName(crfStatus));
}
if (sdvStatus.length() > 0) {
// return eventCRFDAO.countEventCRFsByStudySDV(studyId,
// ("complete".equalsIgnoreCase(sdvStatus)));
}
return eventCRFDAO.countEventCRFsByStudySubject(studySubjectId, studyId, studyId);
}
use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.
the class SDVUtil method setSDVStatusForStudySubjects.
public boolean setSDVStatusForStudySubjects(List<Integer> studySubjectIds, int userId, boolean setVerification) {
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
EventDefinitionCRFDAO eventDefinitionCrfDAO = new EventDefinitionCRFDAO(dataSource);
StudyEventDAO studyEventDAO = new StudyEventDAO(dataSource);
CRFDAO crfDAO = new CRFDAO(dataSource);
if (studySubjectIds == null || studySubjectIds.isEmpty()) {
return true;
}
for (Integer studySubjectId : studySubjectIds) {
ArrayList<EventCRFBean> eventCrfs = eventCRFDAO.getEventCRFsByStudySubjectCompleteOrLocked(studySubjectId);
StudySubjectBean studySubject = (StudySubjectBean) studySubjectDAO.findByPK(studySubjectId);
for (EventCRFBean eventCRFBean : eventCrfs) {
CRFBean crfBean = crfDAO.findByVersionId(eventCRFBean.getCRFVersionId());
StudyEventBean studyEvent = (StudyEventBean) studyEventDAO.findByPK(eventCRFBean.getStudyEventId());
EventDefinitionCRFBean eventDefinitionCrf = eventDefinitionCrfDAO.findByStudyEventDefinitionIdAndCRFIdAndStudyId(studyEvent.getStudyEventDefinitionId(), crfBean.getId(), studySubject.getStudyId());
if (eventDefinitionCrf.getId() == 0) {
eventDefinitionCrf = eventDefinitionCrfDAO.findForStudyByStudyEventDefinitionIdAndCRFId(studyEvent.getStudyEventDefinitionId(), crfBean.getId());
}
if (eventDefinitionCrf.getSourceDataVerification() == SourceDataVerification.AllREQUIRED || eventDefinitionCrf.getSourceDataVerification() == SourceDataVerification.PARTIALREQUIRED) {
try {
eventCRFDAO.setSDVStatus(setVerification, userId, eventCRFBean.getId());
} catch (Exception exc) {
// System.out.println(exc.getMessage());
return false;
}
}
}
studySubjectDAO.update(studySubject);
}
return true;
}
Aggregations