use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class StudySubjectServiceImpl method populateUncompletedCRFsWithCRFAndVersions.
@SuppressWarnings({ "rawtypes", "unchecked" })
public void populateUncompletedCRFsWithCRFAndVersions(ArrayList<DisplayEventDefinitionCRFBean> uncompletedEventDefinitionCRFs, Map<Integer, FormLayoutBean> formLayoutById, Map<Integer, CRFBean> crfById) {
FormLayoutDAO formLayoutDAo = new FormLayoutDAO(dataSource);
int size = uncompletedEventDefinitionCRFs.size();
for (int i = 0; i < size; i++) {
DisplayEventDefinitionCRFBean dedcrf = uncompletedEventDefinitionCRFs.get(i);
CRFBean cb = crfById.get(dedcrf.getEdc().getCrfId());
dedcrf.getEdc().setCrf(cb);
ArrayList<FormLayoutBean> theVersions = (ArrayList<FormLayoutBean>) formLayoutDAo.findAllActiveByCRF(dedcrf.getEdc().getCrfId());
ArrayList<FormLayoutBean> versions = new ArrayList<FormLayoutBean>();
HashMap<String, FormLayoutBean> formLayoutIds = new HashMap<String, FormLayoutBean>();
for (int j = 0; j < theVersions.size(); j++) {
FormLayoutBean formLayout = theVersions.get(j);
formLayoutIds.put(String.valueOf(formLayout.getId()), formLayout);
}
if (!dedcrf.getEdc().getSelectedVersionIds().equals("")) {
String[] kk = dedcrf.getEdc().getSelectedVersionIds().split(",");
for (String string : kk) {
if (formLayoutIds.get(string) != null) {
versions.add(formLayoutIds.get(string));
}
}
} else {
versions = theVersions;
}
dedcrf.getEdc().setVersions(versions);
uncompletedEventDefinitionCRFs.set(i, dedcrf);
}
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class OdmExtractDAO method getFormLayoutRefs.
List<ElementRefBean> getFormLayoutRefs(ElementRefBean formRef, int defaultVersionId) {
CRFBean crfBean = crfdao.findByOid(formRef.getElementDefOID());
List<FormLayoutBean> formLayouts = fldao.findAllByCRFId(crfBean.getId());
List<ElementRefBean> elementRefs = new ArrayList<>();
ElementRefBean element;
for (FormLayoutBean formLayout : formLayouts) {
element = new ElementRefBean();
element.setName(formLayout.getName());
if (formLayout.getId() == defaultVersionId) {
element.setDefaultVersion(true);
} else {
element.setDefaultVersion(false);
}
elementRefs.add(element);
}
return elementRefs;
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class OdmController method getFormDataPerCrf.
private ODMcomplexTypeDefinitionFormData getFormDataPerCrf(FormLayoutBean formLayout, StudyEventBean nextEvent, List<EventCRFBean> eventCrfs, CRFDAO crfDAO, String formUrl, boolean itemDataExists) {
EventCRFBean selectedEventCRFBean = null;
CRFBean crfBean = (CRFBean) crfDAO.findByVersionId(formLayout.getId());
for (EventCRFBean eventCRFBean : eventCrfs) {
if (eventCRFBean.getCRFVersionId() == formLayout.getId()) {
selectedEventCRFBean = eventCRFBean;
break;
}
}
return generateFormData(formLayout, nextEvent, selectedEventCRFBean, crfBean, formUrl, itemDataExists);
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class RuleRunner method prepareEmailContents.
HashMap<String, String> prepareEmailContents(RuleSetBean ruleSet, RuleSetRuleBean ruleSetRule, StudyBean currentStudy, RuleActionBean ruleAction) {
// get the Study Event
StudyEventBean studyEvent = (StudyEventBean) getStudyEventDao().findByPK(Integer.valueOf(getExpressionService().getStudyEventDefenitionOrdninalCurated(ruleSet.getTarget().getValue())));
// get the Study Subject
StudySubjectBean studySubject = (StudySubjectBean) getStudySubjectDao().findByPK(studyEvent.getStudySubjectId());
// get Study/Site Associated with Subject
StudyBean theStudy = (StudyBean) getStudyDao().findByPK(studySubject.getStudyId());
String theStudyName, theSiteName = "";
if (theStudy.getParentStudyId() > 0) {
StudyBean theParentStudy = (StudyBean) getStudyDao().findByPK(theStudy.getParentStudyId());
theStudyName = theParentStudy.getName() + " / " + theParentStudy.getIdentifier();
theSiteName = theStudy.getName() + " / " + theStudy.getIdentifier();
} else {
theStudyName = theStudy.getName() + " / " + theStudy.getIdentifier();
}
// get the eventCrf & subsequently the CRF Version
// EventCRFBean eventCrf = (EventCRFBean) getEventCrfDao().findAllByStudyEvent(studyEvent).get(0);
EventCRFBean eventCrf = (EventCRFBean) getEventCrfDao().findAllByStudyEventAndCrfOrCrfVersionOid(studyEvent, getExpressionService().getCrfOid(ruleSet.getTarget().getValue())).get(0);
CRFVersionBean crfVersion = (CRFVersionBean) getCrfVersionDao().findByPK(eventCrf.getCRFVersionId());
CRFBean crf = (CRFBean) getCrfDao().findByPK(crfVersion.getCrfId());
String studyEventDefinitionName = getExpressionService().getStudyEventDefinitionFromExpression(ruleSet.getTarget().getValue(), currentStudy).getName();
studyEventDefinitionName += " [" + studyEvent.getSampleOrdinal() + "]";
String itemGroupName = getExpressionService().getItemGroupNameAndOrdinal(ruleSet.getTarget().getValue());
ItemGroupBean itemGroupBean = getExpressionService().getItemGroupExpression(ruleSet.getTarget().getValue());
ItemBean itemBean = getExpressionService().getItemExpression(ruleSet.getTarget().getValue(), itemGroupBean);
String itemName = itemBean.getName();
SectionBean section = (SectionBean) getSectionDAO().findByPK(getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemBean.getId(), crfVersion.getId()).getSectionId());
StringBuffer sb = new StringBuffer();
ResourceBundle respage = ResourceBundleProvider.getPageMessagesBundle();
sb.append(respage.getString("email_header_1"));
sb.append(" " + contextPath + " ");
sb.append(respage.getString("email_header_2"));
sb.append(" '" + currentStudy.getName() + "' ");
sb.append(respage.getString("email_header_3"));
sb.append(" \n\n ");
sb.append(respage.getString("email_body_1") + " " + theStudyName + " \n ");
sb.append(respage.getString("email_body_1_a") + " " + theSiteName + " \n ");
sb.append(respage.getString("email_body_2") + " " + studySubject.getName() + " \n ");
sb.append(respage.getString("email_body_3") + " " + studyEventDefinitionName + " \n ");
sb.append(respage.getString("email_body_4") + " " + crf.getName() + " " + crfVersion.getName() + " \n ");
sb.append(respage.getString("email_body_5") + " " + section.getTitle() + " \n ");
sb.append(respage.getString("email_body_6") + " " + itemGroupName + " \n ");
sb.append(respage.getString("email_body_7") + " " + itemName + " \n ");
sb.append(respage.getString("email_body_8") + " " + ruleAction.getCuratedMessage() + " \n ");
sb.append(" \n\n ");
sb.append(respage.getString("email_body_9"));
sb.append(" " + contextPath + " ");
sb.append(respage.getString("email_body_10"));
sb.append(" \n");
requestURLMinusServletPath = requestURLMinusServletPath == null ? "" : requestURLMinusServletPath;
sb.append(requestURLMinusServletPath + "/ViewSectionDataEntry?ecId=" + eventCrf.getId() + "§ionId=" + section.getId() + "&tabId=" + section.getOrdinal());
// &eventId="+ studyEvent.getId());
sb.append("\n\n");
sb.append(respage.getString("email_footer"));
String subject = contextPath + " - [" + currentStudy.getName() + "] ";
String ruleSummary = ruleAction.getSummary() != null ? ruleAction.getSummary() : "";
String message = ruleSummary.length() < 20 ? ruleSummary : ruleSummary.substring(0, 20) + " ... ";
subject += message;
HashMap<String, String> emailContents = new HashMap<String, String>();
emailContents.put("body", sb.toString());
emailContents.put("subject", subject);
return emailContents;
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class BatchCRFMigrationServlet method processRequest.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
ArrayList<CRFVersionBean> crfVersionList = null;
ArrayList<StudyEventDefinitionBean> eventList = null;
ArrayList<StudyBean> siteList = null;
// checks which module the requests are from, manage or admin
String module = fp.getString(MODULE);
request.setAttribute(MODULE, module);
int crfId = fp.getInt(CRF_ID);
if (crfId == 0) {
addPageMessage(respage.getString("please_choose_a_CRF_to_view"));
forwardPage(Page.CRF_LIST);
} else {
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource());
CRFBean crf = (CRFBean) cdao.findByPK(crfId);
request.setAttribute("crfName", crf.getName());
ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) vdao.findAllByCRF(crfId);
crfVersionList = new ArrayList<CRFVersionBean>();
for (CRFVersionBean version : versions) {
if (version.getStatus().isAvailable())
crfVersionList.add(version);
}
crf.setVersions(crfVersionList);
ArrayList<StudyBean> listOfSites = (ArrayList<StudyBean>) sdao().findAllByParent(currentStudy.getId());
siteList = new ArrayList<StudyBean>();
StudyBean studyBean = new StudyBean();
studyBean.setOid(currentStudy.getOid());
studyBean.setName(resterm.getString("Study_Level_Subjects_Only"));
siteList.add(studyBean);
for (StudyBean s : listOfSites) {
if (s.getStatus().isAvailable()) {
siteList.add(s);
}
}
ArrayList<StudyEventDefinitionBean> listOfDefn = seddao().findAllByStudy(currentStudy);
eventList = new ArrayList<StudyEventDefinitionBean>();
for (StudyEventDefinitionBean d : listOfDefn) {
if (d.getStatus().isAvailable()) {
eventList.add(d);
}
}
// if coming from change crf version -> display message
String crfVersionChangeMsg = fp.getString("isFromCRFVersionBatchChange");
if (crfVersionChangeMsg != null && !crfVersionChangeMsg.equals("")) {
addPageMessage(crfVersionChangeMsg);
}
request.setAttribute("study", currentStudy);
request.setAttribute("siteList", siteList);
request.setAttribute("eventList", eventList);
request.setAttribute(CRF, crf);
forwardPage(Page.BATCH_CRF_MIGRATION);
}
}
Aggregations