use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class RuleSetServiceTest method getRuleSetsByCrfStudyAndStudyEventDefinition.
// @pgawade 08-NOV-2010 Commented out the test
// "testFilterRuleSetsByStudyEventOrdinal" temporarily. Krikor will look
// into this.
// public void testFilterRuleSetsByStudyEventOrdinal() {
// List<RuleSetBean> ruleSets = getRuleSets();
// StudyEventDAO studyEventDao = new StudyEventDAO(getDataSource());
// StudyEventBean studyEventBean = (StudyEventBean)
// studyEventDao.findByPK(1);
//
// RuleSetServiceInterface instance = (RuleSetServiceInterface)
// getContext().getBean("ruleSetService");
// List<RuleSetBean> ruleSets1 =
// instance.filterRuleSetsByStudyEventOrdinal(ruleSets, studyEventBean);
//
// assertEquals("Expressions Size inside this RuleSet should be 1", 1,
// ruleSets1.get(0).getExpressions().size());
// assertEquals("Expression Value should be SE_ED2REPEA[1].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// "SE_ED2REPEA[1].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// ruleSets1.get(0).getExpressions().get(0).getValue());
// }
//
// @pgawade 08-NOV-2010 Commented out the test
// "testFilterRuleSetsByStudyEventOrdinalWithALL" temporarily. Krikor will
// look into this.
// public void testFilterRuleSetsByStudyEventOrdinalWithALL() {
// List<RuleSetBean> ruleSets = getRuleSets();
// StudyEventDAO studyEventDao = new StudyEventDAO(getDataSource());
// StudyEventBean studyEventBean = (StudyEventBean)
// studyEventDao.findByPK(2);
//
// RuleSetServiceInterface instance = (RuleSetServiceInterface)
// getContext().getBean("ruleSetService");
// ruleSets.get(0).getTarget().setValue("SE_ED2REPEA[ALL].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME");
// List<RuleSetBean> ruleSets2 =
// instance.filterRuleSetsByStudyEventOrdinal(ruleSets, studyEventBean);
//
// assertEquals("Expressions Size inside this RuleSet should be 1", 1,
// ruleSets2.get(0).getExpressions().size());
// assertEquals("Expression Value should be SE_ED2REPEA[2].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// "SE_ED2REPEA[2].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// ruleSets2.get(0).getExpressions().get(0).getValue());
// }
private List<RuleSetBean> getRuleSetsByCrfStudyAndStudyEventDefinition() {
StudyDAO studyDao = new StudyDAO(getDataSource());
StudyBean study = (StudyBean) studyDao.findByPK(1);
assertNotNull(study);
StudyEventDefinitionDAO studyEventDefinitionDao = new StudyEventDefinitionDAO(getDataSource());
StudyEventDefinitionBean studyEventDefinition = (StudyEventDefinitionBean) studyEventDefinitionDao.findByPK(2);
assertNotNull(studyEventDefinition);
CRFVersionDAO crfVersionDao = new CRFVersionDAO(getDataSource());
CRFVersionBean crfVersion = (CRFVersionBean) crfVersionDao.findByPK(2);
assertNotNull(crfVersion);
RuleSetServiceInterface instance = (RuleSetServiceInterface) getContext().getBean("ruleSetService");
List<RuleSetBean> ruleSets = instance.getRuleSetsByCrfStudyAndStudyEventDefinition(study, studyEventDefinition, crfVersion);
return ruleSets;
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class PrintAllEventCRFServlet method processRequest.
@Override
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
FormProcessor fp = new FormProcessor(request);
SessionManager sm = (SessionManager) request.getSession().getAttribute("sm");
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
ArrayList<SectionBean> allSectionBeans;
// The PrintDataEntry servlet handles this parameter
boolean isSubmitted = false;
StudyEventDefinitionDAO sedao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
seds = sedao.findAllByStudy(currentStudy);
// ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByStudy(site);
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
ArrayList<EventDefinitionCRFBean> edcs = new ArrayList();
for (StudyEventDefinitionBean sed : seds) {
int defId = sed.getId();
edcs.addAll(edcdao.findAllByDefinition(currentStudy, defId));
}
Map eventDefinitionDefaultVersions = new LinkedHashMap();
for (int i = 0; i < edcs.size(); i++) {
EventDefinitionCRFBean edc = edcs.get(i);
ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
edc.setVersions(versions);
CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
// edc.setCrfLabel(crf.getLabel());
edc.setCrfName(crf.getName());
// to show/hide edit action on jsp page
if (crf.getStatus().equals(Status.AVAILABLE)) {
edc.setOwner(crf.getOwner());
}
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
StudyEventDefinitionBean studyEventDefinitionBean = (StudyEventDefinitionBean) sedao.findByPK(edc.getStudyEventDefinitionId());
edc.setDefaultVersionName(defaultVersion.getName());
if (defaultVersion.getStatus().isAvailable()) {
List list = (ArrayList) eventDefinitionDefaultVersions.get(studyEventDefinitionBean);
if (list == null)
list = new ArrayList();
list.add(defaultVersion);
eventDefinitionDefaultVersions.put(studyEventDefinitionBean, list);
}
}
// Whether IE6 or IE7 is involved
String isIE = fp.getString("ie");
if ("y".equalsIgnoreCase(isIE)) {
request.setAttribute("isInternetExplorer", "true");
}
SectionDAO sdao = new SectionDAO(sm.getDataSource());
CRFVersionDAO crfVersionDAO = new CRFVersionDAO(sm.getDataSource());
CRFDAO crfDao = new CRFDAO(sm.getDataSource());
Map sedCrfBeans = null;
for (Iterator it = eventDefinitionDefaultVersions.keySet().iterator(); it.hasNext(); ) {
if (sedCrfBeans == null)
sedCrfBeans = new LinkedHashMap();
StudyEventDefinitionBean sedBean = (StudyEventDefinitionBean) it.next();
List crfVersions = (ArrayList) eventDefinitionDefaultVersions.get(sedBean);
for (Iterator crfIt = crfVersions.iterator(); crfIt.hasNext(); ) {
CRFVersionBean crfVersionBean = (CRFVersionBean) crfIt.next();
allSectionBeans = new ArrayList<SectionBean>();
ArrayList sectionBeans = new ArrayList();
ItemGroupDAO itemGroupDao = new ItemGroupDAO(sm.getDataSource());
// Find truely grouped tables, not groups with a name of 'Ungrouped'
List<ItemGroupBean> itemGroupBeans = itemGroupDao.findOnlyGroupsByCRFVersionID(crfVersionBean.getId());
CRFBean crfBean = crfDao.findByVersionId(crfVersionBean.getId());
if (itemGroupBeans.size() > 0) {
// get a DisplaySectionBean for each section of the CRF, sort
// them, then
// dispatch the request to a print JSP. The constructor for this
// handler takes
// a boolean value depending on whether data is involved or not
// ('false' in terms of this
// servlet; see PrintDataEntryServlet).
DisplaySectionBeanHandler handler = new DisplaySectionBeanHandler(false, getDataSource(), getServletContext());
handler.setCrfVersionId(crfVersionBean.getId());
// handler.setEventCRFId(eventCRFId);
List<DisplaySectionBean> displaySectionBeans = handler.getDisplaySectionBeans();
request.setAttribute("listOfDisplaySectionBeans", displaySectionBeans);
// Make available the CRF names and versions for
// the web page's header
CRFVersionBean crfverBean = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionBean.getId());
request.setAttribute("crfVersionBean", crfverBean);
request.setAttribute("crfBean", crfBean);
// Set an attribute signaling that data is not involved
request.setAttribute("dataInvolved", "false");
PrintCRFBean printCrfBean = new PrintCRFBean();
printCrfBean.setDisplaySectionBeans(displaySectionBeans);
printCrfBean.setCrfVersionBean(crfVersionBean);
printCrfBean.setCrfBean(crfBean);
printCrfBean.setEventCrfBean(ecb);
printCrfBean.setGrouped(true);
List list = (ArrayList) sedCrfBeans.get(sedBean);
if (list == null)
list = new ArrayList();
list.add(printCrfBean);
sedCrfBeans.put(sedBean, list);
continue;
}
ecb = new EventCRFBean();
ecb.setCRFVersionId(crfVersionBean.getId());
CRFVersionBean version = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionBean.getId());
ArrayList sects = (ArrayList) sdao.findByVersionId(version.getId());
for (int i = 0; i < sects.size(); i++) {
sb = (SectionBean) sects.get(i);
// super.sb = sb;
int sectId = sb.getId();
if (sectId > 0) {
allSectionBeans.add((SectionBean) sdao.findByPK(sectId));
}
}
request.setAttribute(INPUT_EVENT_CRF, ecb);
request.setAttribute(SECTION_BEAN, sb);
request.setAttribute(ALL_SECTION_BEANS, allSectionBeans);
sectionBeans = super.getAllDisplayBeans(request);
DisplaySectionBean dsb = super.getDisplayBean(false, false, request, isSubmitted);
PrintCRFBean printCrfBean = new PrintCRFBean();
printCrfBean.setAllSections(sectionBeans);
printCrfBean.setDisplaySectionBean(dsb);
printCrfBean.setEventCrfBean(ecb);
printCrfBean.setCrfVersionBean(crfVersionBean);
printCrfBean.setCrfBean(crfBean);
printCrfBean.setGrouped(false);
List list = (ArrayList) sedCrfBeans.get(sedBean);
if (list == null)
list = new ArrayList();
list.add(printCrfBean);
sedCrfBeans.put(sedBean, list);
}
}
request.setAttribute("sedCrfBeans", sedCrfBeans);
request.setAttribute("studyName", currentStudy.getName());
forwardPage(Page.VIEW_ALL_DEFAULT_CRF_VERSIONS_PRINT, request, response);
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class ListStudySubjectServlet method processRequest.
// >>
// < ResourceBundleresword;
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
locale = LocaleResolver.getLocale(request);
// < resword =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.words",locale);
// BWP 3098 << close the info side panel and show icons
request.setAttribute("closeInfoShowIcons", true);
// >>
// BWP 3195, 3330 : designed to address pagination issues
String pageNumber = fp.getString(SUBJECT_PAGE_NUMBER);
StringBuilder paginatingQuery = new StringBuilder("");
String filterKeyword = fp.getString(FILTER_KEYWORD);
String tmpSearch = fp.getString(SEARCH_SUBMITTED);
boolean searchSubmitted = !(tmpSearch == null || "".equalsIgnoreCase(tmpSearch)) && !"".equalsIgnoreCase(filterKeyword) && !"+".equalsIgnoreCase(filterKeyword);
if (pageNumber != null && !"".equalsIgnoreCase(pageNumber)) {
int tempNum = 0;
try {
tempNum = Integer.parseInt(pageNumber);
} catch (NumberFormatException nfe) {
// tempNum is already initialized to 0
}
if (tempNum > 0) {
paginatingQuery = new StringBuilder(SUBJECT_PAGE_NUMBER).append("=").append(pageNumber);
paginatingQuery.append("&ebl_paginated=1");
}
}
// URL encode the search keyword, since it will be a parameter in the
// URL
String filterKeywordURLEncode = java.net.URLEncoder.encode(filterKeyword, "UTF-8");
if (searchSubmitted) {
paginatingQuery.append("&ebl_sortColumnInd=0&submitted=1&ebl_sortAscending=1&ebl_filtered=1");
paginatingQuery.append("&").append(FILTER_KEYWORD).append("=").append(filterKeywordURLEncode);
}
request.setAttribute(PAGINATING_QUERY, paginatingQuery.toString());
StudyDAO stdao = new StudyDAO(sm.getDataSource());
StudySubjectDAO sdao = new StudySubjectDAO(sm.getDataSource());
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
// YW << update study parameters of current study.
// "collectDob" and "genderRequired" are set as the same as the parent
// study
// tbh, also add the params "subjectPersonIdRequired",
// "subjectIdGeneration", "subjectIdPrefixSuffix"
int parentStudyId = currentStudy.getParentStudyId();
ArrayList studyGroupClasses = new ArrayList();
ArrayList allDefs = new ArrayList();
// tbh
if (parentStudyId > 0) {
StudyBean parentStudy = (StudyBean) stdao.findByPK(parentStudyId);
studyGroupClasses = sgcdao.findAllActiveByStudy(parentStudy);
allDefs = seddao.findAllActiveByStudy(parentStudy);
} else {
parentStudyId = currentStudy.getId();
studyGroupClasses = sgcdao.findAllActiveByStudy(currentStudy);
allDefs = seddao.findAllActiveByStudy(currentStudy);
}
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
StudyParameterValueBean parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "collectDob");
currentStudy.getStudyParameterConfig().setCollectDob(parentSPV.getValue());
parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "genderRequired");
currentStudy.getStudyParameterConfig().setGenderRequired(parentSPV.getValue());
parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectPersonIdRequired");
currentStudy.getStudyParameterConfig().setSubjectPersonIdRequired(parentSPV.getValue());
parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectIdGeneration");
currentStudy.getStudyParameterConfig().setSubjectIdGeneration(parentSPV.getValue());
parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectIdPrefixSuffix");
currentStudy.getStudyParameterConfig().setSubjectIdPrefixSuffix(parentSPV.getValue());
// for all the study groups for each group class
for (int i = 0; i < studyGroupClasses.size(); i++) {
StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(i);
ArrayList groups = sgdao.findAllByGroupClass(sgc);
sgc.setStudyGroups(groups);
}
request.setAttribute("studyGroupClasses", studyGroupClasses);
// information for the event tabs
session.setAttribute("allDefsArray", allDefs);
session.setAttribute("allDefsNumber", new Integer(allDefs.size()));
session.setAttribute("groupSize", new Integer(studyGroupClasses.size()));
// find all the subjects in current study
ArrayList subjects = sdao.findAllByStudyId(currentStudy.getId());
ArrayList<DisplayStudySubjectBean> displayStudySubs = new ArrayList<DisplayStudySubjectBean>();
// BEGIN LOOPING THROUGH SUBJECTS
for (int i = 0; i < subjects.size(); i++) {
StudySubjectBean studySub = (StudySubjectBean) subjects.get(i);
ArrayList groups = (ArrayList) sgmdao.findAllByStudySubject(studySub.getId());
ArrayList subGClasses = new ArrayList();
for (int j = 0; j < studyGroupClasses.size(); j++) {
StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(j);
boolean hasClass = false;
for (int k = 0; k < groups.size(); k++) {
SubjectGroupMapBean sgmb = (SubjectGroupMapBean) groups.get(k);
if (sgmb.getGroupClassName().equalsIgnoreCase(sgc.getName())) {
subGClasses.add(sgmb);
hasClass = true;
break;
}
}
if (!hasClass) {
subGClasses.add(new SubjectGroupMapBean());
}
}
ArrayList subEvents = new ArrayList();
// find all events order by definition ordinal
ArrayList events = sedao.findAllByStudySubject(studySub);
for (int j = 0; j < allDefs.size(); j++) {
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) allDefs.get(j);
boolean hasDef = false;
// logger.info("...set blank to "+blankid);
for (int k = 0; k < events.size(); k++) {
StudyEventBean se = (StudyEventBean) events.get(k);
if (se.getStudyEventDefinitionId() == sed.getId()) {
se.setStudyEventDefinition(sed);
// logger.info(">>>found assigned id "+sed.getId()+" sed
// name: "+sed.getName()+" "+se.getId());
subEvents.add(se);
hasDef = true;
}
}
if (!hasDef) {
StudyEventBean blank = new StudyEventBean();
blank.setSubjectEventStatus(SubjectEventStatus.NOT_SCHEDULED);
blank.setStudyEventDefinitionId(sed.getId());
// how can we set the following:
// logger.info("...resetting blank id: "+blank.getId()+" to
// "+blankid);
// blank.setId(blankid);
blank.setStudyEventDefinition(sed);
// logger.info(">>>blank id: "+blank.getId());
// logger.info(">>>found unassigned id "+sed.getId()+" sed
// name: "+sed.getName()+" ");
subEvents.add(blank);
}
}
// logger.info("subevents size after all adds: "+subEvents.size());
// reorganize the events and find the repeating ones
// subEvents:[aa bbb cc d ee]
// finalEvents:[a(2) b(3) c(2) d e(2)]
int prevDefId = 0;
int currDefId = 0;
ArrayList finalEvents = new ArrayList();
int repeatingNum = 1;
int count = 0;
StudyEventBean event = new StudyEventBean();
// begin looping through subject events
for (int j = 0; j < subEvents.size(); j++) {
StudyEventBean se = (StudyEventBean) subEvents.get(j);
currDefId = se.getStudyEventDefinitionId();
if (currDefId != prevDefId) {
// find a new event
if (repeatingNum > 1) {
event.setRepeatingNum(repeatingNum);
repeatingNum = 1;
}
// add current event to final
finalEvents.add(se);
event = se;
count++;
// logger.info("event id? "+event.getId());
} else {
// repeating event
repeatingNum++;
event.getRepeatEvents().add(se);
// event.getRepeatEvents().size());
if (j == subEvents.size() - 1) {
event.setRepeatingNum(repeatingNum);
repeatingNum = 1;
}
}
prevDefId = currDefId;
}
// end looping through subject events
DisplayStudySubjectBean dssb = new DisplayStudySubjectBean();
// logger.info("final events size: "+finalEvents.size());
dssb.setStudyEvents(finalEvents);
dssb.setStudySubject(studySub);
dssb.setStudyGroups(subGClasses);
displayStudySubs.add(dssb);
}
// END LOOPING THROUGH SUBJECTS
// Set a subject property to determine whether to show a signed-type
// icon (electronic signature)
// in the JSP view or not
// Get all event crfs by studyevent id; then use
// EventDefinitionCRFDAO.isRequired to
// determine whether any uncompleted CRFs are required.
boolean isRequiredUncomplete = false;
for (DisplayStudySubjectBean subject : displayStudySubs) {
for (Iterator it = subject.getStudyEvents().iterator(); it.hasNext(); ) {
StudyEventBean event = (StudyEventBean) it.next();
if (event.getSubjectEventStatus() != null && event.getSubjectEventStatus().getId() == 3) {
// disallow the subject from signing any studies
subject.setStudySignable(false);
break;
} else {
// determine whether the subject has any required,
// uncompleted event CRFs
isRequiredUncomplete = eventHasRequiredUncompleteCRFs(event);
if (isRequiredUncomplete) {
subject.setStudySignable(false);
break;
}
}
}
}
fp = new FormProcessor(request);
EntityBeanTable table = fp.getEntityBeanTable();
ArrayList allStudyRows = DisplayStudySubjectRow.generateRowsFromBeans(displayStudySubs);
ArrayList columnArray = new ArrayList();
columnArray.add(resword.getString("study_subject_ID"));
columnArray.add(resword.getString("subject_status"));
columnArray.add(resword.getString("OID"));
columnArray.add(resword.getString("gender"));
// new
columnArray.add(resword.getString("secondary_ID"));
for (int i = 0; i < studyGroupClasses.size(); i++) {
StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(i);
columnArray.add(sgc.getName());
}
for (int i = 0; i < allDefs.size(); i++) {
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) allDefs.get(i);
columnArray.add(sed.getName());
}
columnArray.add(resword.getString("actions"));
String[] columns = new String[columnArray.size()];
columnArray.toArray(columns);
// String[] columns = {"ID", "Subject Status", "Gender", "Enrollment
// Date",
// "Study Events", "Actions" };
table.setColumns(new ArrayList(Arrays.asList(columns)));
table.setQuery(getBaseURL(), new HashMap());
table.hideColumnLink(columnArray.size() - 1);
// table.addLink("Enroll a new subject",
// "javascript:leftnavExpand('addSubjectRowExpress');");
table.setRows(allStudyRows);
if (filterKeyword != null && !"".equalsIgnoreCase(filterKeyword)) {
table.setKeywordFilter(filterKeyword);
}
table.computeDisplay();
request.setAttribute("table", table);
// request.setAttribute("subjects", subjects);
String idSetting = currentStudy.getStudyParameterConfig().getSubjectIdGeneration();
// set up auto study subject id
if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
// Shaoyu Su
// int nextLabel = ssdao.findTheGreatestLabel() + 1;
// request.setAttribute("label", new Integer(nextLabel).toString());
request.setAttribute("label", resword.getString("id_generated_Save_Add"));
}
FormDiscrepancyNotes discNotes = new FormDiscrepancyNotes();
session.setAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME, discNotes);
forwardPage(getJSP());
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class ListStudySubjectServlet method getDisplayStudyEventsForStudySubject.
public static DisplayStudyEventBean getDisplayStudyEventsForStudySubject(StudySubjectBean studySub, StudyEventBean event, DataSource ds, UserAccountBean ub, StudyUserRoleBean currentRole, StudyBean study) {
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(ds);
StudyEventDAO sedao = new StudyEventDAO(ds);
EventCRFDAO ecdao = new EventCRFDAO(ds);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(event.getStudyEventDefinitionId());
event.setStudyEventDefinition(sed);
// find all active crfs in the definition
ArrayList eventDefinitionCRFs = edcdao.findAllActiveByEventDefinitionId(sed.getId());
ArrayList eventCRFs = ecdao.findAllByStudyEvent(event);
// construct info needed on view study event page
DisplayStudyEventBean de = new DisplayStudyEventBean();
de.setStudyEvent(event);
de.setDisplayEventCRFs(ViewStudySubjectServlet.getDisplayEventCRFs(ds, eventCRFs, eventDefinitionCRFs, ub, currentRole, event.getSubjectEventStatus(), study));
ArrayList al = ViewStudySubjectServlet.getUncompletedCRFs(ds, eventDefinitionCRFs, eventCRFs, event.getSubjectEventStatus());
// ViewStudySubjectServlet.populateUncompletedCRFsWithCRFAndVersions(ds,
// al);
de.setUncompletedCRFs(al);
return de;
}
use of org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean in project OpenClinica by OpenClinica.
the class ListEventDefinitionServlet method processRequest.
/**
* Processes the request
*/
@Override
public void processRequest() throws Exception {
StudyEventDefinitionDAO edao = new StudyEventDefinitionDAO(sm.getDataSource());
UserAccountDAO sdao = new UserAccountDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
CRFDAO crfDao = new CRFDAO(sm.getDataSource());
CRFVersionDAO crfVersionDao = new CRFVersionDAO(sm.getDataSource());
ArrayList seds = edao.findAllByStudy(currentStudy);
// request.setAttribute("seds", seds);
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (int i = 0; i < seds.size(); i++) {
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seds.get(i);
Collection eventDefinitionCRFlist = edcdao.findAllParentsByDefinition(sed.getId());
Map crfWithDefaultVersion = new LinkedHashMap();
for (Iterator it = eventDefinitionCRFlist.iterator(); it.hasNext(); ) {
EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) it.next();
CRFBean crfBean = (CRFBean) crfDao.findByPK(edcBean.getCrfId());
CRFVersionBean crfVersionBean = (CRFVersionBean) crfVersionDao.findByPK(edcBean.getDefaultVersionId());
logger.info("ED[" + sed.getName() + "]crf[" + crfBean.getName() + "]dv[" + crfVersionBean.getName() + "]");
crfWithDefaultVersion.put(crfBean.getName(), crfVersionBean.getName());
}
sed.setCrfsWithDefaultVersion(crfWithDefaultVersion);
logger.info("CRF size [" + sed.getCrfs().size() + "]");
if (sed.getUpdater().getId() == 0) {
sed.setUpdater(sed.getOwner());
sed.setUpdatedDate(sed.getCreatedDate());
}
if (isPopulated(sed, sedao)) {
sed.setPopulated(true);
}
}
FormProcessor fp = new FormProcessor(request);
EntityBeanTable table = fp.getEntityBeanTable();
ArrayList allStudyRows = StudyEventDefinitionRow.generateRowsFromBeans(seds);
String[] columns = { resword.getString("order"), resword.getString("name"), resword.getString("OID"), resword.getString("repeating"), resword.getString("type"), resword.getString("category"), resword.getString("populated"), resword.getString("date_created"), resword.getString("date_updated"), resword.getString("CRFs"), resword.getString("default_version"), resword.getString("actions") };
table.setColumns(new ArrayList(Arrays.asList(columns)));
// >> tbh #4169 09/2009
table.hideColumnLink(2);
table.hideColumnLink(3);
table.hideColumnLink(4);
table.hideColumnLink(6);
table.hideColumnLink(7);
table.hideColumnLink(8);
table.hideColumnLink(9);
// crfs, tbh
table.hideColumnLink(10);
table.hideColumnLink(11);
table.hideColumnLink(12);
// << tbh 09/2009
table.setQuery("ListEventDefinition", new HashMap());
// if (!currentStudy.getStatus().isLocked()) {
// table.addLink(resworkflow.getString(
// "create_a_new_study_event_definition"), "DefineStudyEvent");
// }
table.setRows(allStudyRows);
table.setPaginated(false);
table.computeDisplay();
request.setAttribute("table", table);
request.setAttribute("defSize", new Integer(seds.size()));
if (request.getParameter("read") != null && request.getParameter("read").equals("true")) {
request.setAttribute("readOnly", true);
}
forwardPage(Page.STUDY_EVENT_DEFINITION_LIST);
}
Aggregations