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;
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class ListDiscNotesForCRFTableFactory method setDataAndLimitVariables.
@SuppressWarnings("unchecked")
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
Limit limit = tableFacade.getLimit();
ListDiscNotesForCRFFilter listDiscNotesForCRF = getListEventsForSubjectFilter(limit);
listDiscNotesForCRF.addFilter("dn.discrepancy_note_type_id", this.discNoteType);
StringBuffer constraints = new StringBuffer();
if (this.discNoteType > 0 && this.discNoteType < 10) {
constraints.append(" and dn.discrepancy_note_type_id=" + this.discNoteType);
}
if (this.resolutionStatusIds != null && this.resolutionStatusIds.size() > 0) {
String s = " and (";
for (Integer resolutionStatusId : this.resolutionStatusIds) {
s += "dn.resolution_status_id = " + resolutionStatusId + " or ";
}
s = s.substring(0, s.length() - 3) + " )";
listDiscNotesForCRF.addFilter("dn.resolution_status_id", s);
constraints.append(s);
}
if (!limit.isComplete()) {
int totalRows = getStudySubjectDAO().getCountWithFilter(listDiscNotesForCRF, getStudyBean());
tableFacade.setTotalRows(totalRows);
}
ListDiscNotesForCRFSort eventsForSubjectSort = getListEventsForSubjectSort(limit);
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(), listDiscNotesForCRF, eventsForSubjectSort, rowStart, rowEnd);
Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
boolean hasDN = false;
for (StudySubjectBean studySubjectBean : items) {
HashMap<Object, Object> theItem = new HashMap<Object, Object>();
theItem.put("studySubject", studySubjectBean);
theItem.put("studySubject.label", studySubjectBean.getLabel());
theItem.put("studySubject.status", studySubjectBean.getStatus());
SubjectBean subjectBean = (SubjectBean) getSubjectDAO().findByPK(studySubjectBean.getSubjectId());
theItem.put("subject", subjectBean);
theItem.put("subject.charGender", subjectBean.getGender());
// Get EventCrfs for study Subject
List<EventCRFBean> eventCrfs = getEventCRFDAO().findAllByStudySubject(studySubjectBean.getId());
HashMap<String, EventCRFBean> crfAsKeyEventCrfAsValue = new HashMap<String, EventCRFBean>();
for (EventCRFBean eventCRFBean : eventCrfs) {
CRFBean crf = getCrfDAO().findByVersionId(eventCRFBean.getCRFVersionId());
crfAsKeyEventCrfAsValue.put(crf.getId() + "_" + eventCRFBean.getStudyEventId(), eventCRFBean);
}
// Get the event Status
List<StudyEventBean> eventsForStudySubjectAndEventDefinitions = getStudyEventDAO().findAllByDefinitionAndSubject(selectedStudyEventDefinition, studySubjectBean);
List<DisplayBean> events = new ArrayList<DisplayBean>();
// study event size < 1
if (eventsForStudySubjectAndEventDefinitions.size() < 1) {
DisplayBean d = new DisplayBean();
d.getProps().put("event", null);
d.getProps().put("event.status", SubjectEventStatus.NOT_SCHEDULED);
d.getProps().put("event.startDate", null);
for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
HashMap<ResolutionStatus, Integer> discCounts = new HashMap<ResolutionStatus, Integer>();
d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
d.getProps().put("crf_" + crf.getId() + "_crf", crf);
d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
d.getProps().put("crf_" + crf.getId() + "_discCounts", discCounts);
theItem.put("crf_" + crf.getId(), "");
}
events.add(d);
}
// study event size >0
for (StudyEventBean studyEventBean : eventsForStudySubjectAndEventDefinitions) {
DisplayBean d = new DisplayBean();
d.getProps().put("event", studyEventBean);
d.getProps().put("event.status", studyEventBean.getSubjectEventStatus());
d.getProps().put("event.startDate", studyEventBean.getCreatedDate());
for (int i = 0; i < getCrfs(selectedStudyEventDefinition).size(); i++) {
CRFBean crf = getCrfs(selectedStudyEventDefinition).get(i);
EventCRFBean eventCRFBean = crfAsKeyEventCrfAsValue.get(crf.getId() + "_" + studyEventBean.getId());
HashMap<ResolutionStatus, Integer> discCounts = new HashMap<ResolutionStatus, Integer>();
if (eventCRFBean != null) {
d.getProps().put("crf_" + crf.getId(), eventCRFBean.getStage());
d.getProps().put("crf_" + crf.getId() + "_eventCrf", eventCRFBean);
// List<DiscrepancyNoteBean> discs =
// getDiscrepancyNoteDAO().findAllByStudyEvent(studyEventBean);
List<DiscrepancyNoteBean> discs = getDiscrepancyNoteDAO().findAllParentItemNotesByEventCRFWithConstraints(eventCRFBean.getId(), constraints);
hasDN = hasDN == false ? discs != null && discs.size() > 0 : hasDN;
for (DiscrepancyNoteBean discrepancyNoteBean : discs) {
Integer value = discCounts.get(discrepancyNoteBean.getResStatus());
if (value != null) {
discCounts.put(discrepancyNoteBean.getResStatus(), ++value);
} else {
discCounts.put(discrepancyNoteBean.getResStatus(), 1);
}
}
d.getProps().put("crf_" + crf.getId() + "_discCounts", discCounts);
} else {
d.getProps().put("crf_" + crf.getId(), DataEntryStage.UNCOMPLETED);
d.getProps().put("crf_" + crf.getId() + "_eventCrf", null);
d.getProps().put("crf_" + crf.getId() + "_discCounts", discCounts);
}
d.getProps().put("crf_" + crf.getId() + "_crf", crf);
d.getProps().put("crf_" + crf.getId() + "_eventDefinitionCrf", eventDefinitionCrfs.get(i));
theItem.put("crf_" + crf.getId(), "");
}
events.add(d);
}
theItem.put("events", events);
theItem.put("event.status", "");
theItem.put("event.startDate", "");
theItems.add(theItem);
}
// Do not forget to set the items back on the tableFacade.
tableFacade.setItems(theItems);
this.setStudyHasDiscNotes(hasDN);
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class ListDiscNotesForCRFTableFactory method getCrfs.
@SuppressWarnings("unchecked")
private ArrayList<CRFBean> getCrfs(StudyEventDefinitionBean eventDefinition) {
if (this.crfBeans == null) {
crfBeans = new ArrayList<CRFBean>();
eventDefinitionCrfs = new ArrayList<EventDefinitionCRFBean>();
ArrayList<Integer> ids = new ArrayList<Integer>();
List<EventDefinitionCRFBean> edcs = new ArrayList<EventDefinitionCRFBean>();
if (this.getStudyBean().getParentStudyId() > 0) {
edcs = (List<EventDefinitionCRFBean>) getEventDefintionCRFDAO().findAllActiveNonHiddenByEventDefinitionIdAndStudy(eventDefinition.getId(), this.getStudyBean());
} else {
edcs = getEventDefintionCRFDAO().findAllActiveByEventDefinitionId(eventDefinition.getId());
}
if (edcs.size() > 0) {
for (EventDefinitionCRFBean eventDefinitionCrf : edcs) {
CRFBean crf = (CRFBean) getCrfDAO().findByPK(eventDefinitionCrf.getCrfId());
if (!ids.contains(crf.getId())) {
crfBeans.add(crf);
ids.add(crf.getId());
eventDefinitionCrfs.add(eventDefinitionCrf);
}
}
}
return crfBeans;
}
return crfBeans;
}
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 OdmController method getFormDataPerCrf.
private ODMcomplexTypeDefinitionFormData getFormDataPerCrf(CRFVersionBean crfVersion, StudyEventBean nextEvent, List<EventCRFBean> eventCrfs, CRFDAO crfDAO, String formUrl, boolean itemDataExists) {
EventCRFBean selectedEventCRFBean = null;
CRFBean crfBean = (CRFBean) crfDAO.findByVersionId(crfVersion.getId());
for (EventCRFBean eventCRFBean : eventCrfs) {
if (eventCRFBean.getCRFVersionId() == crfVersion.getId()) {
selectedEventCRFBean = eventCRFBean;
break;
}
}
return generateFormData(crfVersion, nextEvent, selectedEventCRFBean, crfBean, formUrl, itemDataExists);
}
Aggregations