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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations