use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method isEachSectionReviewedOnce.
/**
* Checks if all the sections in an event crf are reviewed once
* tbh updated to prevent duplicates, 03/2011
* @param request TODO
*
* @return
*/
protected boolean isEachSectionReviewedOnce(HttpServletRequest request) {
SectionDAO sdao = new SectionDAO(getDataSource());
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
DataEntryStage stage = ecb.getStage();
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
// below block changed tbh 04/2011, to remove repeating items generated by mistake
ArrayList<SectionBean> sections = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
/* for (SectionBean section : sections) {
boolean toContinue = isSectionReviewedOnce(section, request);
if (!toContinue) {
return false;
}
}*/
HashMap numItemsHM = sdao.getNumItemsBySectionId();
HashMap numItemsPendingHM = sdao.getNumItemsPendingBySectionId(ecb);
HashMap numItemsCompletedHM = sdao.getNumItemsCompletedBySectionId(ecb);
for (int i = 0; i < sections.size(); i++) {
SectionBean sb = sections.get(i);
Integer key = new Integer(sb.getId());
int numItems = TableOfContentsServlet.getIntById(numItemsHM, key);
int numItemsPending = TableOfContentsServlet.getIntById(numItemsPendingHM, key);
int numItemsCompleted = TableOfContentsServlet.getIntById(numItemsCompletedHM, key);
if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY) && edcb.isDoubleEntry()) {
if (numItemsPending == 0 && numItems > 0) {
return false;
}
} else {
if (numItemsCompleted == 0 && numItems > 0) {
return false;
} else if (numItemsCompleted < numItems) {
return false;
}
}
}
return true;
// if we get this far, all sections are checked and we return a true
// return true;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method prepareScoreItemdata.
protected HashMap<String, String> prepareScoreItemdata(HttpServletRequest request) {
HashMap<String, String> scoreItemdata = new HashMap<String, String>();
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
SectionDAO sdao = new SectionDAO(getDataSource());
ArrayList<SectionBean> sbs = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
for (SectionBean section : sbs) {
HashMap<String, String> data = prepareSectionItemDataBeans(section.getId(), request);
if (data != null && data.size() > 0) {
scoreItemdata.putAll(data);
}
}
return scoreItemdata;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method getChildrenDisplayItems.
/**
* Get the DisplayItemBean objects corresponding to the items which are children of the specified parent.
*
* @param parent
* The item whose children are to be retrieved.
* @param request TODO
* @return An array of DisplayItemBean objects corresponding to the items which are children of parent, and are sorted by column number (ascending), then
* ordinal (ascending).
*/
private ArrayList getChildrenDisplayItems(DisplayItemBean parent, EventDefinitionCRFBean edcb, HttpServletRequest request) {
ArrayList answer = new ArrayList();
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
int parentId = parent.getItem().getId();
ItemDAO idao = new ItemDAO(getDataSource());
ArrayList childItemBeans = idao.findAllByParentIdAndCRFVersionId(parentId, ecb.getCRFVersionId());
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(getDataSource());
for (int i = 0; i < childItemBeans.size(); i++) {
ItemBean child = (ItemBean) childItemBeans.get(i);
ItemDataBean data = iddao.findByItemIdAndEventCRFId(child.getId(), ecb.getId());
ItemFormMetadataBean metadata = ifmdao.findByItemIdAndCRFVersionId(child.getId(), ecb.getCRFVersionId());
DisplayItemBean dib = new DisplayItemBean();
dib.setEventDefinitionCRF(edcb);
dib.setItem(child);
// tbh
if (!getServletPage(request).equals(Page.DOUBLE_DATA_ENTRY_SERVLET)) {
dib.setData(data);
}
// <<tbh 07/2009, bug #3883
// ItemDataBean dbData = iddao.findByItemIdAndEventCRFIdAndOrdinal(itemId, eventCRFId, ordinal)
dib.setDbData(data);
boolean showItem = getItemMetadataService().isShown(metadata.getItemId(), ecb, data);
if (getServletPage(request).equals(Page.DOUBLE_DATA_ENTRY_SERVLET)) {
showItem = getItemMetadataService().hasPassedDDE(metadata, ecb, data);
}
// boolean passedDDE = getItemMetadataService().hasPassedDDE(data);
if (showItem) {
LOGGER.debug("set show item: " + metadata.getItemId() + " data " + data.getId());
// metadata.setShowItem(showItem);
metadata.setShowItem(true);
}
// logger.debug("did not catch NPE");
dib.setMetadata(metadata);
if (shouldLoadDBValues(dib)) {
LOGGER.trace("should load db values is true, set value");
dib.loadDBValue();
LOGGER.trace("just loaded the child value: " + dib.getData().getValue());
}
answer.add(dib);
}
// this is a pretty slow and memory intensive way to sort... see if we
// can
// have the db do this instead
Collections.sort(answer);
return answer;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class ViewSectionDataEntryPreview method setEventCRFAnnotations.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.submit.DataEntryServlet#setEventCRFAnnotations(java.lang.String)
*/
@Override
protected void setEventCRFAnnotations(String annotations, HttpServletRequest request) {
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
ecb.setAnnotations(annotations);
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class CreateDiscrepancyNoteServlet method updateStudySubjectStatus.
/**
* Pulls the note related information from database according to note type
*
* @param note
*/
private void updateStudySubjectStatus(String entityType, int entityId) {
if ("itemData".equalsIgnoreCase(entityType)) {
int itemDataId = entityId;
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
ItemDataBean itemData = (ItemDataBean) iddao.findByPK(itemDataId);
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(sm.getDataSource());
EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
StudySubjectBean studySubject = (StudySubjectBean) studySubjectDAO.findByPK(event.getStudySubjectId());
if (studySubject.getStatus() != null && studySubject.getStatus().equals(Status.SIGNED)) {
studySubject.setStatus(Status.AVAILABLE);
studySubject.setUpdater(ub);
studySubject.setUpdatedDate(new Date());
studySubjectDAO.update(studySubject);
}
if (ec.isSdvStatus()) {
studySubject.setStatus(Status.AVAILABLE);
studySubject.setUpdater(ub);
studySubject.setUpdatedDate(new Date());
studySubjectDAO.update(studySubject);
ec.setSdvStatus(false);
ec.setSdvUpdateId(ub.getId());
ecdao.update(ec);
}
}
}
Aggregations