use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class StudySubjectServiceImpl method getUncompletedCRFs.
private ArrayList<DisplayEventDefinitionCRFBean> getUncompletedCRFs(List eventDefinitionCRFs, List eventCRFs, SubjectEventStatus status, Set<Integer> nonEmptyEventCrf, Map<Integer, FormLayoutBean> formLayoutById, Map<Integer, CRFBean> crfById) {
int i;
HashMap<Integer, Boolean> completed = new HashMap<Integer, Boolean>();
HashMap<Integer, EventCRFBean> startedButIncompleted = new HashMap<Integer, EventCRFBean>();
ArrayList<DisplayEventDefinitionCRFBean> answer = new ArrayList<DisplayEventDefinitionCRFBean>();
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());
}
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
int crfId = formLayoutById.get(ecrf.getFormLayoutId()).getCrfId();
if (nonEmptyEventCrf.contains(ecrf.getId())) {
// 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);
}
}
// TODO possible relation to 1689 here, tbh
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
// available (i.e., not removed)
if (edcrf.getStatus().equals(Status.AVAILABLE)) {
dedc.setEdc(edcrf);
// below added tbh, 112007 to fix bug 1943
if (status.equals(SubjectEventStatus.LOCKED)) {
dedc.setStatus(Status.LOCKED);
}
Boolean b = completed.get(new Integer(edcrf.getCrfId()));
EventCRFBean ev = startedButIncompleted.get(new Integer(edcrf.getCrfId()));
if (b == null || !b.booleanValue()) {
dedc.setEventCRF(ev);
answer.add(dedc);
}
}
}
return answer;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class EventDefinitionCrfTagDAO method findAll.
@Override
public Collection findAll() {
this.setTypesExpected();
ArrayList alist = this.select(digester.getQuery("findAll"));
ArrayList al = new ArrayList();
Iterator it = alist.iterator();
while (it.hasNext()) {
EventDefinitionCRFBean eb = (EventDefinitionCRFBean) this.getEntityFromHashMap((HashMap) it.next());
al.add(eb);
}
return al;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class EventDefinitionCRFDAO method findForStudyByStudyEventIdAndFormLayoutId.
public EventDefinitionCRFBean findForStudyByStudyEventIdAndFormLayoutId(int studyEventId, int formLayoutId) {
EventDefinitionCRFBean answer = new EventDefinitionCRFBean();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(studyEventId));
variables.put(new Integer(2), new Integer(formLayoutId));
String sql = digester.getQuery("findForStudyByStudyEventIdAndFormLayoutId");
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
while (it.hasNext()) {
answer = (EventDefinitionCRFBean) this.getEntityFromHashMap((HashMap) it.next());
}
return answer;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class PrintAllEventCRFServlet method processRequest.
@Override
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
FormProcessor fp = new FormProcessor(request);
SessionManager sm = (SessionManager) request.getSession().getAttribute("sm");
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
ArrayList<SectionBean> allSectionBeans;
// The PrintDataEntry servlet handles this parameter
boolean isSubmitted = false;
StudyEventDefinitionDAO sedao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
seds = sedao.findAllByStudy(currentStudy);
// ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByStudy(site);
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
ArrayList<EventDefinitionCRFBean> edcs = new ArrayList();
for (StudyEventDefinitionBean sed : seds) {
int defId = sed.getId();
edcs.addAll(edcdao.findAllByDefinition(currentStudy, defId));
}
Map eventDefinitionDefaultVersions = new LinkedHashMap();
for (int i = 0; i < edcs.size(); i++) {
EventDefinitionCRFBean edc = edcs.get(i);
ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
edc.setVersions(versions);
CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
// edc.setCrfLabel(crf.getLabel());
edc.setCrfName(crf.getName());
// to show/hide edit action on jsp page
if (crf.getStatus().equals(Status.AVAILABLE)) {
edc.setOwner(crf.getOwner());
}
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
StudyEventDefinitionBean studyEventDefinitionBean = (StudyEventDefinitionBean) sedao.findByPK(edc.getStudyEventDefinitionId());
edc.setDefaultVersionName(defaultVersion.getName());
if (defaultVersion.getStatus().isAvailable()) {
List list = (ArrayList) eventDefinitionDefaultVersions.get(studyEventDefinitionBean);
if (list == null)
list = new ArrayList();
list.add(defaultVersion);
eventDefinitionDefaultVersions.put(studyEventDefinitionBean, list);
}
}
// Whether IE6 or IE7 is involved
String isIE = fp.getString("ie");
if ("y".equalsIgnoreCase(isIE)) {
request.setAttribute("isInternetExplorer", "true");
}
SectionDAO sdao = new SectionDAO(sm.getDataSource());
CRFVersionDAO crfVersionDAO = new CRFVersionDAO(sm.getDataSource());
CRFDAO crfDao = new CRFDAO(sm.getDataSource());
Map sedCrfBeans = null;
for (Iterator it = eventDefinitionDefaultVersions.keySet().iterator(); it.hasNext(); ) {
if (sedCrfBeans == null)
sedCrfBeans = new LinkedHashMap();
StudyEventDefinitionBean sedBean = (StudyEventDefinitionBean) it.next();
List crfVersions = (ArrayList) eventDefinitionDefaultVersions.get(sedBean);
for (Iterator crfIt = crfVersions.iterator(); crfIt.hasNext(); ) {
CRFVersionBean crfVersionBean = (CRFVersionBean) crfIt.next();
allSectionBeans = new ArrayList<SectionBean>();
ArrayList sectionBeans = new ArrayList();
ItemGroupDAO itemGroupDao = new ItemGroupDAO(sm.getDataSource());
// Find truely grouped tables, not groups with a name of 'Ungrouped'
List<ItemGroupBean> itemGroupBeans = itemGroupDao.findOnlyGroupsByCRFVersionID(crfVersionBean.getId());
CRFBean crfBean = crfDao.findByVersionId(crfVersionBean.getId());
if (itemGroupBeans.size() > 0) {
// get a DisplaySectionBean for each section of the CRF, sort
// them, then
// dispatch the request to a print JSP. The constructor for this
// handler takes
// a boolean value depending on whether data is involved or not
// ('false' in terms of this
// servlet; see PrintDataEntryServlet).
DisplaySectionBeanHandler handler = new DisplaySectionBeanHandler(false, getDataSource(), getServletContext());
handler.setCrfVersionId(crfVersionBean.getId());
// handler.setEventCRFId(eventCRFId);
List<DisplaySectionBean> displaySectionBeans = handler.getDisplaySectionBeans();
request.setAttribute("listOfDisplaySectionBeans", displaySectionBeans);
// Make available the CRF names and versions for
// the web page's header
CRFVersionBean crfverBean = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionBean.getId());
request.setAttribute("crfVersionBean", crfverBean);
request.setAttribute("crfBean", crfBean);
// Set an attribute signaling that data is not involved
request.setAttribute("dataInvolved", "false");
PrintCRFBean printCrfBean = new PrintCRFBean();
printCrfBean.setDisplaySectionBeans(displaySectionBeans);
printCrfBean.setCrfVersionBean(crfVersionBean);
printCrfBean.setCrfBean(crfBean);
printCrfBean.setEventCrfBean(ecb);
printCrfBean.setGrouped(true);
List list = (ArrayList) sedCrfBeans.get(sedBean);
if (list == null)
list = new ArrayList();
list.add(printCrfBean);
sedCrfBeans.put(sedBean, list);
continue;
}
ecb = new EventCRFBean();
ecb.setCRFVersionId(crfVersionBean.getId());
CRFVersionBean version = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionBean.getId());
ArrayList sects = (ArrayList) sdao.findByVersionId(version.getId());
for (int i = 0; i < sects.size(); i++) {
sb = (SectionBean) sects.get(i);
// super.sb = sb;
int sectId = sb.getId();
if (sectId > 0) {
allSectionBeans.add((SectionBean) sdao.findByPK(sectId));
}
}
request.setAttribute(INPUT_EVENT_CRF, ecb);
request.setAttribute(SECTION_BEAN, sb);
request.setAttribute(ALL_SECTION_BEANS, allSectionBeans);
sectionBeans = super.getAllDisplayBeans(request);
DisplaySectionBean dsb = super.getDisplayBean(false, false, request, isSubmitted);
PrintCRFBean printCrfBean = new PrintCRFBean();
printCrfBean.setAllSections(sectionBeans);
printCrfBean.setDisplaySectionBean(dsb);
printCrfBean.setEventCrfBean(ecb);
printCrfBean.setCrfVersionBean(crfVersionBean);
printCrfBean.setCrfBean(crfBean);
printCrfBean.setGrouped(false);
List list = (ArrayList) sedCrfBeans.get(sedBean);
if (list == null)
list = new ArrayList();
list.add(printCrfBean);
sedCrfBeans.put(sedBean, list);
}
}
request.setAttribute("sedCrfBeans", sedCrfBeans);
request.setAttribute("studyName", currentStudy.getName());
forwardPage(Page.VIEW_ALL_DEFAULT_CRF_VERSIONS_PRINT, request, response);
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class ListEventDefinitionServlet method processRequest.
/**
* Processes the request
*/
@Override
public void processRequest() throws Exception {
StudyEventDefinitionDAO edao = new StudyEventDefinitionDAO(sm.getDataSource());
UserAccountDAO sdao = new UserAccountDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
CRFDAO crfDao = new CRFDAO(sm.getDataSource());
CRFVersionDAO crfVersionDao = new CRFVersionDAO(sm.getDataSource());
ArrayList seds = edao.findAllByStudy(currentStudy);
// request.setAttribute("seds", seds);
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (int i = 0; i < seds.size(); i++) {
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seds.get(i);
Collection eventDefinitionCRFlist = edcdao.findAllParentsByDefinition(sed.getId());
Map crfWithDefaultVersion = new LinkedHashMap();
for (Iterator it = eventDefinitionCRFlist.iterator(); it.hasNext(); ) {
EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) it.next();
CRFBean crfBean = (CRFBean) crfDao.findByPK(edcBean.getCrfId());
CRFVersionBean crfVersionBean = (CRFVersionBean) crfVersionDao.findByPK(edcBean.getDefaultVersionId());
logger.info("ED[" + sed.getName() + "]crf[" + crfBean.getName() + "]dv[" + crfVersionBean.getName() + "]");
crfWithDefaultVersion.put(crfBean.getName(), crfVersionBean.getName());
}
sed.setCrfsWithDefaultVersion(crfWithDefaultVersion);
logger.info("CRF size [" + sed.getCrfs().size() + "]");
if (sed.getUpdater().getId() == 0) {
sed.setUpdater(sed.getOwner());
sed.setUpdatedDate(sed.getCreatedDate());
}
if (isPopulated(sed, sedao)) {
sed.setPopulated(true);
}
}
FormProcessor fp = new FormProcessor(request);
EntityBeanTable table = fp.getEntityBeanTable();
ArrayList allStudyRows = StudyEventDefinitionRow.generateRowsFromBeans(seds);
String[] columns = { resword.getString("order"), resword.getString("name"), resword.getString("OID"), resword.getString("repeating"), resword.getString("type"), resword.getString("category"), resword.getString("populated"), resword.getString("date_created"), resword.getString("date_updated"), resword.getString("CRFs"), resword.getString("default_version"), resword.getString("actions") };
table.setColumns(new ArrayList(Arrays.asList(columns)));
// >> tbh #4169 09/2009
table.hideColumnLink(2);
table.hideColumnLink(3);
table.hideColumnLink(4);
table.hideColumnLink(6);
table.hideColumnLink(7);
table.hideColumnLink(8);
table.hideColumnLink(9);
// crfs, tbh
table.hideColumnLink(10);
table.hideColumnLink(11);
table.hideColumnLink(12);
// << tbh 09/2009
table.setQuery("ListEventDefinition", new HashMap());
// if (!currentStudy.getStatus().isLocked()) {
// table.addLink(resworkflow.getString(
// "create_a_new_study_event_definition"), "DefineStudyEvent");
// }
table.setRows(allStudyRows);
table.setPaginated(false);
table.computeDisplay();
request.setAttribute("table", table);
request.setAttribute("defSize", new Integer(seds.size()));
if (request.getParameter("read") != null && request.getParameter("read").equals("true")) {
request.setAttribute("readOnly", true);
}
forwardPage(Page.STUDY_EVENT_DEFINITION_LIST);
}
Aggregations