use of org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO in project OpenClinica by OpenClinica.
the class ViewNotesServlet method processRequest.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
@Override
protected void processRequest() throws Exception {
String module = request.getParameter("module");
String moduleStr = "manage";
if (module != null && module.trim().length() > 0) {
if ("submit".equals(module)) {
request.setAttribute("module", "submit");
moduleStr = "submit";
} else if ("admin".equals(module)) {
request.setAttribute("module", "admin");
moduleStr = "admin";
} else {
request.setAttribute("module", "manage");
}
}
FormProcessor fp = new FormProcessor(request);
if (fp.getString("showMoreLink").equals("")) {
showMoreLink = true;
} else {
showMoreLink = Boolean.parseBoolean(fp.getString("showMoreLink"));
}
int oneSubjectId = fp.getInt("id");
// BWP 11/03/2008 3029: This session attribute in removed in
// ResolveDiscrepancyServlet.mayProceed() >>
session.setAttribute("subjectId", oneSubjectId);
// >>
int resolutionStatusSubj = fp.getInt(RESOLUTION_STATUS);
int discNoteType = 0;
try {
discNoteType = Integer.parseInt(request.getParameter("type"));
} catch (NumberFormatException nfe) {
// Show all DN's
discNoteType = -1;
}
request.setAttribute(DISCREPANCY_NOTE_TYPE, discNoteType);
boolean removeSession = fp.getBoolean("removeSession");
// BWP 11/03/2008 3029: This session attribute in removed in
// ResolveDiscrepancyServlet.mayProceed() >>
session.setAttribute("module", module);
// >>
// Do we only want to view the notes for 1 subject?
String viewForOne = fp.getString("viewForOne");
boolean isForOneSubjectsNotes = "y".equalsIgnoreCase(viewForOne);
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
dndao.setFetchMapping(true);
int resolutionStatus = 0;
try {
resolutionStatus = Integer.parseInt(request.getParameter("resolutionStatus"));
} catch (NumberFormatException nfe) {
// Show all DN's
resolutionStatus = -1;
}
if (removeSession) {
session.removeAttribute(WIN_LOCATION);
session.removeAttribute(NOTES_TABLE);
}
// after resolving a note, user wants to go back to view notes page, we
// save the current URL
// so we can go back later
session.setAttribute(WIN_LOCATION, "ViewNotes?viewForOne=" + viewForOne + "&id=" + oneSubjectId + "&module=" + module + " &removeSession=1");
boolean hasAResolutionStatus = resolutionStatus >= 1 && resolutionStatus <= 6;
Set<Integer> resolutionStatusIds = (HashSet) session.getAttribute(RESOLUTION_STATUS);
// remove the session if there is no resolution status
if (!hasAResolutionStatus && resolutionStatusIds != null) {
session.removeAttribute(RESOLUTION_STATUS);
resolutionStatusIds = null;
}
if (hasAResolutionStatus) {
if (resolutionStatusIds == null) {
resolutionStatusIds = new HashSet<Integer>();
}
resolutionStatusIds.add(resolutionStatus);
session.setAttribute(RESOLUTION_STATUS, resolutionStatusIds);
}
StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
UserAccountDAO uadao = new UserAccountDAO(sm.getDataSource());
CRFVersionDAO crfVersionDao = new CRFVersionDAO(sm.getDataSource());
CRFDAO crfDao = new CRFDAO(sm.getDataSource());
StudyEventDAO studyEventDao = new StudyEventDAO(sm.getDataSource());
StudyEventDefinitionDAO studyEventDefinitionDao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO eventDefinitionCRFDao = new EventDefinitionCRFDAO(sm.getDataSource());
ItemDataDAO itemDataDao = new ItemDataDAO(sm.getDataSource());
ItemDAO itemDao = new ItemDAO(sm.getDataSource());
EventCRFDAO eventCRFDao = new EventCRFDAO(sm.getDataSource());
ListNotesTableFactory factory = new ListNotesTableFactory(showMoreLink);
factory.setSubjectDao(sdao);
factory.setStudySubjectDao(subdao);
factory.setUserAccountDao(uadao);
factory.setStudyDao(studyDao);
factory.setCurrentStudy(currentStudy);
factory.setDiscrepancyNoteDao(dndao);
factory.setCrfDao(crfDao);
factory.setCrfVersionDao(crfVersionDao);
factory.setStudyEventDao(studyEventDao);
factory.setStudyEventDefinitionDao(studyEventDefinitionDao);
factory.setEventDefinitionCRFDao(eventDefinitionCRFDao);
factory.setItemDao(itemDao);
factory.setItemDataDao(itemDataDao);
factory.setEventCRFDao(eventCRFDao);
factory.setModule(moduleStr);
factory.setDiscNoteType(discNoteType);
factory.setResolutionStatus(resolutionStatus);
factory.setViewNotesService(resolveViewNotesService());
// factory.setResolutionStatusIds(resolutionStatusIds);
TableFacade tf = factory.createTable(request, response);
Map<String, Map<String, String>> stats = generateDiscrepancyNotesSummary(factory.getNotesSummary());
Map<String, String> totalMap = generateDiscrepancyNotesTotal(stats);
int grandTotal = 0;
for (String typeName : totalMap.keySet()) {
String total = totalMap.get(typeName);
grandTotal = total.equals("--") ? grandTotal + 0 : grandTotal + Integer.parseInt(total);
}
request.setAttribute("summaryMap", stats);
tf.setTotalRows(grandTotal);
String viewNotesHtml = tf.render();
request.setAttribute("viewNotesHtml", viewNotesHtml);
String viewNotesURL = this.getPageURL();
session.setAttribute("viewNotesURL", viewNotesURL);
String viewNotesPageFileName = this.getPageServletFileName();
session.setAttribute("viewNotesPageFileName", viewNotesPageFileName);
request.setAttribute("mapKeys", ResolutionStatus.getMembers());
request.setAttribute("typeNames", DiscrepancyNoteUtil.getTypeNames());
request.setAttribute("typeKeys", totalMap);
request.setAttribute("grandTotal", grandTotal);
if ("yes".equalsIgnoreCase(fp.getString(PRINT))) {
List<DiscrepancyNoteBean> allNotes = factory.findAllNotes(tf);
request.setAttribute("allNotes", allNotes);
forwardPage(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_PRINT);
} else {
forwardPage(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY);
}
}
use of org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO in project OpenClinica by OpenClinica.
the class ViewSiteServlet method viewSiteEventDefinitions.
private void viewSiteEventDefinitions(StudyBean siteToView) throws MalformedURLException {
int siteId = siteToView.getId();
ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
seds = sedDao.findAllByStudy(siteToView);
int start = 0;
for (StudyEventDefinitionBean sed : seds) {
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
request.setAttribute("participateFormStatus", participateFormStatus);
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
int defId = sed.getId();
ArrayList<EventDefinitionCRFBean> edcs = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllByDefinitionAndSiteIdAndParentStudyId(defId, siteId, siteToView.getParentStudyId());
ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>();
for (EventDefinitionCRFBean edcBean : edcs) {
CRFBean cBean = (CRFBean) cdao.findByPK(edcBean.getCrfId());
String crfPath = sed.getOid() + "." + cBean.getOid();
edcBean.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
int edcStatusId = edcBean.getStatus().getId();
CRFBean crf = (CRFBean) cdao.findByPK(edcBean.getCrfId());
int crfStatusId = crf.getStatusId();
ArrayList<FormLayoutBean> versions = (ArrayList<FormLayoutBean>) fldao.findAllActiveByCRF(edcBean.getCrfId());
edcBean.setVersions(versions);
edcBean.setCrfName(crf.getName());
FormLayoutBean defaultVersion = (FormLayoutBean) fldao.findByPK(edcBean.getDefaultVersionId());
edcBean.setDefaultVersionName(defaultVersion.getName());
String sversionIds = edcBean.getSelectedVersionIds();
ArrayList<Integer> idList = new ArrayList<Integer>();
String idNames = "";
if (sversionIds.length() > 0) {
String[] ids = sversionIds.split("\\,");
for (String id : ids) {
idList.add(Integer.valueOf(id));
for (FormLayoutBean v : versions) {
if (v.getId() == Integer.valueOf(id)) {
idNames += v.getName() + ",";
break;
}
}
}
idNames = idNames.substring(0, idNames.length() - 1);
}
if (edcBean.getParentId() < 1) {
edcBean.setSubmissionUrl("");
}
edcBean.setSelectedVersionIdList(idList);
edcBean.setSelectedVersionNames(idNames);
defCrfs.add(edcBean);
++start;
}
sed.setCrfs(defCrfs);
sed.setCrfNum(defCrfs.size());
}
request.setAttribute("definitions", seds);
ArrayList<String> sdvOptions = new ArrayList<String>();
sdvOptions.add(SourceDataVerification.AllREQUIRED.toString());
sdvOptions.add(SourceDataVerification.PARTIALREQUIRED.toString());
sdvOptions.add(SourceDataVerification.NOTREQUIRED.toString());
sdvOptions.add(SourceDataVerification.NOTAPPLICABLE.toString());
request.setAttribute("sdvOptions", sdvOptions);
}
use of org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO in project OpenClinica by OpenClinica.
the class ViewStudyEventsServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
// checks which module requests are from
String module = fp.getString(MODULE);
request.setAttribute(MODULE, module);
int sedId = fp.getInt("sedId");
int statusId = fp.getInt(INPUT_STATUS_ID);
int definitionId = fp.getInt(INPUT_DEF_ID);
Date startDate = fp.getDate(INPUT_STARTDATE);
Date endDate = fp.getDate(INPUT_ENDDATE);
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
int month = cal.get(Calendar.MONTH) + 1;
int year = cal.get(Calendar.YEAR);
String defaultStartDateString = month + "/01/" + year;
Date defaultStartDate = new Date();
defaultStartDate = new SimpleDateFormat("MM/dd/yy").parse(defaultStartDateString);
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
defaultStartDateString = dateFormatter.format(defaultStartDate);
cal.setTime(defaultStartDate);
cal.add(Calendar.DATE, 30);
Date defaultEndDate = cal.getTime();
if (!fp.isSubmitted()) {
logger.info("not submitted");
HashMap presetValues = new HashMap();
presetValues.put(INPUT_STARTDATE, local_df.format(defaultStartDate));
presetValues.put(INPUT_ENDDATE, local_df.format(defaultEndDate));
startDate = defaultStartDate;
endDate = defaultEndDate;
setPresetValues(presetValues);
} else {
Validator v = new Validator(request);
v.addValidation(INPUT_STARTDATE, Validator.IS_A_DATE);
v.addValidation(INPUT_ENDDATE, Validator.IS_A_DATE);
errors = v.validate();
if (!errors.isEmpty()) {
setInputMessages(errors);
startDate = defaultStartDate;
endDate = defaultEndDate;
}
fp.addPresetValue(INPUT_STARTDATE, fp.getString(INPUT_STARTDATE));
fp.addPresetValue(INPUT_ENDDATE, fp.getString(INPUT_ENDDATE));
fp.addPresetValue(INPUT_DEF_ID, fp.getInt(INPUT_DEF_ID));
fp.addPresetValue(INPUT_STATUS_ID, fp.getInt(INPUT_STATUS_ID));
setPresetValues(fp.getPresetValues());
}
request.setAttribute(STATUS_MAP, SubjectEventStatus.toArrayList());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
ArrayList definitions = seddao.findAllByStudy(currentStudy);
request.setAttribute(DEFINITION_MAP, definitions);
ArrayList allEvents = new ArrayList();
allEvents = genTables(fp, definitions, startDate, endDate, sedId, definitionId, statusId);
request.setAttribute("allEvents", allEvents);
// for print version
String queryUrl = INPUT_STARTDATE + "=" + local_df.format(startDate) + "&" + INPUT_ENDDATE + "=" + local_df.format(endDate) + "&" + INPUT_DEF_ID + "=" + definitionId + "&" + INPUT_STATUS_ID + "=" + statusId + "&" + "sedId=" + sedId + "&submitted=" + fp.getInt("submitted");
request.setAttribute("queryUrl", queryUrl);
if ("yes".equalsIgnoreCase(fp.getString(PRINT))) {
allEvents = genEventsForPrint(fp, definitions, startDate, endDate, sedId, definitionId, statusId);
request.setAttribute("allEvents", allEvents);
forwardPage(Page.VIEW_STUDY_EVENTS_PRINT);
} else {
forwardPage(Page.VIEW_STUDY_EVENTS);
}
}
use of org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO in project OpenClinica by OpenClinica.
the class ViewEventCRFContentServlet method getStudyEvent.
/*
* Get the Study Event to display on screen as well as print some of its
* information. Krikor 10/19/2006
*/
private StudyEventBean getStudyEvent(int eventId) throws Exception {
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
StudyBean studyWithSED = currentStudy;
if (currentStudy.getParentStudyId() > 0) {
studyWithSED = new StudyBean();
studyWithSED.setId(currentStudy.getParentStudyId());
}
AuditableEntityBean aeb = sedao.findByPKAndStudy(eventId, studyWithSED);
if (!aeb.isActive()) {
addPageMessage(respage.getString("the_SE_you_attempting_enter_data_not_belong"));
throw new InsufficientPermissionException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("SE_does_not_belong_current_study"), "1");
// >> changed tbh, 06/2009
}
StudyEventBean seb = (StudyEventBean) aeb;
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(seb.getStudyEventDefinitionId());
seb.setStudyEventDefinition(sedb);
return seb;
}
use of org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO in project OpenClinica by OpenClinica.
the class ViewEventDefinitionReadOnlyServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int defId = fp.getInt(EVENT_ID, true);
String eventOid = fp.getString(EVENT_OID);
if (defId == 0 && eventOid == null) {
addPageMessage(respage.getString("please_choose_a_definition_to_view"));
forwardPage(Page.LIST_DEFINITION_SERVLET);
return;
}
// definition id
StudyEventDefinitionBean sed = defId > 0 ? (StudyEventDefinitionBean) sdao.findByPK(defId) : (StudyEventDefinitionBean) sdao.findByOid(eventOid);
EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(this.currentStudy, sed.getId());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.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());
}
CRFBean cBean = (CRFBean) cdao.findByPK(edc.getCrfId());
String crfPath = sed.getOid() + "." + cBean.getOid();
edc.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
edc.setDefaultVersionName(defaultVersion.getName());
}
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
request.setAttribute("participateFormStatus", participateFormStatus);
request.setAttribute("definition", sed);
request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
request.setAttribute("defSize", new Integer(eventDefinitionCRFs.size()));
// ArrayList(tm.values()));
if (defId > 0) {
forwardPage(Page.VIEW_EVENT_DEFINITION_READONLY);
} else {
forwardPage(Page.VIEW_EVENT_DEFINITION_NOSIDEBAR);
}
}
Aggregations