Search in sources :

Example 1 with StudySubjectDao

use of org.akaza.openclinica.dao.hibernate.StudySubjectDao 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;
    }
    // This piece of code identifies if the study subject is assigned to study level or site level. If the study 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)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)1 OdmClinicalDataBean (org.akaza.openclinica.bean.odmbeans.OdmClinicalDataBean)1 StudySubjectDao (org.akaza.openclinica.dao.hibernate.StudySubjectDao)1 Study (org.akaza.openclinica.domain.datamap.Study)1 StudySubject (org.akaza.openclinica.domain.datamap.StudySubject)1 StudyUserRole (org.akaza.openclinica.domain.datamap.StudyUserRole)1 UserAccount (org.akaza.openclinica.domain.user.UserAccount)1