use of org.akaza.openclinica.bean.submit.EventCRFBean 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.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method injectDiscNotesIntoDisplayStudyEvents.
/**
* This method is an overloaded version of the previous method, with the
* only difference being the resolutionStatusIds parameter in this method.
* This method adds the associated discrepancy notes to the appropriate
* StudyEventBean (contained by DisplayStudyBeans).
*
* @param displayStudyBeans
* A List of DisplayStudyEventBeans.
* @param resolutionStatusIds
* A HashSet object consisting of resolution status ids (i.e.,
* 1,2,3).
* @param dataSource
* A DataSource object, for use with the DAO methods.
* @param discNoteType
* An int discrepancy note type, for filtering the discrepancy
* notes that
* @param discrepancyNoteThreads
* A List of DiscrepancyNoteThreads
*/
public void injectDiscNotesIntoDisplayStudyEvents(List<DisplayStudyEventBean> displayStudyBeans, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType, List<DiscrepancyNoteThread> discrepancyNoteThreads) {
if (displayStudyBeans == null) {
return;
}
// booleans representing whether this method should only get
// DiscrepancyNoteBeans with
// certain resolution status or discrepancyNoteTypeId number.
boolean hasResolutionStatus = this.checkResolutionStatus(resolutionStatusIds);
boolean hasDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
StudyEventBean studyEventBean;
List<EventCRFBean> eventCRFBeans = new ArrayList<EventCRFBean>();
List<DiscrepancyNoteBean> foundDiscNotes = new ArrayList<DiscrepancyNoteBean>();
for (DisplayStudyEventBean dStudyEventBean : displayStudyBeans) {
studyEventBean = dStudyEventBean.getStudyEvent();
// All EventCRFs for a study event
eventCRFBeans = eventCRFDAO.findAllByStudyEvent(studyEventBean);
for (EventCRFBean eventCrfBean : eventCRFBeans) {
// Find ItemData type notes associated with an event crf
foundDiscNotes = discrepancyNoteDAO.findItemDataDNotesFromEventCRF(eventCrfBean);
// return only parent beans
foundDiscNotes = filterDiscNotesForOnlyParents(foundDiscNotes, discrepancyNoteThreads);
// update the resolution status of these parent discrepancy
// notes
updateStatusUsingThread(foundDiscNotes, discrepancyNoteThreads);
// filter for any specified disc note type
if (!foundDiscNotes.isEmpty() && hasDiscNoteType) {
// only include disc notes that have the specified disc note
// type id
foundDiscNotes = filterforDiscNoteType(foundDiscNotes, discNoteType);
}
if (!foundDiscNotes.isEmpty()) {
if (!hasResolutionStatus) {
studyEventBean.getDiscBeanList().addAll(foundDiscNotes);
} else {
// session variable
for (DiscrepancyNoteBean discBean : foundDiscNotes) {
for (int statusId : resolutionStatusIds) {
if (discBean.getResolutionStatusId() == statusId) {
studyEventBean.getDiscBeanList().add(discBean);
}
}
}
}
}
// 3014: Not for now; Find EventCRF type notes
/*
* foundDiscNotes =
* discrepancyNoteDAO.findEventCRFDNotesFromEventCRF(eventCrfBean);
* //filter for any specified disc note type if((!
* foundDiscNotes.isEmpty()) && hasDiscNoteType){ foundDiscNotes =
* filterforDiscNoteType(foundDiscNotes,discNoteType); }
*
* if(! foundDiscNotes.isEmpty()){ if(! hasResolutionStatus) {
* studyEventBean.getDiscBeanList().addAll(foundDiscNotes); }
* else { //Only include disc notes with a particular resolution
* status, specified by //the parameter passed to the servlet
* for(DiscrepancyNoteBean discBean : foundDiscNotes) { for(int
* statusId : resolutionStatusIds){
* if(discBean.getResolutionStatusId() == statusId){
* studyEventBean.getDiscBeanList().add(discBean); } } } } }
*/
// end if(! foundDiscNotes.isEmpty()){
}
// end for(EventCRFBean...
}
// end for (DisplayStudyEventBean
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method getEventCRFIdsFromDisplayEvents.
private SortedSet<Integer> getEventCRFIdsFromDisplayEvents(List<DisplayStudyEventBean> displayEvents) {
SortedSet<Integer> treeSet = new TreeSet<Integer>();
if (displayEvents == null || displayEvents.isEmpty()) {
return treeSet;
}
StudyEventBean studyEventBean = null;
List<DisplayEventCRFBean> displayEventCRFBeans = null;
List<EventCRFBean> eventCRFBeans = null;
for (DisplayStudyEventBean displayStudyEventBean : displayEvents) {
displayEventCRFBeans = displayStudyEventBean.getDisplayEventCRFs();
if (displayEventCRFBeans.isEmpty()) {
eventCRFBeans = displayStudyEventBean.getStudyEvent().getEventCRFs();
for (EventCRFBean evBean : eventCRFBeans) {
treeSet.add(evBean.getId());
}
// move on to the next DisplayStudyEventBean
continue;
}
for (DisplayEventCRFBean disBean : displayEventCRFBeans) {
treeSet.add(disBean.getEventCRF().getId());
}
}
return treeSet;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method injectDiscNotesIntoDisplayStudyEvents.
/**
* Add associated discrepancy notes to the appropriate StudyEventBean
* (contained by DisplayStudyBeans). A StudyEventBean has a List of
* DiscrepancyNoteBeans.
*
* @param displayStudyBeans
* A List of DisplayStudyEventBeans
* @param resolutionStatus
* An int representing the resolution status, if we are filtering
* the DiscrepancyNoteBeans based on their resolutionStatus id
* number.
* @param dataSource
* A DataSource used for the DAO methods.
* @param discNoteType
* An int representing the discrepancy note type, if we are
* filtering the DiscrepancyNoteBeans based on their
* discrepancyNoteTypeId number.
*/
public void injectDiscNotesIntoDisplayStudyEvents(List<DisplayStudyEventBean> displayStudyBeans, int resolutionStatus, DataSource dataSource, int discNoteType) {
if (displayStudyBeans == null) {
return;
}
// booleans representing whether this method should only get
// DiscrepancyNoteBeans with
// certain resolution status or discrepancyNoteTypeId number.
boolean hasResolutionStatus = resolutionStatus >= 1 && resolutionStatus <= 5;
boolean hasDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
StudyEventBean studyEventBean;
List<EventCRFBean> eventCRFBeans = new ArrayList<EventCRFBean>();
List<DiscrepancyNoteBean> foundDiscNotes = new ArrayList<DiscrepancyNoteBean>();
for (DisplayStudyEventBean dStudyEventBean : displayStudyBeans) {
studyEventBean = dStudyEventBean.getStudyEvent();
// All EventCRFs for a study event
eventCRFBeans = eventCRFDAO.findAllByStudyEvent(studyEventBean);
for (EventCRFBean eventCrfBean : eventCRFBeans) {
// Find ItemData type notes associated iwth an event crf
foundDiscNotes = discrepancyNoteDAO.findItemDataDNotesFromEventCRF(eventCrfBean);
// filter for any specified disc note type
if (!foundDiscNotes.isEmpty() && hasDiscNoteType) {
// only include disc notes that have the specified disc note
// type id
foundDiscNotes = filterforDiscNoteType(foundDiscNotes, discNoteType);
}
if (!foundDiscNotes.isEmpty()) {
if (!hasResolutionStatus) {
studyEventBean.getDiscBeanList().addAll(foundDiscNotes);
} else {
// the parameter passed to the servlet
for (DiscrepancyNoteBean discBean : foundDiscNotes) {
if (discBean.getResolutionStatusId() == resolutionStatus) {
studyEventBean.getDiscBeanList().add(discBean);
}
}
}
}
// Find EventCRF type notes
foundDiscNotes = discrepancyNoteDAO.findEventCRFDNotesFromEventCRF(eventCrfBean);
// filter for any specified disc note type
if (!foundDiscNotes.isEmpty() && hasDiscNoteType) {
foundDiscNotes = filterforDiscNoteType(foundDiscNotes, discNoteType);
}
if (!foundDiscNotes.isEmpty()) {
if (!hasResolutionStatus) {
studyEventBean.getDiscBeanList().addAll(foundDiscNotes);
} else {
// the parameter passed to the servlet
for (DiscrepancyNoteBean discBean : foundDiscNotes) {
if (discBean.getResolutionStatusId() == resolutionStatus) {
studyEventBean.getDiscBeanList().add(discBean);
}
}
}
}
// end if(! foundDiscNotes.isEmpty()){
}
// end for(EventCRFBean...
}
// end for (DisplayStudyEventBean
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DynamicsMetadataService method show.
public void show(Integer itemDataId, List<PropertyBean> properties, RuleSetBean ruleSet) {
ItemDataBean itemDataBeanA = (ItemDataBean) getItemDataDAO().findByPK(itemDataId);
EventCRFBean eventCrfBeanA = (EventCRFBean) getEventCRFDAO().findByPK(itemDataBeanA.getEventCRFId());
StudyEventBean studyEventBeanA = (StudyEventBean) getStudyEventDAO().findByPK(eventCrfBeanA.getStudyEventId());
ItemGroupMetadataBean itemGroupMetadataBeanA = (ItemGroupMetadataBean) getItemGroupMetadataDAO().findByItemAndCrfVersion(itemDataBeanA.getItemId(), eventCrfBeanA.getCRFVersionId());
Boolean isGroupARepeating = isGroupRepeating(itemGroupMetadataBeanA);
String itemGroupAOrdinal = getExpressionService().getGroupOrdninalCurated(ruleSet.getTarget().getValue());
for (PropertyBean propertyBean : properties) {
String oid = propertyBean.getOid();
ItemOrItemGroupHolder itemOrItemGroup = getItemOrItemGroup(oid);
// OID is an item
if (itemOrItemGroup.getItemBean() != null) {
ItemDataBean oidBasedItemData = getItemData(itemOrItemGroup.getItemBean(), eventCrfBeanA, itemDataBeanA.getOrdinal());
ItemFormMetadataBean itemFormMetadataBean = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemOrItemGroup.getItemBean().getId(), eventCrfBeanA.getCRFVersionId());
DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBeanA, oidBasedItemData);
if (dynamicsMetadataBean == null) {
showItem(itemFormMetadataBean, eventCrfBeanA, oidBasedItemData);
} else if (dynamicsMetadataBean != null && !dynamicsMetadataBean.isShowItem()) {
dynamicsMetadataBean.setShowItem(true);
getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
}
} else // OID is a group
{
logger.debug("found item group id 1 " + oid);
ItemGroupBean itemGroupBean = itemOrItemGroup.getItemGroupBean();
ArrayList sectionBeans = getSectionDAO().findAllByCRFVersionId(eventCrfBeanA.getCRFVersionId());
for (int i = 0; i < sectionBeans.size(); i++) {
SectionBean sectionBean = (SectionBean) sectionBeans.get(i);
// System.out.println("found section " + sectionBean.getId());
List<ItemGroupMetadataBean> itemGroupMetadataBeans = getItemGroupMetadataDAO().findMetaByGroupAndSection(itemGroupBean.getId(), eventCrfBeanA.getCRFVersionId(), sectionBean.getId());
for (ItemGroupMetadataBean itemGroupMetadataBean : itemGroupMetadataBeans) {
if (itemGroupMetadataBean.getItemGroupId() == itemGroupBean.getId()) {
// System.out.println("found item group id 2 " + oid);
DynamicsItemGroupMetadataBean dynamicsGroupBean = getDynamicsItemGroupMetadataBean(itemGroupMetadataBean, eventCrfBeanA);
if (dynamicsGroupBean == null) {
showGroup(itemGroupMetadataBean, eventCrfBeanA);
} else if (dynamicsGroupBean != null && !dynamicsGroupBean.isShowGroup()) {
dynamicsGroupBean.setShowGroup(true);
getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
}
}
}
}
}
}
}
Aggregations