use of org.akaza.openclinica.bean.managestudy.StudyEventBean in project OpenClinica by OpenClinica.
the class ExtractBean method getSEDCRFVersionName.
private String getSEDCRFVersionName(int h, int sedInd, int crfInd) {
// syncCRFIndex(sedInd, crfInd);
StudyEventBean seb = getEvent(h, sedInd, crfInd);
EventCRFBean eventCRF = null;
if (seb.getEventCRFs().size() > 0) {
eventCRF = (EventCRFBean) seb.getEventCRFs().get(0);
}
String returnMe = "";
// EventCRFBean eventCRF = null;
if (seb.getEventCRFs().size() > 0) {
logger.info("found getEventCRFs.size " + seb.getEventCRFs().size());
for (int t = 0; t < seb.getEventCRFs().size(); t++) {
eventCRF = (EventCRFBean) seb.getEventCRFs().get(t);
returnMe = eventCRF.getCrfVersion().getName();
// logger.info("found versions.size "+versions.size());
// for (int s = 0; s < versions.size(); s++) {
// CRFVersionBean version = (CRFVersionBean)versions.get(s);
// if (version.getId()==eventCRF.getCRFVersionId()) {
// returnMe = version.getName();
// break;
// }
// }
}
}
logger.info("returning the following for crf version name: " + returnMe);
return returnMe;
}
use of org.akaza.openclinica.bean.managestudy.StudyEventBean in project OpenClinica by OpenClinica.
the class ExtractBean method getCRFInterviewerDate.
protected String getCRFInterviewerDate(int h, int i, int j) {
StudyEventBean seb = getEvent(h, i, j);
EventCRFBean eventCRF = null;
if (seb.getEventCRFs().size() > 0) {
eventCRF = (EventCRFBean) seb.getEventCRFs().get(0);
}
// c.setTime(eventCRF.getDateInterviewed());
return eventCRF != null && eventCRF.getDateInterviewed() != null ? sdf.format(eventCRF.getDateInterviewed()) : "";
}
use of org.akaza.openclinica.bean.managestudy.StudyEventBean in project OpenClinica by OpenClinica.
the class ExtractBean method getAgeAtEvent.
private String getAgeAtEvent(int h, int i, int j) {
// syncSubjectIndex(h);
StudyEventBean seb = getEvent(h, i, j);
Date startDate = seb.getDateStarted();
// to try and avoid NPEs, tbh 092007
startDate = seb.getDateStarted() != null ? seb.getDateStarted() : new Date();
Date age = currentSubject.getDateOfBirth();
String answer = "";
if (age.before(startDate)) {
Calendar dateOfBirth = Calendar.getInstance();
// new GregorianCalendar(age);
dateOfBirth.setTime(age);
// new
Calendar theStartDate = Calendar.getInstance();
// GregorianCalendar(startDate);
theStartDate.setTime(startDate);
int theAge = theStartDate.get(Calendar.YEAR) - dateOfBirth.get(Calendar.YEAR);
Calendar today = Calendar.getInstance();
// add the age to the year to see if it's happened yet
dateOfBirth.add(Calendar.YEAR, theAge);
// subtract one from the age if the birthday hasn't happened yet
if (today.before(dateOfBirth)) {
theAge--;
}
answer = "" + theAge;
} else {
// ideally should not get here, but we have an 'error' code if it
// does, tbh
answer = "-1";
// logger.info("reached error state for age at event");
}
return answer;
}
use of org.akaza.openclinica.bean.managestudy.StudyEventBean in project OpenClinica by OpenClinica.
the class ExtractBean method getCRFVersionName.
protected String getCRFVersionName(int h, int i, int j) {
// syncCRFIndex(ind, crfv);
// how to cross ref this with what's being entered???
// return currentCRF.getVersions()
StudyEventBean seb = getEvent(h, i, j);
EventCRFBean eventCRF = null;
if (seb.getEventCRFs().size() == 1) {
eventCRF = (EventCRFBean) seb.getEventCRFs().get(0);
} else {
eventCRF = (EventCRFBean) seb.getEventCRFs().get(j - 1);
}
return eventCRF != null ? eventCRF.getCrfVersion().getName() : "";
}
use of org.akaza.openclinica.bean.managestudy.StudyEventBean in project OpenClinica by OpenClinica.
the class StudySubjectServiceImpl method getDisplayStudyEventsForStudySubject.
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<DisplayStudyEventBean> getDisplayStudyEventsForStudySubject(StudySubjectBean studySubject, UserAccountBean userAccount, StudyUserRoleBean currentRole) {
StudyEventDAO studyEventDao = new StudyEventDAO(dataSource);
StudyEventDefinitionDAO studyEventDefinitionDao = new StudyEventDefinitionDAO(dataSource);
StudyDAO studyDao = new StudyDAO(dataSource);
EventDefinitionCRFDAO eventDefinitionCrfDao = new EventDefinitionCRFDAO(dataSource);
EventCRFDAO eventCrfDao = new EventCRFDAO(dataSource);
CRFDAO crfDao = new CRFDAO(dataSource);
CRFVersionDAO crfVersionDao = new CRFVersionDAO(dataSource);
ArrayList events = studyEventDao.findAllByStudySubject(studySubject);
Map<Integer, StudyEventDefinitionBean> eventDefinitionByEvent = studyEventDefinitionDao.findByStudySubject(studySubject.getId());
StudyBean study = (StudyBean) studyDao.findByPK(studySubject.getStudyId());
Map<Integer, SortedSet<EventDefinitionCRFBean>> eventDefinitionCrfByStudyEventDefinition;
if (study.getParentStudyId() < 1) {
// Is a study
eventDefinitionCrfByStudyEventDefinition = eventDefinitionCrfDao.buildEventDefinitionCRFListByStudyEventDefinitionForStudy(studySubject.getId());
} else {
// Is a site
eventDefinitionCrfByStudyEventDefinition = eventDefinitionCrfDao.buildEventDefinitionCRFListByStudyEventDefinition(studySubject.getId(), study.getId(), study.getParentStudyId());
}
Map<Integer, SortedSet<EventCRFBean>> eventCrfListByStudyEvent = eventCrfDao.buildEventCrfListByStudyEvent(studySubject.getId());
Map<Integer, Integer> maxOrdinalByStudyEvent = studyEventDefinitionDao.buildMaxOrdinalByStudyEvent(studySubject.getId());
Set<Integer> nonEmptyEventCrf = eventCrfDao.buildNonEmptyEventCrfIds(studySubject.getId());
Map<Integer, CRFVersionBean> crfVersionById = crfVersionDao.buildCrfVersionById(studySubject.getId());
Map<Integer, CRFBean> crfById = crfDao.buildCrfById(studySubject.getId());
ArrayList<DisplayStudyEventBean> displayEvents = new ArrayList<DisplayStudyEventBean>();
for (int i = 0; i < events.size(); i++) {
StudyEventBean event = (StudyEventBean) events.get(i);
StudyEventDefinitionBean sed = eventDefinitionByEvent.get(event.getStudyEventDefinitionId());
event.setStudyEventDefinition(sed);
List eventDefinitionCRFs = new ArrayList((eventDefinitionCrfByStudyEventDefinition.containsKey(sed.getId()) ? eventDefinitionCrfByStudyEventDefinition.get(sed.getId()) : Collections.EMPTY_LIST));
List eventCRFs = new ArrayList((eventCrfListByStudyEvent.containsKey(event.getId())) ? eventCrfListByStudyEvent.get(event.getId()) : Collections.EMPTY_LIST);
// construct info needed on view study event page
DisplayStudyEventBean de = new DisplayStudyEventBean();
de.setStudyEvent(event);
de.setDisplayEventCRFs((ArrayList<DisplayEventCRFBean>) getDisplayEventCRFs(eventCRFs, userAccount, currentRole, event.getSubjectEventStatus(), study, nonEmptyEventCrf, crfVersionById, crfById, event.getStudyEventDefinitionId(), eventDefinitionCRFs));
ArrayList<DisplayEventDefinitionCRFBean> al = getUncompletedCRFs(eventDefinitionCRFs, eventCRFs, event.getSubjectEventStatus(), nonEmptyEventCrf, crfVersionById, crfById);
populateUncompletedCRFsWithCRFAndVersions(al, crfVersionById, crfById);
de.setUncompletedCRFs(al);
// de.setMaximumSampleOrdinal(studyEventDao.getMaxSampleOrdinal(sed,
// studySubject));
de.setMaximumSampleOrdinal(maxOrdinalByStudyEvent.get(event.getStudyEventDefinitionId()));
displayEvents.add(de);
// event.setEventCRFs(createAllEventCRFs(eventCRFs,
// eventDefinitionCRFs));
}
return displayEvents;
}
Aggregations