use of org.akaza.openclinica.dao.managestudy.StudySubjectDAO in project OpenClinica by OpenClinica.
the class AccountController method updateStudySubjectBean.
private void updateStudySubjectBean(StudySubjectBean sBean) {
ssdao = new StudySubjectDAO(dataSource);
ssdao.update(sBean);
}
use of org.akaza.openclinica.dao.managestudy.StudySubjectDAO in project OpenClinica by OpenClinica.
the class DiscrepancyNoteController method buidDiscrepancyNote.
@RequestMapping(value = "/dnote", method = RequestMethod.POST)
public ResponseEntity buidDiscrepancyNote(@RequestBody HashMap<String, String> map, HttpServletRequest request) throws Exception {
ResourceBundleProvider.updateLocale(new Locale("en_US"));
System.out.println("I'm in EnketoForm DN Rest Method");
org.springframework.http.HttpStatus httpStatus = null;
String se_oid = map.get("EntityID");
String ordinal = map.get("Ordinal");
// start_date , end_date , location
String entityName = map.get("EntityName");
String studySubjectOid = map.get("SS_OID");
String noteType = map.get("NoteType");
String resolutionStatus = map.get("Status");
String assignedUser = map.get("AssignedUser");
String owner = map.get("Owner");
String description = map.get("Description");
String detailedNotes = map.get("DetailedNote");
String dn_id = map.get("DN_Id");
dn_id = dn_id != null ? dn_id.replaceFirst("DN_", "") : dn_id;
UserAccountDAO udao = new UserAccountDAO(dataSource);
StudySubjectDAO ssdao = new StudySubjectDAO(dataSource);
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(dataSource);
StudyEventDAO sedao = new StudyEventDAO(dataSource);
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(dataSource);
UserAccountBean assignedUserBean = (UserAccountBean) udao.findByUserName(assignedUser);
UserAccountBean ownerBean = (UserAccountBean) request.getSession().getAttribute("userBean");
StudySubjectBean ssBean = ssdao.findByOid(studySubjectOid);
StudyEventDefinitionBean sedBean = seddao.findByOid(se_oid);
StudyBean studyBean = getStudy(sedBean.getStudyId());
StudyEventBean seBean = (StudyEventBean) sedao.findByStudySubjectIdAndDefinitionIdAndOrdinal(ssBean.getId(), sedBean.getId(), Integer.valueOf(ordinal));
String entityType = "studyEvent";
DiscrepancyNoteBean parent = (DiscrepancyNoteBean) dndao.findByPK(Integer.valueOf(dn_id));
if (!mayProceed(resolutionStatus, noteType, seBean, entityName, parent, ownerBean)) {
httpStatus = org.springframework.http.HttpStatus.BAD_REQUEST;
return new ResponseEntity(httpStatus);
}
if (!parent.isActive()) {
saveFieldNotes(description, detailedNotes, seBean.getId(), entityType, studyBean, ownerBean, assignedUserBean, resolutionStatus, noteType, entityName);
httpStatus = org.springframework.http.HttpStatus.OK;
} else {
createDiscrepancyNoteBean(description, detailedNotes, seBean.getId(), entityType, studyBean, ownerBean, assignedUserBean, parent.getId(), resolutionStatus, noteType, entityName);
httpStatus = org.springframework.http.HttpStatus.OK;
}
return new ResponseEntity(httpStatus);
}
use of org.akaza.openclinica.dao.managestudy.StudySubjectDAO in project OpenClinica by OpenClinica.
the class AccountController method getStudySubject.
private StudySubjectBean getStudySubject(String label, StudyBean study) {
ssdao = new StudySubjectDAO(dataSource);
StudySubjectBean studySubjectBean = (StudySubjectBean) ssdao.findByLabelAndStudy(label, study);
return studySubjectBean;
}
use of org.akaza.openclinica.dao.managestudy.StudySubjectDAO in project OpenClinica by OpenClinica.
the class DiscrepancyNoteOutputServlet method populateRowsWithAttachedData.
private ArrayList<DiscrepancyNoteBean> populateRowsWithAttachedData(ArrayList<DiscrepancyNoteBean> noteRows) {
Locale l = LocaleResolver.getLocale(request);
resword = ResourceBundleProvider.getWordsBundle(l);
resformat = ResourceBundleProvider.getFormatBundle(l);
SimpleDateFormat sdf = new SimpleDateFormat(resformat.getString("date_format_string"), ResourceBundleProvider.getLocale());
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(sm.getDataSource());
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
ItemDAO idao = new ItemDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
ItemGroupMetadataDAO<String, ArrayList> igmdao = new ItemGroupMetadataDAO<String, ArrayList>(sm.getDataSource());
ItemGroupDAO<String, ArrayList> igdao = new ItemGroupDAO<String, ArrayList>(sm.getDataSource());
ArrayList<DiscrepancyNoteBean> allNotes = new ArrayList<DiscrepancyNoteBean>();
for (int i = 0; i < noteRows.size(); i++) {
DiscrepancyNoteBean dnb = noteRows.get(i);
dnb.setCreatedDateString(dnb.getCreatedDate() == null ? "" : sdf.format(dnb.getCreatedDate()));
if (dnb.getParentDnId() == 0) {
ArrayList children = dndao.findAllByStudyAndParent(currentStudy, dnb.getId());
children = children == null ? new ArrayList() : children;
dnb.setNumChildren(children.size());
dnb.setChildren(children);
int lastDnId = dnb.getId();
int lastChild = 0;
for (int j = 0; j < children.size(); j++) {
DiscrepancyNoteBean child = (DiscrepancyNoteBean) children.get(j);
child.setCreatedDateString(child.getCreatedDate() == null ? "" : sdf.format(child.getCreatedDate()));
child.setUpdatedDateString(child.getCreatedDate() != null ? sdf.format(child.getCreatedDate()) : "");
if (child.getId() > lastDnId) {
lastDnId = child.getId();
lastChild = j;
}
}
if (children.size() > 0) {
DiscrepancyNoteBean lastdn = (DiscrepancyNoteBean) children.get(lastChild);
//dnb.setResStatus(ResolutionStatus.get(lastdn.getResolutionStatusId()));
/*
* The update date is the date created of the latest child
* note
*/
dnb.setUpdatedDate(lastdn.getCreatedDate());
dnb.setUpdatedDateString(dnb.getUpdatedDate() != null ? sdf.format(dnb.getUpdatedDate()) : "");
}
}
String entityType = dnb.getEntityType();
if (dnb.getEntityId() > 0 && !entityType.equals("")) {
AuditableEntityBean aeb = dndao.findEntity(dnb);
dnb.setEntityName(aeb.getName());
if (entityType.equalsIgnoreCase("subject")) {
// allNotes.add(dnb);
SubjectBean sb = (SubjectBean) aeb;
StudySubjectBean ssb = studySubjectDAO.findBySubjectIdAndStudy(sb.getId(), currentStudy);
dnb.setStudySub(ssb);
dnb.setSubjectName(ssb.getLabel());
String column = dnb.getColumn().trim();
if (!StringUtil.isBlank(column)) {
if ("gender".equalsIgnoreCase(column)) {
dnb.setEntityValue(sb.getGender() + "");
dnb.setEntityName(resword.getString("gender"));
} else if ("date_of_birth".equals(column)) {
if (sb.getDateOfBirth() != null) {
dnb.setEntityValue(sb.getDateOfBirth().toString());
}
dnb.setEntityName(resword.getString("date_of_birth"));
} else if ("unique_identifier".equalsIgnoreCase(column)) {
dnb.setEntityName(resword.getString("unique_identifier"));
dnb.setEntityValue(sb.getUniqueIdentifier());
}
}
} else if (entityType.equalsIgnoreCase("studySub")) {
// allNotes.add(dnb);
StudySubjectBean ssb = (StudySubjectBean) aeb;
dnb.setStudySub(ssb);
dnb.setSubjectName(ssb.getLabel());
String column = dnb.getColumn().trim();
if (!StringUtil.isBlank(column)) {
if ("enrollment_date".equals(column)) {
if (ssb.getEnrollmentDate() != null) {
dnb.setEntityValue(ssb.getEnrollmentDate().toString());
}
dnb.setEntityName(resword.getString("enrollment_date"));
}
}
} else if (entityType.equalsIgnoreCase("eventCRF")) {
StudyEventBean se = (StudyEventBean) sedao.findByPK(dnb.getEntityId());
StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
EventCRFBean ecb = (EventCRFBean) aeb;
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(ecb.getCRFVersionId());
CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
dnb.setStageId(ecb.getStage().getId());
dnb.setEntityName(cb.getName() + " (" + cvb.getName() + ")");
StudySubjectBean ssub = (StudySubjectBean) studySubjectDAO.findByPK(ecb.getStudySubjectId());
dnb.setStudySub(ssub);
dnb.setSubjectName(ssub.getLabel());
if (se != null) {
dnb.setEventStart(se.getDateStarted());
dnb.setEventName(se.getName());
}
dnb.setCrfName(cb.getName());
String crfStatus = resword.getString(ecb.getStage().getNameRaw());
if (crfStatus.equals("Invalid")) {
crfStatus = "";
} else if (crfStatus.equals("Data Entry Complete")) {
crfStatus = "Complete";
}
dnb.setCrfStatus(crfStatus);
String column = dnb.getColumn().trim();
if (!StringUtil.isBlank(column)) {
if ("date_interviewed".equals(column)) {
if (ecb.getDateInterviewed() != null) {
dnb.setEntityValue(ecb.getDateInterviewed().toString());
}
dnb.setEntityName(resword.getString("date_interviewed"));
} else if ("interviewer_name".equals(column)) {
dnb.setEntityValue(ecb.getInterviewerName());
dnb.setEntityName(resword.getString("interviewer_name"));
}
}
dnb.setEvent(se);
dnb.setStudyEventDefinitionBean(sedb);
// }
} else if (entityType.equalsIgnoreCase("studyEvent")) {
// allNotes.add(dnb);
StudyEventBean se = (StudyEventBean) sedao.findByPK(dnb.getEntityId());
StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
se.setName(sedb.getName());
dnb.setEntityName(sedb.getName());
StudySubjectBean ssub = (StudySubjectBean) studySubjectDAO.findByPK(se.getStudySubjectId());
dnb.setStudySub(ssub);
dnb.setEventStart(se.getDateStarted());
dnb.setEventName(se.getName());
dnb.setSubjectName(ssub.getLabel());
String column = dnb.getColumn().trim();
if (!StringUtil.isBlank(column)) {
if ("date_start".equals(column)) {
if (se.getDateStarted() != null) {
dnb.setEntityValue(se.getDateStarted().toString());
}
dnb.setEntityName(resword.getString("start_date"));
} else if ("date_end".equals(column)) {
if (se.getDateEnded() != null) {
dnb.setEntityValue(se.getDateEnded().toString());
}
dnb.setEntityName(resword.getString("end_date"));
} else if ("location".equals(column)) {
dnb.setEntityValue(se.getLocation());
dnb.setEntityName(resword.getString("location"));
}
}
dnb.setEvent(se);
dnb.setStudyEventDefinitionBean(sedb);
} else if (entityType.equalsIgnoreCase("itemData")) {
ItemDataBean idb = (ItemDataBean) iddao.findByPK(dnb.getEntityId());
ItemBean ib = (ItemBean) idao.findByPK(idb.getItemId());
EventCRFBean ec = (EventCRFBean) ecdao.findByPK(idb.getEventCRFId());
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(ec.getCRFVersionId());
CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
ItemGroupMetadataBean itemGroupMetadataBean = (ItemGroupMetadataBean) igmdao.findByItemAndCrfVersion(ib.getId(), cvb.getId());
Boolean isRepeatForSure = itemGroupMetadataBean.isRepeatingGroup();
if (isRepeatForSure) {
ItemGroupBean ig = (ItemGroupBean) igdao.findByPK(itemGroupMetadataBean.getItemGroupId());
dnb.setItemDataOrdinal(idb.getOrdinal());
dnb.setItemGroupName(ig.getName());
}
// allNotes.add(dnb);
dnb.setStageId(ec.getStage().getId());
dnb.setEntityName(ib.getName());
dnb.setEntityValue(idb.getValue());
StudyEventBean se = (StudyEventBean) sedao.findByPK(ec.getStudyEventId());
StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
se.setName(sedb.getName());
StudySubjectBean ssub = (StudySubjectBean) studySubjectDAO.findByPK(ec.getStudySubjectId());
dnb.setStudySub(ssub);
dnb.setSubjectName(ssub.getLabel());
dnb.setEventStart(se.getDateStarted());
dnb.setEventName(se.getName());
dnb.setCrfName(cb.getName());
String crfStatus = resword.getString(ec.getStage().getNameRaw());
if (crfStatus.equals("Invalid")) {
crfStatus = "";
} else if (crfStatus.equals("Data Entry Complete")) {
crfStatus = "Complete";
}
dnb.setCrfStatus(crfStatus);
dnb.setEvent(se);
dnb.setStudyEventDefinitionBean(sedb);
}
}
dnb.setStudy((StudyBean) studyDao.findByPK(dnb.getStudyId()));
if (dnb.getParentDnId() == 0 && dnb.getChildren().size() > 0) {
ArrayList<DiscrepancyNoteBean> children = dnb.getChildren();
int childrenSize = children.size();
for (int j = 0; j < childrenSize; j++) {
DiscrepancyNoteBean child = children.get(j);
child.setSubjectName(dnb.getSubjectName());
child.setEventName(dnb.getEventName());
child.setCrfName(dnb.getCrfName());
child.setCrfStatus(dnb.getCrfStatus());
child.setEntityName(dnb.getEntityName());
child.setEntityValue(dnb.getEntityValue());
child.setStudySub(dnb.getStudySub());
child.setStudy(dnb.getStudy());
}
}
allNotes.add(dnb);
}
return allNotes;
}
use of org.akaza.openclinica.dao.managestudy.StudySubjectDAO in project OpenClinica by OpenClinica.
the class SecureController method getNoteInfo.
public DiscrepancyNoteBean getNoteInfo(DiscrepancyNoteBean note) {
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
if ("itemData".equalsIgnoreCase(note.getEntityType())) {
int itemDataId = note.getEntityId();
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
ItemDataBean itemData = (ItemDataBean) iddao.findByPK(itemDataId);
ItemDAO idao = new ItemDAO(sm.getDataSource());
if (StringUtil.isBlank(note.getEntityName())) {
ItemBean item = (ItemBean) idao.findByPK(itemData.getItemId());
note.setEntityName(item.getName());
request.setAttribute("item", item);
}
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(event.getStudyEventDefinitionId());
note.setEventName(sed.getName());
note.setEventStart(event.getDateStarted());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFBean crf = cdao.findByVersionId(ec.getCRFVersionId());
note.setCrfName(crf.getName());
note.setEventCRFId(ec.getId());
if (StringUtil.isBlank(note.getSubjectName())) {
StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(ec.getStudySubjectId());
note.setSubjectName(ss.getName());
}
if (note.getDiscrepancyNoteTypeId() == 0) {
// default
note.setDiscrepancyNoteTypeId(DiscrepancyNoteType.FAILEDVAL.getId());
// value
}
} else if ("eventCrf".equalsIgnoreCase(note.getEntityType())) {
int eventCRFId = note.getEntityId();
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
EventCRFBean ec = (EventCRFBean) ecdao.findByPK(eventCRFId);
StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(event.getStudyEventDefinitionId());
note.setEventName(sed.getName());
note.setEventStart(event.getDateStarted());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFBean crf = cdao.findByVersionId(ec.getCRFVersionId());
note.setCrfName(crf.getName());
StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(ec.getStudySubjectId());
note.setSubjectName(ss.getName());
note.setEventCRFId(ec.getId());
} else if ("studyEvent".equalsIgnoreCase(note.getEntityType())) {
int eventId = note.getEntityId();
StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
StudyEventBean event = (StudyEventBean) svdao.findByPK(eventId);
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(event.getStudyEventDefinitionId());
note.setEventName(sed.getName());
note.setEventStart(event.getDateStarted());
StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(event.getStudySubjectId());
note.setSubjectName(ss.getName());
} else if ("studySub".equalsIgnoreCase(note.getEntityType())) {
int studySubjectId = note.getEntityId();
StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(studySubjectId);
note.setSubjectName(ss.getName());
} else if ("Subject".equalsIgnoreCase(note.getEntityType())) {
int subjectId = note.getEntityId();
StudySubjectBean ss = ssdao.findBySubjectIdAndStudy(subjectId, currentStudy);
note.setSubjectName(ss.getName());
}
return note;
}
Aggregations