Search in sources :

Example 66 with StudyBean

use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.

the class EditFormController method fetchEditUrl.

private String fetchEditUrl(String studyOID, CRFVersionBean crfVersion, int studyEventDefinitionId) throws Exception {
    StudyBean parentStudyBean = getParentStudy(studyOID);
    PFormCache cache = PFormCache.getInstance(context);
    String enketoURL = cache.getPFormURL(parentStudyBean.getOid(), crfVersion.getOid());
    String contextHash = cache.putAnonymousFormContext(studyOID, crfVersion.getOid(), studyEventDefinitionId);
    String url = enketoURL + "&" + FORM_CONTEXT + "=" + contextHash;
    logger.debug("Enketo URL for " + crfVersion.getName() + "= " + url);
    return url;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) PFormCache(org.akaza.openclinica.web.pform.PFormCache)

Example 67 with StudyBean

use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.

the class EditFormController method getStudy.

private StudyBean getStudy(Integer id) {
    sdao = new StudyDAO(dataSource);
    StudyBean studyBean = (StudyBean) sdao.findByPK(id);
    return studyBean;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 68 with StudyBean

use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.

the class IdtViewController method getStudy.

private StudyBean getStudy(Integer id) {
    sdao = new StudyDAO(dataSource);
    StudyBean studyBean = (StudyBean) sdao.findByPK(id);
    return studyBean;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 69 with StudyBean

use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.

the class IdtViewController method getStudy.

private StudyBean getStudy(String oid) {
    sdao = new StudyDAO(dataSource);
    StudyBean studyBean = (StudyBean) sdao.findByOid(oid);
    return studyBean;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 70 with StudyBean

use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.

the class OdmController method getODM.

private ODM getODM(String studyOID, String subjectKey) {
    ODM odm = new ODM();
    String ssoid = subjectKey;
    if (ssoid == null) {
        return null;
    }
    CRFVersionDAO versionDAO = new CRFVersionDAO(dataSource);
    StudyDAO studyDAO = new StudyDAO(dataSource);
    StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
    EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
    ItemDataDAO itemDataDAO = new ItemDataDAO(dataSource);
    CRFDAO crfDAO = new CRFDAO(dataSource);
    List<ODMcomplexTypeDefinitionFormData> formDatas = new ArrayList<>();
    try {
        // Retrieve crfs for next event
        StudySubjectBean studySubjectBean = studySubjectDAO.findByOid(ssoid);
        ParticipantEventService participantEventService = new ParticipantEventService(dataSource);
        StudyEventBean nextEvent = participantEventService.getNextParticipantEvent(studySubjectBean);
        if (nextEvent != null) {
            logger.debug("Found event: " + nextEvent.getName() + " - ID: " + nextEvent.getId());
            List<EventCRFBean> eventCrfs = eventCRFDAO.findAllByStudyEvent(nextEvent);
            StudyBean study = studyDAO.findByOid(studyOID);
            if (!mayProceed(studyOID, studySubjectBean))
                return odm;
            List<EventDefinitionCRFBean> eventDefCrfs = participantEventService.getEventDefCrfsForStudyEvent(studySubjectBean, nextEvent);
            for (EventDefinitionCRFBean eventDefCrf : eventDefCrfs) {
                if (eventDefCrf.isParticipantForm()) {
                    EventCRFBean eventCRF = participantEventService.getExistingEventCRF(studySubjectBean, nextEvent, eventDefCrf);
                    boolean itemDataExists = false;
                    boolean validStatus = true;
                    CRFVersionBean crfVersion = null;
                    if (eventCRF != null) {
                        if (eventCRF.getStatus().getId() != 1 && eventCRF.getStatus().getId() != 2)
                            validStatus = false;
                        if (itemDataDAO.findAllByEventCRFId(eventCRF.getId()).size() > 0)
                            itemDataExists = true;
                        crfVersion = (CRFVersionBean) versionDAO.findByPK(eventCRF.getCRFVersionId());
                    } else
                        crfVersion = (CRFVersionBean) versionDAO.findByPK(eventDefCrf.getDefaultVersionId());
                    if (validStatus) {
                        String formUrl = null;
                        if (!itemDataExists)
                            formUrl = createEnketoUrl(studyOID, crfVersion, nextEvent, ssoid);
                        else
                            formUrl = createEditUrl(studyOID, crfVersion, nextEvent, ssoid);
                        formDatas.add(getFormDataPerCrf(crfVersion, nextEvent, eventCrfs, crfDAO, formUrl, itemDataExists));
                    }
                }
            }
            return createOdm(study, studySubjectBean, nextEvent, formDatas);
        } else {
            logger.debug("Unable to find next event for subject.");
        }
    } catch (Exception e) {
        logger.error(e.getMessage());
        logger.error(ExceptionUtils.getStackTrace(e));
    }
    return odm;
}
Also used : EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) ParticipantEventService(org.akaza.openclinica.service.ParticipantEventService) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) ODMcomplexTypeDefinitionFormData(org.cdisc.ns.odm.v130_api.ODMcomplexTypeDefinitionFormData) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) ODM(org.cdisc.ns.odm.v130_api.ODM) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Aggregations

StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)366 ArrayList (java.util.ArrayList)185 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)184 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)92 HashMap (java.util.HashMap)85 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)68 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)65 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)62 Date (java.util.Date)61 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)59 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)58 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)57 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)56 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)52 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)52 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)45 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)42 Locale (java.util.Locale)41 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)41 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)38