use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method prepareSectionItemdata.
protected HashMap<Integer, String> prepareSectionItemdata(int sectionId, HttpServletRequest request) {
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
HashMap<Integer, String> itemdata = new HashMap<Integer, String>();
ArrayList<ItemDataBean> idbs = iddao.findAllActiveBySectionIdAndEventCRFId(sectionId, ecb.getId());
for (ItemDataBean idb : idbs) {
itemdata.put(idb.getId(), idb.getValue());
}
return itemdata;
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method buildMatrixForRepeatingGroups.
// @pgawade 30-May-2012 Fix for issue 13963 - added an extra parameter 'isSubmitted' to method buildMatrixForRepeatingGroups
protected DisplayItemWithGroupBean buildMatrixForRepeatingGroups(DisplayItemWithGroupBean diwgb, DisplayItemGroupBean itemGroup, EventCRFBean ecb, SectionBean sb, List<ItemBean> itBeans, Map<String, ItemDataBean> dataMap, List<String> nullValuesList, boolean isSubmitted) {
int tempOrdinal = 1;
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
int maxOrdinal = iddao.getMaxOrdinalForGroup(ecb, sb, itemGroup.getItemGroupBean());
// Incase of no data
if (maxOrdinal == 0)
maxOrdinal = 1;
ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO<String, ArrayList>(getDataSource());
List<DisplayItemGroupBean> itemGroups = new ArrayList<DisplayItemGroupBean>();
boolean groupHasData = false;
for (int i = 1; i <= maxOrdinal; i++) {
List<DisplayItemBean> displayItemBeans = new ArrayList<DisplayItemBean>();
DisplayItemGroupBean dig = new DisplayItemGroupBean();
for (ItemBean itBean : itBeans) {
DisplayItemBean displayItemBean = new DisplayItemBean();
ItemFormMetadataBean ifm = ifmdao.findByItemIdAndCRFVersionId(itBean.getId(), ecb.getCRFVersionId());
// itBean.setItemMeta(ifm);//TODO:remove this or the one down displayItemBean.setMetadata(ifm);
displayItemBean.setMetadata(ifm);
displayItemBean.setItem(itBean);
ItemDataBean itemData = dataMap.get(itBean.getId() + "," + i);
if (itemData != null) {
// to indicate any item in the group has data;
groupHasData = true;
displayItemBean.setIsNewItem(false);
}
if (itemData == null) {
itemData = displayItemBean.getData();
itemData.setValue("");
itemData.setOrdinal(i);
}
addNullValues(displayItemBean, nullValuesList);
displayItemBean.setData(itemData);
// displayItemBean.loadDBValue();
if (ecb.getStage() == DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE || ecb.getStage() == DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) {
if (shouldLoadDBValues(displayItemBean) && !isSubmitted) {
displayItemBean.loadDBValue();
}
} else {
if (shouldLoadDBValues(displayItemBean)) {
LOGGER.trace("should load db values is true, set value");
displayItemBean.loadDBValue();
LOGGER.trace("just got data loaded: " + displayItemBean.getData().getValue());
}
}
displayItemBeans.add(displayItemBean);
}
Collections.sort(displayItemBeans);
dig.setItems(displayItemBeans);
dig.setHasData(groupHasData);
itemGroups.add(dig);
}
diwgb.setItemGroups(itemGroups);
diwgb.setDbItemGroups(itemGroups);
return diwgb;
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class CrfBusinessLogicHelper method isEachRequiredFieldFillout.
protected boolean isEachRequiredFieldFillout(EventCRFBean ecb) {
ItemDataDAO iddao = new ItemDataDAO(ds);
ItemDAO idao = new ItemDAO(ds);
int allRequiredNum = idao.findAllRequiredByCRFVersionId(ecb.getCRFVersionId());
int allRequiredFilledOut = iddao.findAllRequiredByEventCRFId(ecb);
if (allRequiredNum > allRequiredFilledOut) {
return false;
}
ArrayList allFilled = iddao.findAllBlankRequiredByEventCRFId(ecb.getId(), ecb.getCRFVersionId());
if (!allFilled.isEmpty()) {
return false;
}
return true;
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class UpdateStudyEventServlet method getUncompletedCRFs.
private ArrayList getUncompletedCRFs(ArrayList eventDefinitionCRFs, ArrayList eventCRFs) {
int i;
HashMap completed = new HashMap();
HashMap startedButIncompleted = new HashMap();
ArrayList answer = new ArrayList();
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
}
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
int crfId = cvdao.getCRFIdFromCRFVersionId(ecrf.getCRFVersionId());
ArrayList idata = iddao.findAllByEventCRFId(ecrf.getId());
if (!idata.isEmpty()) {
// this crf has data already
completed.put(new Integer(crfId), Boolean.TRUE);
} else {
// event crf got created, but no data entered
startedButIncompleted.put(new Integer(crfId), ecrf);
}
}
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
dedc.setEdc(edcrf);
Boolean b = (Boolean) completed.get(new Integer(edcrf.getCrfId()));
EventCRFBean ev = (EventCRFBean) startedButIncompleted.get(new Integer(edcrf.getCrfId()));
if (b == null || !b.booleanValue()) {
dedc.setEventCRF(ev);
answer.add(dedc);
}
}
return answer;
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class ResolveDiscrepancyServlet method prepareRequestForResolution.
public boolean prepareRequestForResolution(HttpServletRequest request, DataSource ds, StudyBean currentStudy, DiscrepancyNoteBean note, boolean isCompleted) {
String entityType = note.getEntityType().toLowerCase();
int id = note.getEntityId();
if ("subject".equalsIgnoreCase(entityType)) {
StudySubjectDAO ssdao = new StudySubjectDAO(ds);
StudySubjectBean ssb = ssdao.findBySubjectIdAndStudy(id, currentStudy);
request.setAttribute("action", "show");
request.setAttribute("id", String.valueOf(note.getEntityId()));
request.setAttribute("studySubId", String.valueOf(ssb.getId()));
} else if ("studysub".equalsIgnoreCase(entityType)) {
request.setAttribute("action", "show");
request.setAttribute("id", String.valueOf(note.getEntityId()));
} else if ("eventcrf".equalsIgnoreCase(entityType)) {
request.setAttribute("editInterview", "1");
EventCRFDAO ecdao = new EventCRFDAO(ds);
EventCRFBean ecb = (EventCRFBean) ecdao.findByPK(id);
request.setAttribute(TableOfContentsServlet.INPUT_EVENT_CRF_BEAN, ecb);
// If the request is passed along to ViewSectionDataEntryServlet,
// that code needs
// an event crf id; the (ecb.getId()+"") is necessary because
// FormProcessor throws
// a ClassCastException without the casting to a String
request.setAttribute(ViewSectionDataEntryServlet.EVENT_CRF_ID, ecb.getId() + "");
} else if ("studyevent".equalsIgnoreCase(entityType)) {
StudyEventDAO sedao = new StudyEventDAO(ds);
StudyEventBean seb = (StudyEventBean) sedao.findByPK(id);
request.setAttribute(EnterDataForStudyEventServlet.INPUT_EVENT_ID, String.valueOf(id));
request.setAttribute(UpdateStudyEventServlet.EVENT_ID, String.valueOf(id));
request.setAttribute(UpdateStudyEventServlet.STUDY_SUBJECT_ID, String.valueOf(seb.getStudySubjectId()));
} else // this is for item data
if ("itemdata".equalsIgnoreCase(entityType)) {
ItemDataDAO iddao = new ItemDataDAO(ds);
ItemDataBean idb = (ItemDataBean) iddao.findByPK(id);
EventCRFDAO ecdao = new EventCRFDAO(ds);
EventCRFBean ecb = (EventCRFBean) ecdao.findByPK(idb.getEventCRFId());
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
StudySubjectBean ssb = (StudySubjectBean) ssdao.findByPK(ecb.getStudySubjectId());
ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(ds);
ItemFormMetadataBean ifmb = ifmdao.findByItemIdAndCRFVersionId(idb.getItemId(), ecb.getCRFVersionId());
if (currentRole.getRole().equals(Role.MONITOR) || !isCompleted) {
StudyEventDAO sedao = new StudyEventDAO(ds);
StudyEventBean seb = (StudyEventBean) sedao.findByPK(id);
request.setAttribute(EVENT_CRF_ID, String.valueOf(idb.getEventCRFId()));
request.setAttribute(STUDY_SUB_ID, String.valueOf(seb.getStudySubjectId()));
} else {
request.setAttribute(DataEntryServlet.INPUT_EVENT_CRF_ID, String.valueOf(idb.getEventCRFId()));
request.setAttribute(DataEntryServlet.INPUT_SECTION_ID, String.valueOf(ifmb.getSectionId()));
}
DataEntryStage stage = ecb.getStage();
// if (!stage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE)) {
// return false;
// }
}
return true;
}
Aggregations