use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class InitUpdateSubStudyServlet method createEventDefinitions.
private void createEventDefinitions(StudyBean parentStudy) throws MalformedURLException {
FormProcessor fp = new FormProcessor(request);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
int siteId = Integer.valueOf(request.getParameter("id").trim());
ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
seds = sedDao.findAllByStudy(parentStudy);
int start = 0;
for (StudyEventDefinitionBean sed : seds) {
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
int defId = sed.getId();
ArrayList<EventDefinitionCRFBean> edcs = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllByDefinitionAndSiteIdAndParentStudyId(defId, siteId, parentStudy.getId());
ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>();
// sed.setCrfNum(edcs.size());
for (EventDefinitionCRFBean edcBean : edcs) {
CRFBean cBean = (CRFBean) cdao.findByPK(edcBean.getCrfId());
String crfPath = sed.getOid() + "." + cBean.getOid();
edcBean.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
int edcStatusId = edcBean.getStatus().getId();
CRFBean crf = (CRFBean) cdao.findByPK(edcBean.getCrfId());
int crfStatusId = crf.getStatusId();
if (edcStatusId == 5 || edcStatusId == 7 || crfStatusId == 5 || crfStatusId == 7) {
} else {
ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) cvdao.findAllActiveByCRF(edcBean.getCrfId());
edcBean.setVersions(versions);
edcBean.setCrfName(crf.getName());
if (edcBean.getParentId() == 0)
edcBean.setSubmissionUrl("");
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edcBean.getDefaultVersionId());
edcBean.setDefaultVersionName(defaultVersion.getName());
String sversionIds = edcBean.getSelectedVersionIds();
ArrayList<Integer> idList = new ArrayList<Integer>();
if (sversionIds.length() > 0) {
String[] ids = sversionIds.split("\\,");
for (String id : ids) {
idList.add(Integer.valueOf(id));
}
}
edcBean.setSelectedVersionIdList(idList);
defCrfs.add(edcBean);
++start;
}
}
logger.debug("definitionCrfs size=" + defCrfs.size() + " total size=" + edcs.size());
sed.setCrfs(defCrfs);
sed.setCrfNum(defCrfs.size());
}
// not sure if request is better, since not sure if there is another
// process using this.
session.setAttribute("definitions", seds);
session.setAttribute("sdvOptions", this.setSDVOptions());
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class CreateSubStudyServlet method initDefinitions.
private ArrayList<StudyEventDefinitionBean> initDefinitions(StudyBean site) throws MalformedURLException {
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
StudyBean parentStudy = (StudyBean) new StudyDAO(sm.getDataSource()).findByPK(site.getParentStudyId());
seds = sedDao.findAllByStudy(parentStudy);
int start = 0;
for (StudyEventDefinitionBean sed : seds) {
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
int defId = sed.getId();
ArrayList<EventDefinitionCRFBean> edcs = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllByDefinitionAndSiteIdAndParentStudyId(defId, site.getId(), parentStudy.getId());
ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>();
// sed.setCrfNum(edcs.size());
for (EventDefinitionCRFBean edcBean : edcs) {
CRFBean cBean = (CRFBean) cdao.findByPK(edcBean.getCrfId());
String crfPath = sed.getOid() + "." + cBean.getOid();
edcBean.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
int edcStatusId = edcBean.getStatus().getId();
CRFBean crf = (CRFBean) cdao.findByPK(edcBean.getCrfId());
int crfStatusId = crf.getStatusId();
if (edcStatusId == 5 || edcStatusId == 7 || crfStatusId == 5 || crfStatusId == 7) {
} else {
ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) cvdao.findAllActiveByCRF(edcBean.getCrfId());
edcBean.setVersions(versions);
edcBean.setCrfName(crf.getName());
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edcBean.getDefaultVersionId());
edcBean.setDefaultVersionName(defaultVersion.getName());
edcBean.setSubmissionUrl("");
/* EventDefinitionCRFBean eBean = (EventDefinitionCRFBean) edcdao.findByPK(edcBean.getId());
if (eBean.isActive()){
edcBean.setSubmissionUrl(eBean.getSubmissionUrl());
}else{
edcBean.setSubmissionUrl("");
}
*/
String sversionIds = edcBean.getSelectedVersionIds();
ArrayList<Integer> idList = new ArrayList<Integer>();
if (sversionIds.length() > 0) {
String[] ids = sversionIds.split("\\,");
for (String id : ids) {
idList.add(Integer.valueOf(id));
}
}
edcBean.setSelectedVersionIdList(idList);
defCrfs.add(edcBean);
++start;
}
}
logger.debug("definitionCrfs size=" + defCrfs.size() + " total size=" + edcs.size());
sed.setCrfs(defCrfs);
sed.setCrfNum(defCrfs.size());
}
return seds;
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method getDisplayBean.
/**
* Retrieve the DisplaySectionBean which will be used to display the Event CRF Section on the JSP, and also is used to controll processRequest.
* @param request TODO
* @param isSubmitted TODO
*/
protected DisplaySectionBean getDisplayBean(boolean hasGroup, boolean includeUngroupedItems, HttpServletRequest request, boolean isSubmitted) throws Exception {
DisplaySectionBean section = new DisplaySectionBean();
FormProcessor fp = new FormProcessor(request);
HttpSession session = request.getSession();
Locale loc = this.locale == null ? LocaleResolver.getLocale(request) : this.locale;
StudyBean study = (StudyBean) session.getAttribute("study");
SessionManager sm = (SessionManager) request.getSession().getAttribute("sm");
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
SectionDAO sdao;
// Find out whether there are ungrouped items in this section
boolean hasUngroupedItems = false;
int eventDefinitionCRFId = fp.getInt("eventDefinitionCRFId");
if (eventDefinitionCRFId <= 0) {
// TODO: this block of code repeats
// many times, need to clean up
// synchronized(this)
{
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(getDataSource());
EventDefinitionCRFBean edcBean = edcdao.findByStudyEventIdAndCRFVersionId(study, ecb.getStudyEventId(), ecb.getCRFVersionId());
eventDefinitionCRFId = edcBean.getId();
}
}
LOGGER.trace("eventDefinitionCRFId " + eventDefinitionCRFId);
// Use this class to find out whether there are ungrouped items in this
// section
FormBeanUtil formBeanUtil = new FormBeanUtil();
List<DisplayItemGroupBean> itemGroups = new ArrayList<DisplayItemGroupBean>();
if (hasGroup) {
DisplaySectionBean newDisplayBean = new DisplaySectionBean();
if (includeUngroupedItems) {
// Null values: this method adds null values to the
// displayitembeans
newDisplayBean = formBeanUtil.createDisplaySectionBWithFormGroups(sb.getId(), ecb.getCRFVersionId(), getDataSource(), eventDefinitionCRFId, ecb, getServletContext());
} else {
newDisplayBean = formBeanUtil.createDisplaySectionWithItemGroups(study, sb.getId(), ecb, ecb.getStudyEventId(), sm, eventDefinitionCRFId, getServletContext());
}
itemGroups = newDisplayBean.getDisplayFormGroups();
// setDataForDisplayItemGroups(itemGroups, sb,ecb,sm);
LOGGER.trace("found item group size: " + itemGroups.size() + " and to string: " + itemGroups.toString());
section.setDisplayFormGroups(itemGroups);
}
// Find out whether any display items are *not* grouped; see issue 1689
hasUngroupedItems = formBeanUtil.sectionHasUngroupedItems(getDataSource(), sb.getId(), itemGroups);
sdao = new SectionDAO(getDataSource());
//
sb.setHasSCDItem(hasUngroupedItems ? sdao.hasSCDItem(sb.getId()) : false);
section.setEventCRF(ecb);
if (sb.getParentId() > 0) {
SectionBean parent = (SectionBean) sdao.findByPK(sb.getParentId());
sb.setParent(parent);
}
section.setSection(sb);
CRFVersionDAO cvdao = new CRFVersionDAO(getDataSource());
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(ecb.getCRFVersionId());
section.setCrfVersion(cvb);
CRFDAO cdao = new CRFDAO(getDataSource());
CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
section.setCrf(cb);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(getDataSource());
// EventDefinitionCRFBean edcb =
// edcdao.findByStudyEventIdAndCRFVersionId(study,
// ecb.getStudyEventId(), cvb.getId());
section.setEventDefinitionCRF(edcb);
// setup DAO's here to avoid creating too many objects
ItemDAO idao = new ItemDAO(getDataSource());
ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(getDataSource());
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), loc);
// Use itemGroups to determine if there are any ungrouped items
// get all the parent display item beans not in group
logMe("Entering getParentDisplayItems::: Thread is? " + Thread.currentThread());
ArrayList displayItems = getParentDisplayItems(hasGroup, sb, edcb, idao, ifmdao, iddao, hasUngroupedItems, request);
logMe("Entering getParentDisplayItems::: Done and Thread is? " + Thread.currentThread());
LOGGER.debug("just ran get parent display, has group " + hasGroup + " has ungrouped " + hasUngroupedItems);
// now sort them by ordinal,
// JN: Commenting out this logic, its wrong and will give erroneous results.
Collections.sort(displayItems);
// now get the child DisplayItemBeans
for (int i = 0; i < displayItems.size(); i++) {
DisplayItemBean dib = (DisplayItemBean) displayItems.get(i);
dib.setChildren(getChildrenDisplayItems(dib, edcb, request));
//
if (ecb.getStage() == DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE || ecb.getStage() == DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) {
if (shouldLoadDBValues(dib) && !isSubmitted) {
dib.loadDBValue();
}
} else {
if (shouldLoadDBValues(dib)) {
LOGGER.trace("should load db values is true, set value");
dib.loadDBValue();
LOGGER.trace("just got data loaded: " + dib.getData().getValue());
}
}
displayItems.set(i, dib);
}
section.setItems(displayItems);
return section;
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class EnterDataForStudyEventServlet method populateUncompletedCRFsWithCRFAndVersions.
private void populateUncompletedCRFsWithCRFAndVersions(ArrayList uncompletedEventDefinitionCRFs) {
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
int size = uncompletedEventDefinitionCRFs.size();
for (int i = 0; i < size; i++) {
DisplayEventDefinitionCRFBean dedcrf = (DisplayEventDefinitionCRFBean) uncompletedEventDefinitionCRFs.get(i);
CRFBean cb = (CRFBean) cdao.findByPK(dedcrf.getEdc().getCrfId());
// check it here, tbh 102007
if (cb.getStatus().equals(Status.AVAILABLE)) {
// the above does not allow us to show the CRF as a thing with
// status of 'invalid' so we have to
// go to the JSP for this one, I think
dedcrf.getEdc().setCrf(cb);
ArrayList theVersions = (ArrayList) cvdao.findAllActiveByCRF(dedcrf.getEdc().getCrfId());
ArrayList versions = new ArrayList();
HashMap<String, CRFVersionBean> crfVersionIds = new HashMap<String, CRFVersionBean>();
for (int j = 0; j < theVersions.size(); j++) {
CRFVersionBean crfVersion = (CRFVersionBean) theVersions.get(j);
crfVersionIds.put(String.valueOf(crfVersion.getId()), crfVersion);
}
if (!dedcrf.getEdc().getSelectedVersionIds().equals("")) {
String[] kk = dedcrf.getEdc().getSelectedVersionIds().split(",");
for (String string : kk) {
if (crfVersionIds.get(string) != null) {
versions.add(crfVersionIds.get(string));
}
}
} else {
versions = theVersions;
}
dedcrf.getEdc().setVersions(versions);
// added tbh 092007, fix for 1461
if (versions != null && versions.size() != 0) {
boolean isLocked = false;
for (int ii = 0; ii < versions.size(); ii++) {
CRFVersionBean crfvb = (CRFVersionBean) versions.get(ii);
logger.debug("...checking versions..." + crfvb.getName());
if (!crfvb.getStatus().equals(Status.AVAILABLE)) {
logger.debug("found a non active crf version");
isLocked = true;
}
}
logger.debug("re-set event def, line 240: " + isLocked);
if (isLocked) {
dedcrf.setStatus(Status.LOCKED);
dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
}
uncompletedEventDefinitionCRFs.set(i, dedcrf);
} else {
// above added 092007, tbh
dedcrf.setStatus(Status.LOCKED);
dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
uncompletedEventDefinitionCRFs.set(i, dedcrf);
}
// added 102007, tbh
} else {
dedcrf.getEdc().setCrf(cb);
logger.debug("_found a non active crf _");
dedcrf.setStatus(Status.LOCKED);
dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
dedcrf.getEdc().getCrf().setStatus(Status.LOCKED);
uncompletedEventDefinitionCRFs.set(i, dedcrf);
}
// enclosing if statement added 102007, tbh
}
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class CreateDiscrepancyNoteServlet method getCrf.
private CRFBean getCrf(int eventCRFId) {
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionBean cv = (CRFVersionBean) cvdao.findByPK(getEventCrf(eventCRFId).getCRFVersionId());
CRFBean c = (CRFBean) cdao.findByPK(cv.getCrfId());
return c;
}
Aggregations