use of org.akaza.openclinica.domain.user.UserAccount in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method getClinicalData.
/**
* This is a generic method where the control enters first. Regardless what URL is being used. Depending upon the
* combination of URL parameters, further course is determined.
*/
@Override
public LinkedHashMap<String, OdmClinicalDataBean> getClinicalData(String studyOID, String studySubjectOID, String studyEventOID, String formVersionOID, Boolean collectDNs, Boolean collectAudit, Locale locale, int userId) {
setLocale(locale);
setCollectDns(collectDNs);
setCollectAudits(collectAudit);
LinkedHashMap<String, OdmClinicalDataBean> clinicalDataHash = new LinkedHashMap<String, OdmClinicalDataBean>();
UserAccount userAccount = getUserAccountDao().findByColumnName(userId, "userId");
LOGGER.debug("Entering the URL with " + studyOID + ":" + studySubjectOID + ":" + studyEventOID + ":" + formVersionOID + ":DNS:" + collectDNs + ":Audits:" + collectAudit);
LOGGER.info("Determining the generic paramters...");
Study study = getStudyDao().findByOcOID(studyOID);
int parentStudyId = 0;
int studyId = study.getStudyId();
if (study.getStudy() != null) {
isActiveRoleAtSite = true;
parentStudyId = study.getStudy().getStudyId();
} else {
parentStudyId = studyId;
isActiveRoleAtSite = false;
}
ArrayList<StudyUserRole> surlist = getStudyUserRoleDao().findAllUserRolesByUserAccount(userAccount, studyId, parentStudyId);
if (surlist == null || surlist.size() == 0) {
// Does not have permission to view study or site info / return null
return null;
}
// subject assigned to site is pulled from study level this will get the site OID correctly displayed.
if (!studySubjectOID.equals(INDICATE_ALL)) {
StudySubjectDao ssdao = getStudySubjectDao();
StudySubject ss = (StudySubject) getStudySubjectDao().findByColumnName(studySubjectOID, "ocOid");
studyOID = ss.getStudy().getOc_oid();
}
if (studyEventOID.equals(INDICATE_ALL) && formVersionOID.equals(INDICATE_ALL) && !studySubjectOID.equals(INDICATE_ALL) && !studyOID.equals(INDICATE_ALL)) {
LOGGER.info("Adding all the study events,formevents as it is a *");
LOGGER.info("study subject is not all and so is study");
clinicalDataHash.put(studyOID, getClinicalData(studyOID, studySubjectOID));
return clinicalDataHash;
} else if (studyEventOID.equals(INDICATE_ALL) && formVersionOID.equals(INDICATE_ALL) && studySubjectOID.equals(INDICATE_ALL) && !studyOID.equals(INDICATE_ALL)) {
LOGGER.info("At the study level.. study event,study subject and forms are *");
return getClinicalData(studyOID);
} else if (!studyEventOID.equals(INDICATE_ALL) && !studySubjectOID.equals(INDICATE_ALL) && !studyOID.equals(INDICATE_ALL) && formVersionOID.equals(INDICATE_ALL)) {
LOGGER.info("Obtaining the form version specific");
clinicalDataHash.put(studyOID, getClinicalDatas(studyOID, studySubjectOID, studyEventOID, null));
return clinicalDataHash;
} else if (!studyEventOID.equals(INDICATE_ALL) && !studySubjectOID.equals(INDICATE_ALL) && !studyOID.equals(INDICATE_ALL) && !formVersionOID.equals(INDICATE_ALL)) {
clinicalDataHash.put(studyOID, getClinicalDatas(studyOID, studySubjectOID, studyEventOID, formVersionOID));
return clinicalDataHash;
}
return null;
}
use of org.akaza.openclinica.domain.user.UserAccount in project OpenClinica by OpenClinica.
the class EnketoUrlService method buildQueryElement.
public QueriesBean buildQueryElement(ItemData itemdata) {
QueriesBean queryElement = new QueriesBean();
List<QueryBean> queryBeans = new ArrayList<>();
List<LogBean> logBeans = new ArrayList<LogBean>();
List<DiscrepancyNote> dns = discrepancyNoteDao.findChildQueriesByItemData(itemdata.getItemDataId());
int i = 0;
for (DiscrepancyNote dn : dns) {
i++;
QueryBean query = new QueryBean();
query.setId(String.valueOf(i));
query.setAssigned_to(dn.getUserAccountByOwnerId().getUserName());
query.setComment(escapedValue(dn.getDetailedNotes()));
query.setStatus(dn.getResolutionStatus().getName().toLowerCase());
DateTime dateTime = new DateTime(dn.getDateCreated());
query.setDate_time(convertDateFormat(dateTime));
query.setNotify(false);
query.setUser(dn.getUserAccountByOwnerId().getUserName());
query.setType(COMMENT);
queryBeans.add(query);
}
AuditLogEvent auditLog = new AuditLogEvent();
auditLog.setEntityId(new Integer(itemdata.getItemDataId()));
auditLog.setAuditTable(ITEMDATA);
ArrayList<AuditLogEvent> auditLogEvents = auditLogEventDao.findByParam(auditLog, null);
for (AuditLogEvent audit : auditLogEvents) {
LogBean logBean = new LogBean();
String oldValue = audit.getOldValue() != null ? audit.getOldValue() : "";
String newValue = audit.getNewValue() != null ? audit.getNewValue() : "";
logBean.setMessage("Value Changed from \"" + escapedValue(oldValue) + "\" to \"" + escapedValue(newValue) + "\"");
DateTime dateTime = new DateTime(audit.getAuditDate());
logBean.setDate_time(convertDateFormat(dateTime));
UserAccount uAccount = userAccountDao.findById(audit.getUserAccount().getUserId());
logBean.setUser(uAccount.getUserName());
logBean.setAssigned_to(uAccount.getUserName());
logBean.setType(AUDIT);
logBeans.add(logBean);
}
queryElement.setQueries(queryBeans);
queryElement.setLogs(logBeans);
if (queryElement.getQueries().size() != 0 || queryElement.getLogs().size() != 0)
return queryElement;
else
return null;
}
Aggregations