use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class ViewStudySubjectServlet method getDisplayStudyEventsForStudySubject.
public static ArrayList<DisplayStudyEventBean> getDisplayStudyEventsForStudySubject(StudySubjectBean studySub, DataSource ds, UserAccountBean ub, StudyUserRoleBean currentRole) {
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(ds);
StudyEventDAO sedao = new StudyEventDAO(ds);
EventCRFDAO ecdao = new EventCRFDAO(ds);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
StudySubjectDAO ssdao = new StudySubjectDAO(ds);
StudyDAO sdao = new StudyDAO(ds);
ArrayList events = sedao.findAllByStudySubject(studySub);
ArrayList displayEvents = new ArrayList();
for (int i = 0; i < events.size(); i++) {
StudyEventBean event = (StudyEventBean) events.get(i);
StudySubjectBean studySubject = (StudySubjectBean) ssdao.findByPK(event.getStudySubjectId());
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(event.getStudyEventDefinitionId());
event.setStudyEventDefinition(sed);
// find all active crfs in the definition
StudyBean study = (StudyBean) sdao.findByPK(studySubject.getStudyId());
ArrayList eventDefinitionCRFs = (ArrayList) edcdao.findAllActiveByEventDefinitionId(study, sed.getId());
ArrayList eventCRFs = ecdao.findAllByStudyEvent(event);
// construct info needed on view study event page
DisplayStudyEventBean de = new DisplayStudyEventBean();
de.setStudyEvent(event);
de.setDisplayEventCRFs(getDisplayEventCRFs(ds, eventCRFs, eventDefinitionCRFs, ub, currentRole, event.getSubjectEventStatus(), study));
ArrayList al = getUncompletedCRFs(ds, eventDefinitionCRFs, eventCRFs, event.getSubjectEventStatus());
populateUncompletedCRFsWithCRFAndVersions(ds, al);
de.setUncompletedCRFs(al);
de.setMaximumSampleOrdinal(sedao.getMaxSampleOrdinal(sed, studySubject));
displayEvents.add(de);
// event.setEventCRFs(createAllEventCRFs(eventCRFs,
// eventDefinitionCRFs));
}
return displayEvents;
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class ViewSubjectGroupClassServlet method processRequest.
@Override
public void processRequest() throws Exception {
String action = request.getParameter("action");
FormProcessor fp = new FormProcessor(request);
int classId = fp.getInt("id");
if (classId == 0) {
addPageMessage(respage.getString("please_choose_a_subject_group_class_to_view"));
forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
} else {
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
StudyGroupClassBean sgcb = (StudyGroupClassBean) sgcdao.findByPK(classId);
StudyBean study = (StudyBean) studyDao.findByPK(sgcb.getStudyId());
checkRoleByUserAndStudy(ub, sgcb.getStudyId(), study.getParentStudyId());
// YW 09-19-2007 <<
sgcb.setGroupClassTypeName(GroupClassType.get(sgcb.getGroupClassTypeId()).getName());
// YW >>
ArrayList groups = sgdao.findAllByGroupClass(sgcb);
ArrayList studyGroups = new ArrayList();
for (int i = 0; i < groups.size(); i++) {
StudyGroupBean sg = (StudyGroupBean) groups.get(i);
ArrayList subjectMaps = sgmdao.findAllByStudyGroupClassAndGroup(sgcb.getId(), sg.getId());
sg.setSubjectMaps(subjectMaps);
// YW<<
studyGroups.add(sg);
// YW>>
}
request.setAttribute("group", sgcb);
// request.setAttribute("studyGroups", groups);
request.setAttribute("studyGroups", studyGroups);
forwardPage(Page.VIEW_SUBJECT_GROUP_CLASS);
}
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class EnterDataForStudyEventServlet method processRequest.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
@Override
protected void processRequest() throws Exception {
// removeLockedCRF(ub.getId());
getCrfLocker().unlockAllForUser(ub.getId());
FormProcessor fp = new FormProcessor(request);
int eventId = fp.getInt(INPUT_EVENT_ID, true);
request.setAttribute("eventId", eventId + "");
// so we can display the event for which we're entering data
StudyEventBean seb = getStudyEvent(eventId);
// so we can display the subject's label
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
StudySubjectBean studySubjectBean = (StudySubjectBean) ssdao.findByPK(seb.getStudySubjectId());
int studyId = studySubjectBean.getStudyId();
StudyDAO studydao = new StudyDAO(sm.getDataSource());
StudyBean study = (StudyBean) studydao.findByPK(studyId);
// If the study subject derives from a site, and is being viewed from a
// parent study,
// then the study IDs will be different. However, since each note is
// saved with the specific
// study ID, then its study ID may be different than the study subject's
// ID.
boolean subjectStudyIsCurrentStudy = studyId == currentStudy.getId();
boolean isParentStudy = study.getParentStudyId() < 1;
// Get any disc notes for this study event
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(sm.getDataSource());
ArrayList<DiscrepancyNoteBean> allNotesforSubjectAndEvent = new ArrayList<DiscrepancyNoteBean>();
// These methods return only parent disc notes
if (subjectStudyIsCurrentStudy && isParentStudy) {
allNotesforSubjectAndEvent = discrepancyNoteDAO.findAllStudyEventByStudyAndId(currentStudy, studySubjectBean.getId());
} else {
// findAllStudyEventByStudiesAndSubjectId
if (!isParentStudy) {
StudyBean stParent = (StudyBean) studydao.findByPK(study.getParentStudyId());
allNotesforSubjectAndEvent = discrepancyNoteDAO.findAllStudyEventByStudiesAndSubjectId(stParent, study, studySubjectBean.getId());
} else {
allNotesforSubjectAndEvent = discrepancyNoteDAO.findAllStudyEventByStudiesAndSubjectId(currentStudy, study, studySubjectBean.getId());
}
}
if (!allNotesforSubjectAndEvent.isEmpty()) {
setRequestAttributesForNotes(allNotesforSubjectAndEvent);
}
// prepare to figure out what the display should look like
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
ArrayList<EventCRFBean> eventCRFs = ecdao.findAllByStudyEvent(seb);
ArrayList<Boolean> doRuleSetsExist = new ArrayList<Boolean>();
RuleSetDAO ruleSetDao = new RuleSetDAO(sm.getDataSource());
for (EventCRFBean eventCrfBean : eventCRFs) {
// Boolean result = ruleSetDao.findByEventCrf(eventCrfBean) != null
// ? Boolean.TRUE : Boolean.FALSE;
// doRuleSetsExist.add(result);
}
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList eventDefinitionCRFs = (ArrayList) edcdao.findAllActiveByEventDefinitionId(study, seb.getStudyEventDefinitionId());
// get the event definition CRFs for which no event CRF exists
// the event definition CRFs must be populated with versions so we can
// let the user choose which version he will enter data for
// However, this method seems to be returning DisplayEventDefinitionCRFs
// that contain valid eventCRFs??
ArrayList uncompletedEventDefinitionCRFs = getUncompletedCRFs(eventDefinitionCRFs, eventCRFs);
populateUncompletedCRFsWithCRFAndVersions(uncompletedEventDefinitionCRFs);
// BWP 2816 << Attempt to provide the DisplayEventDefinitionCRF with a
// valid owner
// only if its container eventCRf has a valid id
populateUncompletedCRFsWithAnOwner(uncompletedEventDefinitionCRFs);
// >>BWP
// for the event definition CRFs for which event CRFs exist, get
// DisplayEventCRFBeans, which the JSP will use to determine what
// the user will see for each event CRF
// removing the below row in exchange for the ViewStudySubjectServlet
// version, for two
// reasons:
// 1. concentrate all business logic in one place
// 2. VSSS seems to handle the javascript creation correctly
// ArrayList displayEventCRFs = getDisplayEventCRFs(eventCRFs,
// eventDefinitionCRFs, seb.getSubjectEventStatus());
ArrayList displayEventCRFs = ViewStudySubjectServlet.getDisplayEventCRFs(sm.getDataSource(), eventCRFs, eventDefinitionCRFs, ub, currentRole, seb.getSubjectEventStatus(), study);
// Issue 3212 BWP << hide certain CRFs at the site level
if (currentStudy.getParentStudyId() > 0) {
HideCRFManager hideCRFManager = HideCRFManager.createHideCRFManager();
uncompletedEventDefinitionCRFs = hideCRFManager.removeHiddenEventDefinitionCRFBeans(uncompletedEventDefinitionCRFs);
displayEventCRFs = hideCRFManager.removeHiddenEventCRFBeans(displayEventCRFs);
}
// >>
request.setAttribute(BEAN_STUDY_EVENT, seb);
request.setAttribute("doRuleSetsExist", doRuleSetsExist);
request.setAttribute(BEAN_STUDY_SUBJECT, studySubjectBean);
request.setAttribute(BEAN_UNCOMPLETED_EVENTDEFINITIONCRFS, uncompletedEventDefinitionCRFs);
request.setAttribute(BEAN_DISPLAY_EVENT_CRFS, displayEventCRFs);
// @pgawade 31-Aug-2012 fix for issue #15315: Reverting to set the request variable "beans" back
// this is for generating side info panel
ArrayList beans = ViewStudySubjectServlet.getDisplayStudyEventsForStudySubject(studySubjectBean, sm.getDataSource(), ub, currentRole);
request.setAttribute("beans", beans);
EventCRFBean ecb = new EventCRFBean();
ecb.setStudyEventId(eventId);
request.setAttribute("eventCRF", ecb);
// Make available the study
request.setAttribute("study", currentStudy);
forwardPage(Page.ENTER_DATA_FOR_STUDY_EVENT);
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class DiscNotesSubjectStatisticsFactory method setDataAndLimitVariables.
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
StudyBean study = this.getStudyBean();
Limit limit = tableFacade.getLimit();
ListDiscNotesSubjectFilter subjectFilter = getSubjectFilter(limit);
// subjectFilter.addFilter("dn.discrepancy_note_type_id", this.discNoteType);
StringBuffer constraints = new StringBuffer();
/* if (this.discNoteType > 0 && this.discNoteType < 10) {
constraints.append(" and dn.discrepancy_note_type_id=" + this.discNoteType);
}
if (this.resolutionStatusIds != null && this.resolutionStatusIds.size() > 0) {
String s = " and (";
for (Integer resolutionStatusId : this.resolutionStatusIds) {
s += "dn.resolution_status_id = " + resolutionStatusId + " or ";
}
s = s.substring(0, s.length() - 3) + " )";
subjectFilter.addFilter("dn.resolution_status_id", s);
constraints.append(s);
}
*/
if (!limit.isComplete()) {
// int totalRows = getStudySubjectDAO().getCountWithFilter(subjectFilter, study);
tableFacade.setTotalRows(6);
}
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = 6;
ListDiscNotesSubjectSort subjectSort = getSubjectSort(limit);
HashMap<Object, Map> items = (HashMap<Object, Map>) getDiscrepancyMap();
Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
Collection<HashMap<Object, Object>> theItemsKeys = new ArrayList<HashMap<Object, Object>>();
Collection<HashMap<Object, Object>> theItemsVals = new ArrayList<HashMap<Object, Object>>();
Iterator keyIt = null;
if (items.values().iterator().hasNext())
keyIt = items.values().iterator().next().keySet().iterator();
HashMap<Object, Object> theItem = new HashMap();
Set theKeys = items.keySet();
List<Object> existingKey = new ArrayList();
Iterator theKeysItr = theKeys.iterator();
while (keyIt.hasNext()) {
String key = "", val = "";
key = keyIt.next().toString();
for (Map<String, String[]> firstVals : items.values()) {
theItem = new HashMap();
Iterator it = firstVals.values().iterator();
// keyIt = firstVals.keySet().iterator();
String label = (String) theKeysItr.next();
while (it.hasNext()) {
theItem.put("_", key);
theItem.put(label, it.next());
}
theItems.add(theItem);
}
theItemsVals.addAll(theItems);
tableFacade.setItems(theItemsVals);
}
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class CreateDiscrepancyNoteServlet method generateUserAccounts.
private ArrayList generateUserAccounts(int studyId, int subjectId) {
UserAccountDAO userAccountDAO = new UserAccountDAO(sm.getDataSource());
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
StudyBean subjectStudy = studyDAO.findByStudySubjectId(subjectId);
// study id, tbh 03/2009
ArrayList userAccounts = new ArrayList();
if (currentStudy.getParentStudyId() > 0) {
userAccounts = userAccountDAO.findAllUsersByStudyOrSite(studyId, currentStudy.getParentStudyId(), subjectId);
} else if (subjectStudy.getParentStudyId() > 0) {
userAccounts = userAccountDAO.findAllUsersByStudyOrSite(subjectStudy.getId(), subjectStudy.getParentStudyId(), subjectId);
} else {
userAccounts = userAccountDAO.findAllUsersByStudyOrSite(studyId, 0, subjectId);
}
return userAccounts;
}
Aggregations