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