use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class ListDiscNotesSubjectTableFactory method setDataAndLimitVariables.
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
StudyBean study = this.getStudyBean();
Limit limit = tableFacade.getLimit();
ListDiscNotesSubjectFilter subjectFilter = getSubjectFilter(limit);
subjectFilter.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) + " )";
subjectFilter.addFilter("dn.resolution_status_id", s);
constraints.append(s);
}
if (!limit.isComplete()) {
int totalRows = getStudySubjectDAO().getCountWithFilter(subjectFilter, study);
tableFacade.setTotalRows(totalRows);
}
ListDiscNotesSubjectSort subjectSort = getSubjectSort(limit);
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(study, subjectFilter, subjectSort, 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());
theItem.put("enrolledAt", ((StudyBean) getStudyDAO().findByPK(studySubjectBean.getStudyId())).getIdentifier());
// Get All study events for this study subject and then put list in
// HashMap with study event definition id as
// key and a list of study events as the value.
List<StudyEventBean> allStudyEventsForStudySubject = getStudyEventDAO().findAllByStudySubject(studySubjectBean);
HashMap<Integer, List<StudyEventBean>> allStudyEventsForStudySubjectBySedId = new HashMap<Integer, List<StudyEventBean>>();
theItem.put("isSignable", isSignable(allStudyEventsForStudySubject));
for (StudyEventBean studyEventBean : allStudyEventsForStudySubject) {
if (allStudyEventsForStudySubjectBySedId.get(studyEventBean.getStudyEventDefinitionId()) == null) {
ArrayList<StudyEventBean> a = new ArrayList<StudyEventBean>();
a.add(studyEventBean);
allStudyEventsForStudySubjectBySedId.put(studyEventBean.getStudyEventDefinitionId(), a);
} else {
allStudyEventsForStudySubjectBySedId.get(studyEventBean.getStudyEventDefinitionId()).add(studyEventBean);
}
}
for (StudyEventDefinitionBean studyEventDefinition : getStudyEventDefinitions()) {
List<StudyEventBean> studyEvents = allStudyEventsForStudySubjectBySedId.get(studyEventDefinition.getId());
SubjectEventStatus subjectEventStatus = null;
HashMap<ResolutionStatus, Integer> discCounts = new HashMap<ResolutionStatus, Integer>();
studyEvents = studyEvents == null ? new ArrayList<StudyEventBean>() : studyEvents;
if (studyEvents.size() < 1) {
subjectEventStatus = SubjectEventStatus.NOT_SCHEDULED;
} else {
for (StudyEventBean studyEventBean : studyEvents) {
discCounts = countAll(discCounts, studyEventBean, constraints, study.isSite(study.getParentStudyId()));
hasDN = hasDN == false ? discCounts.size() > 0 : hasDN;
if (studyEventBean.getSampleOrdinal() == 1) {
subjectEventStatus = studyEventBean.getSubjectEventStatus();
// break;
}
}
}
theItem.put("sed_" + studyEventDefinition.getId() + "_discCounts", discCounts);
theItem.put("sed_" + studyEventDefinition.getId(), subjectEventStatus.getId());
theItem.put("sed_" + studyEventDefinition.getId() + "_studyEvents", studyEvents);
theItem.put("sed_" + studyEventDefinition.getId() + "_object", studyEventDefinition);
}
theItems.add(theItem);
}
// Do not forget to set the items back on the tableFacade.
tableFacade.setItems(theItems);
setStudyHasDiscNotes(hasDN);
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class ListDiscNotesSubjectTableFactory method getStudyEventDefinitions.
@SuppressWarnings("unchecked")
private ArrayList<StudyEventDefinitionBean> getStudyEventDefinitions() {
if (this.studyEventDefinitions == null) {
if (studyBean.getParentStudyId() > 0) {
StudyBean parentStudy = (StudyBean) getStudyDAO().findByPK(studyBean.getParentStudyId());
studyEventDefinitions = getStudyEventDefinitionDao().findAllByStudy(parentStudy);
} else {
studyEventDefinitions = getStudyEventDefinitionDao().findAllByStudy(studyBean);
}
}
return this.studyEventDefinitions;
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class ListDiscNotesForCRFTableFactory method getStudyGroupClasses.
@SuppressWarnings("unchecked")
private ArrayList<StudyGroupClassBean> getStudyGroupClasses() {
if (this.studyGroupClasses == null) {
if (studyBean.getParentStudyId() > 0) {
StudyBean parentStudy = (StudyBean) getStudyDAO().findByPK(studyBean.getParentStudyId());
studyGroupClasses = getStudyGroupClassDAO().findAllActiveByStudy(parentStudy);
} else {
studyGroupClasses = getStudyGroupClassDAO().findAllActiveByStudy(studyBean);
}
}
return studyGroupClasses;
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class TableOfContentsServlet method createEventCRF.
/**
* Creates a new Event CRF or update the exsiting one, that is, an event CRF
* can be created but not item data yet, in this case, still consider it is
* not started(called uncompleted before)
*
* @return
* @throws Exception
*/
private EventCRFBean createEventCRF() throws Exception {
EventCRFBean ecb;
ecdao = new EventCRFDAO(sm.getDataSource());
int crfVersionId = fp.getInt(INPUT_CRF_VERSION_ID);
int studyEventId = fp.getInt(INPUT_STUDY_EVENT_ID);
int eventDefinitionCRFId = fp.getInt(INPUT_EVENT_DEFINITION_CRF_ID);
int subjectId = fp.getInt(INPUT_SUBJECT_ID);
int eventCRFId = fp.getInt(INPUT_EVENT_CRF_ID);
logger.info("Creating event CRF within Table of Contents. Study id: " + currentStudy.getId() + "; CRF Version id: " + crfVersionId + "; Study Event id: " + studyEventId + "; Event Definition CRF id: " + eventDefinitionCRFId + "; Subject: " + subjectId);
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
StudySubjectBean ssb = ssdao.findBySubjectIdAndStudy(subjectId, currentStudy);
if (!ssb.isActive()) {
throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("trying_to_begin_DE1"));
}
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sedb = seddao.findByEventDefinitionCRFId(eventDefinitionCRFId);
if (!ssb.isActive() || !sedb.isActive()) {
throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("trying_to_begin_DE2"));
}
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
EntityBean eb = cvdao.findByPK(crfVersionId);
if (!eb.isActive()) {
throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("trying_to_begin_DE3"));
}
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
StudyEventBean sEvent = (StudyEventBean) sedao.findByPK(studyEventId);
StudyBean studyWithSED = currentStudy;
if (currentStudy.getParentStudyId() > 0) {
studyWithSED = new StudyBean();
studyWithSED.setId(currentStudy.getParentStudyId());
}
AuditableEntityBean aeb = sedao.findByPKAndStudy(studyEventId, studyWithSED);
if (!aeb.isActive()) {
throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("trying_to_begin_DE4"));
}
ecb = new EventCRFBean();
if (eventCRFId == 0) {
// no event CRF created yet
ecb.setAnnotations("");
ecb.setCreatedDate(new Date());
ecb.setCRFVersionId(crfVersionId);
ecb.setInterviewerName("");
if (sEvent.getDateStarted() != null) {
// default date
ecb.setDateInterviewed(sEvent.getDateStarted());
} else {
ecb.setDateInterviewed(null);
}
ecb.setOwnerId(ub.getId());
ecb.setStatus(Status.AVAILABLE);
ecb.setCompletionStatusId(1);
ecb.setStudySubjectId(ssb.getId());
ecb.setStudyEventId(studyEventId);
ecb.setValidateString("");
ecb.setValidatorAnnotations("");
ecb = (EventCRFBean) ecdao.create(ecb);
logger.info("CREATED EVENT CRF");
} else {
// there is an event CRF already, only need to update
ecb = (EventCRFBean) ecdao.findByPK(eventCRFId);
ecb.setCRFVersionId(crfVersionId);
ecb.setUpdatedDate(new Date());
ecb.setUpdater(ub);
ecb = (EventCRFBean) ecdao.update(ecb);
}
if (!ecb.isActive()) {
throw new InconsistentStateException(Page.LIST_STUDY_SUBJECTS_SERVLET, resexception.getString("new_event_CRF_not_created_database_error"));
} else {
sEvent.setSubjectEventStatus(SubjectEventStatus.DATA_ENTRY_STARTED);
sEvent.setUpdater(ub);
sEvent.setUpdatedDate(new Date());
sedao.update(sEvent);
}
return ecb;
}
use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.
the class EditFormController method mayProceed.
private boolean mayProceed(String studyOid) throws Exception {
boolean accessPermission = false;
StudyBean siteStudy = getStudy(studyOid);
StudyBean study = getParentStudy(studyOid);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
participantPortalRegistrar = new ParticipantPortalRegistrar();
// ACTIVE ,
String pManageStatus = participantPortalRegistrar.getRegistrationStatus(study.getOid()).toString();
// PENDING ,
// INACTIVE
// enabled , disabled
String participateStatus = pStatus.getValue().toString();
// available , pending , frozen , locked
String studyStatus = study.getStatus().getName().toString();
// available , pending , frozen , locked
String siteStatus = siteStudy.getStatus().getName().toString();
System.out.println("pManageStatus: " + pManageStatus + " participantStatus: " + participateStatus + " studyStatus: " + studyStatus + " siteStatus: " + siteStatus);
logger.info("pManageStatus: " + pManageStatus + " participantStatus: " + participateStatus + " studyStatus: " + studyStatus + " siteStatus: " + siteStatus);
if (participateStatus.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && siteStatus.equalsIgnoreCase("available") && pManageStatus.equalsIgnoreCase("ACTIVE")) {
accessPermission = true;
}
return accessPermission;
}
Aggregations