use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class ViewEventCRFServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int eventCRFId = fp.getInt("id", true);
int studySubId = fp.getInt("studySubId", true);
StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
ItemDAO idao = new ItemDAO(sm.getDataSource());
ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
SectionDAO secdao = new SectionDAO(sm.getDataSource());
if (eventCRFId == 0) {
addPageMessage(respage.getString("please_choose_an_event_CRF_to_view"));
forwardPage(Page.LIST_STUDY_SUBJECTS);
} else {
StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
request.setAttribute("studySub", studySub);
EventCRFBean eventCRF = (EventCRFBean) ecdao.findByPK(eventCRFId);
CRFBean crf = cdao.findByVersionId(eventCRF.getCRFVersionId());
request.setAttribute("crf", crf);
ArrayList sections = secdao.findAllByCRFVersionId(eventCRF.getCRFVersionId());
for (int j = 0; j < sections.size(); j++) {
SectionBean section = (SectionBean) sections.get(j);
ArrayList itemData = iddao.findAllByEventCRFId(eventCRFId);
ArrayList displayItemData = new ArrayList();
for (int i = 0; i < itemData.size(); i++) {
ItemDataBean id = (ItemDataBean) itemData.get(i);
DisplayItemBean dib = new DisplayItemBean();
ItemBean item = (ItemBean) idao.findByPK(id.getItemId());
ItemFormMetadataBean ifm = ifmdao.findByItemIdAndCRFVersionId(item.getId(), eventCRF.getCRFVersionId());
item.setItemMeta(ifm);
dib.setItem(item);
dib.setData(id);
dib.setMetadata(ifm);
displayItemData.add(dib);
}
section.setItems(displayItemData);
}
request.setAttribute("sections", sections);
request.setAttribute("studySubId", new Integer(studySubId).toString());
forwardPage(Page.VIEW_EVENT_CRF);
}
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class CreateDiscrepancyNoteServlet method updateStudySubjectStatus.
/**
* Pulls the note related information from database according to note type
*
* @param note
*/
private void updateStudySubjectStatus(String entityType, int entityId) {
if ("itemData".equalsIgnoreCase(entityType)) {
int itemDataId = entityId;
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
ItemDataBean itemData = (ItemDataBean) iddao.findByPK(itemDataId);
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(sm.getDataSource());
EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
StudySubjectBean studySubject = (StudySubjectBean) studySubjectDAO.findByPK(event.getStudySubjectId());
if (studySubject.getStatus() != null && studySubject.getStatus().equals(Status.SIGNED)) {
studySubject.setStatus(Status.AVAILABLE);
studySubject.setUpdater(ub);
studySubject.setUpdatedDate(new Date());
studySubjectDAO.update(studySubject);
}
if (ec.isSdvStatus()) {
studySubject.setStatus(Status.AVAILABLE);
studySubject.setUpdater(ub);
studySubject.setUpdatedDate(new Date());
studySubjectDAO.update(studySubject);
ec.setSdvStatus(false);
ec.setSdvUpdateId(ub.getId());
ecdao.update(ec);
}
}
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class CreateOneDiscrepancyNoteServlet method updateStudyEvent.
private void updateStudyEvent(String entityType, int entityId) {
if ("itemData".equalsIgnoreCase(entityType)) {
int itemDataId = entityId;
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
ItemDataBean itemData = (ItemDataBean) iddao.findByPK(itemDataId);
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
if (event.getSubjectEventStatus().equals(SubjectEventStatus.SIGNED)) {
event.setSubjectEventStatus(SubjectEventStatus.COMPLETED);
event.setUpdater(ub);
event.setUpdatedDate(new Date());
svdao.update(event);
}
} else if ("eventCrf".equalsIgnoreCase(entityType)) {
int eventCRFId = entityId;
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
EventCRFBean ec = (EventCRFBean) ecdao.findByPK(eventCRFId);
StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
if (event.getSubjectEventStatus().equals(SubjectEventStatus.SIGNED)) {
event.setSubjectEventStatus(SubjectEventStatus.COMPLETED);
event.setUpdater(ub);
event.setUpdatedDate(new Date());
svdao.update(event);
}
}
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO in project OpenClinica by OpenClinica.
the class DoubleDataEntryServlet method validateCalcTypeDisplayItemBean.
@Override
protected DisplayItemBean validateCalcTypeDisplayItemBean(ScoreItemValidator sv, DisplayItemBean dib, String inputName, HttpServletRequest request) {
org.akaza.openclinica.bean.core.ResponseType rt = dib.getMetadata().getResponseSet().getResponseType();
ItemDataDAO iddao = new ItemDataDAO(getDataSource());
boolean isSingleItem = false;
HttpSession session = request.getSession();
if (StringUtil.isBlank(inputName)) {
// for single items
inputName = getInputName(dib);
isSingleItem = true;
}
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
// 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) session.getAttribute(COUNT_VALIDATE + keyId);
ItemDataBean valueToCompare = new ItemDataBean();
if (isSingleItem) {
int idId = dib.getData().getId();
if (idId > 0) {
valueToCompare = (ItemDataBean) iddao.findByPK(idId);
}
} else {
valueToCompare = dib.getDbData();
}
if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.CALCULATION) || rt.equals(org.akaza.openclinica.bean.core.ResponseType.GROUP_CALCULATION)) {
boolean showOriginalItem = getItemMetadataService().isShown(dib.getItem().getId(), ecb, valueToCompare);
boolean showItem = dib.getMetadata().isShowItem();
// .isShown(dib.getItem().getId(), ecb, dib.getDbData());
boolean showDuplicateItem = getItemMetadataService().hasPassedDDE(dib.getMetadata(), ecb, valueToCompare);
if (showOriginalItem && showDuplicateItem || showItem) {
dib = validateDisplayItemBeanText(sv, dib, inputName, request);
}
if (showOriginalItem && showDuplicateItem || showItem) {
sv.addValidation(inputName, Validator.MATCHES_INITIAL_DATA_ENTRY_VALUE, valueToCompare, false);
sv.setErrorMessage(respage.getString("value_you_specified") + " " + valueToCompare.getValue() + " " + respage.getString("from_initial_data_entry"));
}
}
return dib;
}
use of org.akaza.openclinica.dao.submit.ItemDataDAO 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());
}
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;
}
Aggregations