use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class UpdateEventDefinitionServlet method removeAllEventsItems.
public void removeAllEventsItems(EventDefinitionCRFBean edc, StudyEventDefinitionBean sed) {
StudyEventDAO seDao = new StudyEventDAO(sm.getDataSource());
EventCRFDAO ecrfDao = new EventCRFDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
// Getting Study Events
ArrayList seList = seDao.findAllByStudyEventDefinitionAndCrfOids(sed.getOid(), edc.getCrf().getOid());
for (int j = 0; j < seList.size(); j++) {
StudyEventBean seBean = (StudyEventBean) seList.get(j);
// Getting Event CRFs
ArrayList ecrfList = ecrfDao.findAllByStudyEventAndCrfOrCrfVersionOid(seBean, edc.getCrf().getOid());
for (int k = 0; k < ecrfList.size(); k++) {
EventCRFBean ecrfBean = (EventCRFBean) ecrfList.get(k);
ecrfBean.setOldStatus(ecrfBean.getStatus());
ecrfBean.setStatus(Status.AUTO_DELETED);
ecrfBean.setUpdater(ub);
ecrfBean.setUpdatedDate(new Date());
ecrfDao.update(ecrfBean);
// Getting Item Data
ArrayList itemData = iddao.findAllByEventCRFId(ecrfBean.getId());
// remove all the item data
for (int a = 0; a < itemData.size(); a++) {
ItemDataBean item = (ItemDataBean) itemData.get(a);
if (!item.getStatus().equals(Status.DELETED)) {
item.setOldStatus(item.getStatus());
item.setStatus(Status.AUTO_DELETED);
item.setUpdater(ub);
item.setUpdatedDate(new Date());
iddao.update(item);
DiscrepancyNoteDAO dnDao = new DiscrepancyNoteDAO(sm.getDataSource());
List dnNotesOfRemovedItem = dnDao.findExistingNotesForItemData(item.getId());
if (!dnNotesOfRemovedItem.isEmpty()) {
DiscrepancyNoteBean itemParentNote = null;
for (Object obj : dnNotesOfRemovedItem) {
if (((DiscrepancyNoteBean) obj).getParentDnId() == 0) {
itemParentNote = (DiscrepancyNoteBean) obj;
}
}
DiscrepancyNoteBean dnb = new DiscrepancyNoteBean();
if (itemParentNote != null) {
dnb.setParentDnId(itemParentNote.getId());
dnb.setDiscrepancyNoteTypeId(itemParentNote.getDiscrepancyNoteTypeId());
}
dnb.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
dnb.setStudyId(currentStudy.getId());
dnb.setAssignedUserId(ub.getId());
dnb.setOwner(ub);
dnb.setEntityType(DiscrepancyNoteBean.ITEM_DATA);
dnb.setEntityId(item.getId());
dnb.setColumn("value");
dnb.setCreatedDate(new Date());
dnb.setDescription("The item has been removed, this Discrepancy Note has been Closed.");
dnDao.create(dnb);
dnDao.createMapping(dnb);
itemParentNote.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
dnDao.update(itemParentNote);
}
}
}
}
}
}
use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class SignStudySubjectServlet method signSubjectEvents.
public static boolean signSubjectEvents(StudySubjectBean studySub, DataSource ds, UserAccountBean ub) {
boolean updated = true;
// StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(ds);
StudyEventDAO sedao = new StudyEventDAO(ds);
EventCRFDAO ecdao = new EventCRFDAO(ds);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(ds);
// StudySubjectDAO ssdao = new StudySubjectDAO(ds);
DiscrepancyNoteDAO discDao = new DiscrepancyNoteDAO(ds);
ArrayList studyEvents = sedao.findAllByStudySubject(studySub);
for (int l = 0; l < studyEvents.size(); l++) {
try {
StudyEventBean studyEvent = (StudyEventBean) studyEvents.get(l);
studyEvent.setUpdater(ub);
studyEvent.setUpdatedDate(new Date());
studyEvent.setSubjectEventStatus(SubjectEventStatus.SIGNED);
sedao.update(studyEvent);
} catch (Exception ex) {
updated = false;
}
}
return updated;
}
use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class TableOfContentsServlet method processRequest.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
@Override
protected void processRequest() throws Exception {
FormDiscrepancyNotes discNotes;
if (action.equals(ACTION_START_INITIAL_DATA_ENTRY)) {
ecb = createEventCRF();
} else {
validateEventCRFAndAction();
}
updatePresetValues(ecb);
Boolean b = (Boolean) request.getAttribute(DataEntryServlet.INPUT_IGNORE_PARAMETERS);
if (fp.isSubmitted() && b == null) {
discNotes = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
if (discNotes == null) {
discNotes = new FormDiscrepancyNotes();
session.setAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME, discNotes);
}
DiscrepancyValidator v = new DiscrepancyValidator(request, discNotes);
v.addValidation(INPUT_INTERVIEWER, Validator.NO_BLANKS);
v.addValidation(INPUT_INTERVIEW_DATE, Validator.IS_A_DATE);
v.alwaysExecuteLastValidation(INPUT_INTERVIEW_DATE);
errors = v.validate();
if (errors.isEmpty()) {
ecb.setInterviewerName(fp.getString(INPUT_INTERVIEWER));
ecb.setDateInterviewed(fp.getDate(INPUT_INTERVIEW_DATE));
if (ecdao == null) {
ecdao = new EventCRFDAO(sm.getDataSource());
}
ecb = (EventCRFBean) ecdao.update(ecb);
// save discrepancy notes into DB
FormDiscrepancyNotes fdn = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
AddNewSubjectServlet.saveFieldNotes(INPUT_INTERVIEWER, fdn, dndao, ecb.getId(), "EventCRF", currentStudy);
AddNewSubjectServlet.saveFieldNotes(INPUT_INTERVIEW_DATE, fdn, dndao, ecb.getId(), "EventCRF", currentStudy);
if (ecdao.isQuerySuccessful()) {
updatePresetValues(ecb);
if (!fp.getBoolean("editInterview", true)) {
// editing completed
addPageMessage(respage.getString("interviewer_name_date_updated"));
}
} else {
addPageMessage(respage.getString("database_error_interviewer_name_date_not_updated"));
}
} else {
String[] textFields = { INPUT_INTERVIEWER, INPUT_INTERVIEW_DATE };
fp.setCurrentStringValuesAsPreset(textFields);
setInputMessages(errors);
setPresetValues(fp.getPresetValues());
}
} else {
discNotes = new FormDiscrepancyNotes();
session.setAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME, discNotes);
}
DisplayTableOfContentsBean displayBean = getDisplayBean(ecb, sm.getDataSource(), currentStudy);
// this is for generating side info panel
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
StudySubjectBean ssb = (StudySubjectBean) ssdao.findByPK(ecb.getStudySubjectId());
ArrayList beans = ViewStudySubjectServlet.getDisplayStudyEventsForStudySubject(ssb, sm.getDataSource(), ub, currentRole);
request.setAttribute("studySubject", ssb);
request.setAttribute("beans", beans);
request.setAttribute("eventCRF", ecb);
request.setAttribute(BEAN_DISPLAY, displayBean);
boolean allowEnterData = true;
if (StringUtil.isBlank(ecb.getInterviewerName())) {
if (discNotes == null || discNotes.getNotes(TableOfContentsServlet.INPUT_INTERVIEWER).isEmpty()) {
allowEnterData = false;
}
}
if (ecb.getDateInterviewed() == null) {
if (discNotes == null || discNotes.getNotes(TableOfContentsServlet.INPUT_INTERVIEW_DATE).isEmpty()) {
allowEnterData = false;
}
}
if (!allowEnterData) {
request.setAttribute("allowEnterData", "no");
// forwardPage(Page.INTERVIEWER);
/*
* BWP 2966 >> the original Page.INTERVIEWER jsp is not a complete
* web page and did not provide a body tag for producing a popup
* window for discrepancy notes. So I changed it to create a
* complete web page.
*/
forwardPage(Page.INTERVIEWER_ENTIRE_PAGE);
} else {
if (fp.getBoolean("editInterview", true)) {
// user wants to edit interview info
request.setAttribute("allowEnterData", "yes");
forwardPage(Page.INTERVIEWER);
} else {
if (fp.isSubmitted() && !errors.isEmpty()) {
// interview form submitted, but has blank field or
// validation error
request.setAttribute("allowEnterData", "no");
forwardPage(Page.INTERVIEWER);
} else {
request.setAttribute("allowEnterData", "yes");
forwardPage(Page.TABLE_OF_CONTENTS);
}
}
}
}
use of org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO in project OpenClinica by OpenClinica.
the class VerifyImportedCRFDataServlet 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);
// System.out.println("just created mapping");
return note;
}
Aggregations