use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.
the class MarkEventCRFCompleteServlet method processRequest.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
@Override
protected void processRequest() throws Exception {
// FormDiscrepancyNotes discNotes =
// (FormDiscrepancyNotes)session.getAttribute(AddNewSubjectServlet.
// FORM_DISCREPANCY_NOTES_NAME);
getEventCRFBean();
getEventDefinitionCRFBean();
DataEntryStage stage = ecb.getStage();
request.setAttribute(TableOfContentsServlet.INPUT_EVENT_CRF_BEAN, ecb);
// Page errorPage = Page.TABLE_OF_CONTENTS_SERVLET;
Page errorPage = Page.LIST_STUDY_SUBJECTS_SERVLET;
if (stage.equals(DataEntryStage.UNCOMPLETED) || stage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) || stage.equals(DataEntryStage.LOCKED)) {
throw new InconsistentStateException(errorPage, respage.getString("not_mark_CRF_complete1"));
}
if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) || stage.equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
if (!edcb.isDoubleEntry()) {
throw new InconsistentStateException(errorPage, respage.getString("not_mark_CRF_complete2"));
}
}
if (!isEachRequiredFieldFillout()) {
throw new InconsistentStateException(errorPage, respage.getString("not_mark_CRF_complete4"));
}
if (ecb.getInterviewerName().trim().equals("")) {
throw new InconsistentStateException(errorPage, respage.getString("not_mark_CRF_complete5"));
}
if (!fp.isSubmitted()) {
DisplayTableOfContentsBean toc = TableOfContentsServlet.getDisplayBean(ecb, sm.getDataSource(), currentStudy);
toc = TableOfContentsServlet.getDisplayBeanWithShownSections(sm.getDataSource(), toc, (DynamicsMetadataService) SpringServletAccess.getApplicationContext(getServletContext()).getBean("dynamicsMetadataService"));
request.setAttribute(BEAN_DISPLAY, toc);
resetPanel();
panel.setStudyInfoShown(false);
panel.setOrderedData(true);
setToPanel(resword.getString("subject"), toc.getStudySubject().getLabel());
setToPanel(resword.getString("study_event_definition"), toc.getStudyEventDefinition().getName());
StudyEventBean seb = toc.getStudyEvent();
setToPanel(resword.getString("location"), seb.getLocation());
setToPanel(resword.getString("start_date"), seb.getDateStarted().toString());
setToPanel(resword.getString("end_date"), seb.getDateEnded().toString());
setToPanel(resword.getString("CRF"), toc.getCrf().getName());
setToPanel(resword.getString("CRF_version"), toc.getCrfVersion().getName());
forwardPage(Page.MARK_EVENT_CRF_COMPLETE);
} else {
boolean markComplete = fp.getString(INPUT_MARK_COMPLETE).equals(VALUE_YES);
if (markComplete) {
Status newStatus = ecb.getStatus();
boolean ide = true;
if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY) && edcb.isDoubleEntry()) {
newStatus = Status.PENDING;
ecb.setUpdaterId(ub.getId());
ecb.setUpdatedDate(new Date());
ecb.setDateCompleted(new Date());
} else if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY) && !edcb.isDoubleEntry()) {
newStatus = Status.UNAVAILABLE;
ecb.setUpdaterId(ub.getId());
ecb.setUpdatedDate(new Date());
ecb.setDateCompleted(new Date());
ecb.setDateValidateCompleted(new Date());
} else if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) || stage.equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
newStatus = Status.UNAVAILABLE;
ecb.setDateValidateCompleted(new Date());
ide = false;
}
ecb.setStatus(newStatus);
ecb = (EventCRFBean) ecdao.update(ecb);
ecdao.markComplete(ecb, ide);
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
iddao.updateStatusByEventCRF(ecb, newStatus);
// change status for event
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
StudyEventBean seb = (StudyEventBean) sedao.findByPK(ecb.getStudyEventId());
seb.setUpdatedDate(new Date());
seb.setUpdater(ub);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList allCRFs = ecdao.findAllByStudyEvent(seb);
ArrayList allEDCs = edcdao.findAllActiveByEventDefinitionId(seb.getStudyEventDefinitionId());
boolean eventCompleted = true;
for (int i = 0; i < allCRFs.size(); i++) {
EventCRFBean ec = (EventCRFBean) allCRFs.get(i);
if (!ec.getStatus().equals(Status.UNAVAILABLE)) {
eventCompleted = false;
break;
}
}
if (eventCompleted && allCRFs.size() >= allEDCs.size()) {
seb.setSubjectEventStatus(SubjectEventStatus.COMPLETED);
}
seb = (StudyEventBean) sedao.update(seb);
addPageMessage(respage.getString("event_CRF_marked_complete"));
request.setAttribute(EnterDataForStudyEventServlet.INPUT_EVENT_ID, String.valueOf(ecb.getStudyEventId()));
forwardPage(Page.ENTER_DATA_FOR_STUDY_EVENT_SERVLET);
} else {
request.setAttribute(DataEntryServlet.INPUT_IGNORE_PARAMETERS, Boolean.TRUE);
addPageMessage(respage.getString("event_CRF_not_marked_complete"));
forwardPage(errorPage);
}
}
}
use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.
the class AnonymousFormControllerV2 method getEnketoForm.
/**
* @api {post} /pages/api/v2/anonymousform/form Retrieve anonymous form URL
* @apiName getEnketoForm
* @apiPermission Module participate - enabled
* @apiVersion 3.8.0
* @apiParam {String} studyOid Study Oid
* @apiParam {String} submissionUri Submission Url
* @apiGroup Form
* @apiDescription Retrieve anonymous form url.
* @apiParamExample {json} Request-Example:
* {
* "studyOid": "S_BL101",
* "submissionUri": "abcde"
* }
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* "url":
* "http://localhost:8006/::YYYi?iframe=true&ecid=abb764d026830e98b895ece6d9dcaf3c5e817983cc00a4ebfaabcb6c3700b4d5",
* "offline": "false"
* }
*/
@RequestMapping(value = "/form", method = RequestMethod.POST)
public ResponseEntity<AnonymousUrlResponse> getEnketoForm(@RequestBody HashMap<String, String> map) throws Exception {
ResourceBundleProvider.updateLocale(new Locale("en_US"));
EventDefinitionCrfTagService tagService = (EventDefinitionCrfTagService) SpringServletAccess.getApplicationContext(context).getBean("eventDefinitionCrfTagService");
String formUrl = null;
String studyOid = map.get("studyOid");
if (!mayProceed(studyOid))
return new ResponseEntity<AnonymousUrlResponse>(org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
String submissionUri = map.get("submissionUri");
if (submissionUri != "" && submissionUri != null) {
StudyBean study = getStudy(studyOid);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(dataSource);
ArrayList<EventDefinitionCRFBean> edcBeans = edcdao.findAllSubmissionUriAndStudyId(submissionUri, study.getId());
if (edcBeans.size() != 0) {
EventDefinitionCRFBean edcBean = edcBeans.get(0);
CRFDAO crfdao = new CRFDAO(dataSource);
FormLayoutDAO fldao = new FormLayoutDAO(dataSource);
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(dataSource);
FormLayoutBean formLayout = (FormLayoutBean) fldao.findByPK(edcBean.getDefaultVersionId());
CRFBean crf = (CRFBean) crfdao.findByPK(formLayout.getCrfId());
StudyBean sBean = (StudyBean) sdao.findByPK(edcBean.getStudyId());
StudyEventDefinitionBean sedBean = (StudyEventDefinitionBean) seddao.findByPK(edcBean.getStudyEventDefinitionId());
String tagPath = sedBean.getOid() + "." + crf.getOid();
boolean isOffline = tagService.getEventDefnCrfOfflineStatus(2, tagPath, true);
String offline = null;
if (isOffline)
offline = "true";
else
offline = "false";
formUrl = createAnonymousEnketoUrl(sBean.getOid(), formLayout, edcBean, isOffline);
AnonymousUrlResponse anonResponse = new AnonymousUrlResponse(formUrl, offline, crf.getName(), formLayout.getDescription());
return new ResponseEntity<AnonymousUrlResponse>(anonResponse, org.springframework.http.HttpStatus.OK);
} else {
return new ResponseEntity<AnonymousUrlResponse>(org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
}
} else {
return new ResponseEntity<AnonymousUrlResponse>(org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
}
}
use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.
the class FormBeanUtil method getNullValuesByEventCRFDefId.
public List<String> getNullValuesByEventCRFDefId(int eventDefinitionCRFId, DataSource dataSource) {
if (eventDefinitionCRFId < 1 || dataSource == null) {
return new ArrayList<String>();
}
List<String> nullValuesList = new ArrayList<String>();
// hold the bean's return value
List<NullValue> nullObjectList = new ArrayList<NullValue>();
EventDefinitionCRFBean eventCRFDefBean;
EventDefinitionCRFDAO eventDefinitionCRFDAO = new EventDefinitionCRFDAO(dataSource);
eventCRFDefBean = (EventDefinitionCRFBean) eventDefinitionCRFDAO.findByPK(eventDefinitionCRFId);
nullObjectList = eventCRFDefBean.getNullValuesList();
if (nullObjectList == null) {
return new ArrayList<String>();
}
for (NullValue nullVal : nullObjectList) {
nullValuesList.add(nullVal.getName());
}
return nullValuesList;
}
use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.
the class FormBeanUtil method createDisplaySectionWithItemGroups.
/**
* Create a DisplaySectionBean with a list of ItemGroupBeans. NOTE:
* unGrouped Items are not included
*
* @param study
* The StudyBean
* @param sectionId
* The Section ID associated with the Items, which end up
* providing the content of the tables.
* @param crfVersionId
* The CRF version ID associated with the Items.
* @param studyEventId
* The Study Event ID associated with the CRF Version ID.
* @param sm
* A SessionManager, from which DataSources are acquired for the
* DAO objects.
* @return A DisplaySectionBean.
*/
public DisplaySectionBean createDisplaySectionWithItemGroups(StudyBean study, int sectionId, EventCRFBean eventCrfBean, int studyEventId, SessionManager sm, int eventDefinitionCRFId, ServletContext context) {
DisplaySectionBean dBean = new DisplaySectionBean();
ItemGroupDAO formGroupDAO = new ItemGroupDAO(sm.getDataSource());
ItemGroupMetadataDAO igMetaDAO = new ItemGroupMetadataDAO(sm.getDataSource());
ItemDAO itemDao = new ItemDAO(sm.getDataSource());
ItemFormMetadataDAO metaDao = new ItemFormMetadataDAO(sm.getDataSource());
List<ItemGroupBean> arrList = formGroupDAO.findLegitGroupBySectionId(sectionId);
// all items associated with the section, including those not in a group
List<ItemFormMetadataBean> allMetas = new ArrayList<ItemFormMetadataBean>();
try {
allMetas = metaDao.findAllBySectionId(sectionId);
} catch (OpenClinicaException oce) {
logger.info("oce.getOpenClinicaMessage() = " + oce.getOpenClinicaMessage());
}
// Collections.sort(allMetas);
if (arrList.isEmpty())
return dBean;
// Find out whether there are any checkboxes/radios/select elements
// and if so, get any null values
// associated with them
List<String> nullValuesList = new ArrayList<String>();
boolean itemsHaveChecksRadios = itemsIncludeChecksRadiosSelects(allMetas);
// "+eventDefinitionCRFId);
if (eventDefinitionCRFId <= 0) {
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
EventDefinitionCRFBean edcBean = edcdao.findByStudyEventIdAndCRFVersionId(study, studyEventId, eventCrfBean.getCRFVersionId());
eventDefinitionCRFId = edcBean.getId();
}
// "+eventDefinitionCRFId);
if (itemsHaveChecksRadios && eventDefinitionCRFId > 0) {
// method returns null values as a List<String>
nullValuesList = this.getNullValuesByEventCRFDefId(eventDefinitionCRFId, sm.getDataSource());
}
// Get the items associated with each group
List<ItemBean> itBeans;
List<DisplayItemBean> displayItems;
List<DisplayItemGroupBean> displayFormBeans = new ArrayList<DisplayItemGroupBean>();
DisplayItemGroupBean displayItemGBean;
for (ItemGroupBean itemGroup : arrList) {
itBeans = itemDao.findAllItemsByGroupId(itemGroup.getId(), eventCrfBean.getCRFVersionId());
List<ItemGroupMetadataBean> metadata = igMetaDAO.findMetaByGroupAndSection(itemGroup.getId(), eventCrfBean.getCRFVersionId(), sectionId);
if (!metadata.isEmpty()) {
// for a given crf version, all the items in the same group
// have the same group metadata
// so we can get one of them and set metadata for the group
ItemGroupMetadataBean meta = metadata.get(0);
itemGroup.setMeta(meta);
}
// include arrayList parameter until I determine difference in
// classes
displayItems = getDisplayBeansFromItems(itBeans, sm.getDataSource(), eventCrfBean, sectionId, nullValuesList, context);
displayItemGBean = this.createDisplayFormGroup(displayItems, itemGroup);
displayFormBeans.add(displayItemGBean);
}
// We still have to sort these display item group beans on their
// ItemGroupMetadataBean?
// then number their ordinals accordingly
Collections.sort(displayFormBeans, new Comparator<DisplayItemGroupBean>() {
public int compare(DisplayItemGroupBean displayItemGroupBean, DisplayItemGroupBean displayItemGroupBean1) {
return displayItemGroupBean.getGroupMetaBean().compareTo(displayItemGroupBean1.getGroupMetaBean());
}
});
// Now provide the display item group beans with an ordinal
int digOrdinal = 0;
for (DisplayItemGroupBean digBean : displayFormBeans) {
digBean.setOrdinal(++digOrdinal);
}
dBean.setDisplayFormGroups(displayFormBeans);
return dBean;
}
use of org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO in project OpenClinica by OpenClinica.
the class CrfBusinessLogicHelper method areAllRequired.
protected boolean areAllRequired(StudyEventBean seBean, StudyBean study) {
EventDefinitionCRFDAO edcDao = new EventDefinitionCRFDAO(ds);
// EventCRFDAO eventCrfDao = new EventCRFDAO(ds);
// ArrayList allCRFs = eventCrfDao.findAllByStudyEvent(seBean);
ArrayList allEDCs = (ArrayList) edcDao.findAllActiveByEventDefinitionId(study, seBean.getStudyEventDefinitionId());
boolean areAllRequired = true;
for (int i = 0; i < allEDCs.size(); i++) {
EventDefinitionCRFBean ec = (EventDefinitionCRFBean) allEDCs.get(i);
if (!ec.isRequiredCRF()) {
areAllRequired = false;
break;
}
}
logger.info("returning for are all required: " + areAllRequired);
return areAllRequired;
}
Aggregations