use of org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean in project OpenClinica by OpenClinica.
the class DynamicsMetadataService method hide.
public boolean hide(Object metadataBean, EventCRFBean eventCrfBean) {
// TODO -- interesting problem, where is the SpringServletAccess object going to live now? tbh 03/2010
ItemFormMetadataBean itemFormMetadataBean = (ItemFormMetadataBean) metadataBean;
itemFormMetadataBean.setShowItem(false);
// DynamicsItemFormMetadataDao dynamicsMetadataDao = (DynamicsItemFormMetadataDao) metadataDao;
// DynamicsItemFormMetadataDao metadataDao = (DynamicsItemFormMetadataDao) SpringServletAccess.getApplicationContext(context).getBean("dynamicsItemFormMetadataDao");
DynamicsItemFormMetadataBean dynamicsMetadataBean = new DynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBean);
dynamicsMetadataBean.setShowItem(false);
getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
return true;
}
use of org.akaza.openclinica.domain.crfdata.DynamicsItemFormMetadataBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method isEachRequiredFieldFillout.
protected boolean isEachRequiredFieldFillout(HttpServletRequest request) {
HttpSession session = request.getSession();
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(getDataSource());
// need to update this method to accomodate dynamics, tbh
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
ItemDAO idao = new ItemDAO(getDataSource());
ItemFormMetadataDAO itemFormMetadataDao = new ItemFormMetadataDAO(getDataSource());
// Below code will iterate all shown and hidden required fields/items in a crf version and verify if the data field is filled up with value or if not , then it is a hidden field with no show rule triggered for the item.
ArrayList<ItemFormMetadataBean> shownRequiredAllItemsInCrfVersion = itemFormMetadataDao.findAllItemsRequiredAndShownByCrfVersionId(ecb.getCRFVersionId());
ArrayList<ItemFormMetadataBean> hiddenRequiredAllItemsInCrfVersion = itemFormMetadataDao.findAllItemsRequiredAndHiddenByCrfVersionId(ecb.getCRFVersionId());
ItemGroupMetadataDAO<String, ArrayList> igdao = new ItemGroupMetadataDAO<String, ArrayList>(dataSource);
ArrayList<ItemDataBean> itemdatas = null;
for (ItemFormMetadataBean shownItemMeta : shownRequiredAllItemsInCrfVersion) {
ItemGroupMetadataBean igBean = (ItemGroupMetadataBean) igdao.findByItemAndCrfVersion(shownItemMeta.getItemId(), ecb.getCRFVersionId());
// verifies if the group that the item belongs to is not hidden.
if (igBean != null && igBean.isShowGroup()) {
itemdatas = iddao.findAllByEventCRFIdAndItemId(ecb.getId(), shownItemMeta.getItemId());
if (itemdatas == null || itemdatas.size() == 0)
return false;
for (ItemDataBean itemdata : itemdatas) {
System.out.println(itemdata.getItemId() + " : " + itemdata.getValue());
if ((itemdata.getValue() == null || itemdata.getValue().equals("") || itemdata.getValue().trim().length() == 0) && dndao.findNumExistingNotesForItem(itemdata.getId()) < 1) {
return false;
}
}
}
ArrayList<DynamicsItemFormMetadataBean> dynamicsItemFormMetadataBeans = null;
for (ItemFormMetadataBean hiddenItemMeta : hiddenRequiredAllItemsInCrfVersion) {
itemdatas = iddao.findAllByEventCRFIdAndItemId(ecb.getId(), hiddenItemMeta.getItemId());
dynamicsItemFormMetadataBeans = getItemMetadataService().getDynamicsItemFormMetadataDao().findByItemAndEventCrfShown(ecb, hiddenItemMeta.getItemId());
if (itemdatas.size() == 0 && dynamicsItemFormMetadataBeans.size() > 0) {
return false;
}
for (ItemDataBean itemdata : itemdatas) {
if ((itemdata.getValue() == null || itemdata.getValue().equals("") || itemdata.getValue().trim().length() == 0) && dndao.findNumExistingNotesForItem(itemdata.getId()) < 1 && dynamicsItemFormMetadataBeans.size() > 0) {
return false;
}
}
}
}
// had to change the query below to allow for hidden items here, tbh 04/2010
ArrayList allFilled = iddao.findAllBlankRequiredByEventCRFId(ecb.getId(), ecb.getCRFVersionId());
int numNotes = 0;
if (!allFilled.isEmpty()) {
LOGGER.trace("allFilled is not empty");
FormDiscrepancyNotes fdn = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
HashMap idNotes = fdn.getIdNotes();
for (int i = 0; i < allFilled.size(); i++) {
ItemDataBean idb = (ItemDataBean) allFilled.get(i);
int exsitingNotes = dndao.findNumExistingNotesForItem(idb.getId());
if (exsitingNotes > 0) {
LOGGER.trace("has existing note");
numNotes++;
} else if (idNotes.containsKey(idb.getId())) {
LOGGER.trace("has note in session");
numNotes++;
}
}
LOGGER.trace("numNotes allFilled.size:" + numNotes + " " + allFilled.size());
if (numNotes >= allFilled.size()) {
LOGGER.trace("all required are filled out");
return true;
} else {
LOGGER.debug("numNotes < allFilled.size() " + numNotes + ": " + allFilled.size());
return false;
}
}
return true;
}
Aggregations