Search in sources :

Example 56 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteDAO method create.

/**
     * Creates a new discrepancy note
     */
@Override
public EntityBean create(EntityBean eb) {
    DiscrepancyNoteBean sb = (DiscrepancyNoteBean) eb;
    HashMap variables = new HashMap();
    HashMap nullVars = new HashMap();
    // INSERT INTO discrepancy_note
    // (description, discrepancy_note_type_id ,
    // resolution_status_id , detailed_notes , date_created,
    // owner_id, parent_dn_id)
    // VALUES (?,?,?,?,now(),?,?)
    variables.put(Integer.valueOf(1), sb.getDescription());
    variables.put(Integer.valueOf(2), Integer.valueOf(sb.getDiscrepancyNoteTypeId()));
    variables.put(Integer.valueOf(3), Integer.valueOf(sb.getResolutionStatusId()));
    variables.put(Integer.valueOf(4), sb.getDetailedNotes());
    variables.put(Integer.valueOf(5), Integer.valueOf(sb.getOwner().getId()));
    if (sb.getParentDnId() == 0) {
        nullVars.put(Integer.valueOf(6), Integer.valueOf(Types.INTEGER));
        variables.put(Integer.valueOf(6), null);
    } else {
        variables.put(Integer.valueOf(6), Integer.valueOf(sb.getParentDnId()));
    }
    variables.put(Integer.valueOf(7), sb.getEntityType());
    variables.put(Integer.valueOf(8), Integer.valueOf(sb.getStudyId()));
    if (sb.getAssignedUserId() == 0) {
        nullVars.put(Integer.valueOf(9), Integer.valueOf(Types.INTEGER));
        variables.put(Integer.valueOf(9), null);
    } else {
        variables.put(Integer.valueOf(9), Integer.valueOf(sb.getAssignedUserId()));
    }
    // variables.put(Integer.valueOf(9), Integer.valueOf(sb.getAssignedUserId()));
    this.executeWithPK(digester.getQuery("create"), variables, nullVars);
    if (isQuerySuccessful()) {
        sb.setId(getLatestPK());
    }
    return sb;
}
Also used : HashMap(java.util.HashMap) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)

Example 57 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteDAO method findAllByEntityAndColumn.

public Collection findAllByEntityAndColumn(String entityName, int entityId, String column) {
    this.setTypesExpected();
    // ss.label
    this.setTypeExpected(12, TypeNames.STRING);
    ArrayList alist = new ArrayList();
    HashMap variables = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(entityId));
    variables.put(Integer.valueOf(2), column);
    if ("subject".equalsIgnoreCase(entityName)) {
        alist = this.select(digester.getQuery("findAllBySubjectAndColumn"), variables);
    } else if ("studySub".equalsIgnoreCase(entityName)) {
        alist = this.select(digester.getQuery("findAllByStudySubjectAndColumn"), variables);
    } else if ("eventCrf".equalsIgnoreCase(entityName)) {
        // date_start
        this.setTypeExpected(13, TypeNames.DATE);
        // sed_name
        this.setTypeExpected(14, TypeNames.STRING);
        // crf_name
        this.setTypeExpected(15, TypeNames.STRING);
        alist = this.select(digester.getQuery("findAllByEventCRFAndColumn"), variables);
    } else if ("studyEvent".equalsIgnoreCase(entityName)) {
        // date_start
        this.setTypeExpected(13, TypeNames.DATE);
        // sed_name
        this.setTypeExpected(14, TypeNames.STRING);
        alist = this.select(digester.getQuery("findAllByStudyEventAndColumn"), variables);
    } else if ("itemData".equalsIgnoreCase(entityName)) {
        // date_start
        this.setTypeExpected(13, TypeNames.DATE);
        // sed_name
        this.setTypeExpected(14, TypeNames.STRING);
        // crf_name
        this.setTypeExpected(15, TypeNames.STRING);
        // item_name
        this.setTypeExpected(16, TypeNames.STRING);
        alist = this.select(digester.getQuery("findAllByItemDataAndColumn"), variables);
    }
    ArrayList al = new ArrayList();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        HashMap hm = (HashMap) it.next();
        DiscrepancyNoteBean eb = (DiscrepancyNoteBean) this.getEntityFromHashMap(hm);
        eb.setSubjectName((String) hm.get("label"));
        if ("eventCrf".equalsIgnoreCase(entityName) || "itemData".equalsIgnoreCase(entityName)) {
            eb.setEventName((String) hm.get("sed_name"));
            eb.setEventStart((Date) hm.get("date_start"));
            eb.setCrfName((String) hm.get("crf_name"));
            eb.setEntityName((String) hm.get("item_name"));
        } else if ("studyEvent".equalsIgnoreCase(entityName)) {
            eb.setEventName((String) hm.get("sed_name"));
            eb.setEventStart((Date) hm.get("date_start"));
        }
        if (fetchMapping) {
            eb = findSingleMapping(eb);
        }
        al.add(eb);
    }
    return al;
}
Also used : HashMap(java.util.HashMap) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Date(java.util.Date)

