use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.
the class ViewEventCRFServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int eventCRFId = fp.getInt("id", true);
int studySubId = fp.getInt("studySubId", true);
StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
ItemDAO idao = new ItemDAO(sm.getDataSource());
ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
SectionDAO secdao = new SectionDAO(sm.getDataSource());
if (eventCRFId == 0) {
addPageMessage(respage.getString("please_choose_an_event_CRF_to_view"));
forwardPage(Page.LIST_STUDY_SUBJECTS);
} else {
StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
request.setAttribute("studySub", studySub);
EventCRFBean eventCRF = (EventCRFBean) ecdao.findByPK(eventCRFId);
CRFBean crf = cdao.findByVersionId(eventCRF.getCRFVersionId());
request.setAttribute("crf", crf);
ArrayList sections = secdao.findAllByCRFVersionId(eventCRF.getCRFVersionId());
for (int j = 0; j < sections.size(); j++) {
SectionBean section = (SectionBean) sections.get(j);
ArrayList itemData = iddao.findAllByEventCRFId(eventCRFId);
ArrayList displayItemData = new ArrayList();
for (int i = 0; i < itemData.size(); i++) {
ItemDataBean id = (ItemDataBean) itemData.get(i);
DisplayItemBean dib = new DisplayItemBean();
ItemBean item = (ItemBean) idao.findByPK(id.getItemId());
ItemFormMetadataBean ifm = ifmdao.findByItemIdAndCRFVersionId(item.getId(), eventCRF.getCRFVersionId());
item.setItemMeta(ifm);
dib.setItem(item);
dib.setData(id);
dib.setMetadata(ifm);
displayItemData.add(dib);
}
section.setItems(displayItemData);
}
request.setAttribute("sections", sections);
request.setAttribute("studySubId", new Integer(studySubId).toString());
forwardPage(Page.VIEW_EVENT_CRF);
}
}
use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method isCreateItemReqd.
protected boolean isCreateItemReqd(SectionBean sb, HttpServletRequest request) {
SectionDAO sdao = new SectionDAO(getDataSource());
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
DataEntryStage stage = ecb.getStage();
HashMap numItemsHM = sdao.getNumItemsBySectionId();
HashMap numItemsPendingHM = sdao.getNumItemsPendingBySectionId(ecb);
HashMap numItemsCompletedHM = sdao.getNumItemsCompletedBySection(ecb);
HashMap numItemsBlankHM = sdao.getNumItemsBlankBySectionId(ecb);
Integer key = new Integer(sb.getId());
int numItems = TableOfContentsServlet.getIntById(numItemsHM, key);
int numItemsPending = TableOfContentsServlet.getIntById(numItemsPendingHM, key);
int numItemsCompleted = TableOfContentsServlet.getIntById(numItemsCompletedHM, key);
int numItemsBlank = TableOfContentsServlet.getIntById(numItemsBlankHM, key);
LOGGER.debug(" for " + key + " num items " + numItems + " num items blank " + numItemsBlank + " num items pending " + numItemsPending + " completed " + numItemsCompleted);
if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY) && edcb.isDoubleEntry()) {
if (numItemsPending == 0 && numItems > 0) {
// System.out.println("returns false on ide loop " + key);
return false;
}
} else {
if (numItemsCompleted < numItems) {
return false;
}
}
return true;
}
use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method isSectionReviewedOnce.
/**
* Checks if a section is reviewed at least once by user
* updated tbh 03/2011, to fix duplicates issues
* @param sb
* @param request TODO
* @return
*/
protected boolean isSectionReviewedOnce(SectionBean sb, HttpServletRequest request) {
SectionDAO sdao = new SectionDAO(getDataSource());
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
DataEntryStage stage = ecb.getStage();
HashMap numItemsHM = sdao.getNumItemsBySectionId();
HashMap numItemsPendingHM = sdao.getNumItemsPendingBySectionId(ecb);
HashMap numItemsCompletedHM = sdao.getNumItemsCompletedBySectionId(ecb);
HashMap numItemsBlankHM = sdao.getNumItemsBlankBySectionId(ecb);
Integer key = new Integer(sb.getId());
int numItems = TableOfContentsServlet.getIntById(numItemsHM, key);
int numItemsPending = TableOfContentsServlet.getIntById(numItemsPendingHM, key);
int numItemsCompleted = TableOfContentsServlet.getIntById(numItemsCompletedHM, key);
int numItemsBlank = TableOfContentsServlet.getIntById(numItemsBlankHM, key);
LOGGER.debug(" for " + key + " num items " + numItems + " num items blank " + numItemsBlank + " num items pending " + numItemsPending + " completed " + numItemsCompleted);
if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY) && edcb.isDoubleEntry()) {
if (numItemsPending == 0 && numItems > 0) {
LOGGER.debug("returns false on ide loop " + key);
return false;
}
} else {
if (numItemsCompleted == 0 && numItems > 0) {
LOGGER.debug("returns false on other loop " + key);
return false;
}
}
return true;
}
use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method checkGroups.
/**
* Tries to check if a seciton has item groups
* @param fp TODO
* @param ecb TODO
*
* @return
*/
protected boolean checkGroups(FormProcessor fp, EventCRFBean ecb) {
int sectionId = fp.getInt(INPUT_SECTION_ID, true);
SectionDAO sdao = new SectionDAO(getDataSource());
if (sectionId <= 0) {
ArrayList sections = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
for (int i = 0; i < sections.size(); i++) {
SectionBean sb = (SectionBean) sections.get(i);
// find the first section of this CRF
sectionId = sb.getId();
break;
}
}
// we will look into db to see if any repeating items for this CRF
// section
ItemGroupDAO igdao = new ItemGroupDAO(getDataSource());
// find any item group which doesn't equal to 'Ungrouped'
ItemGroupBean itemGroup = igdao.findTopOneGroupBySectionId(sectionId);
if (itemGroup != null && itemGroup.getId() > 0) {
LOGGER.trace("This section has group");
return true;
}
return false;
}
use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method saveItemsToMarkComplete.
/**
* 06/13/2007- jxu Since we don't require users to review each section before mark a CRF as complete, we need to create item data in the database because
* items will not be created unless the section which contains the items is reviewed by users
* @param request TODO
*/
private boolean saveItemsToMarkComplete(Status completeStatus, HttpServletRequest request) throws Exception {
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
SectionDAO sdao = new SectionDAO(getDataSource());
ArrayList sections = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
ItemDAO idao = new ItemDAO(getDataSource());
for (int i = 0; i < sections.size(); i++) {
SectionBean sb = (SectionBean) sections.get(i);
if (!isCreateItemReqd(sb, request)) {
// ArrayList requiredItems =
// idao.findAllRequiredBySectionId(sb.getId());
// if (!requiredItems.isEmpty()) {
// return false;
// }
ArrayList items = idao.findAllBySectionId(sb.getId());
for (int j = 0; j < items.size(); j++) {
ItemBean item = (ItemBean) items.get(j);
ArrayList<ItemDataBean> itemBean = iddao.findAllByEventCRFIdAndItemIdNoStatus(ecb.getId(), item.getId());
ItemDataBean idb = new ItemDataBean();
idb.setItemId(item.getId());
idb.setEventCRFId(ecb.getId());
idb.setCreatedDate(new Date());
idb.setOrdinal(1);
idb.setOwner(ub);
if (completeStatus != null) {
// to avoid null exception
idb.setStatus(completeStatus);
} else {
idb.setStatus(Status.UNAVAILABLE);
}
idb.setValue("");
boolean save = true;
if (itemBean.size() > 0)
save = false;
/* while(itemBean.iterator().hasNext())
{
ItemDataBean temp = itemBean.iterator().next();
if(idb.getEventCRFId()==(temp.getEventCRFId()))
{
if(idb.getItemId()==(temp.getItemId())){
save = false;
}
}
}*/
if (save) {
iddao.create(idb);
}
}
}
}
return true;
}
Aggregations