Search in sources :

Example 16 with SubjectBean

use of org.akaza.openclinica.bean.submit.SubjectBean in project OpenClinica by OpenClinica.

the class SubjectDAO method create.

/**
 * @deprecated Creates a new subject
 */
@Deprecated
public EntityBean create(EntityBean eb) {
    SubjectBean sb = (SubjectBean) eb;
    HashMap variables = new HashMap();
    HashMap nullVars = new HashMap();
    // FATHER_ID,MOTHER_ID, STATUS_ID,
    // DATE_OF_BIRTH,GENDER,UNIQUE_IDENTIFIER,DATE_CREATED,
    // OWNER_ID
    variables.put(new Integer(1), new Integer(sb.getStatus().getId()));
    if (sb.getDateOfBirth() == null) {
        nullVars.put(new Integer(4), new Integer(Types.DATE));
        variables.put(new Integer(4), null);
    } else {
        variables.put(new Integer(4), sb.getDateOfBirth());
    }
    if (sb.getGender() != 'm' && sb.getGender() != 'f') {
        nullVars.put(new Integer(5), new Integer(Types.CHAR));
        variables.put(new Integer(5), null);
    } else {
        char[] ch = { sb.getGender() };
        variables.put(new Integer(5), new String(ch));
    }
    variables.put(new Integer(6), sb.getUniqueIdentifier());
    // DATE_CREATED is now()
    variables.put(new Integer(7), new Integer(sb.getOwner().getId()));
    execute(digester.getQuery("create"), variables, nullVars);
    if (isQuerySuccessful()) {
        sb.setId(getCurrentPK());
    }
    return sb;
}
Also used : SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) HashMap(java.util.HashMap)

Example 17 with SubjectBean

use of org.akaza.openclinica.bean.submit.SubjectBean in project OpenClinica by OpenClinica.

the class SubjectDAO method findByUniqueIdentifierAndStudy.

public SubjectBean findByUniqueIdentifierAndStudy(String uniqueIdentifier, int studyId) {
    SubjectBean answer = new SubjectBean();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(new Integer(1), uniqueIdentifier);
    variables.put(new Integer(2), new Integer(studyId));
    String sql = digester.getQuery("findByUniqueIdentifierAndStudy");
    ArrayList alist = this.select(sql, variables);
    Iterator it = alist.iterator();
    if (it.hasNext()) {
        answer = (SubjectBean) this.getEntityFromHashMap((HashMap) it.next());
    }
    return answer;
}
Also used : SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 18 with SubjectBean

use of org.akaza.openclinica.bean.submit.SubjectBean in project OpenClinica by OpenClinica.

the class SubjectDAO method update.

/**
 * <b>update </b>, the method that returns an updated subject bean after it
 * updates the database.
 *
 * @return sb, an updated study bean.
 */
public EntityBean update(EntityBean eb) {
    SubjectBean sb = (SubjectBean) eb;
    HashMap variables = new HashMap();
    HashMap nullVars = new HashMap();
    // UPDATE subject SET FATHER_ID=?,MOTHER_ID=?, STATUS_ID=?,
    // DATE_OF_BIRTH=?,GENDER=?,UNIQUE_IDENTIFIER=?, DATE_UPDATED=?,
    // UPDATE_ID=? DOB_COLLECTED=? WHERE SUBJECT_ID=?
    // YW <<
    int ind = 1;
    variables.put(new Integer(ind++), new Integer(sb.getStatus().getId()));
    if (sb.getDateOfBirth() != null) {
        variables.put(new Integer(ind), sb.getDateOfBirth());
    } else {
        nullVars.put(new Integer(ind), new Integer(Types.DATE));
        variables.put(new Integer(ind), null);
    }
    ind++;
    if (sb.getGender() != 'm' && sb.getGender() != 'f') {
        nullVars.put(new Integer(ind), new Integer(Types.CHAR));
        variables.put(new Integer(ind), null);
    } else {
        char[] ch = { sb.getGender() };
        variables.put(new Integer(ind), new String(ch));
    }
    ind++;
    variables.put(new Integer(ind++), new String(sb.getUniqueIdentifier()));
    // date_updated is set to now()
    // variables.put(new Integer(ind++), new java.util.Date());
    variables.put(new Integer(ind++), new Integer(sb.getUpdater().getId()));
    variables.put(new Integer(ind++), new Boolean(sb.isDobCollected()));
    // YW >>
    variables.put(new Integer(ind++), new Integer(sb.getId()));
    String sql = digester.getQuery("update");
    this.execute(sql, variables, nullVars);
    return sb;
}
Also used : SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) HashMap(java.util.HashMap)

Example 19 with SubjectBean

use of org.akaza.openclinica.bean.submit.SubjectBean in project OpenClinica by OpenClinica.

the class SubjectDAO method findAllByLimit.

public Collection findAllByLimit(boolean hasLimit) {
    this.setTypesExpected();
    ArrayList alist = null;
    if (hasLimit) {
        alist = this.select(digester.getQuery("findAllByLimit"));
    } else {
        alist = this.select(digester.getQuery("findAll"));
    }
    ArrayList al = new ArrayList();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        SubjectBean eb = (SubjectBean) this.getEntityFromHashMap((HashMap) it.next());
        al.add(eb);
    }
    return al;
}
Also used : SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 20 with SubjectBean

use of org.akaza.openclinica.bean.submit.SubjectBean in project OpenClinica by OpenClinica.

the class SubjectDAO method findAnotherByIdentifier.

public EntityBean findAnotherByIdentifier(String name, int subjectId) {
    SubjectBean eb = new SubjectBean();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(new Integer(1), name);
    variables.put(new Integer(2), new Integer(subjectId));
    String sql = digester.getQuery("findAnotherByIdentifier");
    ArrayList alist = this.select(sql, variables);
    Iterator it = alist.iterator();
    if (it.hasNext()) {
        eb = (SubjectBean) this.getEntityFromHashMap((HashMap) it.next());
    }
    return eb;
}
Also used : SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Aggregations

SubjectBean (org.akaza.openclinica.bean.submit.SubjectBean)50 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)44 ArrayList (java.util.ArrayList)37 HashMap (java.util.HashMap)26 SubjectDAO (org.akaza.openclinica.dao.submit.SubjectDAO)25 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)23 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)22 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)22 Date (java.util.Date)21 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)21 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)19 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)19 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)18 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)15 Iterator (java.util.Iterator)14 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)13 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)11 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)10 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)10 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)9