Search in sources :

Example 86 with StudyBean

use of org.akaza.openclinica.bean.managestudy.StudyBean 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);
            CRFVersionDAO cvdao = new CRFVersionDAO(dataSource);
            StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(dataSource);
            CRFVersionBean crfVersionBean = (CRFVersionBean) cvdao.findByPK(edcBean.getDefaultVersionId());
            CRFBean crf = (CRFBean) crfdao.findByPK(crfVersionBean.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(), crfVersionBean, edcBean, isOffline);
            AnonymousUrlResponse anonResponse = new AnonymousUrlResponse(formUrl, offline, crf.getName(), crfVersionBean.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) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) 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) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 87 with StudyBean

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

the class AnonymousFormControllerV2 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 88 with StudyBean

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

the class AnonymousFormControllerV2 method createAnonymousEnketoUrl.

private String createAnonymousEnketoUrl(String studyOID, CRFVersionBean crfVersion, EventDefinitionCRFBean edcBean, boolean isOffline) throws Exception {
    StudyBean parentStudyBean = getParentStudy(studyOID);
    PFormCache cache = PFormCache.getInstance(context);
    String enketoURL = cache.getPFormURL(parentStudyBean.getOid(), crfVersion.getOid(), isOffline);
    String contextHash = cache.putAnonymousFormContext(studyOID, crfVersion.getOid(), edcBean.getStudyEventDefinitionId());
    String url = null;
    if (isOffline)
        url = enketoURL.split("#", 2)[0] + "?" + FORM_CONTEXT + "=" + contextHash + "#" + enketoURL.split("#", 2)[1];
    else
        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 89 with StudyBean

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

the class AccountController method getStudy.

private StudyBean getStudy(Integer id) {
    StudyDAO 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 90 with StudyBean

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

the class AccountController method doesCRCNotHaveStudyAccessRole.

private Boolean doesCRCNotHaveStudyAccessRole(String crcUserName, Integer pStudyId) {
    UserAccountDAO udao = new UserAccountDAO(dataSource);
    boolean found = false;
    ArrayList<StudyUserRoleBean> studyUserRoleBeans = (ArrayList<StudyUserRoleBean>) udao.findAllRolesByUserName(crcUserName);
    for (StudyUserRoleBean studyUserRoleBean : studyUserRoleBeans) {
        StudyBean study = getParentStudy(studyUserRoleBean.getStudyId());
        if ((study.getId() == pStudyId) && (studyUserRoleBean.getRoleName().equals("ra") || studyUserRoleBean.getRoleName().equals("ra2")) && studyUserRoleBean.getStatus().isAvailable()) {
            found = true;
            System.out.println("if found :" + found);
            break;
        }
    }
    if (!found) {
        logger.info("*** CRC Does not have access to the study/site OR CRC Does not have 'Data Entry Person' role ***");
        return true;
    }
    return false;
}
Also used : StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO)

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