Search in sources :

Example 16 with FormLayoutBean

use of org.akaza.openclinica.bean.submit.FormLayoutBean in project OpenClinica by OpenClinica.

the class ListEventsForSubjectTableFactory method getEventDefinitionCRFBean.

private EventDefinitionCRFBean getEventDefinitionCRFBean(Integer studyEventDefinitionId, CRFBean crfBean, StudySubjectBean studySubject) {
    EventDefinitionCRFBean eventDefinitionCrf = getEventDefintionCRFDAO().findByStudyEventDefinitionIdAndCRFIdAndStudyId(studyEventDefinitionId, crfBean.getId(), studySubject.getStudyId());
    if (eventDefinitionCrf.getId() == 0) {
        eventDefinitionCrf = getEventDefintionCRFDAO().findForStudyByStudyEventDefinitionIdAndCRFId(studyEventDefinitionId, crfBean.getId());
    }
    FormLayoutBean defaultVersion = (FormLayoutBean) getFormLayoutDAO().findByPK(eventDefinitionCrf.getDefaultVersionId());
    eventDefinitionCrf.setDefaultCRF(defaultVersion);
    return eventDefinitionCrf;
}
Also used : FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 17 with FormLayoutBean

use of org.akaza.openclinica.bean.submit.FormLayoutBean in project OpenClinica by OpenClinica.

the class InitUpdateSubStudyServlet method createEventDefinitions.

private void createEventDefinitions(StudyBean parentStudy) throws MalformedURLException {
    FormProcessor fp = new FormProcessor(request);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    int siteId = Integer.valueOf(request.getParameter("id").trim());
    ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
    StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    // CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    seds = sedDao.findAllByStudy(parentStudy);
    int start = 0;
    for (StudyEventDefinitionBean sed : seds) {
        String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
        if (participateFormStatus.equals("enabled"))
            baseUrl();
        request.setAttribute("participateFormStatus", participateFormStatus);
        int defId = sed.getId();
        ArrayList<EventDefinitionCRFBean> edcs = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllByDefinitionAndSiteIdAndParentStudyId(defId, siteId, parentStudy.getId());
        ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>();
        // sed.setCrfNum(edcs.size());
        for (EventDefinitionCRFBean edcBean : edcs) {
            CRFBean cBean = (CRFBean) cdao.findByPK(edcBean.getCrfId());
            String crfPath = sed.getOid() + "." + cBean.getOid();
            edcBean.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
            int edcStatusId = edcBean.getStatus().getId();
            CRFBean crf = (CRFBean) cdao.findByPK(edcBean.getCrfId());
            int crfStatusId = crf.getStatusId();
            if (edcStatusId == 5 || edcStatusId == 7 || crfStatusId == 5 || crfStatusId == 7) {
            } else {
                // ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>)
                // cvdao.findAllActiveByCRF(edcBean.getCrfId());
                ArrayList<FormLayoutBean> versions = (ArrayList<FormLayoutBean>) fldao.findAllActiveByCRF(edcBean.getCrfId());
                edcBean.setVersions(versions);
                edcBean.setCrfName(crf.getName());
                if (edcBean.getParentId() == 0)
                    edcBean.setSubmissionUrl("");
                // CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edcBean.getDefaultVersionId());
                FormLayoutBean defaultVersion = (FormLayoutBean) fldao.findByPK(edcBean.getDefaultVersionId());
                edcBean.setDefaultVersionName(defaultVersion.getName());
                String sversionIds = edcBean.getSelectedVersionIds();
                ArrayList<Integer> idList = new ArrayList<Integer>();
                if (sversionIds.length() > 0) {
                    String[] ids = sversionIds.split("\\,");
                    for (String id : ids) {
                        idList.add(Integer.valueOf(id));
                    }
                }
                edcBean.setSelectedVersionIdList(idList);
                defCrfs.add(edcBean);
                ++start;
            }
        }
        logger.debug("definitionCrfs size=" + defCrfs.size() + " total size=" + edcs.size());
        sed.setCrfs(defCrfs);
        sed.setCrfNum(defCrfs.size());
    }
    // not sure if request is better, since not sure if there is another
    // process using this.
    session.setAttribute("definitions", seds);
    session.setAttribute("sdvOptions", this.setSDVOptions());
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 18 with FormLayoutBean

use of org.akaza.openclinica.bean.submit.FormLayoutBean in project OpenClinica by OpenClinica.

the class EnterDataForStudyEventServlet method populateUncompletedCRFsWithCRFAndVersions.

private void populateUncompletedCRFsWithCRFAndVersions(ArrayList uncompletedEventDefinitionCRFs) {
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
    int size = uncompletedEventDefinitionCRFs.size();
    for (int i = 0; i < size; i++) {
        DisplayEventDefinitionCRFBean dedcrf = (DisplayEventDefinitionCRFBean) uncompletedEventDefinitionCRFs.get(i);
        CRFBean cb = (CRFBean) cdao.findByPK(dedcrf.getEdc().getCrfId());
        // check it here, tbh 102007
        if (cb.getStatus().equals(Status.AVAILABLE)) {
            // the above does not allow us to show the CRF as a thing with
            // status of 'invalid' so we have to
            // go to the JSP for this one, I think
            dedcrf.getEdc().setCrf(cb);
            ArrayList theVersions = (ArrayList) fldao.findAllActiveByCRF(dedcrf.getEdc().getCrfId());
            ArrayList versions = new ArrayList();
            HashMap<String, FormLayoutBean> crfVersionIds = new HashMap<String, FormLayoutBean>();
            for (int j = 0; j < theVersions.size(); j++) {
                FormLayoutBean crfVersion = (FormLayoutBean) theVersions.get(j);
                crfVersionIds.put(String.valueOf(crfVersion.getId()), crfVersion);
            }
            if (!dedcrf.getEdc().getSelectedVersionIds().equals("")) {
                String[] kk = dedcrf.getEdc().getSelectedVersionIds().split(",");
                for (String string : kk) {
                    if (crfVersionIds.get(string) != null) {
                        versions.add(crfVersionIds.get(string));
                    }
                }
            } else {
                versions = theVersions;
            }
            dedcrf.getEdc().setVersions(versions);
            // added tbh 092007, fix for 1461
            if (versions != null && versions.size() != 0) {
                boolean isLocked = false;
                for (int ii = 0; ii < versions.size(); ii++) {
                    FormLayoutBean crfvb = (FormLayoutBean) versions.get(ii);
                    logger.debug("...checking versions..." + crfvb.getName());
                    if (!crfvb.getStatus().equals(Status.AVAILABLE)) {
                        logger.debug("found a non active crf version");
                        isLocked = true;
                    }
                }
                logger.debug("re-set event def, line 240: " + isLocked);
                if (isLocked) {
                    dedcrf.setStatus(Status.LOCKED);
                    dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
                }
                uncompletedEventDefinitionCRFs.set(i, dedcrf);
            } else {
                // above added 092007, tbh
                dedcrf.setStatus(Status.LOCKED);
                dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
                uncompletedEventDefinitionCRFs.set(i, dedcrf);
            }
        // added 102007, tbh
        } else {
            dedcrf.getEdc().setCrf(cb);
            logger.debug("_found a non active crf _");
            dedcrf.setStatus(Status.LOCKED);
            dedcrf.getEventCRF().setStage(DataEntryStage.LOCKED);
            dedcrf.getEdc().getCrf().setStatus(Status.LOCKED);
            uncompletedEventDefinitionCRFs.set(i, dedcrf);
        }
    // enclosing if statement added 102007, tbh
    }
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) HashMap(java.util.HashMap) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 19 with FormLayoutBean

use of org.akaza.openclinica.bean.submit.FormLayoutBean 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;
    }
    FormLayoutDAO formLayoutDAO = new FormLayoutDAO(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;
                    FormLayoutBean formLayout = null;
                    if (eventCRF != null) {
                        if (eventCRF.getStatus().getId() != 1 && eventCRF.getStatus().getId() != 2)
                            validStatus = false;
                        if (itemDataDAO.findAllByEventCRFId(eventCRF.getId()).size() > 0)
                            itemDataExists = true;
                        formLayout = (FormLayoutBean) formLayoutDAO.findByPK(eventCRF.getFormLayoutId());
                    } else
                        formLayout = (FormLayoutBean) formLayoutDAO.findByPK(eventDefCrf.getDefaultVersionId());
                    if (validStatus) {
                        String formUrl = null;
                        if (!itemDataExists)
                            formUrl = createEnketoUrl(studyOID, formLayout, nextEvent, ssoid);
                        else
                            formUrl = createEditUrl(studyOID, formLayout, nextEvent, ssoid);
                        formDatas.add(getFormDataPerCrf(formLayout, 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) ParticipantEventService(org.akaza.openclinica.service.ParticipantEventService) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) 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.ODMcomplexTypeDefinitionFormData) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) ODM(org.cdisc.ns.odm.v130.ODM) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 20 with FormLayoutBean

use of org.akaza.openclinica.bean.submit.FormLayoutBean in project OpenClinica by OpenClinica.

the class AnonymousFormControllerV2 method getEnketoForm.

/**
     * @api {post} /pages/api/v2/anonymousform/form Retrieve anonymous form URL
     * @apiName getEnketoForm
     * @apiPermission Module participate - enabled
     * @apiVersion 3.8.0
     * @apiParam {String} studyOid Study Oid
     * @apiParam {String} submissionUri Submission Url
     * @apiGroup Form
     * @apiDescription Retrieve anonymous form url.
     * @apiParamExample {json} Request-Example:
     *                  {
     *                  "studyOid": "S_BL101",
     *                  "submissionUri": "abcde"
     *                  }
     * @apiSuccessExample {json} Success-Response:
     *                    HTTP/1.1 200 OK
     *                    {
     *                    "url":
     *                    "http://localhost:8006/::YYYi?iframe=true&ecid=abb764d026830e98b895ece6d9dcaf3c5e817983cc00a4ebfaabcb6c3700b4d5",
     *                    "offline": "false"
     *                    }
     */
@RequestMapping(value = "/form", method = RequestMethod.POST)
public ResponseEntity<AnonymousUrlResponse> getEnketoForm(@RequestBody HashMap<String, String> map) throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    EventDefinitionCrfTagService tagService = (EventDefinitionCrfTagService) SpringServletAccess.getApplicationContext(context).getBean("eventDefinitionCrfTagService");
    String formUrl = null;
    String studyOid = map.get("studyOid");
    if (!mayProceed(studyOid))
        return new ResponseEntity<AnonymousUrlResponse>(org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    String submissionUri = map.get("submissionUri");
    if (submissionUri != "" && submissionUri != null) {
        StudyBean study = getStudy(studyOid);
        EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(dataSource);
        ArrayList<EventDefinitionCRFBean> edcBeans = edcdao.findAllSubmissionUriAndStudyId(submissionUri, study.getId());
        if (edcBeans.size() != 0) {
            EventDefinitionCRFBean edcBean = edcBeans.get(0);
            CRFDAO crfdao = new CRFDAO(dataSource);
            FormLayoutDAO fldao = new FormLayoutDAO(dataSource);
            StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(dataSource);
            FormLayoutBean formLayout = (FormLayoutBean) fldao.findByPK(edcBean.getDefaultVersionId());
            CRFBean crf = (CRFBean) crfdao.findByPK(formLayout.getCrfId());
            StudyBean sBean = (StudyBean) sdao.findByPK(edcBean.getStudyId());
            StudyEventDefinitionBean sedBean = (StudyEventDefinitionBean) seddao.findByPK(edcBean.getStudyEventDefinitionId());
            String tagPath = sedBean.getOid() + "." + crf.getOid();
            boolean isOffline = tagService.getEventDefnCrfOfflineStatus(2, tagPath, true);
            String offline = null;
            if (isOffline)
                offline = "true";
            else
                offline = "false";
            formUrl = createAnonymousEnketoUrl(sBean.getOid(), formLayout, edcBean, isOffline);
            AnonymousUrlResponse anonResponse = new AnonymousUrlResponse(formUrl, offline, crf.getName(), formLayout.getDescription());
            return new ResponseEntity<AnonymousUrlResponse>(anonResponse, org.springframework.http.HttpStatus.OK);
        } else {
            return new ResponseEntity<AnonymousUrlResponse>(org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
        }
    } else {
        return new ResponseEntity<AnonymousUrlResponse>(org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    }
}
Also used : Locale(java.util.Locale) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventDefinitionCrfTagService(org.akaza.openclinica.service.managestudy.EventDefinitionCrfTagService) ResponseEntity(org.springframework.http.ResponseEntity) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

FormLayoutBean (org.akaza.openclinica.bean.submit.FormLayoutBean)41 ArrayList (java.util.ArrayList)32 FormLayoutDAO (org.akaza.openclinica.dao.submit.FormLayoutDAO)23 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)22 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)21 HashMap (java.util.HashMap)20 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)16 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)14 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)13 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)12 Iterator (java.util.Iterator)10 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)10 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)9 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)9 StudyParameterValueDAO (org.akaza.openclinica.dao.service.StudyParameterValueDAO)8 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)8 DisplayEventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)7 DisplayEventCRFBean (org.akaza.openclinica.bean.submit.DisplayEventCRFBean)7 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)6 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)5