Search in sources :

Example 96 with StudySubjectBean

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;
    }
}
Also used : StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 97 with StudySubjectBean

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();
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) ParticipantDTO(org.akaza.openclinica.bean.login.ParticipantDTO)

Example 98 with StudySubjectBean

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;
}
Also used : StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean)

Example 99 with StudySubjectBean

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;
}
Also used : HashMap(java.util.HashMap) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 100 with StudySubjectBean

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;
    }
}
Also used : StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Aggregations

StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)155 ArrayList (java.util.ArrayList)102 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)86 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)71 HashMap (java.util.HashMap)66 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)66 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)57 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)52 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)52 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)49 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)45 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)43 Date (java.util.Date)42 Iterator (java.util.Iterator)38 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)35 SubjectBean (org.akaza.openclinica.bean.submit.SubjectBean)29 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)26 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)26 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)26 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)23