use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.
the class UpdateSubjectGroupClassServlet method confirmGroup.
/**
* Validates the first section of study and save it into study bean
*
* @param request
* @param response
* @throws Exception
*/
private void confirmGroup() throws Exception {
Validator v = new Validator(request);
FormProcessor fp = new FormProcessor(request);
v.addValidation("name", Validator.NO_BLANKS);
// v.addValidation("groupClassTypeId", Validator.IS_AN_INTEGER);
v.addValidation("subjectAssignment", Validator.NO_BLANKS);
v.addValidation("name", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 30);
v.addValidation("subjectAssignment", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 30);
ArrayList studyGroups = new ArrayList();
for (int i = 0; i < 10; i++) {
String name = fp.getString("studyGroup" + i);
int studyGroupId = fp.getInt("studyGroupId" + i);
String description = fp.getString("studyGroupDescription" + i);
if (!StringUtil.isBlank(name)) {
StudyGroupBean g = new StudyGroupBean();
g.setName(name);
g.setDescription(description);
g.setId(studyGroupId);
studyGroups.add(g);
if (name.length() > 255) {
request.setAttribute("studyGroupError", resexception.getString("group_name_cannot_be_more_255"));
break;
}
if (description.length() > 1000) {
request.setAttribute("studyGroupError", resexception.getString("group_description_cannot_be_more_100"));
break;
}
}
}
errors = v.validate();
if (fp.getInt("groupClassTypeId") == 0) {
Validator.addError(errors, "groupClassTypeId", "Group Class Type is required.");
}
StudyGroupClassBean group = (StudyGroupClassBean) session.getAttribute("group");
group.setName(fp.getString("name"));
group.setGroupClassTypeId(fp.getInt("groupClassTypeId"));
group.setSubjectAssignment(fp.getString("subjectAssignment"));
session.setAttribute("group", group);
session.setAttribute("studyGroups", studyGroups);
if (errors.isEmpty()) {
logger.info("no errors in the first section");
group.setGroupClassTypeName(GroupClassType.get(group.getGroupClassTypeId()).getName());
forwardPage(Page.UPDATE_SUBJECT_GROUP_CLASS_CONFIRM);
} else {
logger.info("has validation errors in the first section");
request.setAttribute("formMessages", errors);
request.setAttribute("groupTypes", GroupClassType.toArrayList());
forwardPage(Page.UPDATE_SUBJECT_GROUP_CLASS);
}
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.
the class ExtractBean method computeReportData.
public void computeReportData(ReportBean answer) {
answer.nextCell("Subject Event Item Values (Item-CRF-Ordinal)");
answer.nextRow();
// ///////////////////
// //
// COLUMNS //
// //
// ///////////////////
answer.nextCell("SubjID");
answer.nextCell("ProtocolID");
// then CRF info
if (dataset.isShowSubjectDob()) {
if (study.getStudyParameterConfig().getCollectDob().equals("2")) {
answer.nextCell("YOB");
} else if (study.getStudyParameterConfig().getCollectDob().equals("1")) {
answer.nextCell("DOB");
}
}
if (dataset.isShowSubjectGender()) {
answer.nextCell("Gender");
}
// TODO add additional labels here
if (dataset.isShowSubjectStatus()) {
answer.nextCell("SubjectStatus");
eventDescriptions.put("SubjectStatus", "Subject Status");
}
// TODO set datainfo-settable code here, tbh
if (dataset.isShowSubjectUniqueIdentifier() && "1".equals(showUniqueId)) {
answer.nextCell("UniqueID");
eventDescriptions.put("UniqueID", "Unique ID");
}
if (dataset.isShowSubjectSecondaryId()) {
answer.nextCell("SecondaryID");
eventDescriptions.put("SecondaryID", "SecondaryID");
}
// subject group info here, tbh
if (dataset.isShowSubjectGroupInformation()) {
// logger.info("got this far in subject group columns...");
for (int y = 0; y < studyGroupClasses.size(); y++) {
// logger.info("found a study group class here: "+y);
StudyGroupClassBean studyGroupClassBean = (StudyGroupClassBean) studyGroupClasses.get(y);
answer.nextCell(studyGroupClassBean.getName());
// logger.info("found the name:
// "+studyGroupClassBean.getName());
// YW 10-31-2007, for SPSS, eventHeader probably doesn't match
// the final header which will be validated
eventDescriptions.put(studyGroupClassBean.getName(), studyGroupClassBean.getName());
}
}
// ////////////////////
// sed column labels
int numSEDs = getNumSEDs();
for (int i = 1; i <= numSEDs; i++) {
int numSamples = getSEDNumSamples(i);
for (int j = 1; j <= numSamples; j++) {
if (dataset.isShowEventLocation()) {
String location = getColumnLabel(i, j, "Location", numSamples);
String description = getColumnDescription(i, j, "Location For ", currentDef.getName(), numSamples);
answer.nextCell(location);
eventHeaders.add(location);
eventDescriptions.put(location, description);
}
if (dataset.isShowEventStart()) {
String start = getColumnLabel(i, j, "StartDate", numSamples);
String description = getColumnDescription(i, j, "Start Date For ", currentDef.getName(), numSamples);
answer.nextCell(start);
eventHeaders.add(start);
eventDescriptions.put(start, description);
}
if (dataset.isShowEventEnd()) {
String end = getColumnLabel(i, j, "EndDate", numSamples);
String description = getColumnDescription(i, j, "End Date For ", currentDef.getName(), numSamples);
answer.nextCell(end);
eventHeaders.add(end);
eventDescriptions.put(end, description);
}
if (dataset.isShowEventStatus()) {
String eventStatus = getColumnLabel(i, j, "SubjectEventStatus", numSamples);
String description = getColumnDescription(i, j, "Event Status For ", currentDef.getName(), numSamples);
answer.nextCell(eventStatus);
eventHeaders.add(eventStatus);
eventDescriptions.put(eventStatus, description);
}
if (dataset.isShowSubjectAgeAtEvent() && ("1".equals(study.getStudyParameterConfig().getCollectDob()) || "2".equals(study.getStudyParameterConfig().getCollectDob()))) {
String subjectAgeAtEvent = getColumnLabel(i, j, "AgeAtEvent", numSamples);
String description = getColumnDescription(i, j, "Age At Event for ", currentDef.getName(), numSamples);
answer.nextCell(subjectAgeAtEvent);
eventHeaders.add(subjectAgeAtEvent);
eventDescriptions.put(subjectAgeAtEvent, description);
}
}
}
// item-crf-ordinal column labels
for (int i = 1; i <= numSEDs; i++) {
int numSamples = getSEDNumSamples(i);
// int numSEDCRFs = getSEDNumCRFs(i);
for (int j = 1; j <= numSamples; j++) {
int numSEDCRFs = getSEDNumCRFs(i);
if (dataset.isShowCRFcompletionDate()) {
// logger.info();
String crfCompletionDate = getColumnLabel(i, j, "CompletionDate", numSamples);
// FIXME
String description = getColumnDescription(i, j, "Completion Date for ", currentDef.getName(), numSamples);
// is
// this
// correct?
answer.nextCell(crfCompletionDate);
eventHeaders.add(crfCompletionDate);
eventDescriptions.put(crfCompletionDate, description);
}
if (dataset.isShowCRFinterviewerDate()) {
String interviewerDate = getColumnLabel(i, j, "InterviewDate", numSamples);
// FIXME
String description = getColumnDescription(i, j, "Interviewed Date for ", currentDef.getName(), numSamples);
// is
// this
// correct?
answer.nextCell(interviewerDate);
eventHeaders.add(interviewerDate);
eventDescriptions.put(interviewerDate, description);
}
if (dataset.isShowCRFinterviewerName()) {
String interviewerName = getColumnLabel(i, j, "InterviewerName", numSamples);
// FIXME
String description = getColumnDescription(i, j, "Interviewer Name for ", currentDef.getName(), numSamples);
// is
// this
// correct?
answer.nextCell(interviewerName);
eventHeaders.add(interviewerName);
eventDescriptions.put(interviewerName, description);
}
if (dataset.isShowCRFstatus()) {
// numSamples
String crfStatus = getColumnLabel(i, j, "CRFVersionStatus", numSamples);
// ?
// ?
// ?
// FIXME
String description = getColumnDescription(i, j, "Event CRF Status for ", currentDef.getName(), numSamples);
// is
// this
// correct?
answer.nextCell(crfStatus);
eventHeaders.add(crfStatus);
eventDescriptions.put(crfStatus, description);
}
if (dataset.isShowCRFversion()) {
String crfCompletionDate = getColumnLabel(i, j, "VersionName", numSamples);
// FIXME
String description = getColumnDescription(i, j, "CRF Version Name for ", currentDef.getName(), numSamples);
// is
// this
// correct?
answer.nextCell(crfCompletionDate);
eventHeaders.add(crfCompletionDate);
eventDescriptions.put(crfCompletionDate, description);
}
}
}
for (int i = 1; i <= numSEDs; i++) {
int numSamples = getSEDNumSamples(i);
for (int j = 1; j <= numSamples; j++) {
int numSEDCRFs = getSEDNumCRFs(i);
for (int k = 1; k <= numSEDCRFs; k++) {
// add CRF level descriptions here, tbh
int numItems = getNumItems(i, k);
for (int l = 1; l <= numItems; l++) {
// for (int m = 0; m <= maxItemDataBeanOrdinal; m++) {
for (Iterator iter = groupNames.entrySet().iterator(); iter.hasNext(); ) {
java.util.Map.Entry groupEntry = (java.util.Map.Entry) iter.next();
String groupName = (String) groupEntry.getKey();
logger.info("*** Found a row in groupNames: key " + groupName);
// groupName, it will not be added to item title
if (inKeys(i, j, k, l, groupName)) {
Integer groupCount = (Integer) groupEntry.getValue();
for (int m = 1; m <= groupCount.intValue(); m++) {
answer.nextCell(getColumnItemLabel(i, j, k, l, numSamples, m, groupName));
DisplayItemHeaderBean dih = new DisplayItemHeaderBean();
dih.setItemHeaderName(getColumnItemLabel(i, j, k, l, numSamples, m, groupName));
// ItemBean item = new ItemBean();
dih.setItem(currentItem);
itemNames.add(dih);
}
}
}
}
}
}
}
answer.nextRow();
// ////////////////
for (int h = 1; h <= getNumSubjects(); h++) {
DisplayItemDataBean didb = new DisplayItemDataBean();
String label = getSubjectStudyLabel(h);
answer.nextCell(label);
didb.setSubjectName(label);
String protocolId = getParentProtocolId();
answer.nextCell(protocolId);
didb.setStudyLabel(protocolId);
// subject column data
if (dataset.isShowSubjectDob()) {
if (study.getStudyParameterConfig().getCollectDob().equals("2")) {
String yob = getSubjectYearOfBirth(h);
answer.nextCell(yob);
didb.setSubjectDob(yob);
} else if (study.getStudyParameterConfig().getCollectDob().equals("1")) {
String dob = getSubjectDateOfBirth(h);
answer.nextCell(dob);
didb.setSubjectDob(dob);
}
}
if (dataset.isShowSubjectGender()) {
String gender = getSubjectGender(h);
answer.nextCell(gender);
didb.setSubjectGender(gender);
}
// TODO column headers above, column values here, tbh
if (dataset.isShowSubjectStatus()) {
String status = getSubjectStatusName(h);
answer.nextCell(status);
didb.setSubjectStatus(status);
}
if (dataset.isShowSubjectUniqueIdentifier() && "1".equals(showUniqueId)) {
String uniqueName = getSubjectUniqueIdentifier(h);
answer.nextCell(uniqueName);
didb.setSubjectUniqueId(uniqueName);
}
if (dataset.isShowSubjectSecondaryId()) {
String secondaryId = getSubjectSecondaryId(h);
answer.nextCell(secondaryId);
didb.setSubjectSecondaryId(secondaryId);
}
if (dataset.isShowSubjectGroupInformation()) {
ArrayList studyGroupList = new ArrayList();
// studyGroupMap =
studyGroupList = getStudyGroupMap(h);
// "+studyGroupMap.toString());
for (int y = 0; y < studyGroupClasses.size(); y++) {
StudyGroupClassBean sgcBean = (StudyGroupClassBean) studyGroupClasses.get(y);
// if the subject is in the group...
// logger.info("iterating through keys:
// "+sgcBean.getId());
Iterator iter = studyGroupList.iterator();
/*
* case 0 - no groups assigned - should just have a blank
* here
*/
if (!iter.hasNext()) {
answer.nextCell("");
didb.setGroupName(Integer.valueOf(sgcBean.getId()), "");
}
/*
* case 1 - one or more groups assigned - runs through the
* maps and assigns them in rows
*/
while (iter.hasNext()) {
studyGroupMap = (HashMap) iter.next();
if (studyGroupMap.containsKey(Integer.valueOf(sgcBean.getId()))) {
StudyGroupBean groupBean = (StudyGroupBean) studyGroupMap.get(Integer.valueOf(sgcBean.getId()));
// logger.info("found a group name in a group
// class: "+groupBean.getName());
answer.nextCell(groupBean.getName());
didb.setGroupName(Integer.valueOf(sgcBean.getId()), groupBean.getName());
break;
// didb.setGroupName(groupBean.getName());
// otherwise we don't enter anything...
} else {
answer.nextCell("");
didb.setGroupName(Integer.valueOf(sgcBean.getId()), "");
}
// end if
}
// end while
}
// end for
}
// sed column values
for (int i = 1; i <= numSEDs; i++) {
int numSamples = getSEDNumSamples(i);
// add event-specific attributes here, tbh
for (int j = 1; j <= numSamples; j++) {
if (dataset.isShowEventLocation()) {
String location = getEventLocation(h, i, j);
answer.nextCell(location);
didb.getEventValues().add(location);
}
if (dataset.isShowEventStart()) {
String start = getEventStart(h, i, j);
answer.nextCell(start);
didb.getEventValues().add(start);
}
if (dataset.isShowEventEnd()) {
String end = getEventEnd(h, i, j);
answer.nextCell(end);
didb.getEventValues().add(end);
}
if (dataset.isShowEventStatus()) {
String status = getEventStatus(h, i, j);
answer.nextCell(status);
didb.getEventValues().add(status);
}
if (dataset.isShowSubjectAgeAtEvent() && ("1".equals(study.getStudyParameterConfig().getCollectDob()) || "2".equals(study.getStudyParameterConfig().getCollectDob()))) {
String ageAtEvent = currentSubject.getDateOfBirth() != null ? getAgeAtEvent(h, i, j) : "";
answer.nextCell(ageAtEvent);
didb.getEventValues().add(ageAtEvent);
}
}
}
// item-crf-ordinal column labels
for (int i = 1; i <= numSEDs; i++) {
int numSamples = getSEDNumSamples(i);
for (int j = 1; j <= numSamples; j++) {
if (dataset.isShowCRFcompletionDate()) {
String completionDate = getCRFCompletionDate(h, i, j);
answer.nextCell(completionDate);
didb.getEventValues().add(completionDate);
}
if (dataset.isShowCRFinterviewerDate()) {
String interviewerDate = getCRFInterviewerDate(h, i, j);
answer.nextCell(interviewerDate);
didb.getEventValues().add(interviewerDate);
}
if (dataset.isShowCRFinterviewerName()) {
String interviewerName = getCRFInterviewerName(h, i, j);
answer.nextCell(interviewerName);
didb.getEventValues().add(interviewerName);
}
if (dataset.isShowCRFstatus()) {
String crfStatus = getSEDCRFStatus(h, i, j);
answer.nextCell(crfStatus);
didb.getEventValues().add(crfStatus);
}
if (dataset.isShowCRFversion()) {
String crfVersion = getSEDCRFVersionName(h, i, j);
answer.nextCell(crfVersion);
didb.getEventValues().add(crfVersion);
}
}
// end j
}
for (int i = 1; i <= numSEDs; i++) {
int numSamples = getSEDNumSamples(i);
// restart j so that text reports match tbh 03/08
for (int j = 1; j <= numSamples; j++) {
int numSEDCRFs = getSEDNumCRFs(i);
for (int k = 1; k <= numSEDCRFs; k++) {
// add CRF-level column data here, tbh
int numItems = getNumItems(i, k);
for (int l = 1; l <= numItems; l++) {
// {
for (java.util.Iterator iter = groupNames.entrySet().iterator(); iter.hasNext(); ) {
java.util.Map.Entry groupEntry = (java.util.Map.Entry) iter.next();
String groupName = (String) groupEntry.getKey();
if (inKeys(i, j, k, l, groupName)) {
// logger.info("found group name at line
// 703: " + groupName);
Integer groupCount = (Integer) groupEntry.getValue();
// groupCount);
for (int m = 1; m <= groupCount.intValue(); m++) {
String data = getDataByIndex(h, i, j, k, l, m, groupName);
// a guard clause here to take care of
// empties...
// if (!data.equals("") ||
// !groupName.equals(UNGROUPED)) {
answer.nextCell(data);
didb.getItemValues().add(data);
}
}
// }
// removing guard clause for now, tbh
// and the column code above should look about
// the same, tbh
}
}
}
}
}
rowValues.add(didb);
answer.nextRow();
}
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.
the class StudyGroupDAO method findSubjectStudyGroup.
public StudyGroupBean findSubjectStudyGroup(int subjectId, String groupClassName) {
StudyGroupBean eb = new StudyGroupBean();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), subjectId);
variables.put(new Integer(2), groupClassName);
String sql = digester.getQuery("findSubjectStudyGroup");
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
if (it.hasNext()) {
eb = (StudyGroupBean) this.getEntityFromHashMap((HashMap) it.next());
}
return eb;
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.
the class StudyGroupDAO method findAllByGroupClass.
public ArrayList findAllByGroupClass(StudyGroupClassBean group) {
ArrayList answer = new ArrayList();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(group.getId()));
ArrayList alist = this.select(digester.getQuery("findAllByGroupClass"), variables);
Iterator it = alist.iterator();
while (it.hasNext()) {
HashMap hm = (HashMap) it.next();
StudyGroupBean g = (StudyGroupBean) this.getEntityFromHashMap(hm);
answer.add(g);
}
return answer;
}
use of org.akaza.openclinica.bean.managestudy.StudyGroupBean in project OpenClinica by OpenClinica.
the class StudyGroupDAO method findByStudyId.
public EntityBean findByStudyId(int studyId) {
StudyGroupBean eb = new StudyGroupBean();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(studyId));
String sql = digester.getQuery("findByStudyId");
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
if (it.hasNext()) {
eb = (StudyGroupBean) this.getEntityFromHashMap((HashMap) it.next());
}
return eb;
}
Aggregations