Example 58 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteDAO method getEntityFromHashMap.

/**
     * <p>
     * getEntityFromHashMap, the method that gets the object from the database query.
     */
@Override
public Object getEntityFromHashMap(HashMap hm) {
    DiscrepancyNoteBean eb = new DiscrepancyNoteBean();
    Date dateCreated = (Date) hm.get("date_created");
    Integer ownerId = (Integer) hm.get("owner_id");
    eb.setCreatedDate(dateCreated);
    eb.setOwnerId(ownerId.intValue());
    // discrepancy_note_id serial NOT NULL,
    // description varchar(255),
    // discrepancy_note_type_id numeric,
    // resolution_status_id numeric,
    // detailed_notes varchar(1000),
    // date_created date,
    // owner_id numeric,
    // parent_dn_id numeric,
    eb.setId(selectInt(hm, "discrepancy_note_id"));
    eb.setDescription((String) hm.get("description"));
    eb.setDiscrepancyNoteTypeId(((Integer) hm.get("discrepancy_note_type_id")).intValue());
    eb.setResolutionStatusId(((Integer) hm.get("resolution_status_id")).intValue());
    eb.setParentDnId(((Integer) hm.get("parent_dn_id")).intValue());
    eb.setDetailedNotes((String) hm.get("detailed_notes"));
    eb.setEntityType((String) hm.get("entity_type"));
    eb.setDisType(DiscrepancyNoteType.get(eb.getDiscrepancyNoteTypeId()));
    eb.setResStatus(ResolutionStatus.get(eb.getResolutionStatusId()));
    eb.setStudyId(selectInt(hm, "study_id"));
    eb.setAssignedUserId(selectInt(hm, "assigned_user_id"));
    if (eb.getAssignedUserId() > 0) {
        UserAccountDAO userAccountDAO = new UserAccountDAO(ds);
        UserAccountBean assignedUser = (UserAccountBean) userAccountDAO.findByPK(eb.getAssignedUserId());
        eb.setAssignedUser(assignedUser);
    }
    eb.setAge(selectInt(hm, "age"));
    eb.setDays(selectInt(hm, "days"));
    return eb;
}
Also used : DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Date(java.util.Date)

Example 59 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteDAO method findAllStudySubjectByStudy.

public ArrayList findAllStudySubjectByStudy(StudyBean study) {
    this.setTypesExpected();
    ArrayList alist = new ArrayList();
    // ss.label
    this.setTypeExpected(12, TypeNames.STRING);
    // column_name
    this.setTypeExpected(13, TypeNames.STRING);
    // study_subject_id
    this.setTypeExpected(14, TypeNames.INT);
    HashMap variables = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(study.getId()));
    variables.put(Integer.valueOf(2), Integer.valueOf(study.getId()));
    alist = this.select(digester.getQuery("findAllStudySubjectByStudy"), variables);
    ArrayList al = new ArrayList();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        HashMap hm = (HashMap) it.next();
        DiscrepancyNoteBean eb = (DiscrepancyNoteBean) this.getEntityFromHashMap(hm);
        eb.setSubjectName((String) hm.get("label"));
        eb.setColumn((String) hm.get("column_name"));
        eb.setEntityId(((Integer) hm.get("study_subject_id")).intValue());
        al.add(eb);
    }
    return al;
}
Also used : HashMap(java.util.HashMap) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 60 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteDAO method findAllStudyEventByStudy.

public ArrayList findAllStudyEventByStudy(StudyBean study) {
    this.setTypesExpected();
    ArrayList alist = new ArrayList();
    // ss.label
    this.setTypeExpected(12, TypeNames.STRING);
    // date_start
    this.setTypeExpected(13, TypeNames.DATE);
    // sed_name
    this.setTypeExpected(14, TypeNames.STRING);
    // column_name
    this.setTypeExpected(15, TypeNames.STRING);
    // study_event_id
    this.setTypeExpected(16, TypeNames.INT);
    HashMap variables = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(study.getId()));
    variables.put(Integer.valueOf(2), Integer.valueOf(study.getId()));
    alist = this.select(digester.getQuery("findAllStudyEventByStudy"), variables);
    ArrayList al = new ArrayList();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        HashMap hm = (HashMap) it.next();
        DiscrepancyNoteBean eb = (DiscrepancyNoteBean) this.getEntityFromHashMap(hm);
        eb.setSubjectName((String) hm.get("label"));
        eb.setEventName((String) hm.get("sed_name"));
        eb.setEventStart((Date) hm.get("date_start"));
        eb.setColumn((String) hm.get("column_name"));
        eb.setEntityId(((Integer) hm.get("study_event_id")).intValue());
        al.add(eb);
    }
    return al;
}
Also used : HashMap(java.util.HashMap) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Aggregations

DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)122 ArrayList (java.util.ArrayList)81 HashMap (java.util.HashMap)62 Iterator (java.util.Iterator)44 DiscrepancyNoteDAO (org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO)34 Date (java.util.Date)20 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)20 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)20 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)20 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)18 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)18 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)15 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)14 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)14 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)13 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)11 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)11 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)11 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)10 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)10