use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO 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.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method injectParentDiscNotesIntoDisplayStudyEvents.
public void injectParentDiscNotesIntoDisplayStudyEvents(List<DisplayStudyEventBean> displayStudyBeans, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType) {
if (displayStudyBeans == null) {
return;
}
// booleans representing whether this method should only get
// DiscrepancyNoteBeans with
// certain resolution status or discrepancyNoteTypeId number.
boolean hasResolutionStatus = this.checkResolutionStatus(resolutionStatusIds);
boolean hasDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
StudyEventBean studyEventBean;
List<EventCRFBean> eventCRFBeans = new ArrayList<EventCRFBean>();
List<DiscrepancyNoteBean> foundDiscNotes = new ArrayList<DiscrepancyNoteBean>();
for (DisplayStudyEventBean dStudyEventBean : displayStudyBeans) {
studyEventBean = dStudyEventBean.getStudyEvent();
// All EventCRFs for a study event
eventCRFBeans = eventCRFDAO.findAllByStudyEvent(studyEventBean);
for (EventCRFBean eventCrfBean : eventCRFBeans) {
// Find ItemData type notes associated with an event crf
foundDiscNotes = discrepancyNoteDAO.findParentItemDataDNotesFromEventCRF(eventCrfBean);
// filter for any specified disc note type
if (!foundDiscNotes.isEmpty() && hasDiscNoteType) {
// only include disc notes that have the specified disc note
// type id
foundDiscNotes = filterforDiscNoteType(foundDiscNotes, discNoteType);
}
if (!foundDiscNotes.isEmpty()) {
if (!hasResolutionStatus) {
studyEventBean.getDiscBeanList().addAll(foundDiscNotes);
} else {
// session variable
for (DiscrepancyNoteBean discBean : foundDiscNotes) {
for (int statusId : resolutionStatusIds) {
if (discBean.getResolutionStatusId() == statusId) {
studyEventBean.getDiscBeanList().add(discBean);
}
}
}
}
}
}
// end for(EventCRFBean...
}
// end for (DisplayStudyEventBean
}
use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method updateStatusOfParents.
/**
* Take a List of "parent" DiscrepancyNoteBeans and if they have any
* "children," make sure that the resolution status id of the parent matches
* that of the last child DiscrepancyNoteBean.
*
* @param allDiscNotes
* A List of DiscrepancyNoteBeans.
* @param dataSource
* The DataSource the DAO uses.
* @param currentStudy
* A StudyBean representing the current study.
*/
public void updateStatusOfParents(List<DiscrepancyNoteBean> allDiscNotes, DataSource dataSource, StudyBean currentStudy) {
if (allDiscNotes == null || allDiscNotes.isEmpty()) {
return;
}
List<DiscrepancyNoteBean> childDiscBeans = new ArrayList<DiscrepancyNoteBean>();
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
DiscrepancyNoteBean lastChild = new DiscrepancyNoteBean();
int resolutionStatusId = 0;
for (DiscrepancyNoteBean discBean : allDiscNotes) {
childDiscBeans = discrepancyNoteDAO.findAllByStudyAndParent(currentStudy, discBean.getId());
if (!childDiscBeans.isEmpty()) {
lastChild = childDiscBeans.get(childDiscBeans.size() - 1);
resolutionStatusId = lastChild.getResolutionStatusId();
if (discBean.getResolutionStatusId() != resolutionStatusId) {
discBean.setResolutionStatusId(resolutionStatusId);
}
}
// clear the List for the next iteration
if (childDiscBeans != null) {
childDiscBeans.clear();
}
}
}
use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method getDNotesForStudy.
/**
* Acquire the DiscrepancyNoteBeans for a specific study.
*
* @param currentStudy
* A StudyBean object.
* @param resolutionStatus
* An int resolution status; only DiscrepancyNoteBeans will be
* returned if they have this resolutionStatus id.
* @param dataSource
* A DataSource used for various DAO methods.
* @param discNoteType
* An int discrepancy note type id; only DiscrepancyNoteBeans
* will be returned if they have this discrepancyNoteTypeId.
* @return A List of DiscrepancyNoteBeans.
*/
public List<DiscrepancyNoteBean> getDNotesForStudy(StudyBean currentStudy, int resolutionStatus, DataSource dataSource, int discNoteType) {
List<DiscrepancyNoteBean> allDiscNotes = new ArrayList<DiscrepancyNoteBean>();
if (currentStudy == null)
return allDiscNotes;
// Do the returned DN's have to be filtered? A valid resolution status
// has to be between 1 and 5; 0 is "invalid";
// -1 means that no resolutionStatus parameter was passed into the
// servlet
boolean filterDiscNotes = resolutionStatus >= 1 && resolutionStatus <= 5;
boolean filterforDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
// what is the purpose of this data member?
discrepancyNoteDAO.setFetchMapping(true);
EventCRFDAO ecdao = new EventCRFDAO(dataSource);
ArrayList itemDataNotes = discrepancyNoteDAO.findAllItemDataByStudy(currentStudy);
ArrayList subjectNotes = discrepancyNoteDAO.findAllSubjectByStudy(currentStudy);
ArrayList studySubjectNotes = discrepancyNoteDAO.findAllStudySubjectByStudy(currentStudy);
ArrayList studyEventNotes = discrepancyNoteDAO.findAllStudyEventByStudy(currentStudy);
ArrayList eventCRFNotes = discrepancyNoteDAO.findAllEventCRFByStudy(currentStudy);
allDiscNotes.addAll(itemDataNotes);
allDiscNotes.addAll(subjectNotes);
allDiscNotes.addAll(studySubjectNotes);
allDiscNotes.addAll(studyEventNotes);
allDiscNotes.addAll(eventCRFNotes);
if (filterDiscNotes) {
// filter for the resolution status
allDiscNotes = filterDiscNotes(allDiscNotes, resolutionStatus);
}
if (filterforDiscNoteType) {
// filter for the ddiscrepancyNoteTypeId
allDiscNotes = filterforDiscNoteType(allDiscNotes, discNoteType);
}
return allDiscNotes;
}
use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method getDNotesForStudy.
/**
* An overloaded version of the prior method, the difference being a HashSet
* of resolution status ids, instead of a single id.
*
* @param currentStudy
* A StudyBean object.
* @param resolutionStatusIds
* A HashSet object consisting of resolution status ids (i.e.,
* 1,2,3).
* @param dataSource
* A DataSource used for various DAO methods.
* @param discNoteType
* An int discrepancy note type id; only DiscrepancyNoteBeans
* will be returned if they have this discrepancyNoteTypeId.
* @return A List of DiscrepancyNoteBeans.
*/
public List<DiscrepancyNoteBean> getDNotesForStudy(StudyBean currentStudy, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType) {
List<DiscrepancyNoteBean> allDiscNotes = new ArrayList<DiscrepancyNoteBean>();
if (currentStudy == null)
return allDiscNotes;
// Do the returned DN's have to be filtered? A valid resolution status
// has to be between 1 and 5; 0 is "invalid";
// -1 means that no resolutionStatus parameter was passed into the
// servlet
boolean filterDiscNotes = checkResolutionStatus(resolutionStatusIds);
boolean filterforDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
// what is the purpose of this data member?
discrepancyNoteDAO.setFetchMapping(true);
EventCRFDAO ecdao = new EventCRFDAO(dataSource);
ArrayList itemDataNotes = discrepancyNoteDAO.findAllItemDataByStudy(currentStudy);
ArrayList subjectNotes = discrepancyNoteDAO.findAllSubjectByStudy(currentStudy);
ArrayList studySubjectNotes = discrepancyNoteDAO.findAllStudySubjectByStudy(currentStudy);
ArrayList studyEventNotes = discrepancyNoteDAO.findAllStudyEventByStudy(currentStudy);
ArrayList eventCRFNotes = discrepancyNoteDAO.findAllEventCRFByStudy(currentStudy);
allDiscNotes.addAll(itemDataNotes);
allDiscNotes.addAll(subjectNotes);
allDiscNotes.addAll(studySubjectNotes);
allDiscNotes.addAll(studyEventNotes);
allDiscNotes.addAll(eventCRFNotes);
if (filterDiscNotes) {
// filter for the resolution status
allDiscNotes = filterDiscNotes(allDiscNotes, resolutionStatusIds);
}
if (filterforDiscNoteType) {
// filter for the ddiscrepancyNoteTypeId
allDiscNotes = filterforDiscNoteType(allDiscNotes, discNoteType);
}
return allDiscNotes;
}
Aggregations