use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class DataImportService method createDiscrepancyNote.
public DiscrepancyNoteBean createDiscrepancyNote(ItemBean itemBean, String message, EventCRFBean eventCrfBean, DisplayItemBean displayItemBean, Integer parentId, UserAccountBean uab, DataSource ds, StudyBean study) {
DiscrepancyNoteBean note = new DiscrepancyNoteBean();
StudySubjectDAO ssdao = new StudySubjectDAO(ds);
note.setDescription(message);
note.setDetailedNotes("Failed Validation Check");
note.setOwner(uab);
note.setCreatedDate(new Date());
note.setResolutionStatusId(ResolutionStatus.OPEN.getId());
note.setDiscrepancyNoteTypeId(DiscrepancyNoteType.FAILEDVAL.getId());
if (parentId != null) {
note.setParentDnId(parentId);
}
note.setField(itemBean.getName());
note.setStudyId(study.getId());
note.setEntityName(itemBean.getName());
note.setEntityType("ItemData");
note.setEntityValue(displayItemBean.getData().getValue());
note.setEventName(eventCrfBean.getName());
note.setEventStart(eventCrfBean.getCreatedDate());
note.setCrfName(displayItemBean.getEventDefinitionCRF().getCrfName());
StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(eventCrfBean.getStudySubjectId());
note.setSubjectName(ss.getName());
note.setEntityId(displayItemBean.getData().getId());
note.setColumn("value");
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(ds);
note = (DiscrepancyNoteBean) dndao.create(note);
// so that the below method works, need to set the entity above
logger.debug("trying to create mapping with " + note.getId() + " " + note.getEntityId() + " " + note.getColumn() + " " + note.getEntityType());
dndao.createMapping(note);
logger.debug("just created mapping");
return note;
}
use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class ResolveDiscrepancyServlet method processRequest.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
@Override
protected void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int noteId = fp.getInt(INPUT_NOTE_ID);
String module = (String) session.getAttribute("module");
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(sm.getDataSource());
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
dndao.setFetchMapping(true);
// check that the note exists
DiscrepancyNoteBean discrepancyNoteBean = (DiscrepancyNoteBean) dndao.findByPK(noteId);
if (!discrepancyNoteBean.isActive()) {
throw new InconsistentStateException(Page.MANAGE_STUDY_SERVLET, resexception.getString("you_are_trying_resolve_discrepancy_not_exist"));
}
// check that the note has not already been closed
ArrayList children = dndao.findAllByParent(discrepancyNoteBean);
discrepancyNoteBean.setChildren(children);
// This logic has been reverted, issue-7459
// if (parentNoteIsClosed(discrepancyNoteBean)) {
// throw new InconsistentStateException(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_SERVLET, respage
// .getString("the_discrepancy_choose_has_been_closed_resolved_create_new"));
// }
// all clear, send the user to the resolved screen
String entityType = discrepancyNoteBean.getEntityType().toLowerCase();
discrepancyNoteBean.setResStatus(ResolutionStatus.get(discrepancyNoteBean.getResolutionStatusId()));
discrepancyNoteBean.setDisType(DiscrepancyNoteType.get(discrepancyNoteBean.getDiscrepancyNoteTypeId()));
// View Study Events <<
if (currentRole.getRole().equals(Role.MONITOR) && !"itemdata".equalsIgnoreCase(entityType) && !"eventcrf".equalsIgnoreCase(entityType)) {
redirectMonitor(module, discrepancyNoteBean);
return;
}
// If Study is Frozen or Locked
if (currentStudy.getStatus().isFrozen() && !"itemdata".equalsIgnoreCase(entityType) && !"eventcrf".equalsIgnoreCase(entityType)) {
redirectMonitor(module, discrepancyNoteBean);
return;
}
boolean toView = false;
boolean isCompleted = false;
if ("itemdata".equalsIgnoreCase(entityType)) {
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
ItemDataBean idb = (ItemDataBean) iddao.findByPK(discrepancyNoteBean.getEntityId());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
EventCRFBean ecb = (EventCRFBean) ecdao.findByPK(idb.getEventCRFId());
StudySubjectBean studySubjectBean = (StudySubjectBean) studySubjectDAO.findByPK(ecb.getStudySubjectId());
discrepancyNoteBean.setSubjectId(studySubjectBean.getId());
discrepancyNoteBean.setItemId(idb.getItemId());
if (ecb.getStatus().equals(Status.UNAVAILABLE)) {
isCompleted = true;
}
// we want to go to view note page if the note is
toView = true;
// for item data
}
// logger.info("set up pop up url: " + createNoteURL);
// System.out.println("set up pop up url: " + createNoteURL);
boolean goNext = prepareRequestForResolution(request, sm.getDataSource(), currentStudy, discrepancyNoteBean, isCompleted);
Page p = getPageForForwarding(discrepancyNoteBean, isCompleted);
// logger.info("found page for forwarding: " + p.getFileName());
if (p == null) {
throw new InconsistentStateException(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_SERVLET, resexception.getString("the_discrepancy_note_triying_resolve_has_invalid_type"));
} else {
if (p.getFileName().contains("?")) {
if (!p.getFileName().contains("fromViewNotes=1")) {
p.setFileName(p.getFileName() + "&fromViewNotes=1");
}
} else {
p.setFileName(p.getFileName() + "?fromViewNotes=1");
}
String createNoteURL = CreateDiscrepancyNoteServlet.getAddChildURL(discrepancyNoteBean, ResolutionStatus.CLOSED, true);
setPopUpURL(createNoteURL);
}
if (!goNext) {
setPopUpURL("");
addPageMessage(respage.getString("you_may_not_perform_admin_edit_on_CRF_not_completed_by_user"));
p = Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_SERVLET;
}
forwardPage(p);
}
use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class DataEntryServlet method setTotals.
/**
* To set the totals of each resolution status on the DisplayItemBean for each item.
* @param dib
* @param notes
* @param ecbId TODO
*/
private DisplayItemBean setTotals(DisplayItemBean dib, int itemDataId, ArrayList<DiscrepancyNoteBean> notes, int ecbId) {
long t = System.currentTimeMillis();
logMe("Method::::::setTotals" + t);
int resolutionStatus;
int totNew = 0, totRes = 0, totClosed = 0, totUpdated = 0, totNA = 0;
boolean hasOtherThread = false;
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(getDataSource());
ArrayList<DiscrepancyNoteBean> existingNotes = dndao.findExistingNotesForToolTip(itemDataId);
dib.setDiscrepancyNotes(existingNotes);
for (DiscrepancyNoteBean obj : dib.getDiscrepancyNotes()) {
DiscrepancyNoteBean note = obj;
if (note.getParentDnId() == 0) {
resolutionStatus = note.getResolutionStatusId();
//using totNew to show the total parent threads
totNew++;
/* if(resolutionStatus==ResolutionStatus.UPDATED.getId())totUpdated++;
else if(resolutionStatus==ResolutionStatus.RESOLVED.getId())totRes++;//Resolution proposed count
else if(resolutionStatus==ResolutionStatus.CLOSED.getId())totClosed++;
else if(resolutionStatus==ResolutionStatus.NOT_APPLICABLE.getId())totNA++;*/
// not needed any more
}
}
ArrayList parentNotes = dndao.findExistingNotesForItemData(itemDataId);
//Adding this to show the value of only parent threads on discrepancy notes tool tip
for (Object obj : parentNotes) {
DiscrepancyNoteBean note = (DiscrepancyNoteBean) obj;
if (note.getParentDnId() == 0) {
if (hasOtherThread) {
totNew++;
}
hasOtherThread = true;
}
}
logMe("time taken thus far, before audit log check" + (System.currentTimeMillis() - t));
long t1 = System.currentTimeMillis();
AuditDAO adao = new AuditDAO(getDataSource());
ArrayList itemAuditEvents = adao.checkItemAuditEventsExist(dib.getItem().getId(), "item_data", ecbId);
if (itemAuditEvents.size() > 0) {
AuditBean itemFirstAudit = (AuditBean) itemAuditEvents.get(0);
String firstRFC = itemFirstAudit.getReasonForChange();
String oldValue = itemFirstAudit.getOldValue();
if (firstRFC != null && "initial value".equalsIgnoreCase(firstRFC) && (oldValue == null || oldValue.isEmpty())) {
dib.getData().setAuditLog(false);
} else {
dib.getData().setAuditLog(true);
}
}
logMe("time taken thus far, after audit log check" + (System.currentTimeMillis() - t));
logMe("Only for audit check::" + (System.currentTimeMillis() - t1));
//totNew is used for parent thread count
dib.setTotNew(totNew);
dib.setTotRes(totRes);
dib.setTotUpdated(totUpdated);
dib.setTotClosed(totClosed);
dib.setTotNA(totNA);
logMe("returning back..time taken" + (System.currentTimeMillis() - t));
return dib;
}
use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO 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;
}
use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class ImportSpringJob method createDiscrepancyNote.
public static DiscrepancyNoteBean createDiscrepancyNote(ItemBean itemBean, String message, EventCRFBean eventCrfBean, DisplayItemBean displayItemBean, Integer parentId, UserAccountBean uab, DataSource ds, StudyBean study) {
// DisplayItemBean displayItemBean) {
DiscrepancyNoteBean note = new DiscrepancyNoteBean();
StudySubjectDAO ssdao = new StudySubjectDAO(ds);
note.setDescription(message);
note.setDetailedNotes("Failed Validation Check");
note.setOwner(uab);
note.setCreatedDate(new Date());
note.setResolutionStatusId(ResolutionStatus.OPEN.getId());
note.setDiscrepancyNoteTypeId(DiscrepancyNoteType.FAILEDVAL.getId());
if (parentId != null) {
note.setParentDnId(parentId);
}
note.setField(itemBean.getName());
note.setStudyId(study.getId());
note.setEntityName(itemBean.getName());
note.setEntityType(DiscrepancyNoteBean.ITEM_DATA);
note.setEntityValue(displayItemBean.getData().getValue());
note.setEventName(eventCrfBean.getName());
note.setEventStart(eventCrfBean.getCreatedDate());
note.setCrfName(displayItemBean.getEventDefinitionCRF().getCrfName());
StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(eventCrfBean.getStudySubjectId());
note.setSubjectName(ss.getName());
note.setEntityId(displayItemBean.getData().getId());
note.setColumn("value");
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(ds);
note = (DiscrepancyNoteBean) dndao.create(note);
// so that the below method works, need to set the entity above
// System.out.println("trying to create mapping with " + note.getId() +
// " " + note.getEntityId() + " " + note.getColumn() + " " +
// note.getEntityType());
dndao.createMapping(note);
return note;
}
Aggregations