use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.
the class StudySubjectDAO method getCountofStudySubjectsBasedOnStatus.
public Integer getCountofStudySubjectsBasedOnStatus(StudyBean currentStudy, Status status) {
StudySubjectBean studySubjectBean = new StudySubjectBean();
setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), currentStudy.getId());
variables.put(new Integer(2), currentStudy.getId());
variables.put(new Integer(3), status.getId());
String sql = digester.getQuery("getCountofStudySubjectsBasedOnStatus");
ArrayList rows = this.select(sql, variables);
Iterator it = rows.iterator();
if (it.hasNext()) {
Integer count = (Integer) ((HashMap) it.next()).get("count");
return count;
} else {
return null;
}
}
use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.
the class NotificationActionProcessor method runNotificationAction.
public void runNotificationAction(RuleActionBean ruleActionBean, RuleSetBean ruleSet, int studySubjectBeanId, int eventOrdinal) {
String emailList = ((NotificationActionBean) ruleActionBean).getTo();
String message = ((NotificationActionBean) ruleActionBean).getMessage();
String emailSubject = ((NotificationActionBean) ruleActionBean).getSubject();
int sed_Id = ruleSet.getStudyEventDefinitionId();
int studyId = ruleSet.getStudyId();
String eventName = getStudyEventDefnBean(sed_Id).getName();
if (eventOrdinal != 1)
eventName = eventName + "(" + eventOrdinal + ")";
String studyName = getStudyBean(studyId).getName();
if (message == null)
message = "";
if (emailSubject == null)
emailSubject = "";
message = message.replaceAll("\\$\\{event.name}", eventName);
message = message.replaceAll("\\$\\{study.name}", studyName);
emailSubject = emailSubject.replaceAll("\\$\\{event.name}", eventName);
emailSubject = emailSubject.replaceAll("\\$\\{study.name}", studyName);
ParticipantDTO pDTO = null;
StudyBean studyBean = getStudyBean(studyId);
String[] listOfEmails = emailList.split(",");
StudySubjectBean ssBean = (StudySubjectBean) ssdao.findByPK(studySubjectBeanId);
StudyBean parentStudyBean = getParentStudy(ds, studyBean);
String pUserName = parentStudyBean.getOid() + "." + ssBean.getOid();
UserAccountBean uBean = (UserAccountBean) udao.findByUserName(pUserName);
StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(studyBean.getId(), "participantPortal");
// enabled , disabled
String participateStatus = pStatus.getValue().toString();
Thread thread = new Thread(new NotificationActionProcessor(listOfEmails, uBean, studyBean, message, emailSubject, participantPortalRegistrar, mailSender, participateStatus));
thread.start();
}
use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.
the class SubjectService method createStudySubject.
private StudySubjectBean createStudySubject(SubjectBean subject, StudyBean studyBean, Date enrollmentDate, String secondaryId) {
StudySubjectBean studySubject = new StudySubjectBean();
studySubject.setSecondaryLabel(secondaryId);
studySubject.setOwner(getUserAccount());
studySubject.setEnrollmentDate(enrollmentDate);
studySubject.setSubjectId(subject.getId());
studySubject.setStudyId(studyBean.getId());
studySubject.setStatus(Status.AVAILABLE);
int handleStudyId = studyBean.getParentStudyId() > 0 ? studyBean.getParentStudyId() : studyBean.getId();
StudyParameterValueBean subjectIdGenerationParameter = getStudyParameterValueDAO().findByHandleAndStudy(handleStudyId, "subjectIdGeneration");
String idSetting = subjectIdGenerationParameter.getValue();
if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
// Warning: Here we have a race condition.
// At least, a uniqueness constraint should be set on the database! Better provide an atomic method which stores a new label in the database and returns it.
int nextLabel = getStudySubjectDao().findTheGreatestLabel() + 1;
studySubject.setLabel(Integer.toString(nextLabel));
} else {
studySubject.setLabel(subject.getLabel());
subject.setLabel(null);
}
return studySubject;
}
use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.
the class StudySubjectDAO method findAllByStudyIdAndLimit.
public ArrayList findAllByStudyIdAndLimit(int studyId, boolean isLimited) {
ArrayList answer = new ArrayList();
this.setTypesExpected();
int ind = 1;
this.setTypeExpected(ind, TypeNames.STRING);
// unique_identifier
ind++;
this.setTypeExpected(ind, TypeNames.CHAR);
// gender
ind++;
this.setTypeExpected(ind, TypeNames.INT);
// study_subject_id
ind++;
this.setTypeExpected(ind, TypeNames.STRING);
// label
ind++;
this.setTypeExpected(ind, TypeNames.STRING);
// secondary_label
ind++;
this.setTypeExpected(ind, TypeNames.INT);
// subject_id
ind++;
this.setTypeExpected(ind, TypeNames.INT);
// study_id
ind++;
this.setTypeExpected(ind, TypeNames.INT);
// status_id
ind++;
this.setTypeExpected(ind, TypeNames.DATE);
// enrollment_date
ind++;
this.setTypeExpected(ind, TypeNames.DATE);
// date_created
ind++;
this.setTypeExpected(ind, TypeNames.DATE);
// date_updated
ind++;
this.setTypeExpected(ind, TypeNames.INT);
// owner_id
ind++;
this.setTypeExpected(ind, TypeNames.INT);
// update_id
ind++;
this.setTypeExpected(ind, TypeNames.STRING);
// secondary_label
ind++;
this.setTypeExpected(ind, TypeNames.STRING);
// studyName
ind++;
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(studyId));
variables.put(new Integer(2), new Integer(studyId));
String sql = null;
if (isLimited) {
sql = digester.getQuery("findAllByStudyIdAndLimit");
} else {
sql = digester.getQuery("findAllByStudyId");
}
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
while (it.hasNext()) {
HashMap hm = (HashMap) it.next();
StudySubjectBean ssb = (StudySubjectBean) this.getEntityFromHashMap(hm);
ssb.setUniqueIdentifier((String) hm.get("unique_identifier"));
ssb.setStudyName((String) hm.get("name"));
// logger.info("gender here:" + hm.get("gender").getClass());
try {
if (hm.get("gender") == null || ((String) hm.get("gender")).equals(" ")) {
logger.debug("here");
ssb.setGender(' ');
} else {
String gender = (String) hm.get("gender");
char[] genderarr = gender.toCharArray();
ssb.setGender(genderarr[0]);
}
} catch (ClassCastException ce) {
// object type is Character
ssb.setGender(' ');
}
answer.add(ssb);
}
return answer;
}
use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.
the class StudySubjectDAO method getCountofStudySubjects.
public Integer getCountofStudySubjects(StudyBean currentStudy) {
StudySubjectBean studySubjectBean = new StudySubjectBean();
setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), currentStudy.getId());
variables.put(new Integer(2), currentStudy.getId());
String sql = digester.getQuery("getCountofStudySubjects");
ArrayList rows = this.select(sql, variables);
Iterator it = rows.iterator();
if (it.hasNext()) {
Integer count = (Integer) ((HashMap) it.next()).get("count");
return count;
} else {
return null;
}
}
Aggregations