use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class ListDiscNotesForCRFTableFactory method getCrfs.
@SuppressWarnings("unchecked")
private ArrayList<CRFBean> getCrfs(StudyEventDefinitionBean eventDefinition) {
if (this.crfBeans == null) {
crfBeans = new ArrayList<CRFBean>();
eventDefinitionCrfs = new ArrayList<EventDefinitionCRFBean>();
ArrayList<Integer> ids = new ArrayList<Integer>();
List<EventDefinitionCRFBean> edcs = new ArrayList<EventDefinitionCRFBean>();
if (this.getStudyBean().getParentStudyId() > 0) {
edcs = (List<EventDefinitionCRFBean>) getEventDefintionCRFDAO().findAllActiveNonHiddenByEventDefinitionIdAndStudy(eventDefinition.getId(), this.getStudyBean());
} else {
edcs = getEventDefintionCRFDAO().findAllActiveByEventDefinitionId(eventDefinition.getId());
}
if (edcs.size() > 0) {
for (EventDefinitionCRFBean eventDefinitionCrf : edcs) {
CRFBean crf = (CRFBean) getCrfDAO().findByPK(eventDefinitionCrf.getCrfId());
if (!ids.contains(crf.getId())) {
crfBeans.add(crf);
ids.add(crf.getId());
eventDefinitionCrfs.add(eventDefinitionCrf);
}
}
}
return crfBeans;
}
return crfBeans;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean 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;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean 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.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class FormBeanUtil method createDisplaySectionWithItemGroups.
/**
* Create a DisplaySectionBean with a list of ItemGroupBeans. NOTE:
* unGrouped Items are not included
*
* @param study
* The StudyBean
* @param sectionId
* The Section ID associated with the Items, which end up
* providing the content of the tables.
* @param crfVersionId
* The CRF version ID associated with the Items.
* @param studyEventId
* The Study Event ID associated with the CRF Version ID.
* @param sm
* A SessionManager, from which DataSources are acquired for the
* DAO objects.
* @return A DisplaySectionBean.
*/
public DisplaySectionBean createDisplaySectionWithItemGroups(StudyBean study, int sectionId, EventCRFBean eventCrfBean, int studyEventId, SessionManager sm, int eventDefinitionCRFId, ServletContext context) {
DisplaySectionBean dBean = new DisplaySectionBean();
ItemGroupDAO formGroupDAO = new ItemGroupDAO(sm.getDataSource());
ItemGroupMetadataDAO igMetaDAO = new ItemGroupMetadataDAO(sm.getDataSource());
ItemDAO itemDao = new ItemDAO(sm.getDataSource());
ItemFormMetadataDAO metaDao = new ItemFormMetadataDAO(sm.getDataSource());
List<ItemGroupBean> arrList = formGroupDAO.findLegitGroupBySectionId(sectionId);
// all items associated with the section, including those not in a group
List<ItemFormMetadataBean> allMetas = new ArrayList<ItemFormMetadataBean>();
try {
allMetas = metaDao.findAllBySectionId(sectionId);
} catch (OpenClinicaException oce) {
logger.info("oce.getOpenClinicaMessage() = " + oce.getOpenClinicaMessage());
}
// Collections.sort(allMetas);
if (arrList.isEmpty())
return dBean;
// Find out whether there are any checkboxes/radios/select elements
// and if so, get any null values
// associated with them
List<String> nullValuesList = new ArrayList<String>();
boolean itemsHaveChecksRadios = itemsIncludeChecksRadiosSelects(allMetas);
// "+eventDefinitionCRFId);
if (eventDefinitionCRFId <= 0) {
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
EventDefinitionCRFBean edcBean = edcdao.findByStudyEventIdAndCRFVersionId(study, studyEventId, eventCrfBean.getCRFVersionId());
eventDefinitionCRFId = edcBean.getId();
}
// "+eventDefinitionCRFId);
if (itemsHaveChecksRadios && eventDefinitionCRFId > 0) {
// method returns null values as a List<String>
nullValuesList = this.getNullValuesByEventCRFDefId(eventDefinitionCRFId, sm.getDataSource());
}
// Get the items associated with each group
List<ItemBean> itBeans;
List<DisplayItemBean> displayItems;
List<DisplayItemGroupBean> displayFormBeans = new ArrayList<DisplayItemGroupBean>();
DisplayItemGroupBean displayItemGBean;
for (ItemGroupBean itemGroup : arrList) {
itBeans = itemDao.findAllItemsByGroupId(itemGroup.getId(), eventCrfBean.getCRFVersionId());
List<ItemGroupMetadataBean> metadata = igMetaDAO.findMetaByGroupAndSection(itemGroup.getId(), eventCrfBean.getCRFVersionId(), sectionId);
if (!metadata.isEmpty()) {
// for a given crf version, all the items in the same group
// have the same group metadata
// so we can get one of them and set metadata for the group
ItemGroupMetadataBean meta = metadata.get(0);
itemGroup.setMeta(meta);
}
// include arrayList parameter until I determine difference in
// classes
displayItems = getDisplayBeansFromItems(itBeans, sm.getDataSource(), eventCrfBean, sectionId, nullValuesList, context);
displayItemGBean = this.createDisplayFormGroup(displayItems, itemGroup);
displayFormBeans.add(displayItemGBean);
}
// We still have to sort these display item group beans on their
// ItemGroupMetadataBean?
// then number their ordinals accordingly
Collections.sort(displayFormBeans, new Comparator<DisplayItemGroupBean>() {
public int compare(DisplayItemGroupBean displayItemGroupBean, DisplayItemGroupBean displayItemGroupBean1) {
return displayItemGroupBean.getGroupMetaBean().compareTo(displayItemGroupBean1.getGroupMetaBean());
}
});
// Now provide the display item group beans with an ordinal
int digOrdinal = 0;
for (DisplayItemGroupBean digBean : displayFormBeans) {
digBean.setOrdinal(++digOrdinal);
}
dBean.setDisplayFormGroups(displayFormBeans);
return dBean;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class FormBeanUtil method getNullValuesByEventCRFDefId.
public List<String> getNullValuesByEventCRFDefId(int eventDefinitionCRFId, DataSource dataSource) {
if (eventDefinitionCRFId < 1 || dataSource == null) {
return new ArrayList<String>();
}
List<String> nullValuesList = new ArrayList<String>();
// hold the bean's return value
List<NullValue> nullObjectList = new ArrayList<NullValue>();
EventDefinitionCRFBean eventCRFDefBean;
EventDefinitionCRFDAO eventDefinitionCRFDAO = new EventDefinitionCRFDAO(dataSource);
eventCRFDefBean = (EventDefinitionCRFBean) eventDefinitionCRFDAO.findByPK(eventDefinitionCRFId);
nullObjectList = eventCRFDefBean.getNullValuesList();
if (nullObjectList == null) {
return new ArrayList<String>();
}
for (NullValue nullVal : nullObjectList) {
nullValuesList.add(nullVal.getName());
}
return nullValuesList;
}
Aggregations