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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations