Search in sources :

Example 11 with UserAccount

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;
}
Also used : Study(org.akaza.openclinica.domain.datamap.Study) StudyUserRole(org.akaza.openclinica.domain.datamap.StudyUserRole) StudySubject(org.akaza.openclinica.domain.datamap.StudySubject) OdmClinicalDataBean(org.akaza.openclinica.bean.odmbeans.OdmClinicalDataBean) UserAccount(org.akaza.openclinica.domain.user.UserAccount) StudySubjectDao(org.akaza.openclinica.dao.hibernate.StudySubjectDao) LinkedHashMap(java.util.LinkedHashMap)

Example 12 with UserAccount

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;
}
Also used : ArrayList(java.util.ArrayList) DateTime(org.joda.time.DateTime) QueryBean(org.akaza.openclinica.core.form.xform.QueryBean) AuditLogEvent(org.akaza.openclinica.domain.datamap.AuditLogEvent) DiscrepancyNote(org.akaza.openclinica.domain.datamap.DiscrepancyNote) QueriesBean(org.akaza.openclinica.core.form.xform.QueriesBean) LogBean(org.akaza.openclinica.core.form.xform.LogBean) UserAccount(org.akaza.openclinica.domain.user.UserAccount)

Aggregations

UserAccount (org.akaza.openclinica.domain.user.UserAccount)12 Date (java.util.Date)5 StudySubject (org.akaza.openclinica.domain.datamap.StudySubject)5 Study (org.akaza.openclinica.domain.datamap.Study)4 StudyUserRole (org.akaza.openclinica.domain.datamap.StudyUserRole)3 ArrayList (java.util.ArrayList)2 DiscrepancyNote (org.akaza.openclinica.domain.datamap.DiscrepancyNote)2 EventDefinitionCrf (org.akaza.openclinica.domain.datamap.EventDefinitionCrf)2 FormLayout (org.akaza.openclinica.domain.datamap.FormLayout)2 StudyEventDefinition (org.akaza.openclinica.domain.datamap.StudyEventDefinition)2 StudyUserRoleId (org.akaza.openclinica.domain.datamap.StudyUserRoleId)2 Subject (org.akaza.openclinica.domain.datamap.Subject)2 ResponseEntity (org.springframework.http.ResponseEntity)2 StringWriter (java.io.StringWriter)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1