use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class ExtractBean method debug.
/*
* addStudyGroupData: each subject can have more than one Group, so we need
* to create a list for each subject and check if the groupclasses are
* there, and which group it is. tbh
*/
// public void addSubjectGroupData(Integer subjectGroupId,
// Integer subjectGroupClassId) {
// // DO NOT USE -- using another method, tbh
// }
/**
* debug: takes in a event crf bean and spits out all its data. tbh
*/
public void debug(StudyEventBean seb) {
java.lang.StringBuffer buf = new java.lang.StringBuffer();
buf.append("***** ***** *****\n");
buf.append("event crf count: " + seb.getEventCRFs().size() + " ");
buf.append("study event bean location: " + seb.getLocation() + " ");
buf.append("study event def id: " + seb.getStudyEventDefinitionId() + " ");
buf.append("study event date started: " + seb.getDateStarted() + " ");
buf.append("study event date ended: " + seb.getDateEnded() + " ");
buf.append("study event status: " + seb.getStatus().getName() + " ");
buf.append("***** ***** *****\n");
logger.info(buf.toString());
for (int i = 0; i < seb.getEventCRFs().size(); i++) {
EventCRFBean check = (EventCRFBean) seb.getEventCRFs().get(i);
debug(check);
}
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class ExtractBean method getEvent.
/**
* Get the event correspodning to the provided study subject, SED and sample
* ordinal.
*
* @param h
* An index into the array of subjects.
* @param i
* An index into the array of SEDs.
* @param j
* The sample ordinal.
* @return The event correspodning to the provided study subject, SED and
* sample ordinal.
*/
private StudyEventBean getEvent(int h, int i, int j) {
syncSubjectIndex(h);
syncSEDIndex(i);
String key = getStudyEventDataKey(currentSubject.getId(), currentDef.getId(), j);
StudyEventBean seb = (StudyEventBean) eventData.get(key);
if (seb == null) {
// logger.info("dump of event data: "+eventData.toString());
return new StudyEventBean();
} else {
// "+key);
if (seb.getEventCRFs().size() > 0) {
EventCRFBean ecbean = (EventCRFBean) seb.getEventCRFs().get(0);
}
// logger.info("int.name "+ecbean.getInterviewerName());
return seb;
}
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class ExtractBean method addStudyEventDataOld.
// addStudyEventData
/*
* addStudyEventData, a function which puts information about a
* study-subject taking an event-crf into the ExtractBean's interface.
*/
public void addStudyEventDataOld(Integer studySubjectId, String studyEventDefinitionName, Integer studyEventDefinitionId, Integer sampleOrdinal, String studyEventLocation, Date studyEventStart, Date studyEventEnd, String crfVersionName, Integer crfVersionStatusId, Date dateInterviewed, String interviewerName, Date dateCompleted, Date dateValidateCompleted, Integer completionStatusId) {
if (studySubjectId == null || studyEventDefinitionId == null || sampleOrdinal == null || studyEventLocation == null || studyEventStart == null) {
return;
}
if (studyEventDefinitionId.intValue() <= 0 || studySubjectId.intValue() <= 0 || sampleOrdinal.intValue() <= 0) {
return;
}
// YW 08-21-2007 << fetch start_time_flag and end_time_flag
StudyEventDAO sedao = new StudyEventDAO(ds);
StudyEventBean se = (StudyEventBean) sedao.findByStudySubjectIdAndDefinitionIdAndOrdinal(studySubjectId, studyEventDefinitionId, sampleOrdinal);
// YW >>
if (se == null) {
se.setStatus(Status.INVALID);
}
StudyEventBean event = new StudyEventBean();
EventCRFBean eventCRF = new EventCRFBean();
event.setName(studyEventDefinitionName);
event.setDateStarted(studyEventStart);
event.setDateEnded(studyEventEnd);
event.setLocation(studyEventLocation);
event.setSampleOrdinal(sampleOrdinal.intValue());
event.setStudyEventDefinitionId(studyEventDefinitionId.intValue());
event.setStudySubjectId(studySubjectId.intValue());
event.setStartTimeFlag(se.getStartTimeFlag());
event.setEndTimeFlag(se.getEndTimeFlag());
// below needs to be added, tbh
event.setStatus(se.getStatus());
event.setSubjectEventStatus(se.getSubjectEventStatus());
event.setStage(se.getStage());
logger.info("found stage: " + se.getStage().getName());
event.setId(se.getId());
// end tbh, 03/08
//
eventCRF.setCompletionStatusId(completionStatusId.intValue());
eventCRF.setInterviewerName(interviewerName);
eventCRF.setDateCompleted(dateCompleted);
eventCRF.setDateValidateCompleted(dateValidateCompleted);
// eventCRF.setCreatedDate();//same as interviewed date? NO
eventCRF.setDateInterviewed(dateInterviewed);
// eventCRF.setStatus(status); //this is the one that we want, tbh
// EventCRFDAO ecrfdao = new EventCRFDAO(ds);
// ArrayList events = ecrfdao.findAllByStudyEvent(se);
CRFVersionBean crfVersion = new CRFVersionBean();
crfVersion.setName(crfVersionName);
crfVersion.setStatus(Status.get(crfVersionStatusId.intValue()));
crfVersion.setStatusId(crfVersionStatusId.intValue());
eventCRF.setCrfVersion(crfVersion);
// logger.info();
ArrayList events = new ArrayList();
events.add(eventCRF);
// logger.info("///adding an event CRF..."
// + eventCRF.getInterviewerName());
// hmm, one to one relationship?
event.setEventCRFs(events);
// guard clause to see if it's in there already?
// not rly, the above is only used in auditlogging
// could fit in crf and crf version ids here, though
// FIXME def not one to one relationship, tbh, 03.08
String key = getStudyEventDataKey(studySubjectId.intValue(), studyEventDefinitionId.intValue(), sampleOrdinal.intValue());
if (eventData == null) {
eventData = new HashMap();
}
StudyEventBean checkEvent = (StudyEventBean) eventData.get(key);
if (checkEvent == null) {
eventData.put(key, event);
logger.info("###just CREATED key: " + key + " event: " + event.getName() + " int.name: " + eventCRF.getInterviewerName());
} else {
// ArrayList eventCRFs = checkEvent.getEventCRFs();
// eventCRFs.add(eventCRF);
// checkEvent.setEventCRFs(eventCRFs);
// eventData.put(key, checkEvent);
// logger.info("count of eventcrfs "+eventCRFs.size());
// logger.info("other things about the event crf: int.name
// "+eventCRF.getInterviewerName()+" comp status id
// "+eventCRF.getCompletionStatusId()+" version name
// "+eventCRF.getCrfVersion().getName());
// logger.info("###just UPDATED key: "+key+" event:
// "+event.getName()+" int.name: "+eventCRF.getInterviewerName());
}
// the problem: we want to order by start date
// but hashmaps are by their very nature hard to order
// and there is no contigous start date that we can sort on, i.e. we
// only
// look at one at a time.
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class UnlockEventDefinitionServlet method processRequest.
@Override
public void processRequest() throws Exception {
String idString = request.getParameter("id");
int defId = Integer.valueOf(idString.trim()).intValue();
StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
// find all CRFs
EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllByDefinition(defId);
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
ArrayList versions = (ArrayList) cvdao.findAllByCRF(edc.getCrfId());
edc.setVersions(versions);
CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
edc.setCrfName(crf.getName());
}
// finds all events
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
ArrayList events = (ArrayList) sedao.findAllByDefinition(sed.getId());
String action = request.getParameter("action");
if (StringUtil.isBlank(idString)) {
addPageMessage(respage.getString("please_choose_a_SED_to_unlock"));
forwardPage(Page.LIST_DEFINITION_SERVLET);
} else {
if ("confirm".equalsIgnoreCase(action)) {
if (!sed.getStatus().equals(Status.LOCKED)) {
addPageMessage(respage.getString("this_SED_cannot_be_unlocked") + " " + respage.getString("please_contact_sysadmin_for_more_information"));
forwardPage(Page.LIST_DEFINITION_SERVLET);
return;
}
request.setAttribute("definitionToUnlock", sed);
request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
request.setAttribute("events", events);
forwardPage(Page.UNLOCK_DEFINITION);
} else {
logger.info("submit to lock the definition");
// unlock definition
sed.setStatus(Status.AVAILABLE);
sed.setUpdater(ub);
sed.setUpdatedDate(new Date());
sdao.update(sed);
// lock all crfs
for (int j = 0; j < eventDefinitionCRFs.size(); j++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(j);
edc.setStatus(Status.AVAILABLE);
edc.setUpdater(ub);
edc.setUpdatedDate(new Date());
edao.update(edc);
}
// unlock all events
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
for (int j = 0; j < events.size(); j++) {
StudyEventBean event = (StudyEventBean) events.get(j);
event.setStatus(Status.AVAILABLE);
event.setUpdater(ub);
event.setUpdatedDate(new Date());
sedao.update(event);
ArrayList eventCRFs = ecdao.findAllByStudyEvent(event);
// unlock all the item data
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (int k = 0; k < eventCRFs.size(); k++) {
EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(k);
eventCRF.setStatus(Status.AVAILABLE);
eventCRF.setUpdater(ub);
eventCRF.setUpdatedDate(new Date());
ecdao.update(eventCRF);
ArrayList itemDatas = iddao.findAllByEventCRFId(eventCRF.getId());
for (int a = 0; a < itemDatas.size(); a++) {
ItemDataBean item = (ItemDataBean) itemDatas.get(a);
item.setStatus(Status.AVAILABLE);
item.setUpdater(ub);
item.setUpdatedDate(new Date());
iddao.update(item);
}
}
}
String emailBody = respage.getString("the_SED") + " " + sed.getName() + respage.getString("has_been_unlocked_for_the_study") + " " + currentStudy.getName() + ". " + respage.getString("subject_event_data_is_as_it_was_before");
addPageMessage(emailBody);
sendEmail(emailBody);
forwardPage(Page.LIST_DEFINITION_SERVLET);
}
}
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class ViewEventCRFContentServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int eventCRFId = fp.getInt("ecId", true);
int studySubId = fp.getInt("id", true);
int eventId = fp.getInt("eventId", true);
if (eventCRFId == 0) {
addPageMessage(respage.getString("please_choose_an_event_CRF_to_view"));
forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
return;
}
StudyEventBean seb = getStudyEvent(eventId);
StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
request.setAttribute("studySub", studySub);
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
EventCRFBean eventCRF = (EventCRFBean) ecdao.findByPK(eventCRFId);
DisplayTableOfContentsBean displayBean = TableOfContentsServlet.getDisplayBean(eventCRF, sm.getDataSource(), currentStudy);
request.setAttribute("toc", displayBean);
request.getSession().setAttribute(BEAN_STUDY_EVENT, seb);
forwardPage(Page.VIEW_EVENT_CRF_CONTENT);
}
Aggregations