use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class EnterDataForStudyEventServlet method getUncompletedCRFs.
/**
* Finds all the event definitions for which no event CRF exists - which is
* the list of event definitions with uncompleted event CRFs.
*
* @param eventDefinitionCRFs
* All of the event definition CRFs for this study event.
* @param eventCRFs
* All of the event CRFs for this study event.
* @return The list of event definitions for which no event CRF exists.
*/
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());
}
FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
int crfId = fldao.getCRFIdFromFormLayoutId(ecrf.getFormLayoutId());
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.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DoubleDataEntryServlet method validateDisplayItemBean.
@Override
protected DisplayItemBean validateDisplayItemBean(DiscrepancyValidator v, DisplayItemBean dib, String inputName, RuleValidator rv, HashMap<String, ArrayList<String>> groupOrdinalPLusItemOid, Boolean fireRuleValidation, ArrayList<String> messages, HttpServletRequest request) {
org.akaza.openclinica.bean.core.ResponseType rt = dib.getMetadata().getResponseSet().getResponseType();
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
boolean isSingleItem = false;
if (StringUtil.isBlank(inputName)) {
// for single items
inputName = getInputName(dib);
isSingleItem = true;
}
// we only give warning to user if data entered in DDE is different from
// IDE when the first
// time user hits 'save'
int keyId = ecb.getId();
Integer validationCount = (Integer) request.getSession().getAttribute(COUNT_VALIDATE + keyId);
ItemDataBean valueToCompare = dib.getData();
if (!isSingleItem) {
valueToCompare = dib.getDbData();
}
if (isSingleItem) {
dib = loadFormValue(dib, request);
}
if (groupOrdinalPLusItemOid.containsKey(dib.getItem().getOid()) || fireRuleValidation) {
messages = messages == null ? groupOrdinalPLusItemOid.get(dib.getItem().getOid()) : messages;
dib = validateDisplayItemBeanSingleCV(rv, dib, inputName, messages);
}
return dib;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DoubleDataEntryServlet method validateDisplayItemGroupBean.
// note that this step sets us up both for
// displaying the data on the form again, in the event of an error
// and sending the data to the database, in the event of no error
//
// we have to do this after adding the validations, so that we don't
// overwrite the value the item data bean had from initial data entry
// before the validator stores it as part of the Matches Initial Data Entry
// Value validation
// dib = loadFormValue(dib);
// return dib;
// }
// should be from the db, we check here for a difference
@Override
protected List<DisplayItemGroupBean> validateDisplayItemGroupBean(DiscrepancyValidator v, DisplayItemGroupBean digb, List<DisplayItemGroupBean> digbs, List<DisplayItemGroupBean> formGroups, HttpServletRequest request, HttpServletResponse response) {
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
HttpSession session = request.getSession();
LOGGER.info("===got this far");
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
int keyId = ecb.getId();
Integer validationCount = (Integer) session.getAttribute(COUNT_VALIDATE + keyId);
formGroups = loadFormValueForItemGroup(digb, digbs, formGroups, edcb.getId(), request);
LOGGER.info("found formgroups size for " + digb.getGroupMetaBean().getName() + ": " + formGroups.size() + " compare to db groups size: " + digbs.size());
String inputName = "";
for (int i = 0; i < formGroups.size(); i++) {
DisplayItemGroupBean displayGroup = formGroups.get(i);
List<DisplayItemBean> items = displayGroup.getItems();
int order = displayGroup.getOrdinal();
if (displayGroup.isAuto() && displayGroup.getFormInputOrdinal() > 0) {
order = displayGroup.getFormInputOrdinal();
}
for (DisplayItemBean displayItem : items) {
if (displayGroup.isAuto()) {
inputName = getGroupItemInputName(displayGroup, order, displayItem);
} else {
inputName = getGroupItemManualInputName(displayGroup, order, displayItem);
}
validateDisplayItemBean(v, displayItem, inputName, request);
}
if (validationCount == null || validationCount.intValue() == 0) {
if (i == 0 && formGroups.size() != digbs.size()) {
v.addValidation(inputName + "group", Validator.DIFFERENT_NUMBER_OF_GROUPS_IN_DDE);
// TODO internationalize this string, tbh
v.setErrorMessage("There are additional values here that were not present in the initial data entry. You have entered a different number of groups" + " for the item groups containing " + inputName);
}
}
}
return formGroups;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method runDynamicsCheck.
/*
* function written out here to return itemMetadataGroupBeans after they have been checked for show/hide via dynamics.
* author: tbh 04/2010
*
*/
private ItemGroupMetadataBean runDynamicsCheck(ItemGroupMetadataBean metadataBean, HttpServletRequest request) {
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
try {
if (!metadataBean.isShowGroup()) {
// set isShown here, tbh 04/2010
boolean showGroup = getItemMetadataService().isGroupShown(metadataBean.getId(), ecb);
if (getServletPage(request).equals(Page.DOUBLE_DATA_ENTRY_SERVLET)) {
showGroup = getItemMetadataService().hasGroupPassedDDE(metadataBean.getId(), ecb.getId());
}
metadataBean.setShowGroup(showGroup);
// what about the items which should be shown?
// if (getServletPage().equals(Page.ADMIN_EDIT_SERVLET) && metadataBean.isShowGroup()) {
// metadataBean.setHighlighted(true);
// }
// sets highlighting for AE, tbh 05/2010
// unset highlighting for admin editing, tbh 06/2010
}
// << tbh 04/2010
} catch (OpenClinicaException oce) {
// do nothing for right now, just store the bean
LOGGER.debug("throws an OCE for " + metadataBean.getId());
}
return metadataBean;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method prepareSectionItemDataBeans.
protected HashMap<String, String> prepareSectionItemDataBeans(int sectionId, HttpServletRequest request) {
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
HashMap<String, String> scoreItemdata = new HashMap<String, String>();
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
ArrayList<ItemDataBean> idbs = iddao.findAllActiveBySectionIdAndEventCRFId(sectionId, ecb.getId());
for (ItemDataBean idb : idbs) {
if (idb.getId() > 0) {
int ordinal = idb.getOrdinal();
ordinal = ordinal > 0 ? ordinal : 1;
scoreItemdata.put(idb.getItemId() + "_" + ordinal, idb.getValue().length() > 0 ? idb.getValue() : "");
}
}
return scoreItemdata;
}
Aggregations