use of org.akaza.openclinica.bean.managestudy.StudyGroupClassBean in project OpenClinica by OpenClinica.
the class CreateSubjectGroupClassServlet method submitGroup.
/**
* Saves study group information into database
*
* @throws OpenClinicaException
*/
private void submitGroup() throws OpenClinicaException, IOException {
StudyGroupClassBean group = (StudyGroupClassBean) session.getAttribute("group");
ArrayList studyGroups = (ArrayList) session.getAttribute("studyGroups");
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
group.setStudyId(currentStudy.getId());
group.setOwner(ub);
group.setStatus(Status.AVAILABLE);
group = (StudyGroupClassBean) sgcdao.create(group);
if (!group.isActive()) {
addPageMessage(respage.getString("the_subject_group_class_not_created_database"));
} else {
StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
for (int i = 0; i < studyGroups.size(); i++) {
StudyGroupBean sg = (StudyGroupBean) studyGroups.get(i);
sg.setStudyGroupClassId(group.getId());
sg.setOwner(ub);
sg.setStatus(Status.AVAILABLE);
sgdao.create(sg);
}
addPageMessage(respage.getString("the_subject_group_class_created_succesfully"));
}
ArrayList pageMessages = (ArrayList) request.getAttribute(PAGE_MESSAGE);
session.setAttribute("pageMessages", pageMessages);
response.sendRedirect(request.getContextPath() + Page.MANAGE_STUDY_MODULE.getFileName());
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupClassBean in project OpenClinica by OpenClinica.
the class ListEventsForSubjectTableFactory method getColumnNamesMap.
private void getColumnNamesMap() {
ArrayList<String> columnNamesList = new ArrayList<String>();
columnNamesList.add("studySubject.label");
columnNamesList.add("studySubject.status");
columnNamesList.add("enrolledAt");
columnNamesList.add("subject.charGender");
for (StudyGroupClassBean studyGroupClass : getStudyGroupClasses()) {
columnNamesList.add("sgc_" + studyGroupClass.getId());
}
columnNamesList.add("event.status");
columnNamesList.add("studySubject.createdDate");
for (CRFBean crfBean : getCrfs(selectedStudyEventDefinition)) {
columnNamesList.add("crf_" + crfBean.getId());
}
columnNamesList.add("actions");
columnNames = columnNamesList.toArray(columnNames);
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupClassBean in project OpenClinica by OpenClinica.
the class ListEventsForSubjectTableFactory method setDataAndLimitVariables.
@SuppressWarnings("unchecked")
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
Limit limit = tableFacade.getLimit();
ListEventsForSubjectFilter eventsForSubjectFilter = getListEventsForSubjectFilter(limit);
if (!limit.isComplete()) {
int totalRows = getStudySubjectDAO().getCountWithFilter(eventsForSubjectFilter, getStudyBean());
tableFacade.setTotalRows(totalRows);
}
ListEventsForSubjectSort eventsForSubjectSort = getListEventsForSubjectSort(limit);
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(), eventsForSubjectFilter, eventsForSubjectSort, rowStart, rowEnd);
Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
for (StudySubjectBean studySubjectBean : items) {
HashMap<Object, Object> theItem = new HashMap<Object, Object>();
theItem.put("studySubject", studySubjectBean);
theItem.put("studySubject.label", studySubjectBean.getLabel());
theItem.put("studySubject.status", studySubjectBean.getStatus());
theItem.put("enrolledAt", ((StudyBean) getStudyDAO().findByPK(studySubjectBean.getStudyId())).getIdentifier());
SubjectBean subjectBean = (SubjectBean) getSubjectDAO().findByPK(studySubjectBean.getSubjectId());
theItem.put("subject", subjectBean);
theItem.put("subject.charGender", subjectBean.getGender());
// study group classes
SubjectGroupMapBean subjectGroupMapBean = new SubjectGroupMapBean();
for (StudyGroupClassBean studyGroupClass : getStudyGroupClasses()) {
subjectGroupMapBean = getSubjectGroupMapDAO().findAllByStudySubjectAndStudyGroupClass(studySubjectBean.getId(), studyGroupClass.getId());
if (null != subjectGroupMapBean) {
theItem.put("sgc_" + studyGroupClass.getId(), subjectGroupMapBean.getStudyGroupId());
theItem.put("grpName_sgc_" + studyGroupClass.getId(), subjectGroupMapBean.getStudyGroupName());
}
}
subjectGroupMapBean = null;
// Get EventCrfs for study Subject
List<EventCRFBean> eventCrfs = getEventCRFDAO().findAllByStudySubject(studySubjectBean.getId());
HashMap<String, EventCRFBean> crfAsKeyEventCrfAsValue = new HashMap<String, EventCRFBean>();
for (EventCRFBean eventCRFBean : eventCrfs) {
CRFBean crf = getCrfDAO().findByVersionId(eventCRFBean.getCRFVersionId());
crfAsKeyEventCrfAsValue.put(crf.getId() + "_" + eventCRFBean.getStudyEventId(), eventCRFBean);
}
// Get the event Status
List<StudyEventBean> eventsForStudySubjectAndEventDefinitions = getStudyEventDAO().findAllByDefinitionAndSubject(selectedStudyEventDefinition, studySubjectBean);
List<DisplayBean> events = new ArrayList<DisplayBean>();
// study event size < 1
if (eventsForStudySubjectAndEventDefinitions.size() < 1) {
DisplayBean d = new DisplayBean();
d.getProps().put("event", null);
d.getProps().put("event.status", SubjectEventStatus.NOT_SCHEDULED);
d.getProps().put("studySubject.createdDate", null);
for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
d.getProps().put("crf_" + crf.getId() + "_crf", crf);
// d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", getEventDefinitionCRFBean(selectedStudyEventDefinition.getId(), crf, studySubjectBean));
theItem.put("crf_" + crf.getId(), "");
}
events.add(d);
}
// study event size >0
for (StudyEventBean studyEventBean : eventsForStudySubjectAndEventDefinitions) {
DisplayBean d = new DisplayBean();
d.getProps().put("event", studyEventBean);
d.getProps().put("event.status", studyEventBean.getSubjectEventStatus());
d.getProps().put("studySubject.createdDate", studyEventBean.getDateStarted());
for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
EventCRFBean eventCRFBean = crfAsKeyEventCrfAsValue.get(crf.getId() + "_" + studyEventBean.getId());
if (eventCRFBean != null) {
d.getProps().put("crf_" + crf.getId(), eventCRFBean.getStage());
d.getProps().put("crf_" + crf.getId() + "_eventCrf", eventCRFBean);
} else {
d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
}
d.getProps().put("crf_" + crf.getId() + "_crf", crf);
// d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", getEventDefinitionCRFBean(selectedStudyEventDefinition.getId(), crf, studySubjectBean));
theItem.put("crf_" + crf.getId(), "");
}
events.add(d);
}
theItem.put("events", events);
theItem.put("event.status", "");
theItem.put("studySubject.createdDate", "");
theItem.put("webappContext", tableFacade.getWebContext().getContextPath());
theItems.add(theItem);
}
// Do not forget to set the items back on the tableFacade.
tableFacade.setItems(theItems);
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupClassBean in project OpenClinica by OpenClinica.
the class CoreSecureController method getStudyGroupClassesByCurrentStudy.
public ArrayList getStudyGroupClassesByCurrentStudy(HttpServletRequest request) {
StudyDAO studyDAO = new StudyDAO(getDataSource());
StudyGroupClassDAO studyGroupClassDAO = new StudyGroupClassDAO(getDataSource());
StudyGroupDAO studyGroupDAO = new StudyGroupDAO(getDataSource());
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
int parentStudyId = currentStudy.getParentStudyId();
ArrayList studyGroupClasses = new ArrayList();
if (parentStudyId > 0) {
StudyBean parentStudy = (StudyBean) studyDAO.findByPK(parentStudyId);
studyGroupClasses = studyGroupClassDAO.findAllActiveByStudy(parentStudy);
} else {
parentStudyId = currentStudy.getId();
studyGroupClasses = studyGroupClassDAO.findAllActiveByStudy(currentStudy);
}
for (int i = 0; i < studyGroupClasses.size(); i++) {
StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(i);
ArrayList groups = studyGroupDAO.findAllByGroupClass(sgc);
sgc.setStudyGroups(groups);
}
return studyGroupClasses;
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupClassBean in project OpenClinica by OpenClinica.
the class EditSelectedServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
boolean selectAll = fp.getBoolean("all");
boolean selectAllItemsGroupsAttrs = fp.getBoolean("allAttrsAndItems");
// BWP 3095: Only show a "select all items" like on a side info panel if
// it
// is not part of the EditSelected-related JSP>>
request.setAttribute("EditSelectedSubmitted", true);
// <<
ItemDAO idao = new ItemDAO(sm.getDataSource());
// CRFDAO crfdao = new CRFDAO(sm.getDataSource());
ItemFormMetadataDAO imfdao = new ItemFormMetadataDAO(sm.getDataSource());
CRFDAO crfdao = new CRFDAO(sm.getDataSource());
DatasetBean db = (DatasetBean) session.getAttribute("newDataset");
if (db == null) {
db = new DatasetBean();
session.setAttribute("newDataset", db);
}
// << tbh
// HashMap eventlist = (HashMap) request.getAttribute("eventlist");
// if (eventlist == null) {
// System.out.println("TTTTT found the second hashmap!");
HashMap eventlist = (LinkedHashMap) session.getAttribute("eventsForCreateDataset");
// }
ArrayList<String> ids = CreateDatasetServlet.allSedItemIdsInStudy(eventlist, crfdao, idao);
// >> tbh 11/09, need to fill in a session variable
if (selectAll) {
logger.info("select all..........");
db = selectAll(db);
MessageFormat msg = new MessageFormat("");
msg.setLocale(locale);
msg.applyPattern(respage.getString("choose_include_all_items_dataset"));
Object[] arguments = { ids.size() };
addPageMessage(msg.format(arguments));
// addPageMessage("You choose to include all items in current study
// for the dataset, " +db.getItemIds().size() + " items total.");
}
if (selectAllItemsGroupsAttrs) {
logger.info("select everything....");
db = selectAll(db);
db.setShowCRFcompletionDate(true);
db.setShowCRFinterviewerDate(true);
db.setShowCRFinterviewerName(true);
db.setShowCRFstatus(true);
db.setShowCRFversion(true);
db.setShowEventEnd(true);
db.setShowEventEndTime(true);
db.setShowEventLocation(true);
db.setShowEventStart(true);
db.setShowEventStartTime(true);
db.setShowEventStatus(true);
db.setShowSubjectAgeAtEvent(true);
db.setShowSubjectDob(true);
db.setShowSubjectGender(true);
db.setShowSubjectGroupInformation(true);
db.setShowSubjectStatus(true);
db.setShowSubjectUniqueIdentifier(true);
// select all groups
ArrayList sgclasses = (ArrayList) session.getAttribute("allSelectedGroups");
//
ArrayList newsgclasses = new ArrayList();
StudyDAO studydao = new StudyDAO(sm.getDataSource());
StudyGroupClassDAO sgclassdao = new StudyGroupClassDAO(sm.getDataSource());
StudyBean theStudy = (StudyBean) studydao.findByPK(sm.getUserBean().getActiveStudyId());
sgclasses = sgclassdao.findAllActiveByStudy(theStudy);
for (int i = 0; i < sgclasses.size(); i++) {
StudyGroupClassBean sgclass = (StudyGroupClassBean) sgclasses.get(i);
sgclass.setSelected(true);
newsgclasses.add(sgclass);
}
session.setAttribute("allSelectedGroups", newsgclasses);
request.setAttribute("allSelectedGroups", newsgclasses);
}
session.setAttribute("newDataset", db);
HashMap events = (HashMap) session.getAttribute(CreateDatasetServlet.EVENTS_FOR_CREATE_DATASET);
if (events == null) {
events = new HashMap();
}
ArrayList allSelectItems = selectAll ? selectAll(events, crfdao, idao) : ViewSelectedServlet.getAllSelected(db, idao, imfdao);
// >> tbh
session.setAttribute("numberOfStudyItems", new Integer(ids.size()).toString());
// << tbh 11/2009
session.setAttribute("allSelectedItems", allSelectItems);
setUpStudyGroups();
forwardPage(Page.CREATE_DATASET_VIEW_SELECTED);
}
Aggregations