use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class DynamicsMetadataService method insert.
private void insert(Integer itemDataId, List<PropertyBean> properties, UserAccountBean ub, RuleSetBean ruleSet, Status itemDataStatus, List<StratificationFactorBean> stratificationFactorBeans) {
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 expression = getExpressionService().constructFullExpressionIfPartialProvided(propertyBean.getOid(), ruleSet.getTarget().getValue());
ItemBean itemBeanB = getExpressionService().getItemBeanFromExpression(expression);
ItemGroupBean itemGroupBeanB = getExpressionService().getItemGroupExpression(expression);
ItemGroupMetadataBean itemGroupMetadataBeanB = null;
Boolean isGroupBRepeating = null;
String itemGroupBOrdinal = null;
EventCRFBean eventCrfBeanB = null;
Boolean isItemInSameForm = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemBeanB.getId(), eventCrfBeanA.getCRFVersionId()).getId() != 0 ? true : false;
// Item Does not below to same form
if (!isItemInSameForm) {
List<EventCRFBean> eventCrfs = getEventCRFDAO().findAllByStudyEventAndCrfOrCrfVersionOid(studyEventBeanA, getExpressionService().getCrfOid(expression));
if (eventCrfs.size() == 0) {
CRFVersionBean crfVersion = getExpressionService().getCRFVersionFromExpression(expression);
CRFBean crf = getExpressionService().getCRFFromExpression(expression);
int crfVersionId = 0;
EventDefinitionCRFBean eventDefinitionCRFBean = getEventDefinitionCRfDAO().findByStudyEventDefinitionIdAndCRFId(studyEventBeanA.getStudyEventDefinitionId(), crf.getId());
if (eventDefinitionCRFBean.getId() != 0) {
crfVersionId = crfVersion != null ? crfVersion.getId() : eventDefinitionCRFBean.getDefaultVersionId();
}
// Create new event crf
eventCrfBeanB = eventCrfBeanA.copy();
eventCrfBeanB.setStatus(Status.AVAILABLE);
eventCrfBeanB.setId(0);
eventCrfBeanB.setCRFVersionId(crfVersionId);
eventCrfBeanB = (EventCRFBean) getEventCRFDAO().create(eventCrfBeanB);
} else {
eventCrfBeanB = eventCrfs.get(0);
}
}
if (isItemInSameForm) {
eventCrfBeanB = eventCrfBeanA;
}
itemGroupMetadataBeanB = (ItemGroupMetadataBean) getItemGroupMetadataDAO().findByItemAndCrfVersion(itemBeanB.getId(), eventCrfBeanB.getCRFVersionId());
isGroupBRepeating = isGroupRepeating(itemGroupMetadataBeanB);
itemGroupBOrdinal = getExpressionService().getGroupOrdninalCurated(expression);
// If A and B are both non repeating groups
if (!isGroupARepeating && !isGroupBRepeating) {
ItemDataBean oidBasedItemData = oneToOne(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, 1);
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
// If A is not repeating group & B is a repeating group with no index selected
if (!isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("")) {
List<ItemDataBean> oidBasedItemDatas = oneToMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub);
for (ItemDataBean oidBasedItemData : oidBasedItemDatas) {
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
}
// If A is not repeating group & B is a repeating group with index selected
if (!isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("")) {
ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupBOrdinal));
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
// If A is repeating/ non repeating group & B is a repeating group with index selected as END
if (isGroupBRepeating && itemGroupBOrdinal.equals("END")) {
ItemDataBean oidBasedItemData = oneToEndMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub);
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
// If A is repeating group with index & B is a repeating group with index selected
if (isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("") && !itemGroupBOrdinal.equals("END")) {
ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupBOrdinal));
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
// If A is repeating group with index & B is a repeating group with no index selected
if (isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("")) {
ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupAOrdinal));
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
// // If A is repeating group with index & B is none-repeating group
// if (isGroupARepeating && !isGroupBRepeating ) {
// ItemDataBean oidBasedItemData =
// oneToOne(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, 1);
//
// oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA));
// getItemDataDAO().updateValue(oidBasedItemData, "yyyy-MM-dd");
// }
}
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class HideCRFManager method studyEventHasAHideCRFProperty.
public boolean studyEventHasAHideCRFProperty(DisplayStudyEventBean displayStudyEventBean) {
EventDefinitionCRFBean tempEventCRFBean = new EventDefinitionCRFBean();
boolean hasAHideCRFProperty = false;
for (DisplayEventCRFBean deCRFBean : displayStudyEventBean.getAllEventCRFs()) {
tempEventCRFBean = deCRFBean.getEventDefinitionCRF();
if (tempEventCRFBean.isHideCrf()) {
hasAHideCRFProperty = true;
}
}
for (DisplayEventCRFBean deCRFBean : displayStudyEventBean.getDisplayEventCRFs()) {
tempEventCRFBean = deCRFBean.getEventDefinitionCRF();
if (tempEventCRFBean.isHideCrf()) {
hasAHideCRFProperty = true;
}
}
return hasAHideCRFProperty;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class HideCRFManager method removeHiddenCRFBeans.
/**
* Given a StudyEventDefinitionBean and a list of CRFBeans as parameters,
* this method returns of new list of CRFBeans containing only unhidden CRFs
* (their isHideCRF property is false).
*
* @param studyEventBean
* The StudyEventDefinitionBean
* @param crfBeans
* An ArrayList of CRFBeans
* @param dataSource
* A javax.sql.DataSource for the use of the
* EventDefinitionCRFDAO.
* @return An ArrayList of CRFBeans containing only "unhidden" CRFs.
*/
public ArrayList<CRFBean> removeHiddenCRFBeans(StudyBean study, StudyEventDefinitionBean studyEventBean, ArrayList<CRFBean> crfBeans, DataSource dataSource) {
ArrayList<CRFBean> newBeans = new ArrayList<CRFBean>();
if (crfBeans == null || crfBeans.isEmpty()) {
return newBeans;
}
EventDefinitionCRFDAO eventDefinitionCRFDAO = new EventDefinitionCRFDAO(dataSource);
EventDefinitionCRFBean tempBean = new EventDefinitionCRFBean();
for (CRFBean crfBean : crfBeans) {
tempBean = eventDefinitionCRFDAO.findByStudyEventDefinitionIdAndCRFId(study, studyEventBean.getId(), crfBean.getId());
if (tempBean != null && !tempBean.isHideCrf()) {
newBeans.add(crfBean);
}
}
return newBeans;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class HideCRFManager method suppressHiddenEventCRFBeans.
private ArrayList<DisplayEventCRFBean> suppressHiddenEventCRFBeans(List<DisplayEventCRFBean> eventCRFBeans) {
// Must make this an ArrayList because of the
// displayStudyEventBean.setAllEventCRFs()
// method definition
ArrayList<DisplayEventCRFBean> newEventCRFBeans = new ArrayList<DisplayEventCRFBean>();
EventDefinitionCRFBean definitionCRFBean = new EventDefinitionCRFBean();
for (DisplayEventCRFBean deCRFBean : eventCRFBeans) {
definitionCRFBean = deCRFBean.getEventDefinitionCRF();
if (!definitionCRFBean.isHideCrf()) {
newEventCRFBeans.add(deCRFBean);
}
}
return newEventCRFBeans;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class HideCRFManager method removeHiddenEventDefinitionCRFBeans.
public ArrayList<DisplayEventDefinitionCRFBean> removeHiddenEventDefinitionCRFBeans(List<DisplayEventDefinitionCRFBean> displayEventDefinitionCRFBeans) {
ArrayList<DisplayEventDefinitionCRFBean> newDisplayEventDefinitionCRFBeans = new ArrayList<DisplayEventDefinitionCRFBean>();
EventDefinitionCRFBean eventDefinitionCRFBean = new EventDefinitionCRFBean();
for (DisplayEventDefinitionCRFBean displayEventDefinitionCRFBean : displayEventDefinitionCRFBeans) {
eventDefinitionCRFBean = displayEventDefinitionCRFBean.getEdc();
if (!eventDefinitionCRFBean.isHideCrf()) {
newDisplayEventDefinitionCRFBeans.add(displayEventDefinitionCRFBean);
}
}
return newDisplayEventDefinitionCRFBeans;
}
Aggregations